Changeset 2977 in orxonox.OLD for orxonox/branches/osX/importer/object.cc
- Timestamp:
- Nov 24, 2004, 12:50:55 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/osX/importer/object.cc
r2863 r2977 48 48 \param scaling The factor that the object will be scaled with. 49 49 */ 50 51 50 Object::Object(char* fileName, float scaling) 52 51 { … … 90 89 groupCount = 0; 91 90 92 initGroup ( currentGroup);91 initGroup (firstGroup); 93 92 mtlFileName = ""; 94 93 scaleFactor = 1; 95 94 material = new Material(); 96 95 97 glEnableClientState (GL_VERTEX_ARRAY);96 // glEnableClientState (GL_VERTEX_ARRAY); 98 97 // glEnableClientState (GL_NORMAL_ARRAY); 99 98 // glEnableClientState (GL_TEXTURE_COORD_ARRAY); … … 226 225 group->name = ""; 227 226 group->faceMode = -1; 228 group->faceCount = 0;227 group->faceCount = 0; 229 228 if ((group->listNumber = glGenLists(1)) == 0 ) 230 229 { … … 237 236 group->firstVertex = 0; 238 237 group->firstNormal = 0; 239 group->first Normal= 0;238 group->firstVertexTexture = 0; 240 239 } 241 240 else … … 265 264 glEndList(); 266 265 } 266 267 267 /** 268 268 \brief deletes the Arrays of the Group to save space. … … 295 295 } 296 296 objFileName = fileName; 297 char Buffer[ 500];297 char Buffer[10000]; 298 298 while(!OBJ_FILE->eof()) 299 299 { 300 OBJ_FILE->getline(Buffer, 500);300 OBJ_FILE->getline(Buffer, 10000); 301 301 if (verbose >=4) 302 302 printf ("Read input line: %s\n",Buffer); … … 377 377 { 378 378 currentGroup->vertices->finalizeArray(); 379 glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());379 // glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray()); 380 380 currentGroup->normals->finalizeArray(); 381 glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());381 // glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray()); 382 382 currentGroup->vTexture->finalizeArray(); 383 383 } … … 385 385 readingVertices = false; 386 386 currentGroup->faceCount++; 387 char subbuffer1[20]; 388 char subbuffer2[20]; 389 char subbuffer3[20]; 390 char subbuffer4[20] =""; 391 sscanf (faceString, "%s %s %s %s", subbuffer1, subbuffer2, subbuffer3, subbuffer4); 392 if (!strcmp(subbuffer4, "")) 387 388 int elemCount = 0; 389 390 FaceElement* firstElem = new FaceElement; 391 FaceElement* tmpElem = firstElem; 392 393 394 while(strcmp (faceString, "\0")) 395 { 396 if (elemCount>0) 397 tmpElem = tmpElem->next = new FaceElement; 398 tmpElem->next = NULL; 399 400 401 sscanf (faceString, "%s", tmpElem->value); 402 faceString += strlen(tmpElem->value); 403 if (strcmp (faceString, "\0")) 404 faceString++; 405 elemCount++; 406 407 408 } 409 410 411 if (elemCount == 3) 393 412 { 394 413 if (currentGroup->faceMode != 3) … … 401 420 currentGroup->faceMode = 3; 402 421 if (verbose >=3) 403 printf ("found triag: %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3); 404 addGLElement(subbuffer1); 405 addGLElement(subbuffer2); 406 addGLElement(subbuffer3); 407 return true; 408 } 409 else 422 printf ("found triag.\n"); 423 } 424 425 else if (elemCount == 4) 410 426 { 411 427 if (currentGroup->faceMode != 4) … … 417 433 currentGroup->faceMode = 4; 418 434 if (verbose >=3 ) 419 printf ("found quad: %s, %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3, subbuffer4); 420 addGLElement(subbuffer1); 421 addGLElement(subbuffer2); 422 addGLElement(subbuffer3); 423 addGLElement(subbuffer4); 424 return true; 425 } 435 printf ("found quad.\n"); 436 } 437 438 else if (elemCount > 4) 439 { 440 if (currentGroup->faceMode != -1) 441 glEnd(); 442 glBegin(GL_POLYGON); 443 if (verbose >=3) 444 printf ("Polygon with %i faces found.", elemCount); 445 currentGroup->faceMode = elemCount; 446 } 447 448 tmpElem = firstElem; 449 FaceElement* delElem; 450 while (tmpElem != NULL) 451 { 452 // printf ("%s\n", tmpElem->value); 453 addGLElement(tmpElem->value); 454 delElem = tmpElem; 455 tmpElem = tmpElem->next; 456 delete delElem; 457 } 458 426 459 } 427 460 … … 442 475 443 476 char* texture; 444 texture = strstr (vertex, "/"); 445 texture[0] = '\0'; 446 texture ++; 447 if (verbose>=3) 448 printf ("includeing texture #%i, and mapping it to group texture #%i, textureArray has %i entries.\n", atoi(texture), (atoi(texture)-1 - currentGroup->firstVertexTexture)*3, currentGroup->vTexture->getCount()); 449 glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2); 450 451 char* normal; 452 if ((normal = strstr (texture, "/")) !=NULL) 453 { 454 normal[0] = '\0'; 455 normal ++; 456 //glArrayElement(atoi(vertex)-1); 457 glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3); 477 if ((texture = strstr (vertex, "/")) != NULL) 478 { 479 texture[0] = '\0'; 480 texture ++; 481 if (verbose>=3) 482 printf ("includeing texture #%i, and mapping it to group texture #%i, textureArray has %i entries.\n", atoi(texture), (atoi(texture)-1 - currentGroup->firstVertexTexture)*2, currentGroup->vTexture->getCount()); 483 glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2); 484 485 char* normal; 486 if ((normal = strstr (texture, "/")) !=NULL) 487 { 488 normal[0] = '\0'; 489 normal ++; 490 //glArrayElement(atoi(vertex)-1); 491 glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3); 492 } 458 493 } 459 494 if (verbose>=3) … … 603 638 \param matString the Material that will be set. 604 639 */ 605 606 640 bool Object::readUseMtl (char* matString) 607 641 { … … 635 669 readVertex ("-0.500000 -0.500000 -0.500000"); 636 670 readVertex ("0.500000 -0.500000 -0.500000"); 671 637 672 readVertexTexture ("0.000000 0.000000"); 638 673 readVertexTexture ("1.000000 0.000000");
Note: See TracChangeset
for help on using the changeset viewer.