[4680] | 1 | /*! |
---|
[4885] | 2 | * @file world_entity.h |
---|
| 3 | * Definition of the basic WorldEntity |
---|
[2190] | 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 | |
---|
[5511] | 13 | #include "glincl.h" |
---|
[5995] | 14 | #include <vector> |
---|
[5511] | 15 | |
---|
[4885] | 16 | // FORWARD DECLARATION |
---|
[4504] | 17 | class SoundBuffer; |
---|
| 18 | class SoundSource; |
---|
[5143] | 19 | class BVTree; |
---|
[5511] | 20 | class Model; |
---|
[4504] | 21 | |
---|
[5498] | 22 | //class CharacterAttributes; |
---|
[4682] | 23 | |
---|
[5498] | 24 | |
---|
[4885] | 25 | //! Basis-class all interactive stuff in the world is derived from |
---|
[5996] | 26 | class WorldEntity : public PNode, public Synchronizeable |
---|
[4680] | 27 | { |
---|
[2036] | 28 | public: |
---|
[4261] | 29 | WorldEntity(const TiXmlElement* root = NULL); |
---|
[3221] | 30 | virtual ~WorldEntity (); |
---|
[3365] | 31 | |
---|
[4261] | 32 | void loadParams(const TiXmlElement* root); |
---|
[5994] | 33 | |
---|
[5995] | 34 | void loadModel(const char* fileName, float scaling = 1.0f, unsigned int modelNumber = 0); |
---|
[5994] | 35 | void setModel(Model* model, unsigned int modelNumber = 0); |
---|
[5995] | 36 | Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; }; |
---|
[5994] | 37 | |
---|
[5061] | 38 | bool buildObbTree(unsigned int depth); |
---|
[5994] | 39 | /** @returns a reference to the obb tree of this worldentity */ |
---|
| 40 | BVTree* getOBBTree() const { return this->obbTree; }; |
---|
[5057] | 41 | |
---|
[4885] | 42 | /** @param visibility if the Entity should be visible (been draw) */ |
---|
| 43 | void setVisibiliy (bool visibility) { this->bVisible = visibility; }; |
---|
| 44 | /** @returns true if the entity is visible, false otherwise */ |
---|
[5511] | 45 | inline bool isVisible() const { return this->bVisible; }; |
---|
[5026] | 46 | |
---|
[3583] | 47 | |
---|
[5026] | 48 | |
---|
[3229] | 49 | virtual void postSpawn (); |
---|
[3583] | 50 | virtual void leftWorld (); |
---|
| 51 | |
---|
[5501] | 52 | virtual void tick (float time); |
---|
[6005] | 53 | |
---|
[5501] | 54 | virtual void draw () const; |
---|
[6005] | 55 | void drawLODsafe() const; |
---|
| 56 | |
---|
[5029] | 57 | virtual void collidesWith (WorldEntity* entity, const Vector& location); |
---|
[5510] | 58 | void drawBVTree(unsigned int depth, int drawMode) const; |
---|
[5501] | 59 | |
---|
[5510] | 60 | /* @returns the Count of Faces on this WorldEntity */ |
---|
| 61 | //unsigned int getFaceCount () const { return (this->model != NULL)?this->model->getFaceCount():0; }; |
---|
| 62 | // void addAbility(Ability* ability); |
---|
| 63 | // void removeAbility(Ability* ability); |
---|
| 64 | // void setCharacterAttributes(CharacterAttributes* charAttr); |
---|
| 65 | // CharacterAttributes* getCharacterAttributes(); |
---|
[4680] | 66 | |
---|
| 67 | |
---|
[3583] | 68 | protected: |
---|
[5994] | 69 | // CharacterAttributes* charAttr; //!< the character attributes of a world_entity |
---|
| 70 | |
---|
| 71 | private: |
---|
[5995] | 72 | std::vector<Model*> models; //!< The model that should be loaded for this entity. |
---|
[4885] | 73 | BVTree* obbTree; //!< this is the obb tree reference needed for collision detection |
---|
[4680] | 74 | |
---|
[4885] | 75 | bool bCollide; //!< If it should be considered for the collisiontest. |
---|
| 76 | bool bVisible; //!< If it should be visible. |
---|
[2036] | 77 | }; |
---|
| 78 | |
---|
[3224] | 79 | #endif /* _WORLD_ENTITY_H */ |
---|