Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 4, 2006, 4:39:45 PM (17 years ago)
Author:
patrick
Message:

merged the temp branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/coll_rect.merge/src/world_entities/world_entity.h

    r9869 r10010  
    1212
    1313#include "cr_engine.h"
     14#include "collision_filter.h"
    1415#include "object_manager.h"
    1516#include "glincl.h"
     
    2526namespace OrxSound { class SoundBuffer; class SoundSource; }
    2627namespace OrxGui { class GLGuiWidget; class GLGuiBar; class GLGuiEnergyWidget; };
     28namespace CoRe { class Collision; }
    2729
    2830class BVTree;
     
    3032class AABBTreeNode;
    3133class Model;
    32 class CollisionHandle;
    33 class Collision;
    34 
    35 
    36 //class CharacterAttributes;
    37 
    3834
    3935
     
    4238{
    4339  ObjectListDeclaration(WorldEntity);
     40
    4441public:
    4542  WorldEntity();
     
    5148  void loadModel2(const std::string& fileN, float scal = 1.0f){this->loadModel(fileN,scal,0,4);}
    5249  void setModel(Model* model, unsigned int modelNumber = 0);
    53 Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
     50  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
    5451
    5552  inline void loadMD2Texture(const std::string& fileName) { this->md2TextureFileName = fileName; }
     
    7471  virtual void collidesWithGround(const Vector& feet, const Vector& ray_1, const Vector& ray_2);
    7572
    76 
    7773  /** @returns a reference to the obb tree of this worldentity */
    7874  inline BVTree* getOBBTree() const { return this->obbTree; };
     
    8177  inline AABB* getModelAABB() const { return (this->aabbNode)?this->aabbNode->getAABB():NULL;}
    8278
     79  virtual void hit(float damage, WorldEntity* killer);
     80
     81
    8382  /* --- Collision Reaction Block --- */
    84   void subscribeReaction(CREngine::CRType type);
    85   void subscribeReaction(CREngine::CRType type, const ClassID& target1);
    86   void subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2);
    87   void subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3);
    88   void subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3, const ClassID& target4);
    89 
    90   void unsubscribeReaction(CREngine::CRType type);
    91   void unsubscribeReaction();
    92 
    93   bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);
    94   bool registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall = false);
     83  void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1);
     84  void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2);
     85  void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2, const ClassID& target3);
     86
     87  void unsubscribeReaction(CoRe::CREngine::ReactionType type);
     88  void unsubscribeReactions();
     89
    9590  /** @return true if there is at least on collision reaction subscribed */
    96   inline bool isReactive() const { return this->bReactive; }
    97 
    98   CollisionHandle* getCollisionHandle(CREngine::CRType type) const { return this->collisionHandles[type]; }
     91  inline bool isReactive() const { return this->_collisionFilter.isReactive(); }
     92
     93  /** @param worldEntity the world entity to be checked @returns true if there is a collisionreaction registered for the worldEntity */
     94  inline bool isReactive( const WorldEntity& worldEntity) const { return this->_collisionFilter(worldEntity); }
     95  /** @param worldEntity the world entity to be checked @param type special reaction type @returns true if collision reaction reg. */
     96  inline bool isReactive( const WorldEntity& worldEntity, const CoRe::CREngine::ReactionType& type) const
     97  { return this->_collisionFilter(worldEntity, type); }
     98
     99
     100  const CoRe::CollisionFilter& getCollisionFilter(CoRe::CREngine::ReactionType type) const { return this->_collisionFilter; }
    99101
    100102  /** @returns true if this entity is standing on ground (BSP model) */
    101   bool isOnGround() const { return this->bOnGround; }
     103  bool isOnGround() const { return this->_bOnGround; }
    102104  /** @param flag: marks if this entity is standing on ground */
    103   void setOnGround(bool flag) { this->bOnGround = flag; }
    104 
    105   virtual void hit(float damage, WorldEntity* killer);
     105  void setOnGround(bool flag) { this->_bOnGround = flag; }
    106106
    107107  virtual void destroy( WorldEntity* killer );
     
    128128
    129129  void hide() { if( this->objectListNumber != OM_DEAD) this->lastObjectListNumber = this->objectListNumber; this->toList(OM_DEAD); }
    130 void unhide() { if( this->objectListNumber != this->lastObjectListNumber) this->toList(this->lastObjectListNumber); }
     130  void unhide() { if( this->objectListNumber != this->lastObjectListNumber) this->toList(this->lastObjectListNumber); }
    131131
    132132
    133133  /* --- Character Attribute Block --- */
    134134  /** @returns the scaling of the model */
    135 float getScaling(){return this->scaling;}
     135  float getScaling(){return this->scaling;}
    136136  /** @returns the damage dealt by this world entity */
    137137  float getDamage() const { return this->damage; }
     
    170170  void setHealthMax(float healthMax);
    171171  void createHealthWidget();
    172 
    173   //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
     172    //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
     173
     174
    174175private:
    175176  void updateHealthWidget();
     177
    176178
    177179private:
     
    195197  OM_LIST                 lastObjectListNumber;            //!< the last ObjectList from the ObjectManager this Entity was is in
    196198
    197 
    198 
     199  /* collision reaction stuff */
     200  CoRe::CollisionFilter   _collisionFilter;                //!< filter for collision event filtering (not every entity listens to all collisions)
     201  bool                    _bOnGround;                      //!< flag true if the object is on the ground
     202
     203  PhysicsInterface        physicsInterface;                //!< the physics object of the WorldEntity
     204
     205  /* network help structures */
    199206  float                   scaling;                         //!< model's scaling factor
    200207  int                     scaling_handle;                  //!< handle for syncing var
     
    212219  int                     healthMax_handle;
    213220
    214   CollisionHandle*        collisionHandles[CREngine::CR_NUMBER];  //!< the list of the collision reactions
    215   bool                    bReactive;                              //!< true if there is at least one collision reaction subscibed
    216 
    217   PhysicsInterface        physicsInterface;                //!< the physics object of the WorldEntity
    218   bool                    bOnGround;                       //!< true if this entity is standing on the ground
     221
    219222
    220223protected:
Note: See TracChangeset for help on using the changeset viewer.