Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/cr/src/world_entities/world_entity.h @ 7944

Last change on this file since 7944 was 7944, checked in by patrick, 18 years ago

cr: collision registration work

File size: 5.4 KB
RevLine 
[4680]1/*!
[4885]2 * @file world_entity.h
3 * Definition of the basic WorldEntity
[7711]4 */
[2036]5
[3224]6#ifndef _WORLD_ENTITY_H
7#define _WORLD_ENTITY_H
[2036]8
[3365]9#include "p_node.h"
[5996]10#include "synchronizeable.h"
11#include "model.h"
[2036]12
[7927]13#include "cr_engine.h"
[6142]14#include "object_manager.h"
[5511]15#include "glincl.h"
[5995]16#include <vector>
[5511]17
[7927]18
19
[7933]20
[4885]21// FORWARD DECLARATION
[7460]22namespace OrxSound { class SoundBuffer; class SoundSource; }
[7779]23namespace OrxGui { class GLGuiWidget; class GLGuiBar; };
24
[5143]25class BVTree;
[7944]26class BoundingVolume;
[5511]27class Model;
[7927]28class CollisionHandle;
[7944]29class Collision;
[6440]30
[7927]31
[5498]32//class CharacterAttributes;
[4682]33
[5498]34
[4885]35//! Basis-class all interactive stuff in the world is derived from
[6498]36class WorldEntity : public PNode
[4680]37{
[6430]38public:
39  WorldEntity();
[3221]40  virtual ~WorldEntity ();
[3365]41
[6512]42  virtual void loadParams(const TiXmlElement* root);
[5994]43
[7711]44  void loadModel(const std::string& fileName, float scaling = 1.0f, unsigned int modelNumber = 0, unsigned int obbTreeDepth = 4);
[5994]45  void setModel(Model* model, unsigned int modelNumber = 0);
[6440]46  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
[5994]47
[7221]48  inline void loadMD2Texture(const std::string& fileName) { this->md2TextureFileName = fileName; }
[6222]49
[4885]50  /** @param visibility if the Entity should be visible (been draw) */
51  void setVisibiliy (bool visibility) { this->bVisible = visibility; };
52  /** @returns true if the entity is visible, false otherwise */
[5511]53  inline bool isVisible() const { return this->bVisible; };
[5026]54
[7085]55  virtual void reset();
[3583]56
[3229]57  virtual void postSpawn ();
[6959]58  virtual void leaveWorld ();
[7076]59  virtual void destroy() {};
[3583]60
[5501]61  virtual void tick (float time);
62  virtual void draw () const;
[6005]63
[7927]64  /* --- Collision Detection Block  --- */
[7711]65  bool buildObbTree(int depth);
[5029]66  virtual void collidesWith (WorldEntity* entity, const Vector& location);
[7711]67  /** @returns a reference to the obb tree of this worldentity */
68  inline BVTree* getOBBTree() const { return this->obbTree; };
69  void drawBVTree(int depth, int drawMode) const;
[5501]70
[7927]71  /* --- Collision Reaction Block --- */
[7933]72  void subscribeReaction(CREngine::CRType type, int nrOfTargets, long target, ...);
[7944]73  void registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);
[6424]74
75
[5510]76  /* @returns the Count of Faces on this WorldEntity */
77  //unsigned int getFaceCount () const { return (this->model != NULL)?this->model->getFaceCount():0; };
78  //  void addAbility(Ability* ability);
79  //  void removeAbility(Ability* ability);
80  //  void setCharacterAttributes(CharacterAttributes* charAttr);
81  //  CharacterAttributes* getCharacterAttributes();
[4680]82
[7927]83  /* --- Object Manager Block --- */
[6142]84  void toList(OM_LIST list);
85  /** @returns a Reference to the objectListNumber to set. */
86  OM_LIST& getOMListNumber() { return this->objectListNumber; }
87  /** @returns a Reference to the Iterator */
[7370]88  ObjectManager::EntityList::iterator& getEntityIterator() { return this->objectListIterator; }
[6222]89
[7927]90  /* --- Network Block --- */
[6341]91  int       writeState(const byte* data, int length, int sender);
92  int       readState(byte* data, int maxLength );
[6222]93
[7927]94  /* --- Character Attribute Block --- */
[6430]95  /** @returns the Energy of the entity */
[6700]96  float getHealth() const { return this->health; };
[6430]97  /** @returns the Maximum energy this entity can be charged with */
[6700]98  float getHealthMax() const { return this->healthMax; }
99  float increaseHealth(float health);
100  float decreaseHealth(float health);
101  void increaseHealthMax(float increaseHealth);
[7779]102  OrxGui::GLGuiWidget* getHealthWidget();
[7064]103  bool hasHealthWidget() const { return this->healthWidget; };
[6430]104
[7927]105  /* --- Misc Stuff Block --- */
106  void debugWE() { this->debugEntity(); }
107  ;  ///FIXME
108  void debugEntity() const;
109
110
[6430]111protected:
[7095]112  void setHealth(float health) { this->health = health; this->updateHealthWidget();};
[6700]113  void setHealthWidgetVisibilit(bool visibility);
114  void setHealthMax(float healthMax);
115  void createHealthWidget();
[7711]116
[5994]117  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
[6430]118private:
[6700]119  void updateHealthWidget();
[5994]120
[6430]121private:
122  /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
[6700]123  float                   health;             //!< The Energy of this Entity, if the Entity has any energy at all.
124  float                   healthMax;          //!< The Maximal energy this entity can take.
[7779]125  OrxGui::GLGuiBar*       healthWidget;       //!< The Slider (if wanted).
[6341]126
[6142]127  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
[7221]128  std::string             md2TextureFileName; //!< the file name of the md2 model texture, only if this
129  std::string             modelLODName;       //!< the name of the model lod file
[6142]130  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
[4680]131
[6142]132  bool                    bCollide;           //!< If it should be considered for the collisiontest.
133  bool                    bVisible;           //!< If it should be visible.
134
[7932]135  OM_LIST                           objectListNumber;             //!< The ObjectList from ObjectManager this Entity is in.
136  ObjectManager::EntityList::iterator objectListIterator;         //!< The iterator position of this Entity in the given list of the ObjectManager.
[6142]137
[7932]138  float                   scaling;                                //!< the scaling of the model
139  CollisionHandle*        collisionHandles[CREngine::CR_NUMBER];  //!< the list of the collision reactions
[6341]140
141
[2036]142};
143
[3224]144#endif /* _WORLD_ENTITY_H */
Note: See TracBrowser for help on using the repository browser.