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
169 int vertices = (slices + 1) * stacks;169 int vertices = (slices + 1) * stacks;
170 int indices = 2 * 3 * slices * (stacks - 1);170 int indices = 2 * 3 * slices * (stacks - 1);
171 if (vbo.first == 0) { 171 if (vbo.first == 0) {
172 GLfloat* vertexData = new GLfloat[vertices * 3];172 GLfloat* vertexData = new GLfloat[vertices * 2 * 3];
173 GLfloat* vertex = vertexData;173 GLfloat* vertex = vertexData;
174 for (int i = 0; i <= (stacks - 1); i++) {174 for (int i = 0; i <= (stacks - 1); i++) {
175 float y = (float)i / (stacks - 1);175 float y = (float)i / (stacks - 1);
176 float radius = 1.0f;
177 176
178 for (int j = 0; j <= slices; j++) {177 for (int j = 0; j <= slices; j++) {
179 float theta = 3 * PIf / 2 + PIf * j / slices;178 float theta = 3 * PIf / 2 + PIf * j / slices;
180 179
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);
182 *(vertex++) = y;187 *(vertex++) = y;
183 *(vertex++) = cosf(theta) * radius;188 *(vertex++) = cosf(theta);
184 }189 }
185 }190 }
186 191
@@ -196,7 +201,7 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) { · 9 unmodified lines
196 GLushort bottom = i * (slices + 1);201 GLushort bottom = i * (slices + 1);
197 GLushort top = bottom + slices + 1;202 GLushort top = bottom + slices + 1;
198 for (int j = 0; j < slices; j++) {203 for (int j = 0; j < slices; j++) {
199 int next = (j + 1) % slices;204 int next = j + 1;
200 205
201 *(index++) = bottom + j;206 *(index++) = bottom + j;
202 *(index++) = top + next;207 *(index++) = top + next;
@@ -220,9 +225,9 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) { · 17 unmodified lines
220 }225 }
221 glEnableClientState(GL_VERTEX_ARRAY);226 glEnableClientState(GL_VERTEX_ARRAY);
222 glEnableClientState(GL_NORMAL_ARRAY);227 glEnableClientState(GL_NORMAL_ARRAY);
223 228
224 glVertexPointer(3, GL_FLOAT, 0, 0);229 glNormalPointer(GL_FLOAT, 6 * sizeof(float), 0);
225 glNormalPointer(GL_FLOAT, 0, 0);230 glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), 3 * sizeof(float));
226 231
227 glDrawRangeElementsEXT(GL_TRIANGLES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);232 glDrawRangeElementsEXT(GL_TRIANGLES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);
228 233