25 const float hs = 1.0f;
30 -hs, -hs, hs, 0.0f, 0.0f, 1.0f,
31 hs, -hs, hs, 0.0f, 0.0f, 1.0f,
32 hs, hs, hs, 0.0f, 0.0f, 1.0f,
33 -hs, hs, hs, 0.0f, 0.0f, 1.0f,
36 hs, -hs, -hs, 0.0f, 0.0f, -1.0f,
37 -hs, -hs, -hs, 0.0f, 0.0f, -1.0f,
38 -hs, hs, -hs, 0.0f, 0.0f, -1.0f,
39 hs, hs, -hs, 0.0f, 0.0f, -1.0f,
42 -hs, -hs, -hs, -1.0f, 0.0f, 0.0f,
43 -hs, -hs, hs, -1.0f, 0.0f, 0.0f,
44 -hs, hs, hs, -1.0f, 0.0f, 0.0f,
45 -hs, hs, -hs, -1.0f, 0.0f, 0.0f,
48 hs, -hs, hs, 1.0f, 0.0f, 0.0f,
49 hs, -hs, -hs, 1.0f, 0.0f, 0.0f,
50 hs, hs, -hs, 1.0f, 0.0f, 0.0f,
51 hs, hs, hs, 1.0f, 0.0f, 0.0f,
54 -hs, hs, hs, 0.0f, 1.0f, 0.0f,
55 hs, hs, hs, 0.0f, 1.0f, 0.0f,
56 hs, hs, -hs, 0.0f, 1.0f, 0.0f,
57 -hs, hs, -hs, 0.0f, 1.0f, 0.0f,
60 hs, -hs, hs, 0.0f, -1.0f, 0.0f,
61 -hs, -hs, hs, 0.0f, -1.0f, 0.0f,
62 -hs, -hs, -hs, 0.0f, -1.0f, 0.0f,
63 hs, -hs, -hs, 0.0f, -1.0f, 0.0f
70 12, 13, 14, 14, 15, 12,
71 16, 17, 18, 18, 19, 16,
72 20, 21, 22, 22, 23, 20
85 const float hs = 1.0f;
89 -hs, 0.0f, -hs, 0.0f, 1.0f, 0.0f,
90 hs, 0.0f, -hs, 0.0f, 1.0f, 0.0f,
91 hs, 0.0f, hs, 0.0f, 1.0f, 0.0f,
92 -hs, 0.0f, hs, 0.0f, 1.0f, 0.0f
107 const float hs = 1.0f;
132 VertexType(
vec3 P,
vec3 N) : position(P), normal(N) { }
137 VertexType *
vertices =
new VertexType[t_samples * s_samples * 4];
142 float dtheta = 2.0f *
PI /
float(t_samples);
143 float dphi =
PI /
float(s_samples);
144 for (
int t = 0; t < t_samples; ++t)
146 for (
int s = 0; s < s_samples; ++s)
148 float theta = t * dtheta;
149 float phi = s * dphi;
152 float r1 = sin(phi + dphi);
154 vec3 v00(r0 * cos(theta), cos(phi), r0 * sin(theta));
155 vec3 v10(r0 * cos(theta + dtheta), cos(phi), r0 * sin(theta + dtheta));
156 vec3 v01(r1 * cos(theta), cos(phi + dphi), r1 * sin(theta));
157 vec3 v11(r1 * cos(theta + dtheta), cos(phi + dphi), r1 * sin(theta + dtheta));
159 vertices[vertex_index + 0] = VertexType(v00,
normalize(v00));
160 vertices[vertex_index + 1] = VertexType(v10,
normalize(v10));
161 vertices[vertex_index + 2] = VertexType(v11,
normalize(v11));
162 vertices[vertex_index + 3] = VertexType(v01,
normalize(v01));
164 indices[index_index + 0] = vertex_index + 0;
165 indices[index_index + 1] = vertex_index + 1;
166 indices[index_index + 2] = vertex_index + 2;
167 indices[index_index + 3] = vertex_index + 2;
168 indices[index_index + 4] = vertex_index + 3;
169 indices[index_index + 5] = vertex_index + 0;
void del_buffer(GLuint buffer)
Mesh gen_normal_sphere(int t_samples, int s_samples)
static vec3 normalize(const vec3 &v)
GLsizei GLenum const void * indices
GLuint gen_buffer(GLenum target, GLenum usage, GLsizei size, const void *data)