History

Fix renderHalfCylinder so that normals are correct now. Add facePosition and faceRotation storage to Face class.

Hifi Test Account committed 13 years ago

Commit 1e7dbbb1 parent 988faef3 files · +19 −9Browse files

Showing the changes to interface/src/renderer/GeometryCache.cpp (1 of 3 files). Show all

Unified · Split

interface/src/renderer/GeometryCache.cpp+13−8
@@ -169,18 +169,23 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) { · 168 unmodified lines
169169 int vertices = (slices + 1) * stacks;
170170 int indices = 2 * 3 * slices * (stacks - 1);
171171 if (vbo.first == 0) {
172− GLfloat* vertexData = new GLfloat[vertices * 3];
172+ GLfloat* vertexData = new GLfloat[vertices * 2 * 3];
173173 GLfloat* vertex = vertexData;
174174 for (int i = 0; i <= (stacks - 1); i++) {
175175 float y = (float)i / (stacks - 1);
176− float radius = 1.0f;
177176
178177 for (int j = 0; j <= slices; j++) {
179178 float theta = 3 * PIf / 2 + PIf * j / slices;
180179
181− *(vertex++) = sinf(theta) * radius;
180+ //normals
181+ *(vertex++) = sinf(theta);
182+ *(vertex++) = 0;
183+ *(vertex++) = cosf(theta);
184+
185+ // vertices
186+ *(vertex++) = sinf(theta);
182187 *(vertex++) = y;
183− *(vertex++) = cosf(theta) * radius;
188+ *(vertex++) = cosf(theta);
184189 }
185190 }
186191
@@ -196,7 +201,7 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) { · 9 unmodified lines
196201 GLushort bottom = i * (slices + 1);
197202 GLushort top = bottom + slices + 1;
198203 for (int j = 0; j < slices; j++) {
199− int next = (j + 1) % slices;
204+ int next = j + 1;
200205
201206 *(index++) = bottom + j;
202207 *(index++) = top + next;
@@ -220,9 +225,9 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) { · 17 unmodified lines
220225 }
221226 glEnableClientState(GL_VERTEX_ARRAY);
222227 glEnableClientState(GL_NORMAL_ARRAY);
223−
224− glVertexPointer(3, GL_FLOAT, 0, 0);
225− glNormalPointer(GL_FLOAT, 0, 0);
228+
229+ glNormalPointer(GL_FLOAT, 6 * sizeof(float), 0);
230+ glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), 3 * sizeof(float));
226231
227232 glDrawRangeElementsEXT(GL_TRIANGLES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);
228233