- Timestamp:
- Nov 21, 2004, 3:32:08 AM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/object.cc
r2866 r2935 297 297 } 298 298 objFileName = fileName; 299 char Buffer[ 500];299 char Buffer[10000]; 300 300 while(!OBJ_FILE->eof()) 301 301 { 302 OBJ_FILE->getline(Buffer, 500);302 OBJ_FILE->getline(Buffer, 10000); 303 303 if (verbose >=4) 304 304 printf ("Read input line: %s\n",Buffer); … … 379 379 { 380 380 currentGroup->vertices->finalizeArray(); 381 glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());381 // glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray()); 382 382 currentGroup->normals->finalizeArray(); 383 glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());383 // glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray()); 384 384 currentGroup->vTexture->finalizeArray(); 385 385 } … … 387 387 readingVertices = false; 388 388 currentGroup->faceCount++; 389 char subbuffer1[20]; 390 char subbuffer2[20]; 391 char subbuffer3[20]; 392 char subbuffer4[20] =""; 393 sscanf (faceString, "%s %s %s %s", subbuffer1, subbuffer2, subbuffer3, subbuffer4); 394 if (!strcmp(subbuffer4, "")) 389 390 int elemCount = 0; 391 392 FaceElement* firstElem = new FaceElement; 393 FaceElement* tmpElem = firstElem; 394 395 396 while(strcmp (faceString, "\0")) 397 { 398 if (elemCount>0) 399 tmpElem = tmpElem->next = new FaceElement; 400 tmpElem->next = NULL; 401 402 403 sscanf (faceString, "%s", tmpElem->value); 404 faceString += strlen(tmpElem->value); 405 if (strcmp (faceString, "\0")) 406 faceString++; 407 elemCount++; 408 409 410 } 411 412 413 if (elemCount == 3) 395 414 { 396 415 if (currentGroup->faceMode != 3) … … 403 422 currentGroup->faceMode = 3; 404 423 if (verbose >=3) 405 printf ("found triag: %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3); 406 addGLElement(subbuffer1); 407 addGLElement(subbuffer2); 408 addGLElement(subbuffer3); 409 return true; 410 } 411 else 424 printf ("found triag.\n"); 425 } 426 427 else if (elemCount == 4) 412 428 { 413 429 if (currentGroup->faceMode != 4) … … 419 435 currentGroup->faceMode = 4; 420 436 if (verbose >=3 ) 421 printf ("found quad: %s, %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3, subbuffer4); 422 addGLElement(subbuffer1); 423 addGLElement(subbuffer2); 424 addGLElement(subbuffer3); 425 addGLElement(subbuffer4); 426 return true; 427 } 437 printf ("found quad.\n"); 438 } 439 440 else if (elemCount > 4) 441 { 442 if (currentGroup->faceMode != -1) 443 glEnd(); 444 glBegin(GL_POLYGON); 445 if (verbose >=3) 446 printf ("Polygon with %i faces found.", elemCount); 447 currentGroup->faceMode = elemCount; 448 } 449 450 tmpElem = firstElem; 451 while (tmpElem != NULL) 452 { 453 // printf ("%s\n", tmpElem->value); 454 addGLElement(tmpElem->value); 455 tmpElem = tmpElem->next; 456 } 457 428 458 } 429 459 … … 444 474 445 475 char* texture; 446 texture = strstr (vertex, "/"); 447 texture[0] = '\0'; 448 texture ++; 449 if (verbose>=3) 450 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()); 451 glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2); 452 453 char* normal; 454 if ((normal = strstr (texture, "/")) !=NULL) 455 { 456 normal[0] = '\0'; 457 normal ++; 458 //glArrayElement(atoi(vertex)-1); 459 glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3); 476 if ((texture = strstr (vertex, "/")) != NULL) 477 { 478 texture[0] = '\0'; 479 texture ++; 480 if (verbose>=3) 481 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()); 482 glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2); 483 484 char* normal; 485 if ((normal = strstr (texture, "/")) !=NULL) 486 { 487 normal[0] = '\0'; 488 normal ++; 489 //glArrayElement(atoi(vertex)-1); 490 glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3); 491 } 460 492 } 461 493 if (verbose>=3) -
orxonox/trunk/src/object.h
r2866 r2935 18 18 extern int verbose; //!< fill be removed and added again as a verbose-class 19 19 20 21 struct FaceElement 22 { 23 char value[20]; 24 FaceElement* next; 25 }; 20 26 21 27 //! Class that handles 3D-Objects. it can also read them in and display them.
Note: See TracChangeset
for help on using the changeset viewer.