- Timestamp:
- 02/05/07 13:29:55 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/camera.cpp
r983 r2090 174 174 175 175 switch (type) { 176 case OCTAHEDRON:177 cameras = (Camera *)malloc(sizeof(Camera) * type);176 case 0: 177 cameras = (Camera *)malloc(sizeof(Camera) * OCTAHEDRON); 178 178 if (cameras == NULL) { 179 179 fprintf(stderr, "Error allocating memory\n"); 180 180 exit(1); 181 181 } 182 *numCameras = type;182 *numCameras = OCTAHEDRON; 183 183 drawOctahedron(cameras, radius); 184 184 break; 185 case ICOSAHEDRON:186 cameras = (Camera *)malloc(sizeof(Camera) * type);185 case 1: 186 cameras = (Camera *)malloc(sizeof(Camera) * CUBE); 187 187 if (cameras == NULL) { 188 188 fprintf(stderr, "Error allocating memory\n"); 189 189 exit(1); 190 190 } 191 *numCameras = type;192 draw Icosahedron(cameras, radius);191 *numCameras = CUBE; 192 drawCube(cameras, radius); 193 193 break; 194 case DODECAHEDRON:195 cameras = (Camera *)malloc(sizeof(Camera) * type);194 case 2: 195 cameras = (Camera *)malloc(sizeof(Camera) * ICOSAHEDRON); 196 196 if (cameras == NULL) { 197 197 fprintf(stderr, "Error allocating memory\n"); 198 198 exit(1); 199 199 } 200 *numCameras = type; 200 *numCameras = ICOSAHEDRON; 201 drawIcosahedron(cameras, radius); 202 break; 203 case 3: 204 cameras = (Camera *)malloc(sizeof(Camera) * DODECAHEDRON); 205 if (cameras == NULL) { 206 fprintf(stderr, "Error allocating memory\n"); 207 exit(1); 208 } 209 *numCameras = DODECAHEDRON; 201 210 drawDodecahedron(cameras, radius); 202 211 break; 203 212 default: 204 printf("Error cameras not defined\n");213 printf("Error, cameras not defined\n"); 205 214 exit(1); 206 215 break; 207 216 } 217 218 printf("Number of cameras: %d\n", *numCameras); 208 219 209 220 return cameras; … … 506 517 copyToCameras(cameras, 12, vertices); 507 518 } 519 520 void VMI::drawCube(Camera *cameras, GLdouble r) // any radius in which the polyhedron is inscribed 521 { 522 GLdouble vertices[8][3] = { 523 {-1, -1, 1}, // vertex v0 524 {1, -1, 1}, // vertex v1 525 {1, -1, -1}, // vertex v2 526 {-1, -1, -1}, // vertex v3 527 {-1, 1, 1}, // vertex v4 528 {1, 1, 1}, // vertex v5 529 {1, 1, -1}, // vertex v6 530 {-1, 1, -1}, // vertex v7 531 }; // 8 vertices with x, y, z coordinates 532 int i; 533 #ifdef DRAW_DEBUG 534 int tindex[12][3] = { 535 536 {0, 1, 4}, //polygon v0,v1,v4 537 {1, 5, 4}, //polygon v1,v5,v4 538 {1, 2, 5}, //polygon v1,v2,v5 539 {2, 6, 5}, //polygon v2,v6,v5 540 {2, 3, 6}, //polygon v2,v3,v6 541 {3, 7, 6}, //polygon v3,v7,v6 542 {3, 0, 7}, //polygon v3,v0,v7 543 {0, 4, 7}, //polygon v0,v4,v7 544 {4, 5, 7}, //polygon v4,v5,v7 545 {5, 6, 7}, //polygon v5,v6,v7 546 {3, 2, 0}, //polygon v3,v2,v0 547 {2, 1, 0}, //polygon v2,v1,v0 548 }; 549 #endif 550 551 for(i=0; i<8; i++) 552 { 553 vertices[i][0]*=r; 554 vertices[i][1]*=r; 555 vertices[i][2]*=r; 556 } 557 558 // map vertices to 12 faces 559 #ifdef DRAW_DEBUG 560 561 for (i=0; i<12; i++) { 562 563 glBegin(GL_POINTS ); 564 glVertex3fv(&vertices[tindex[i][0]][0]); 565 glVertex3fv(&vertices[tindex[i][1]][0]); 566 glVertex3fv(&vertices[tindex[i][2]][0]); 567 glEnd(); 568 } 569 570 #endif 571 572 copyToCameras(cameras, 8, vertices); 573 } 574
Note: See TracChangeset
for help on using the changeset viewer.