add transform mode and tollbar button, implement polygon clipping with uvs interpolation and cube faces projection with near plane clipping, add duplicate points removal template function, implement Spere mesh surface section creation.
This commit is contained in:
17
src/shape.h
17
src/shape.h
@@ -22,7 +22,6 @@ protected:
|
||||
bool use_idx = true;
|
||||
bool create_buffers_imp(GLvoid* idx, GLvoid* vertices, int isize, int vsize);
|
||||
public:
|
||||
struct vertex_t { glm::vec4 pos; glm::vec2 uvs; glm::vec2 uvs2; };
|
||||
bool create_buffers(GLushort* idx, GLvoid* vertices, int isize, int vsize);
|
||||
bool create_buffers(GLuint* idx, GLvoid* vertices, int isize, int vsize);
|
||||
bool create_buffers(GLvoid* vertices, int vsize);
|
||||
@@ -198,16 +197,28 @@ public:
|
||||
|
||||
class Sphere : public Shape
|
||||
{
|
||||
void create_impl(int rings, int sectors, float radius, GLushort* idx, vertex_t* vertices);
|
||||
void create_impl(int rings, int sectors, float radius,
|
||||
float lat_start, float lat_end, float lon_start, float lon_end,
|
||||
GLushort* idx, vertex_t* vertices);
|
||||
public:
|
||||
template<int rings, int sectors>
|
||||
bool create(float radius)
|
||||
{
|
||||
static GLushort idx[rings * sectors * 6];
|
||||
static vertex_t vertices[rings * sectors];
|
||||
create_impl(rings, sectors, radius, idx, vertices);
|
||||
create_impl(rings, sectors, radius, -M_PI_2, M_PI_2, 0, M_PI * 2.0, idx, vertices);
|
||||
return create_buffers(idx, vertices, sizeof(idx), sizeof(vertices));
|
||||
}
|
||||
bool create(float radius, float lat_start, float lat_end,
|
||||
float lon_start, float lon_end, float polys_per_angle)
|
||||
{
|
||||
int rings = glm::ceil(glm::degrees(lat_end - lat_start) * polys_per_angle);
|
||||
int sectors = glm::ceil(glm::degrees(lon_end - lon_start) * polys_per_angle);
|
||||
auto idx = std::make_unique<GLushort[]>(rings * sectors * 6);
|
||||
auto vertices = std::make_unique<vertex_t[]>(rings * sectors);
|
||||
create_impl(rings, sectors, radius, lat_start, lat_end, lon_start, lon_end, idx.get(), vertices.get());
|
||||
return create_buffers(idx.get(), vertices.get(), rings * sectors * 6 * sizeof(GLushort), rings * sectors * sizeof(vertex_t));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user