Changeset 10147 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Dec 25, 2006, 1:30:44 PM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/WorldEntities.am
r9869 r10147 24 24 world_entities/planet.cc \ 25 25 world_entities/bsp_entity.cc \ 26 world_entities/mount_point.cc \ 26 27 \ 27 28 world_entities/weapons/test_gun.cc \ … … 127 128 planet.h \ 128 129 bsp_entity.h \ 130 mount_point.h \ 129 131 \ 130 132 weapons/test_gun.h \ -
trunk/src/world_entities/mount_point.cc
r10143 r10147 24 24 #include "debug.h" 25 25 #include "state.h" 26 #include "class_id_DEPRECATED.h"27 26 28 27 -
trunk/src/world_entities/npcs/npc_test.cc
r10114 r10147 39 39 this->registerObject(this, NPC2::_objectList); 40 40 41 if ((float)rand()/RAND_MAX > .5f)42 this->loadModel("models/ships/bolido.obj", 6);43 else44 this->loadModel("models/ships/gobblin.obj", 6);41 // if ((float)rand()/RAND_MAX > .5f) 42 // this->loadModel("models/ships/bolido.obj", 6); 43 // else 44 // this->loadModel("models/ships/gobblin.obj", 6); 45 45 46 46 … … 84 84 * Just override this function with whatever you want to be drawn. 85 85 */ 86 void NPC2::draw() const 87 { 88 glMatrixMode(GL_MODELVIEW); 89 glPushMatrix(); 90 float matrix[4][4]; 91 92 /* translate */ 93 glTranslatef (this->getAbsCoor ().x, 94 this->getAbsCoor ().y, 95 this->getAbsCoor ().z); 96 /* rotate */ 97 this->getAbsDir ().matrix (matrix); 98 glMultMatrixf((float*)matrix); 99 100 // if (this->shader != NULL && this->shader != Shader::getActiveShader()) 101 // shader->activateShader(); 102 103 this->getModel()->draw(); 104 // shader->deactivateShader(); 105 106 107 /* if (this->model) 108 this->model->draw();*/ 109 glPopMatrix(); 110 } 86 // void NPC2::draw() const 87 // { 88 // glMatrixMode(GL_MODELVIEW); 89 // glPushMatrix(); 90 // float matrix[4][4]; 91 // 92 // /* translate */ 93 // glTranslatef (this->getAbsCoor ().x, 94 // this->getAbsCoor ().y, 95 // this->getAbsCoor ().z); 96 // /* rotate */ 97 // this->getAbsDir ().matrix (matrix); 98 // glMultMatrixf((float*)matrix); 99 // 100 // // if (this->shader != NULL && this->shader != Shader::getActiveShader()) 101 // // shader->activateShader(); 102 // 103 // if( this->getModel()) 104 // this->getModel()->draw(); 105 // // shader->deactivateShader(); 106 // 107 // 108 // /* if (this->model) 109 // this->model->draw();*/ 110 // glPopMatrix(); 111 // } 111 112 112 113 -
trunk/src/world_entities/npcs/npc_test.h
r9869 r10147 22 22 23 23 virtual void tick(float dt); 24 virtual void draw() const;24 // virtual void draw() const; 25 25 26 26 private: -
trunk/src/world_entities/world_entity.cc
r10013 r10147 12 12 13 13 ### File Specific: 14 main-programmer: Patrick Boenzli 15 co-programmer: Christian Me yer14 main-programmer: Patrick Boenzli, Benjamin Grauer 15 co-programmer: Christian Meier 16 16 */ 17 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY … … 24 24 #include "md2/md2Model.h" 25 25 #include "md3/md3_model.h" 26 27 #include "oif/object_information_file.h" 28 #include "mount_point.h" 26 29 27 30 #include "aabb_tree_node.h" … … 69 72 this->damage = 0.0f; // no damage dealt by a default entity 70 73 this->scaling = 1.0f; 74 this->oiFile = NULL; 71 75 72 76 /* OSOLETE */ … … 103 107 for (unsigned int i = 0; i < this->models.size(); i++) 104 108 this->setModel(NULL, i); 109 110 // remove the object information file 111 if( this->oiFile) 112 delete this->oiFile; 113 // and clear all monut points 114 this->mountPoints.clear(); 105 115 106 116 // Delete the obbTree … … 191 201 { 192 202 PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str()); 203 // creating the model and loading it 193 204 StaticModel* model = new StaticModel(); 194 205 *model = ResourceOBJ(fileName, this->scaling); … … 201 212 else 202 213 delete model; 214 215 // now get the object information file for this model, if any 216 std::string oifName = fileName.substr(0, fileName.length() - 4) + ".oif"; 217 this->loadObjectInformationFile( oifName); 203 218 } 204 219 /// LOADING AN MD2-model … … 249 264 250 265 266 267 /** 268 * loads the object information file for this model 269 * @param fileName the name of the file 270 */ 271 void WorldEntity::loadObjectInformationFile(const std::string& fileName) 272 { 273 PRINTF(4)("loading the oif File: %s\n", fileName.c_str()); 274 275 this->oiFile = new ObjectInformationFile(fileName); 276 } 277 278 251 279 /** 252 280 * builds the obb-tree … … 290 318 } 291 319 return true; 320 } 321 322 323 /** 324 * adds a mount point to the end of the list 325 * @param mountPoint point to be added 326 */ 327 void WorldEntity::addMountPoint(MountPoint* mountPoint) 328 { 329 // add the mount point at the last position 330 this->mountPoints.push_back(mountPoint); 331 } 332 333 /** 334 * adds a mount point to a world entity 335 * @param mountPoint point to be added 336 */ 337 void WorldEntity::addMountPoint(int slot, MountPoint* mountPoint) 338 { 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()); 342 } 343 344 // just connect the mount point 345 this->mountPoints[slot] = mountPoint; 346 } 347 348 349 /** 350 * mounts a world entity on a specified mount point (~socket) 351 * @param entity entity to be connected 352 */ 353 void WorldEntity::mount(int slot, WorldEntity* entity) 354 { 355 if( this->mountPoints[slot] == NULL) 356 { 357 PRINTF(0)("you tried to add an entity to a mount point that doesn't exist (slot %i)\n", slot); 358 return; 359 } 360 361 // mount the entity 362 this->mountPoints[slot]->mount(entity); 363 } 364 365 366 /** 367 * removes a mount point from a specified mount point 368 * @param mountPoint entity to be unconnected 369 */ 370 void WorldEntity::unmount(int slot) 371 { 372 if( this->mountPoints[slot] == NULL) 373 { 374 PRINTF(0)("you tried to remove an entity from a mount point that doesn't exist (slot %i)\n", slot); 375 return; 376 } 377 378 // unmount the entity 379 this->mountPoints[slot]->unmount(); 292 380 } 293 381 -
trunk/src/world_entities/world_entity.h
r10013 r10147 15 15 #include "object_manager.h" 16 16 #include "glincl.h" 17 18 #include "aabb_tree_node.h" 19 20 #include "physics_interface.h" 21 17 22 #include <vector> 18 19 #include "aabb_tree_node.h"20 21 #include "physics_interface.h"22 23 23 24 24 … … 33 33 class Model; 34 34 35 class ObjectInformationFile; 36 class MountPoint; 37 35 38 36 39 //! Basis-class all interactive stuff in the world is derived from … … 50 53 Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; }; 51 54 55 void loadObjectInformationFile(const std::string& fileName); 52 56 inline void loadMD2Texture(const std::string& fileName) { this->md2TextureFileName = fileName; } 57 58 void addMountPoint(MountPoint* mountPoint); 59 void addMountPoint(int slot, MountPoint* mountPoint); 60 void mount(int slot, WorldEntity* entity); 61 void unmount(int slot); 53 62 54 63 /** @param visibility if the Entity should be visible (been draw) */ … … 185 194 186 195 std::vector<Model*> models; //!< The model that should be loaded for this entity. 196 ObjectInformationFile* oiFile; //!< Reference to the object information file discribing the model of this WE 197 std::vector<MountPoint*> mountPoints; //!< A list with mount points for this model 187 198 std::string md2TextureFileName; //!< the file name of the md2 model texture, only if this 188 199 std::string modelLODName; //!< the name of the model lod file
Note: See TracChangeset
for help on using the changeset viewer.