Changeset 2746 for GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.cpp
- Timestamp:
- 06/10/08 10:54:13 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.cpp
r2642 r2746 89 89 return true; 90 90 } 91 91 92 92 93 void Geometry::GenerateList() … … 112 113 break; 113 114 } 115 114 116 glEndList(); 115 117 } 116 118 } 119 117 120 118 121 void Geometry::Render() … … 238 241 { 239 242 glBegin(GL_TRIANGLE_STRIP); 240 while(teapot_indices[i] != STRIP_END) 241 { 242 int index = teapot_indices[i] * 3; 243 244 glNormal3fv(teapot_normals + index); 245 glVertex3fv(teapot_vertices + index); 246 247 i++; 248 } 243 244 while (teapot_indices[i] != STRIP_END) 245 { 246 int index = teapot_indices[i] * 3; 247 248 glNormal3fv(teapot_normals + index); 249 glVertex3fv(teapot_vertices + index); 250 251 ++ i; 252 } 253 249 254 glEnd(); 250 251 i++; // skip strip end flag 252 } 253 } 255 256 ++ i; // skip strip end flag 257 } 258 } 259 254 260 255 261 void Geometry::CalcBoundingVolume() … … 276 282 Vector3 *rotatedPoints = new Vector3[num_vertices]; 277 283 278 for (int i = 0; i < num_vertices; i++)284 for (int i = 0; i < num_vertices; ++ i) 279 285 { 280 286 copyVector3Values(rotatedPoints[i], vertices[i * 3], … … 288 294 calcCubicHull(mBoundingBox.min, mBoundingBox.max, rotatedPoints, num_vertices); 289 295 290 for (int i=0; i< 3; i++)296 for (int i = 0; i < 3; ++ i) 291 297 { 292 298 mBoundingBox.min[i] *= mScale; … … 325 331 } 326 332 327 /* 328 creates a torus with specified radii, with number of rings and ring 333 /* Creates a torus with specified radii, with number of rings and ring 329 334 subdivision = precision. 330 335 */ … … 338 343 torus_indices = new int[num_torus_indices]; 339 344 340 for (int i = 0; i < precision + 1; ++ i)345 for (int i = 0; i < precision + 1; ++ i) 341 346 { 342 347 int index = i * 3; … … 364 369 } 365 370 366 for (int i_rng = 1; i_rng < precision + 1; ++ i_rng)367 { 368 for(int i =0; i<precision+1; ++i)371 for (int i_rng = 1; i_rng < precision + 1; ++ i_rng) 372 { 373 for(int i = 0; i<precision + 1; ++ i) 369 374 { 370 375 int index = 3 * (i_rng * (precision + 1) + i); … … 388 393 } 389 394 390 for (int i_rng = 0; i_rng < precision; ++ i_rng)391 { 392 for (int i = 0; i < precision; ++ i)395 for (int i_rng = 0; i_rng < precision; ++ i_rng) 396 { 397 for (int i = 0; i < precision; ++ i) 393 398 { 394 399 int index = ((i_rng * precision + i) * 2) * 3; … … 407 412 } 408 413 409 /** 410 counts the triangles of the teapot.414 415 /** Counts the triangles of the teapot. 411 416 traverses through all the triangle strips. 412 417 */ … … 414 419 { 415 420 int result = 0; 416 int i=0; 421 int i = 0; 422 417 423 // n - 2 triangles are drawn for a strip 418 while (i < num_teapot_indices)419 { 420 while (teapot_indices[i] != STRIP_END)424 while (i < num_teapot_indices) 425 { 426 while (teapot_indices[i] != STRIP_END) 421 427 { 422 428 result ++;; 423 i++;429 ++ i; 424 430 } 425 431 result -= 2; 426 i++; // skip STRIP_END 427 } 432 ++ i; // skip STRIP_END 433 } 434 428 435 return result; 429 436 } 430 437 431 /** 432 counts the triangles of the torus438 439 /** Counts the triangles of the torus 433 440 */ 434 441 int Geometry::CountTorusTriangles() … … 452 459 int result = 0; 453 460 454 switch (objectType)461 switch (objectType) 455 462 { 456 463 case TEAPOT: … … 466 473 break; 467 474 } 475 468 476 return result; 469 477 } … … 497 505 } 498 506 499 /** 500 renders a sphere with sphere_precision subdivisions. 501 note: works only for even sphere_precision507 508 /** Renders a sphere with sphere_precision subdivisions. 509 Note: works only for even sphere_precision 502 510 */ 503 511 void Geometry::RenderSphere() … … 508 516 glFrontFace(GL_CW); 509 517 510 for (int j = 0; j < sphere_precision /2; ++j)518 for (int j = 0; j < sphere_precision / 2; ++ j) 511 519 { 512 520 double alpha = j * PI * 2.0 / (double)sphere_precision - PI_2; … … 515 523 glBegin(GL_TRIANGLE_STRIP); 516 524 517 for (int i = 0; i <= sphere_precision; ++ i)525 for (int i = 0; i <= sphere_precision; ++ i) 518 526 { 519 527 double gamma = i * PI * 2.0 / (double)sphere_precision; … … 536 544 glEnd(); 537 545 } 546 538 547 glFrontFace(GL_CCW); 539 548 }
Note: See TracChangeset
for help on using the changeset viewer.