Changeset 3396 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Feb 6, 2005, 3:58:40 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/Makefile.am
r3377 r3396 25 25 environment.cc \ 26 26 importer/model.cc \ 27 importer/objModel.cc \ 27 28 importer/array.cc \ 28 29 importer/material.cc \ -
orxonox/trunk/src/Makefile.in
r3377 r3396 59 59 track.$(OBJEXT) base_entity.$(OBJEXT) game_loader.$(OBJEXT) \ 60 60 campaign.$(OBJEXT) story_entity.$(OBJEXT) \ 61 environment.$(OBJEXT) model.$(OBJEXT) array.$(OBJEXT) \ 62 material.$(OBJEXT) texture.$(OBJEXT) list.$(OBJEXT) \ 63 p_node.$(OBJEXT) null_parent.$(OBJEXT) base_object.$(OBJEXT) \ 64 helper_parent.$(OBJEXT) track_manager.$(OBJEXT) \ 65 matrix.$(OBJEXT) curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT) 61 environment.$(OBJEXT) model.$(OBJEXT) objModel.$(OBJEXT) \ 62 array.$(OBJEXT) material.$(OBJEXT) texture.$(OBJEXT) \ 63 list.$(OBJEXT) p_node.$(OBJEXT) null_parent.$(OBJEXT) \ 64 base_object.$(OBJEXT) helper_parent.$(OBJEXT) \ 65 track_manager.$(OBJEXT) matrix.$(OBJEXT) curve.$(OBJEXT) \ 66 glmenu_imagescreen.$(OBJEXT) 66 67 orxonox_OBJECTS = $(am_orxonox_OBJECTS) 67 68 orxonox_LDADD = $(LDADD) … … 82 83 @AMDEP_TRUE@ ./$(DEPDIR)/list.Po ./$(DEPDIR)/material.Po \ 83 84 @AMDEP_TRUE@ ./$(DEPDIR)/matrix.Po ./$(DEPDIR)/model.Po \ 84 @AMDEP_TRUE@ ./$(DEPDIR)/null_parent.Po ./$(DEPDIR)/o rxonox.Po \85 @AMDEP_TRUE@ ./$(DEPDIR)/ p_node.Po ./$(DEPDIR)/player.Po \86 @AMDEP_TRUE@ ./$(DEPDIR)/ story_entity.Po ./$(DEPDIR)/texture.Po \87 @AMDEP_TRUE@ ./$(DEPDIR)/t rack.Po ./$(DEPDIR)/track_manager.Po \88 @AMDEP_TRUE@ ./$(DEPDIR)/ vector.Po ./$(DEPDIR)/world.Po \89 @AMDEP_TRUE@ ./$(DEPDIR)/world _entity.Po85 @AMDEP_TRUE@ ./$(DEPDIR)/null_parent.Po ./$(DEPDIR)/objModel.Po \ 86 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox.Po ./$(DEPDIR)/p_node.Po \ 87 @AMDEP_TRUE@ ./$(DEPDIR)/player.Po ./$(DEPDIR)/story_entity.Po \ 88 @AMDEP_TRUE@ ./$(DEPDIR)/texture.Po ./$(DEPDIR)/track.Po \ 89 @AMDEP_TRUE@ ./$(DEPDIR)/track_manager.Po ./$(DEPDIR)/vector.Po \ 90 @AMDEP_TRUE@ ./$(DEPDIR)/world.Po ./$(DEPDIR)/world_entity.Po 90 91 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 91 92 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) … … 225 226 environment.cc \ 226 227 importer/model.cc \ 228 importer/objModel.cc \ 227 229 importer/array.cc \ 228 230 importer/material.cc \ … … 378 380 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/model.Po@am__quote@ 379 381 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/null_parent.Po@am__quote@ 382 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/objModel.Po@am__quote@ 380 383 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox.Po@am__quote@ 381 384 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/p_node.Po@am__quote@ … … 420 423 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 421 424 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o model.obj `if test -f 'importer/model.cc'; then $(CYGPATH_W) 'importer/model.cc'; else $(CYGPATH_W) '$(srcdir)/importer/model.cc'; fi` 425 426 objModel.o: importer/objModel.cc 427 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT objModel.o -MD -MP -MF "$(DEPDIR)/objModel.Tpo" -c -o objModel.o `test -f 'importer/objModel.cc' || echo '$(srcdir)/'`importer/objModel.cc; \ 428 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/objModel.Tpo" "$(DEPDIR)/objModel.Po"; else rm -f "$(DEPDIR)/objModel.Tpo"; exit 1; fi 429 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='importer/objModel.cc' object='objModel.o' libtool=no @AMDEPBACKSLASH@ 430 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/objModel.Po' tmpdepfile='$(DEPDIR)/objModel.TPo' @AMDEPBACKSLASH@ 431 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 432 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o objModel.o `test -f 'importer/objModel.cc' || echo '$(srcdir)/'`importer/objModel.cc 433 434 objModel.obj: importer/objModel.cc 435 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT objModel.obj -MD -MP -MF "$(DEPDIR)/objModel.Tpo" -c -o objModel.obj `if test -f 'importer/objModel.cc'; then $(CYGPATH_W) 'importer/objModel.cc'; else $(CYGPATH_W) '$(srcdir)/importer/objModel.cc'; fi`; \ 436 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/objModel.Tpo" "$(DEPDIR)/objModel.Po"; else rm -f "$(DEPDIR)/objModel.Tpo"; exit 1; fi 437 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='importer/objModel.cc' object='objModel.obj' libtool=no @AMDEPBACKSLASH@ 438 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/objModel.Po' tmpdepfile='$(DEPDIR)/objModel.TPo' @AMDEPBACKSLASH@ 439 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 440 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o objModel.obj `if test -f 'importer/objModel.cc'; then $(CYGPATH_W) 'importer/objModel.cc'; else $(CYGPATH_W) '$(srcdir)/importer/objModel.cc'; fi` 422 441 423 442 array.o: importer/array.cc -
orxonox/trunk/src/environment.cc
r3380 r3396 21 21 #include "world_entity.h" 22 22 #include "vector.h" 23 #include "importer/ model.h"23 #include "importer/objModel.h" 24 24 25 25 using namespace std; … … 29 29 Environment::Environment () : WorldEntity() 30 30 { 31 this->model = new Model("../data/models/fighter.obj");31 this->model = new OBJModel("../data/models/fighter.obj"); 32 32 } 33 33 -
orxonox/trunk/src/importer/Makefile.am
r3365 r3396 9 9 windowHandler.cc \ 10 10 model.cc \ 11 objModel.cc \ 11 12 array.cc \ 12 13 material.cc \ … … 17 18 windowHandler.h \ 18 19 model.h \ 20 objModel.h \ 19 21 array.h \ 20 22 material.h \ -
orxonox/trunk/src/importer/Makefile.in
r3377 r3396 54 54 PROGRAMS = $(bin_PROGRAMS) 55 55 am_importer_OBJECTS = framework.$(OBJEXT) windowHandler.$(OBJEXT) \ 56 model.$(OBJEXT) array.$(OBJEXT) material.$(OBJEXT) \57 texture.$(OBJEXT) vector.$(OBJEXT)56 model.$(OBJEXT) objModel.$(OBJEXT) array.$(OBJEXT) \ 57 material.$(OBJEXT) texture.$(OBJEXT) vector.$(OBJEXT) 58 58 importer_OBJECTS = $(am_importer_OBJECTS) 59 59 importer_LDADD = $(LDADD) … … 63 63 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/array.Po ./$(DEPDIR)/framework.Po \ 64 64 @AMDEP_TRUE@ ./$(DEPDIR)/material.Po ./$(DEPDIR)/model.Po \ 65 @AMDEP_TRUE@ ./$(DEPDIR)/ texture.Po ./$(DEPDIR)/vector.Po \66 @AMDEP_TRUE@ ./$(DEPDIR)/ windowHandler.Po65 @AMDEP_TRUE@ ./$(DEPDIR)/objModel.Po ./$(DEPDIR)/texture.Po \ 66 @AMDEP_TRUE@ ./$(DEPDIR)/vector.Po ./$(DEPDIR)/windowHandler.Po 67 67 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 68 68 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) … … 180 180 windowHandler.cc \ 181 181 model.cc \ 182 objModel.cc \ 182 183 array.cc \ 183 184 material.cc \ … … 188 189 windowHandler.h \ 189 190 model.h \ 191 objModel.h \ 190 192 array.h \ 191 193 material.h \ … … 262 264 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/material.Po@am__quote@ 263 265 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/model.Po@am__quote@ 266 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/objModel.Po@am__quote@ 264 267 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/texture.Po@am__quote@ 265 268 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector.Po@am__quote@ -
orxonox/trunk/src/importer/framework.cc
r3365 r3396 71 71 PRINTF(2)("screensize: %i, %i\n", wHandler.screen->w, wHandler.screen->h); 72 72 if (argc>=3) 73 obj = new Model (argv[1], atof(argv[2]));73 obj = new OBJModel (argv[1], atof(argv[2])); 74 74 else if (argc>=2) 75 obj = new Model(argv[1]);75 obj = new OBJModel(argv[1]); 76 76 else 77 obj = new Model();77 obj = (OBJModel*) new Model(); 78 78 79 79 M = Vector(wHandler.screen->w/2, wHandler.screen->h/2, 0); … … 215 215 case SDLK_c: 216 216 if (!obj) 217 obj = new Model(argv[1]);217 obj = new OBJModel(argv[1]); 218 218 break; 219 219 } -
orxonox/trunk/src/importer/framework.h
r3365 r3396 3 3 4 4 #include "windowHandler.h" // Include the Whandler Basecode 5 #include " model.h"5 #include "objModel.h" 6 6 #include "vector.h" 7 7 … … 33 33 34 34 WindowHandler wHandler; // Create an instance of the whandler basecode class 35 Model* obj;35 OBJModel* obj; 36 36 37 37 -
orxonox/trunk/src/importer/material.cc
r3365 r3396 112 112 while (searcher != NULL) 113 113 { 114 PRINT F(2)(".");114 PRINT(2)("."); 115 115 if (!strcmp (searcher->getName(), mtlName)) 116 116 { 117 PRINT F(2)("found.\n");117 PRINT(2)("found.\n"); 118 118 return searcher; 119 119 } 120 120 searcher = searcher->nextMat; 121 121 } 122 PRINT F(2)("not found\n");122 PRINT(2)("not found\n"); 123 123 return NULL; 124 124 } -
orxonox/trunk/src/importer/model.cc
r3365 r3396 36 36 37 37 /** 38 \brief Crates a 3D-Model and loads in a File.39 \param fileName file to parse and load (must be a .obj file)40 */41 Model::Model(char* fileName)42 {43 this->initialize();44 45 this->importFile (fileName);46 47 this->importToGL ();48 49 this->cleanup();50 }51 52 /**53 \brief Crates a 3D-Model, loads in a File and scales it.54 \param fileName file to parse and load (must be a .obj file)55 \param scaling The factor that the model will be scaled with.56 */57 Model::Model(char* fileName, float scaling)58 {59 this->initialize();60 this->scaleFactor = scaling;61 62 this->importFile (fileName);63 64 this->importToGL ();65 66 this->cleanup();67 }68 69 /**70 38 \brief deletes an Model. 71 39 … … 74 42 Model::~Model() 75 43 { 44 PRINTF(0)("Deleting Model "); 45 if (this->name) 46 { 47 PRINT(0)("%s\n"); 48 delete []this->name; 49 } 50 else 51 PRINT(0)("\n"); 52 76 53 PRINTF(2)("Deleting display Lists.\n"); 77 54 Group* walker = this->firstGroup; … … 84 61 } 85 62 86 if (this->objPath)87 delete []this->objPath;88 if (this->objFileName)89 delete []this->objFileName;90 if (this->mtlFileName)91 delete []this->mtlFileName;92 63 PRINTF(2)("Deleting Materials.\n"); 93 64 if (this->material) 94 65 delete this->material; 95 66 } 96 97 67 98 68 /** … … 139 109 walker = walker->next; 140 110 } 141 PRINTF(1)("Model number %i in %s not Found.\n", groupNumber, this-> objFileName);111 PRINTF(1)("Model number %i in %s not Found.\n", groupNumber, this->name); 142 112 return; 143 113 … … 164 134 walker = walker->next; 165 135 } 166 PRINTF(1)("Model Named %s in %s not Found.\n", groupName, this-> objFileName);136 PRINTF(1)("Model Named %s in %s not Found.\n", groupName, this->name); 167 137 return; 168 138 } … … 186 156 PRINTF(2)("new 3D-Model is being created\n"); 187 157 158 this->name = NULL; 188 159 // setting the start group; 189 160 this->firstGroup = new Group; … … 192 163 193 164 this->initGroup (this->currentGroup); 194 this->objPath = NULL;195 this->objFileName = NULL;196 this->mtlFileName = NULL;197 165 this->scaleFactor = 1; 198 166 this->material = new Material(); … … 317 285 318 286 /** 319 \brief Imports a obj file and handles the the relative location320 \param fileName The file to import321 */322 bool Model::importFile (char* fileName)323 {324 PRINTF(3)("preparing to read in file: %s\n", fileName);325 326 327 #ifdef __WIN32__328 // win32 path reading329 char pathSplitter= '\\';330 #else /* __WIN32__ */331 // unix path reading332 char pathSplitter='/';333 #endif /* __WIN32__ */334 char* tmpName = fileName;335 if (tmpName[0] == pathSplitter)336 tmpName++;337 char* name = tmpName;338 while (( tmpName = strchr (tmpName+1, pathSplitter)))339 {340 name = tmpName+1;341 }342 this->objPath = new char[name-fileName];343 strncpy(this->objPath, fileName, name-fileName);344 this->objPath[name-fileName] = '\0';345 if (verbose >=2)346 if (strlen(objPath)> 0)347 PRINTF(0)("Resolved file %s to folder: %s.\n", name, objPath);348 else349 PRINTF(0)("Resolved file %s.\n", name);350 351 if (this->material)352 this->material->addTexturePath(this->objPath);353 this->objFileName = new char[strlen(name)+1];354 strcpy (this->objFileName, name);355 this->readFromObjFile ();356 return true;357 }358 359 /**360 \brief Reads in the .obj File and sets all the Values.361 This function does read the file, parses it for the occurence of things like vertices, faces and so on, and executes the specific tasks362 */363 bool Model::readFromObjFile (void)364 {365 char* fileName = new char [strlen(objPath)+strlen(objFileName)+1];366 if (this->objFileName != NULL && !strcmp(this->objFileName, ""))367 return false;368 strcpy(fileName, this->objPath);369 strcat(fileName, this->objFileName);370 371 ifstream* OBJ_FILE = new ifstream(fileName);372 if (OBJ_FILE->fail())373 {374 PRINTF(1)("unable to open .OBJ file: %s\n Loading Box Model instead.\n", fileName);375 BoxModel();376 OBJ_FILE->close();377 delete []fileName;378 delete OBJ_FILE;379 return false;380 }381 PRINTF(2)("Reading from opened file %s\n", fileName);382 char Buffer[10000];383 while(!OBJ_FILE->eof())384 {385 OBJ_FILE->getline(Buffer, 10000);386 PRINTF(3)("Read input line: %s\n", Buffer);387 388 389 // case vertice390 if (!strncmp(Buffer, "v ", 2))391 {392 this->readVertex(Buffer+2);393 }394 395 // case face396 else if (!strncmp(Buffer, "f ", 2))397 {398 this->readFace (Buffer+2);399 }400 401 else if (!strncmp(Buffer, "mtllib ", 7))402 {403 this->readMtlLib (Buffer+7);404 }405 406 else if (!strncmp(Buffer, "usemtl ", 7))407 {408 this->readUseMtl (Buffer+7);409 }410 411 // case VertexNormal412 else if (!strncmp(Buffer, "vn ", 3))413 {414 this->readVertexNormal(Buffer+3);415 }416 417 // case VertexTextureCoordinate418 else if (!strncmp(Buffer, "vt ", 3))419 {420 this->readVertexTexture(Buffer+3);421 }422 // case group423 else if (!strncmp(Buffer, "g ", 2))424 {425 this->readGroup (Buffer+2);426 }427 else if (!strncmp(Buffer, "s ", 2)) //! \todo smoothing groups have to be implemented428 {429 if (verbose >= 2)430 PRINTF(2)("smoothing groups not supportet yet. line: %s\n", Buffer);431 }432 }433 OBJ_FILE->close();434 delete OBJ_FILE;435 delete []fileName;436 return true;437 438 }439 440 /**441 287 \brief parses a group String 442 288 \param groupString the new Group to create … … 445 291 With it you should be able to import .obj-files with more than one Models inside. 446 292 */ 447 bool Model:: readGroup (char* groupString)293 bool Model::addGroup (char* groupString) 448 294 { 449 295 PRINTF(3)("Read Group: %s.\n", groupString); … … 470 316 If a vertex line is found this function will inject it into the vertex-Array 471 317 */ 472 bool Model:: readVertex (char* vertexString)318 bool Model::addVertex (char* vertexString) 473 319 { 474 320 float subbuffer1; … … 488 334 The function makes a difference between QUADS and TRIANGLES, and will if changed re-open, set and re-close the gl-processe. 489 335 */ 490 bool Model:: readFace (char* faceString)336 bool Model::addFace (char* faceString) 491 337 { 492 338 if (this->currentGroup->faceCount >0) … … 551 397 If a vertexNormal line is found this function will inject it into the vertexNormal-Array 552 398 */ 553 bool Model:: readVertexNormal (char* normalString)399 bool Model::addVertexNormal (char* normalString) 554 400 { 555 401 float subbuffer1; … … 569 415 this function will inject it into the vertexTexture-Array 570 416 */ 571 bool Model:: readVertexTexture (char* vTextureString)417 bool Model::addVertexTexture (char* vTextureString) 572 418 { 573 419 float subbuffer1; … … 580 426 } 581 427 582 /**583 \brief Function to read in a mtl File.584 \param mtlFile The .mtl file to read585 586 This Function parses all Lines of an mtl File.587 The reason for it not to be in the materials-class is,588 that a material does not have to be able to read itself in from a File.589 590 */591 bool Model::readMtlLib (char* mtlFile)592 {593 this->mtlFileName = new char [strlen(mtlFile)+1];594 strcpy(this->mtlFileName, mtlFile);595 char* fileName = new char [strlen(objPath) + strlen(this->mtlFileName)+1];596 strcpy(fileName, this->objPath);597 strcat(fileName, this->mtlFileName);598 599 600 PRINTF(3)("Opening mtlFile: %s\n", fileName);601 602 ifstream* MTL_FILE = new ifstream (fileName);603 if (MTL_FILE->fail())604 {605 PRINTF(1)("unable to open file: %s\n", fileName);606 MTL_FILE->close();607 delete []fileName;608 delete MTL_FILE;609 return false;610 }611 char Buffer[500];612 Material* tmpMat = material;613 while(!MTL_FILE->eof())614 {615 MTL_FILE->getline(Buffer, 500);616 PRINTF(4)("found line in mtlFile: %s\n", Buffer);617 618 619 // create new Material620 if (!strncmp(Buffer, "newmtl ", 7))621 {622 tmpMat = tmpMat->addMaterial(Buffer+7);623 // PRINTF(2)("%s, %p\n", tmpMat->getName(), tmpMat);624 }625 // setting a illumMode626 else if (!strncmp(Buffer, "illum ", 6))627 {628 tmpMat->setIllum(Buffer+6);629 630 }631 // setting Diffuse Color632 else if (!strncmp(Buffer, "Kd ", 3))633 {634 tmpMat->setDiffuse(Buffer+3);635 }636 // setting Ambient Color637 else if (!strncmp(Buffer, "Ka ", 3))638 {639 tmpMat->setAmbient(Buffer+3);640 }641 // setting Specular Color642 else if (!strncmp(Buffer, "Ks ", 3))643 {644 tmpMat->setSpecular(Buffer+3);645 }646 // setting The Specular Shininess647 else if (!strncmp(Buffer, "Ns ", 3))648 {649 tmpMat->setShininess(Buffer+3);650 }651 // setting up transparency652 else if (!strncmp(Buffer, "d ", 2))653 {654 tmpMat->setTransparency(Buffer+2);655 }656 else if (!strncmp(Buffer, "Tf ", 3))657 {658 tmpMat->setTransparency(Buffer+3);659 }660 661 else if (!strncmp(Buffer, "map_Kd ", 7))662 {663 tmpMat->setDiffuseMap(Buffer+7);664 }665 else if (!strncmp(Buffer, "map_Ka ", 7))666 {667 tmpMat->setAmbientMap(Buffer+7);668 }669 else if (!strncmp(Buffer, "map_Ks ", 7))670 {671 tmpMat->setSpecularMap(Buffer+7);672 }673 else if (!strncmp(Buffer, "bump ", 5))674 {675 tmpMat->setBump(Buffer+7);676 }677 678 679 }680 MTL_FILE->close();681 delete []fileName;682 delete MTL_FILE;683 return true;684 }685 686 428 /** 687 429 \brief Function that selects a material, if changed in the obj file. 688 430 \param matString the Material that will be set. 689 431 */ 690 bool Model::readUseMtl (char* matString) 691 { 432 bool Model::addUseMtl (char* matString) 433 { 434 /* 692 435 if (!this->mtlFileName) 693 436 { … … 695 438 return false; 696 439 } 697 440 */ 698 441 if (this->currentGroup->faceCount >0) 699 442 this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face; … … 743 486 glEnd(); 744 487 this->currentGroup->faceMode = 0; 745 PRINTF(2)("using material %s for coming Faces.\n", tmpFace->materialString);746 488 Material* tmpMat; 747 489 if ((tmpMat = material->search(tmpFace->materialString)) != NULL) 748 tmpMat->select(); 490 { 491 tmpMat->select(); 492 PRINTF(2)("using material %s for coming Faces.\n", tmpFace->materialString); 493 } 494 else 495 PRINTF(1)("material %s not found.\n", tmpFace->materialString); 496 749 497 750 498 } … … 909 657 void Model::BoxModel(void) 910 658 { 911 this-> readVertex ("-0.5 -0.5 0.5");912 this-> readVertex ("0.5 -0.5 0.5");913 this-> readVertex ("-0.5 0.5 0.5");914 this-> readVertex ("0.5 0.5 0.5");915 this-> readVertex ("-0.5 0.5 -0.5");916 this-> readVertex ("0.5 0.5 -0.5");917 this-> readVertex ("-0.5 -0.5 -0.5");918 this-> readVertex ("0.5 -0.5 -0.5");919 920 this-> readVertexTexture ("0.0 0.0");921 this-> readVertexTexture ("1.0 0.0");922 this-> readVertexTexture ("0.0 1.0");923 this-> readVertexTexture ("1.0 1.0");924 this-> readVertexTexture ("0.0 2.0");925 this-> readVertexTexture ("1.0 2.0");926 this-> readVertexTexture ("0.0 3.0");927 this-> readVertexTexture ("1.0 3.0");928 this-> readVertexTexture ("0.0 4.0");929 this-> readVertexTexture ("1.0 4.0");930 this-> readVertexTexture ("2.0 0.0");931 this-> readVertexTexture ("2.0 1.0");932 this-> readVertexTexture ("-1.0 0.0");933 this-> readVertexTexture ("-1.0 1.0");934 935 this-> readVertexNormal ("0.0 0.0 1.0");936 this-> readVertexNormal ("0.0 0.0 1.0");937 this-> readVertexNormal ("0.0 0.0 1.0");938 this-> readVertexNormal ("0.0 0.0 1.0");939 this-> readVertexNormal ("0.0 1.0 0.0");940 this-> readVertexNormal ("0.0 1.0 0.0");941 this-> readVertexNormal ("0.0 1.0 0.0");942 this-> readVertexNormal ("0.0 1.0 0.0");943 this-> readVertexNormal ("0.0 0.0 -1.0");944 this-> readVertexNormal ("0.0 0.0 -1.0");945 this-> readVertexNormal ("0.0 0.0 -1.0");946 this-> readVertexNormal ("0.0 0.0 -1.0");947 this-> readVertexNormal ("0.0 -1.0 0.0");948 this-> readVertexNormal ("0.0 -1.0 0.0");949 this-> readVertexNormal ("0.0 -1.0 0.0");950 this-> readVertexNormal ("0.0 -1.0 0.0");951 this-> readVertexNormal ("1.0 0.0 0.0");952 this-> readVertexNormal ("1.0 0.0 0.0");953 this-> readVertexNormal ("1.0 0.0 0.0");954 this-> readVertexNormal ("1.0 0.0 0.0");955 this-> readVertexNormal ("-1.0 0.0 0.0");956 this-> readVertexNormal ("-1.0 0.0 0.0");957 this-> readVertexNormal ("-1.0 0.0 0.0");958 this-> readVertexNormal ("-1.0 0.0 0.0");659 this->addVertex ("-0.5 -0.5 0.5"); 660 this->addVertex ("0.5 -0.5 0.5"); 661 this->addVertex ("-0.5 0.5 0.5"); 662 this->addVertex ("0.5 0.5 0.5"); 663 this->addVertex ("-0.5 0.5 -0.5"); 664 this->addVertex ("0.5 0.5 -0.5"); 665 this->addVertex ("-0.5 -0.5 -0.5"); 666 this->addVertex ("0.5 -0.5 -0.5"); 667 668 this->addVertexTexture ("0.0 0.0"); 669 this->addVertexTexture ("1.0 0.0"); 670 this->addVertexTexture ("0.0 1.0"); 671 this->addVertexTexture ("1.0 1.0"); 672 this->addVertexTexture ("0.0 2.0"); 673 this->addVertexTexture ("1.0 2.0"); 674 this->addVertexTexture ("0.0 3.0"); 675 this->addVertexTexture ("1.0 3.0"); 676 this->addVertexTexture ("0.0 4.0"); 677 this->addVertexTexture ("1.0 4.0"); 678 this->addVertexTexture ("2.0 0.0"); 679 this->addVertexTexture ("2.0 1.0"); 680 this->addVertexTexture ("-1.0 0.0"); 681 this->addVertexTexture ("-1.0 1.0"); 682 683 this->addVertexNormal ("0.0 0.0 1.0"); 684 this->addVertexNormal ("0.0 0.0 1.0"); 685 this->addVertexNormal ("0.0 0.0 1.0"); 686 this->addVertexNormal ("0.0 0.0 1.0"); 687 this->addVertexNormal ("0.0 1.0 0.0"); 688 this->addVertexNormal ("0.0 1.0 0.0"); 689 this->addVertexNormal ("0.0 1.0 0.0"); 690 this->addVertexNormal ("0.0 1.0 0.0"); 691 this->addVertexNormal ("0.0 0.0 -1.0"); 692 this->addVertexNormal ("0.0 0.0 -1.0"); 693 this->addVertexNormal ("0.0 0.0 -1.0"); 694 this->addVertexNormal ("0.0 0.0 -1.0"); 695 this->addVertexNormal ("0.0 -1.0 0.0"); 696 this->addVertexNormal ("0.0 -1.0 0.0"); 697 this->addVertexNormal ("0.0 -1.0 0.0"); 698 this->addVertexNormal ("0.0 -1.0 0.0"); 699 this->addVertexNormal ("1.0 0.0 0.0"); 700 this->addVertexNormal ("1.0 0.0 0.0"); 701 this->addVertexNormal ("1.0 0.0 0.0"); 702 this->addVertexNormal ("1.0 0.0 0.0"); 703 this->addVertexNormal ("-1.0 0.0 0.0"); 704 this->addVertexNormal ("-1.0 0.0 0.0"); 705 this->addVertexNormal ("-1.0 0.0 0.0"); 706 this->addVertexNormal ("-1.0 0.0 0.0"); 959 707 960 708 /* normaleLess-testingMode 961 this-> readFace ("1 2 4 3");962 this-> readFace ("3 4 6 5");963 this-> readFace ("5 6 8 7");964 this-> readFace ("7 8 2 1");965 this-> readFace ("2 8 6 4");966 this-> readFace ("7 1 3 5");709 this->addFace ("1 2 4 3"); 710 this->addFace ("3 4 6 5"); 711 this->addFace ("5 6 8 7"); 712 this->addFace ("7 8 2 1"); 713 this->addFace ("2 8 6 4"); 714 this->addFace ("7 1 3 5"); 967 715 */ 968 716 969 this-> readFace ("1/1/1 2/2/2 4/4/3 3/3/4");970 this-> readFace ("3/3/5 4/4/6 6/6/7 5/5/8");971 this-> readFace ("5/5/9 6/6/10 8/8/11 7/7/12");972 this-> readFace ("7/7/13 8/8/14 2/10/15 1/9/16");973 this-> readFace ("2/2/17 8/11/18 6/12/19 4/4/20");974 this-> readFace ("7/13/21 1/1/22 3/3/23 5/14/24");975 976 } 717 this->addFace ("1/1/1 2/2/2 4/4/3 3/3/4"); 718 this->addFace ("3/3/5 4/4/6 6/6/7 5/5/8"); 719 this->addFace ("5/5/9 6/6/10 8/8/11 7/7/12"); 720 this->addFace ("7/7/13 8/8/14 2/10/15 1/9/16"); 721 this->addFace ("2/2/17 8/11/18 6/12/19 4/4/20"); 722 this->addFace ("7/13/21 1/1/22 3/3/23 5/14/24"); 723 724 } -
orxonox/trunk/src/importer/model.h
r3395 r3396 21 21 { 22 22 public: 23 Model (); 24 Model (char* fileName); 25 Model(char* fileName, float scaling); 26 ~Model (); 23 Model(void); 24 virtual ~Model(void); 27 25 28 void draw 29 void draw 30 void draw 26 void draw(void) const; 27 void draw(int groupNumber) const; 28 void draw(char* groupName) const; 31 29 int getGroupCount() const; 32 30 33 private: 31 protected: 32 char* name; //!< This is the name of the Model; 34 33 //! This is the placeholder of one Vertex beloning to a Face. 35 struct FaceElement 34 struct FaceElement 36 35 { 37 36 int vertexNumber; //!< The number of the Vertex out of the Array* vertices, this vertex points to. … … 87 86 float scaleFactor; //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation 88 87 89 char* objPath; //!< The Path where the obj and mtl-file are located.90 char* objFileName; //!< The Name of the obj-file.91 char* mtlFileName; //!< The Name of the mtl-file (parsed out of the obj-file)92 93 88 bool initialize (void); 94 89 bool initGroup(Group* group); … … 99 94 bool cleanupFaceElement(FaceElement* faceElem); 100 95 101 ///// readin /// 102 bool importFile (char* fileName); 103 bool readFromObjFile (void); 104 105 bool readGroup (char* groupString); 106 bool readVertex (char* vertexString); 107 bool readFace (char* faceString); 108 bool readVertexNormal (char* normalString); 109 bool readVertexTexture (char* vTextureString); 110 bool readMtlLib (char* matFile); 111 bool readUseMtl (char* mtlString); 96 bool addGroup (char* groupString); 97 bool addVertex (char* vertexString); 98 bool addFace (char* faceString); 99 bool addVertexNormal (char* normalString); 100 bool addVertexTexture (char* vTextureString); 101 bool addUseMtl (char* mtlString); 112 102 113 103 bool importToGL (void); -
orxonox/trunk/src/player.cc
r3380 r3396 19 19 #include "stdincl.h" 20 20 #include "collision.h" 21 #include "importer/ model.h"21 #include "importer/objModel.h" 22 22 23 23 using namespace std; … … 27 27 { 28 28 29 this->model = new Model("../data/models/reaplow.obj");29 this->model = new OBJModel("../data/models/reaplow.obj"); 30 30 /* 31 31 objectList = glGenLists(1); -
orxonox/trunk/src/player.h
r3365 r3396 9 9 #include "world_entity.h" 10 10 11 class Model;11 class OBJModel; 12 12 13 13 //! Basic controllable WorldEntity -
orxonox/trunk/src/world_entity.h
r3365 r3396 11 11 12 12 class CollisionCluster; 13 class Model;13 class OBJModel; 14 14 15 15 //! Basic class from which all interactive stuff in the world is derived from … … 22 22 virtual ~WorldEntity (); 23 23 24 Model* model;24 OBJModel* model; 25 25 26 26 void setCollision (CollisionCluster* newhull);
Note: See TracChangeset
for help on using the changeset viewer.