Changeset 8490 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jun 15, 2006, 9:34:48 PM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 9 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/WorldEntities.am
r8271 r8490 15 15 world_entities/test_entity.cc \ 16 16 world_entities/planet.cc \ 17 17 world_entities/bsp_entity.cc \ 18 18 \ 19 19 world_entities/weapons/test_gun.cc \ … … 39 39 world_entities/space_ships/hover.cc \ 40 40 world_entities/space_ships/turbine_hover.cc \ 41 world_entities/space_ships/collision_probe.cc \ 41 42 world_entities/creatures/md2_creature.cc \ 42 43 world_entities/spectator.cc \ … … 70 71 test_entity.h \ 71 72 planet.h \ 72 73 bsp_entity.h \ 73 74 \ 74 75 weapons/test_gun.h \ … … 94 95 space_ships/hover.h \ 95 96 space_ships/turbine_hover.h \ 97 space_ships/collision_probe.cc \ 96 98 creatures/md2_creature.h \ 97 99 spectator.h \ -
trunk/src/world_entities/bsp_entity.cc
r8186 r8490 10 10 11 11 ### File Specific: 12 main-programmer: ...12 main-programmer: Claudio Botta 13 13 co-programmer: ... 14 14 */ … … 17 17 #include "util/loading/resource_manager.h" 18 18 19 CREATE_FACTORY(B SPEntity, CL_BSP_ENTITY);19 CREATE_FACTORY(BspEntity, CL_BSP_ENTITY); 20 20 21 21 22 22 /** 23 * constructs and loads a B SPEntity from a XML-element23 * constructs and loads a BspEntity from a XML-element 24 24 * @param root the XML-element to load from 25 25 */ 26 B SPEntity::BSPEntity(const TiXmlElement* root)26 BspEntity::BspEntity(const TiXmlElement* root) 27 27 { 28 28 this->init(); 29 29 30 if (root != NULL) 30 31 this->loadParams(root); … … 35 36 * standard deconstructor 36 37 */ 37 B SPEntity::~BSPEntity ()38 BspEntity::~BspEntity () 38 39 { 39 40 if( this->bspManager) 41 delete this->bspManager; 40 42 } 41 43 42 void BSPEntity::setName(const std::string& name) 44 45 /** 46 * initializes the BspEntity 47 * @todo change this to what you wish 48 */ 49 void BspEntity::init() 43 50 { 44 printf("+++++++++++ LOADING NAME %s\n", name.c_str()); 51 this->setClassID(CL_BSP_ENTITY, "BspEntity"); 52 53 this->bspManager = new BspManager(this); 54 this->toList(OM_ENVIRON); 55 56 /** 57 * @todo: Write CL_BSP_ENTITY INTO THE src/defs/class_id.h (your own definition) 58 */ 59 } 60 61 62 void BspEntity::setName(const std::string& name) 63 { 64 PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str()); 45 65 46 66 this->bspManager->load(name.c_str(), 0.1f); … … 48 68 49 69 50 51 70 /** 52 * initializes the BSPEntity 53 * @todo change this to what you wish 54 */ 55 void BSPEntity::init() 56 { 57 this->bspManager = new BspManager(); 58 this->setClassID(CL_BSP_ENTITY, "BSPEntity"); 59 60 this->toList(OM_ENVIRON); 61 62 /** 63 * @todo: Write CL_BSP_ENTITY INTO THE src/defs/class_id.h (your own definition) 64 */ 65 66 } 67 68 69 /** 70 * loads a BSPEntity from a XML-element 71 * loads a BspEntity from a XML-element 71 72 * @param root the XML-element to load from 72 73 * @todo make the class Loadable 73 74 */ 74 void B SPEntity::loadParams(const TiXmlElement* root)75 void BspEntity::loadParams(const TiXmlElement* root) 75 76 { 76 77 // all the clases this Entity is directly derived from must be called in this way, to load all settings. 77 78 // WorldEntity::loadParam(root); 78 79 79 LoadParam(root, "Name", this, B SPEntity, setName)80 LoadParam(root, "Name", this, BspEntity, setName) 80 81 .describe("Sets the of the BSP file."); 81 82 … … 91 92 92 93 /** 93 * advances the B SPEntity about time seconds94 * advances the BspEntity about time seconds 94 95 * @param time the Time to step 95 96 */ 96 void B SPEntity::tick(float time)97 void BspEntity::tick(float time) 97 98 { 98 99 this->bspManager->tick(time); 99 100 } 100 101 … … 103 104 * draws this worldEntity 104 105 */ 105 void B SPEntity::draw () const106 void BspEntity::draw () const 106 107 { 107 108 this->bspManager->draw(); … … 113 114 * 114 115 */ 115 void B SPEntity::collidesWith (WorldEntity* entity, const Vector& location)116 void BspEntity::collidesWith (WorldEntity* entity, const Vector& location) 116 117 { 117 118 -
trunk/src/world_entities/bsp_entity.h
r8186 r8490 16 16 17 17 //! A Class to ... 18 class B SPEntity : public WorldEntity18 class BspEntity : public WorldEntity 19 19 { 20 20 21 21 public: 22 B SPEntity(const TiXmlElement* root = NULL);23 virtual ~B SPEntity();22 BspEntity(const TiXmlElement* root = NULL); 23 virtual ~BspEntity(); 24 24 25 25 virtual void loadParams(const TiXmlElement* root); 26 26 27 27 void setName(const std::string& name); 28 28 … … 33 33 virtual void collidesWith (WorldEntity* entity, const Vector& location); 34 34 35 /** @returns the BspManager of this entity */ 36 inline BspManager* getBspManager() { return this->bspManager; } 37 35 38 private: 36 39 BspManager* bspManager; -
trunk/src/world_entities/creatures/md2_creature.cc
r8362 r8490 21 21 22 22 #include "objModel.h" 23 #include "md2 Model.h"23 #include "md2/md2Model.h" 24 24 #include "util/loading/resource_manager.h" 25 25 #include "state.h" … … 256 256 if( this->bJump && likely(this->getModel(0) != NULL)) 257 257 { 258 ((MD2Model*)this->getModel(0))->setAnim (JUMP);258 ((MD2Model*)this->getModel(0))->setAnimation(JUMP); 259 259 } 260 260 else if( this->bFire && likely(this->getModel(0) != NULL)) 261 261 { 262 if( ((MD2Model*)this->getModel(0))->getAnim() != ATTACK) ((MD2Model*)this->getModel(0))->setAnim (ATTACK);262 if( ((MD2Model*)this->getModel(0))->getAnim() != ATTACK) ((MD2Model*)this->getModel(0))->setAnimation(ATTACK); 263 263 } 264 264 else if( fabs(move.len()) > 0.0f && likely(this->getModel(0) != NULL)) 265 265 { 266 if( ((MD2Model*)this->getModel(0))->getAnim() != RUN) ((MD2Model*)this->getModel(0))->setAnim (RUN);266 if( ((MD2Model*)this->getModel(0))->getAnim() != RUN) ((MD2Model*)this->getModel(0))->setAnimation(RUN); 267 267 } 268 268 else if (likely(this->getModel(0) != NULL)) 269 269 { 270 if( ((MD2Model*)this->getModel(0))->getAnim() != STAND) ((MD2Model*)this->getModel(0))->setAnim (STAND);270 if( ((MD2Model*)this->getModel(0))->getAnim() != STAND) ((MD2Model*)this->getModel(0))->setAnimation(STAND); 271 271 } 272 272 -
trunk/src/world_entities/playable.cc
r8316 r8490 65 65 66 66 this->bDead = false; 67 68 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY); 67 69 68 70 registerVar( new SynchronizeableInt( &score, &score, "score" ) ); -
trunk/src/world_entities/space_ships/turbine_hover.h
r7348 r8490 59 59 float rotation; 60 60 61 Vector velocity; //!< the velocity of the TurbineHover.61 // Vector velocity; //!< the velocity of the TurbineHover. 62 62 Quaternion direction; //!< the direction of the TurbineHover. 63 63 float travelSpeed; //!< the current speed of the Hove (to make soft movement) -
trunk/src/world_entities/test_entity.cc
r8316 r8490 26 26 27 27 #include "test_entity.h" 28 #include "stdincl.h" 29 #include "model.h" 30 #include "md2Model.h" 31 #include "obb_tree.h" 28 29 30 #include "interactive_model.h" 31 #include "md2/md2Model.h" 32 32 33 #include "state.h" 33 34 … … 90 91 { 91 92 if( likely(this->getModel(0) != NULL)) 92 (( MD2Model*)this->getModel(0))->setAnim(animationIndex, animPlaybackMode);93 ((InteractiveModel*)this->getModel(0))->setAnimation(animationIndex, animPlaybackMode); 93 94 } 94 95 … … 97 98 { 98 99 if( likely(this->getModel(0) != NULL)) 99 (( MD2Model*)this->getModel(0))->tick(time);100 ((InteractiveModel*)this->getModel(0))->tick(time); 100 101 101 102 } -
trunk/src/world_entities/world_entity.cc
r8316 r8490 21 21 22 22 #include "model.h" 23 #include "md2Model.h" 23 #include "md2/md2Model.h" 24 #include "md3/md3_model.h" 25 24 26 #include "util/loading/resource_manager.h" 25 27 #include "util/loading/load_param.h" … … 77 79 78 80 // registering default reactions: 79 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY); 80 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND, CL_TERRAIN); 81 // this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY); 81 82 82 83 this->toList(OM_NULL); … … 200 201 this->buildObbTree(obbTreeDepth); 201 202 } 203 else if(fileName.find(".md3") != std::string::npos) 204 { 205 PRINTF(4)("fetching MD3 file: %s\n", fileName.c_str()); 206 Model* m = new md3::MD3Model(fileName, this->scaling); 207 this->setModel(m, 0); 208 209 // if( m != NULL) 210 // this->buildObbTree(obbTreeDepth); 211 } 202 212 } 203 213 else … … 411 421 * @param position it collides on the plane 412 422 */ 413 bool WorldEntity::registerCollision(WorldEntity* entity, Plane* plane, Vector position)423 bool WorldEntity::registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position) 414 424 { 415 425 // is there any handler listening? … … 420 430 CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject(); 421 431 assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h 422 c->collide(entity, plane, position);432 c->collide(entity, groundEntity, normal, position); 423 433 424 434 for( int i = 0; i < CREngine::CR_NUMBER; ++i) … … 501 511 502 512 Vector v = this->getAbsDirX(); 503 v.x *= 10; 504 v.y *= 10; 505 v.z *= 10; 506 Vector u = this->getAbsDirY(); 507 508 if(feet.x == (u.x+this->getAbsCoor().x) && feet.y == u.y +this->getAbsCoor().y && feet.z == this->getAbsCoor().z) 513 v.x *= 10.1; 514 v.y *= 10.1; 515 v.z *= 10.1; 516 Vector u = Vector(0.0,-20.0,0.0); 517 518 519 if(!(this->getAbsCoor().x == ray_2.x && this->getAbsCoor().y == ray_2.y && this->getAbsCoor().z == ray_2.z) ) 509 520 { 510 521 511 522 this->setAbsCoor(ray_2 - v); 512 } 513 else 523 524 } 525 else 514 526 { 515 527 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) … … 521 533 522 534 } 535 536 523 537 } 524 538 -
trunk/src/world_entities/world_entity.h
r8190 r8490 29 29 class CollisionHandle; 30 30 class Collision; 31 class Plane;32 31 33 32 … … 86 85 87 86 bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB); 88 bool registerCollision(WorldEntity* entity, Plane* plane, Vector position);87 bool registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position); 89 88 /** @return true if there is at least on collision reaction subscribed */ 90 89 inline bool isReactive() const { return this->bReactive; } … … 138 137 inline float getMass() const { return this->physicsInterface.getMass(); } 139 138 inline float getTotalMass() const { return this->physicsInterface.getTotalMass(); } 139 inline void setVelocity(const Vector& vel) { this->velocity = vel; } 140 140 141 141 … … 187 187 PhysicsInterface physicsInterface; //!< the physics object of the WorldEntity 188 188 189 190 protected: 191 Vector velocity; //!< speed of the entity 192 189 193 }; 190 194
Note: See TracChangeset
for help on using the changeset viewer.