Changeset 5995 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Dec 9, 2005, 11:26:02 AM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/world_entity.cc
r5994 r5995 44 44 this->setClassID(CL_WORLD_ENTITY, "WorldEntity"); 45 45 46 this->model = NULL;47 46 this->obbTree = NULL; 48 47 49 if (root )48 if (root != NULL) 50 49 this->loadParams(root); 51 50 … … 78 77 LoadParam(root, "model", this, WorldEntity, loadModel) 79 78 .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)") 80 .defaultValues( 2, NULL, 1.0f);79 .defaultValues(3, NULL, 1.0f, 0); 81 80 82 81 } … … 89 88 * @todo fix this, so it only has one loadModel-Function. 90 89 */ 91 void WorldEntity::loadModel(const char* fileName, float scaling )90 void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber) 92 91 { 93 92 if (fileName != NULL) … … 102 101 } 103 102 else 104 this-> model = NULL;103 this->setModel(NULL); 105 104 } 106 105 … … 112 111 void WorldEntity::setModel(Model* model, unsigned int modelNumber) 113 112 { 114 if (this->model != NULL) 113 if (this->models.size() <= modelNumber) 114 this->models.resize(modelNumber+1, NULL); 115 116 if (this->models[modelNumber] != NULL) 115 117 { 116 Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->model );118 Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]); 117 119 if (resource != NULL) 118 120 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 119 121 else 120 delete this->model ;121 } 122 this->model = model;122 delete this->models[modelNumber]; 123 } 124 this->models[modelNumber] = model; 123 125 124 126 // if (this->model != NULL) … … 136 138 delete this->obbTree; 137 139 138 if (this->model != NULL)140 if (this->models[0] != NULL) 139 141 { 140 142 PRINTF(4)("creating obb tree\n"); 141 143 142 144 143 this->obbTree = new OBBTree(depth, (sVec3D*)this->model ->getVertexArray(), this->model->getVertexCount());145 this->obbTree = new OBBTree(depth, (sVec3D*)this->models[0]->getVertexArray(), this->models[0]->getVertexCount()); 144 146 return true; 145 147 } … … 236 238 glMultMatrixf((float*)matrix); 237 239 238 if (this->model )239 this->model ->draw();240 if (this->models[0]) 241 this->models[0]->draw(); 240 242 glPopMatrix(); 241 243 } -
trunk/src/world_entities/world_entity.h
r5994 r5995 10 10 11 11 #include "glincl.h" 12 #include <vector> 12 13 13 14 // FORWARD DECLARATION … … 29 30 void loadParams(const TiXmlElement* root); 30 31 31 void loadModel(const char* fileName, float scaling = 1.0f );32 void loadModel(const char* fileName, float scaling = 1.0f, unsigned int modelNumber = 0); 32 33 void setModel(Model* model, unsigned int modelNumber = 0); 33 Model* getModel(unsigned int modelNumber = 0) const { return this->model; };34 Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; }; 34 35 35 36 bool buildObbTree(unsigned int depth); … … 65 66 66 67 private: 67 Model* model; //!< The model that should be loaded for this entity.68 std::vector<Model*> models; //!< The model that should be loaded for this entity. 68 69 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection 69 70
Note: See TracChangeset
for help on using the changeset viewer.