Changeset 3801 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Apr 13, 2005, 6:54:35 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/model.cc
r3750 r3801 236 236 face->firstElem = NULL; 237 237 238 face->material String= NULL;238 face->material = NULL; 239 239 240 240 face->next = NULL; … … 288 288 PRINTF(5)("Cleaning up Face\n"); 289 289 290 if (face->materialString != NULL)291 delete []face->materialString;292 290 if (face->firstElem != NULL) 293 291 { … … 549 547 } 550 548 */ 551 if (this->currentGroup->faceCount > 0)549 if (this->currentGroup->faceCount > 0) 552 550 this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face; 553 551 this->initFace (this->currentGroup->currentFace); 554 552 555 this->currentGroup->currentFace->materialString = new char[strlen(matString)+1]; 556 strcpy (this->currentGroup->currentFace->materialString, matString); 557 553 this->currentGroup->currentFace->material = material->search(matString); 554 558 555 if (this->currentGroup->faceCount == 0) 559 556 this->currentGroup->faceCount ++; 560 557 } 558 559 /** 560 \brief Function that selects a material, if changed in the obj file. 561 \param mtl the Material that will be set. 562 */ 563 bool Model::addUseMtl (Material* mtl) 564 { 565 if (this->currentGroup->faceCount > 0) 566 this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face; 567 this->initFace (this->currentGroup->currentFace); 568 569 this->currentGroup->currentFace->material = mtl; 570 571 if (this->currentGroup->faceCount == 0) 572 this->currentGroup->faceCount ++; 561 573 } 562 574 … … 591 603 while (tmpFace != NULL) 592 604 { 593 if (tmpFace->vertexCount == 0 && tmpFace->material String!= NULL)605 if (tmpFace->vertexCount == 0 && tmpFace->material != NULL) 594 606 { 595 607 if (this->currentGroup->faceMode != -1) … … 597 609 this->currentGroup->faceMode = 0; 598 610 Material* tmpMat; 599 if ( (tmpMat = material->search(tmpFace->materialString))!= NULL)611 if (tmpFace->material != NULL) 600 612 { 601 tmp Mat->select();602 PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material String);613 tmpFace->material->select(); 614 PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getName()); 603 615 } 604 else605 PRINTF(2)("material %s not found.\n", tmpFace->materialString);606 607 608 616 } 609 617 -
orxonox/trunk/src/lib/graphics/importer/model.h
r3657 r3801 54 54 FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face. 55 55 56 char* materialString; //!< The Name of the Material to which to Change.56 Material* material; //!< The Material to use. 57 57 58 58 Face* next; //!< Pointer to the next Face. … … 106 106 bool addVertexTexture(const float u, const float v); 107 107 bool addUseMtl(char* mtlString); 108 bool addUseMtl(Material* mtl); 108 109 void finalize(void); 109 110 -
orxonox/trunk/src/story_entities/world.cc
r3798 r3801 940 940 this->simpleAnimation->tick(seconds); 941 941 942 942 //testAnim->tick(seconds); 943 943 944 944 } -
orxonox/trunk/src/world_entities/skybox.cc
r3796 r3801 47 47 this->setClassName("SkyBox"); 48 48 49 this->model = NULL; 49 50 50 this->model = (Model*)ResourceManager::getInstance()->load("cube", PRIM, RP_LEVEL);51 51 this->setMode(PNODE_MOVEMENT); 52 52 53 53 this->setSize(1900.0); 54 this->rebuild(); 54 55 55 this->material = new Material("Sky"); 56 if (fileName) 57 this->setTexture(fileName); 58 this->material->setIllum(3); 59 this->material->setAmbient(1.0, 1.0, 1.0); 60 56 this->material = new Material*[6]; 57 for (int i = 0; i <6; i++) 58 { 59 this->material[i] = new Material(); 60 this->material[i]->setIllum(3); 61 this->material[i]->setAmbient(1.0, 1.0, 1.0); 62 } 61 63 } 62 64 … … 67 69 SkyBox::~SkyBox() 68 70 { 69 PRINTF(3)("Deleting the SkyBox\n"); 70 delete this->material; 71 PRINTF(5)("Deleting the SkyBox\n"); 72 73 for (int i = 0; i < 6; i++) 74 delete this->material[i]; 75 delete []this->material; 71 76 } 72 77 78 79 void SkyBox::rebuild() 80 { 81 if (this->model) 82 delete model; 83 model = new Model(); 84 85 model->addVertex (-0.5*size, -0.5*size, 0.5*size); 86 model->addVertex (0.5*size, -0.5*size, 0.5*size); 87 model->addVertex (-0.5*size, 0.5*size, 0.5*size); 88 model->addVertex (0.5*size, 0.5*size, 0.5*size); 89 model->addVertex (-0.5*size, 0.5*size, -0.5*size); 90 model->addVertex (0.5*size, 0.5*size, -0.5*size); 91 model->addVertex (-0.5*size, -0.5*size, -0.5*size); 92 model->addVertex (0.5*size, -0.5*size, -0.5*size); 93 94 model->addVertexTexture (0.0, 0.0); 95 model->addVertexTexture (1.0, 0.0); 96 model->addVertexTexture (0.0, 1.0); 97 model->addVertexTexture (1.0, 1.0); 98 model->addVertexTexture (0.0, 2.0); 99 model->addVertexTexture (1.0, 2.0); 100 model->addVertexTexture (0.0, 3.0); 101 model->addVertexTexture (1.0, 3.0); 102 model->addVertexTexture (0.0, 4.0); 103 model->addVertexTexture (1.0, 4.0); 104 model->addVertexTexture (2.0, 0.0); 105 model->addVertexTexture (2.0, 1.0); 106 model->addVertexTexture (-1.0, 0.0); 107 model->addVertexTexture (-1.0, 1.0); 108 109 model->addVertexNormal (0.0, 0.0, 1.0); 110 model->addVertexNormal (0.0, 0.0, 1.0); 111 model->addVertexNormal (0.0, 0.0, 1.0); 112 model->addVertexNormal (0.0, 0.0, 1.0); 113 model->addVertexNormal (0.0, 1.0, 0.0); 114 model->addVertexNormal (0.0, 1.0, 0.0); 115 model->addVertexNormal (0.0, 1.0, 0.0); 116 model->addVertexNormal (0.0, 1.0, 0.0); 117 model->addVertexNormal (0.0, 0.0, -1.0); 118 model->addVertexNormal (0.0, 0.0, -1.0); 119 model->addVertexNormal (0.0, 0.0, -1.0); 120 model->addVertexNormal (0.0, 0.0, -1.0); 121 model->addVertexNormal (0.0, -1.0, 0.0); 122 model->addVertexNormal (0.0, -1.0, 0.0); 123 model->addVertexNormal (0.0, -1.0, 0.0); 124 model->addVertexNormal (0.0, -1.0, 0.0); 125 model->addVertexNormal (1.0, 0.0, 0.0); 126 model->addVertexNormal (1.0, 0.0, 0.0); 127 model->addVertexNormal (1.0, 0.0, 0.0); 128 model->addVertexNormal (1.0, 0.0, 0.0); 129 model->addVertexNormal (-1.0, 0.0, 0.0); 130 model->addVertexNormal (-1.0, 0.0, 0.0); 131 model->addVertexNormal (-1.0, 0.0, 0.0); 132 model->addVertexNormal (-1.0, 0.0, 0.0); 133 134 model->addUseMtl(material[0]); 135 model->addFace (4, 3, 1,1,1, 2,2,2, 4,4,3, 3,3,4); 136 model->addUseMtl(material[1]); 137 model->addFace (4, 3, 3,3,5, 4,4,6, 6,6,7, 5,5,8); 138 model->addUseMtl(material[2]); 139 model->addFace (4, 3, 5,5,9, 6,6,10, 8,8,11, 7,7,12); 140 model->addUseMtl(material[3]); 141 model->addFace (4, 3, 7,7,13, 8,8,14, 2,10,15, 1,9,16); 142 model->addUseMtl(material[4]); 143 model->addFace (4, 3, 2,2,17, 8,11,18, 6,12,19, 4,4,20); 144 model->addUseMtl(material[5]); 145 model->addFace (4, 3, 7,13,21, 1,1,22, 3,3,23, 5,14,24); 146 } 73 147 74 148 /** … … 76 150 \param fileName The filename of the Texture 77 151 */ 78 void SkyBox::setTexture(char* fileName)152 void SkyBox::setTexture(char* top, char* bottom, char* left, char* right, char* front, char* back) 79 153 { 80 this->material->setDiffuseMap(fileName); 154 this->material[0]->setDiffuseMap(top); 155 this->material[1]->setDiffuseMap(bottom); 156 this->material[2]->setDiffuseMap(left); 157 this->material[3]->setDiffuseMap(right); 158 this->material[4]->setDiffuseMap(front); 159 this->material[5]->setDiffuseMap(back); 81 160 } 82 161 … … 94 173 glTranslatef(r.x, r.y, r.z); 95 174 96 this->material ->select();175 this->material[1]->select(); 97 176 98 177 this->model->draw(); -
orxonox/trunk/src/world_entities/skybox.h
r3796 r3801 26 26 27 27 void setSize(float size); 28 void setTexture(char* fileName);28 void setTexture(char* top, char* bottom, char* left, char* right, char* front, char* back); 29 29 30 30 virtual void draw(); 31 31 32 private: 33 Material *material; //!< A Material for the Skybox. 32 private: 33 void rebuild(); 34 35 Material **material; //!< A Material for the Skybox. 34 36 float size; //!< Radius of the Skybox. This should match the frustum maximum range. 35 37
Note: See TracChangeset
for help on using the changeset viewer.