Changeset 10314 in orxonox.OLD for trunk/src/world_entities/world_entity.cc
- Timestamp:
- Jan 24, 2007, 12:45:39 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/world_entity.cc
r10147 r10314 12 12 13 13 ### File Specific: 14 main-programmer: Patrick Boenzli, Benjamin Grauer 15 co-programmer: Christian Meier 14 main-programmer: Patrick Boenzli 15 main-programmer: Benjamin Grauer 16 co-programmer: Christian Meier 16 17 */ 17 18 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY … … 73 74 this->scaling = 1.0f; 74 75 this->oiFile = NULL; 76 // add 10 members to this array 77 this->mountPoints.reserve(10); 75 78 76 79 /* OSOLETE */ … … 141 144 .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)") 142 145 .defaultValues("", 1.0f, 0); 146 147 LoadParam(root, "mountpoints", this, WorldEntity, loadMountPoints) 148 .describe("the fileName of the object information file (optional)"); 143 149 144 150 LoadParam(root, "maxHealth", this, WorldEntity, setHealthMax) … … 204 210 StaticModel* model = new StaticModel(); 205 211 *model = ResourceOBJ(fileName, this->scaling); 212 213 // check if ther is a valid model and load other stuff 206 214 if (model->getVertexCount() > 0) 207 215 { 208 216 this->setModel(model, modelNumber); 209 if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */) 217 218 if( modelNumber == 0) 219 { 210 220 this->buildObbTree(obbTreeDepth); 221 } 211 222 } 212 223 else 213 224 delete model; 214 215 // now get the object information file for this model, if any216 std::string oifName = fileName.substr(0, fileName.length() - 4) + ".oif";217 this->loadObjectInformationFile( oifName);218 225 } 219 226 /// LOADING AN MD2-model … … 269 276 * @param fileName the name of the file 270 277 */ 271 void WorldEntity::loadObjectInformationFile(const std::string& fileName) 272 { 273 PRINTF(4)("loading the oif File: %s\n", fileName.c_str()); 274 278 void WorldEntity::loadMountPoints(const std::string& fileName) 279 { 280 PRINTF(5)("loading the oif File: %s\n", fileName.c_str()); 281 282 // now load the object information file 275 283 this->oiFile = new ObjectInformationFile(fileName); 284 285 // get the model to load 286 Model* model = this->getModel(); 287 288 // extract the mount points 289 model->extractMountPoints(); 290 291 // first get all mount points from the model 292 const std::list<mountPointSkeleton> mpList = model->getMountPoints(); 293 // for each skeleton create a mounting point world entity 294 std::list<mountPointSkeleton>::const_iterator it = mpList.begin(); 295 296 for( ; it != mpList.end(); it++) 297 { 298 // create the mount points world entity 299 MountPoint* mp = new MountPoint( (*it).up, (*it).forward, (*it).center, (*it).name); 300 // parent it to this WE 301 mp->setParent( this); 302 // now add to the right group 303 mp->toList( (OM_LIST)(this->getOMListNumber()+1)); 304 // now get the number and add the mount point to the slot 305 std::string nrStr = (*it).name.substr(3, 2); 306 // add the mount point 307 this->addMountPoint(atoi(nrStr.c_str()), mp); 308 309 // now fill the mount point 310 mp->initMountPoint( this->oiFile->getMountPointDescription()); 311 } 312 276 313 } 277 314 … … 337 374 void WorldEntity::addMountPoint(int slot, MountPoint* mountPoint) 338 375 { 339 if( this->mountPoints[slot] != NULL) 340 { 341 PRINTF(0)("adding a mount point to a slot, that already exists! ignoring - maybe some object do not get connected well (object: %s)\n", this->getClassCName()); 376 if( this->mountPoints.capacity() < (unsigned int)slot) 377 { 378 // reserve 5 more slots than needed so this function is called as rare as possible 379 this->mountPoints.reserve(slot + 5); 380 } 381 else if( this->mountPoints[slot] != NULL) 382 { 383 PRINTF(4)("adding a mount point to a slot, that already is occupied! ignoring - maybe some object did not get connected well (object: %s)\n", this->getClassCName()); 342 384 } 343 385 … … 794 836 795 837 838 839 /** 840 * draw the mounting points 841 */ 842 void WorldEntity::debugDrawMountPoints() const 843 { 844 845 std::vector<MountPoint*>::const_iterator it = this->mountPoints.begin(); 846 for( ; it < this->mountPoints.end(); it++) 847 { 848 if( (*it) != NULL) 849 { 850 (*it)->debugDraw(); 851 } 852 } 853 } 854 855 796 856 /** 797 857 * Debug the WorldEntity
Note: See TracChangeset
for help on using the changeset viewer.