Changeset 9832 in orxonox.OLD for branches/new_class_id
- Timestamp:
- Sep 26, 2006, 3:44:38 PM (18 years ago)
- Location:
- branches/new_class_id/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/graphics/importer/static_model.cc
r9830 r9832 37 37 */ 38 38 StaticModel::StaticModel(const std::string& modelName) 39 : data(new StaticModelData(modelName))39 : data(new StaticModelData(modelName)) 40 40 { 41 41 this->registerObject(this, StaticModel::_objectList); … … 43 43 this->setName(modelName); 44 44 } 45 46 StaticModel::StaticModel(const StaticModel& staticModel) 47 : data(staticModel.data) 48 { 49 this->registerObject(this, StaticModel::_objectList); 50 this->setName(staticModel.getName()); 51 this->updateBase(); 52 } 53 45 54 46 55 /** … … 60 69 } 61 70 71 StaticModel& StaticModel::operator=(const StaticModel& model) 72 { 73 this->data = model.data; 74 this->updateBase(); 75 return *this; 76 }; 77 78 62 79 /** 63 80 * @brief Finalizes an Object. This can be done outside of the Class. … … 66 83 { 67 84 data->finalize(); 85 this->updateBase(); 86 } 68 87 69 // write out the modelInfo data used for the collision detection! 70 this->pModelInfo.pVertices = &this->data->getVertices()[0]; 71 this->pModelInfo.numVertices = this->data->getVertices().size(); 72 this->pModelInfo.pNormals = &this->data->getNormals()[0]; 73 this->pModelInfo.numNormals = this->data->getNormals().size(); 74 this->pModelInfo.pTexCoor = &this->data->getTexCoords()[0]; 75 this->pModelInfo.numTexCoor = this->data->getTexCoords().size(); 76 77 this->pModelInfo.pTriangles = this->data->getTrianglesExt(); 78 this->pModelInfo.numTriangles = this->data->getTriangles().size(); 88 void StaticModel::acquireData(const StaticModelData::Pointer& data) 89 { 90 this->data = data; 91 this->updateBase(); 79 92 } 80 93 … … 92 105 return retVal; 93 106 } 107 108 void StaticModel::updateBase() 109 { 110 // write out the modelInfo data used for the collision detection! 111 this->pModelInfo.pVertices = &this->data->getVertices()[0]; 112 this->pModelInfo.numVertices = this->data->getVertices().size(); 113 this->pModelInfo.pNormals = &this->data->getNormals()[0]; 114 this->pModelInfo.numNormals = this->data->getNormals().size(); 115 this->pModelInfo.pTexCoor = &this->data->getTexCoords()[0]; 116 this->pModelInfo.numTexCoor = this->data->getTexCoords().size(); 117 118 this->pModelInfo.pTriangles = this->data->getTrianglesExt(); 119 this->pModelInfo.numTriangles = this->data->getTriangles().size(); 120 } 121 94 122 95 123 /** -
branches/new_class_id/src/lib/graphics/importer/static_model.h
r9831 r9832 24 24 { 25 25 ObjectListDeclaration(StaticModel); 26 26 public: 27 27 StaticModel(const std::string& modelName = ""); 28 StaticModel(const StaticModel& staticModel); 28 29 virtual ~StaticModel(); 29 30 30 StaticModel& operator=(const StaticModel& model) { this->data = model.data; return *this; };31 StaticModel& operator=(const StaticModel& model); 31 32 32 33 virtual void draw() const { data->draw(); }; … … 58 59 void finalize(); 59 60 60 void acquireData(const StaticModelData::Pointer& data) { this->data = data; };61 void acquireData(const StaticModelData::Pointer& data); 61 62 const StaticModelData::Pointer& dataPointer() const { return this->data; }; 62 63 … … 64 65 float getScaleFactor() const { return data->getScaleFactor(); } 65 66 66 67 protected: 67 68 void cubeModel(); 68 69 69 private: 70 StaticModelData::Pointer data; 70 private: 71 void updateBase(); 72 private: 73 StaticModelData::Pointer data; 71 74 }; 72 75 -
branches/new_class_id/src/world_entities/world_entity.cc
r9727 r9832 20 20 #include "shell_command.h" 21 21 22 #include "model.h" 22 #include "util/loading/new_resource_manager.h" 23 #include "resource_obj.h" 23 24 #include "md2/md2Model.h" 24 25 #include "md3/md3_model.h" … … 26 27 #include "aabb_tree_node.h" 27 28 28 #include "util/loading/resource_manager.h"29 29 #include "util/loading/load_param.h" 30 30 #include "obb_tree.h" … … 83 83 84 84 // registering default reactions: 85 /// FIXME this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /*CL_WORLD_ENTITY*/ CL_PROJECTILE);85 /// FIXME this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /*CL_WORLD_ENTITY*/ CL_PROJECTILE); 86 86 87 87 this->toList(OM_NULL); … … 162 162 std::string name = fileName; 163 163 164 if ( name.find( Resource Manager::getInstance()->getDataDir() ) == 0 )165 { 166 name.erase(Resource Manager::getInstance()->getDataDir().size());164 if ( name.find( Resources::NewResourceManager::getInstance()->mainGlobalPath().name() ) == 0 ) 165 { 166 name.erase(Resources::NewResourceManager::getInstance()->mainGlobalPath().name().size()); 167 167 } 168 168 … … 180 180 { 181 181 lodFile[offset] = 48+(int)i; 182 if (Resource Manager::isInDataDir(lodFile))182 if (Resources::NewResourceManager::getInstance()->checkFileInMainPath( lodFile)) 183 183 this->loadModel(lodFile, scaling, i); 184 184 } … … 190 190 this->scaling = 1.0; 191 191 } 192 /// LOADING AN OBJ FILE 192 193 if(fileName.find(".obj") != std::string::npos) 193 194 { 194 195 PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str()); 195 BaseObject* loadedModel = ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, this->scaling); 196 if (loadedModel != NULL) 197 this->setModel(dynamic_cast<Model*>(loadedModel), modelNumber); 196 StaticModel* model = new StaticModel(); 197 *model = ResourceOBJ(fileName, this->scaling); 198 if (model->getVertexCount() > 0) 199 { 200 this->setModel(model, modelNumber); 201 if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */) 202 this->buildObbTree(obbTreeDepth); 203 } 198 204 else 199 PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str()); 200 201 if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */) 202 this->buildObbTree(obbTreeDepth); 203 } 205 delete model; 206 } 207 /// LOADING AN MD2-model 204 208 else if(fileName.find(".md2") != std::string::npos) 205 209 { … … 212 216 this->buildObbTree(obbTreeDepth); 213 217 } 218 /// LOADING AN MD3-MODEL. 214 219 else if(fileName.find(".md3") != std::string::npos) 215 220 { … … 218 223 this->setModel(m, 0); 219 224 220 // if( m != NULL)221 // this->buildObbTree(obbTreeDepth);225 // if( m != NULL) 226 // this->buildObbTree(obbTreeDepth); 222 227 } 223 228 } … … 240 245 if (this->models[modelNumber] != NULL) 241 246 { 242 Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(dynamic_cast<BaseObject*>(this->models[modelNumber])); 243 if (resource != NULL) 244 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 245 else 246 { 247 PRINTF(4)("Forcing model deletion\n"); 248 delete this->models[modelNumber]; 249 } 247 delete this->models[modelNumber]; 250 248 } 251 249 … … 283 281 } 284 282 285 if( this->models[0] != NULL) { 283 if( this->models[0] != NULL) 284 { 286 285 this->aabbNode = new AABBTreeNode(); 287 286 this->aabbNode->spawnBVTree(this->models[0]); … … 367 366 void WorldEntity::subscribeReaction(CREngine::CRType type) 368 367 { 369 if( this->collisionHandles[type] != NULL) { 368 if( this->collisionHandles[type] != NULL) 369 { 370 370 PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n"); 371 371 return; … … 498 498 void removeFromReflectionList() 499 499 { 500 /// TODO501 /// State::getObject500 /// TODO 501 /// State::getObject 502 502 } 503 503 … … 558 558 { 559 559 560 this->setAbsCoor(ray_2 - v);561 562 } 563 560 this->setAbsCoor(ray_2 - v); 561 562 } 563 else 564 564 { 565 565 if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z) … … 645 645 } 646 646 647 // if( this->aabbNode != NULL)648 // this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true);647 // if( this->aabbNode != NULL) 648 // this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true); 649 649 650 650 glPopMatrix();
Note: See TracChangeset
for help on using the changeset viewer.