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