Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/osx/src/world_entities/world_entity.h @ 7763

Last change on this file since 7763 was 7711, checked in by patrick, 19 years ago

trunk: merged the cd branche back to trunk

File size: 4.7 KB
Line 
1/*!
2 * @file world_entity.h
3 * Definition of the basic WorldEntity
4 */
5
6#ifndef _WORLD_ENTITY_H
7#define _WORLD_ENTITY_H
8
9#include "p_node.h"
10#include "synchronizeable.h"
11#include "model.h"
12
13#include "object_manager.h"
14#include "glincl.h"
15#include <vector>
16
17// FORWARD DECLARATION
18namespace OrxSound { class SoundBuffer; class SoundSource; }
19class BVTree;
20class Model;
21
22class GLGuiWidget;
23class GLGuiBar;
24
25//class CharacterAttributes;
26
27
28//! Basis-class all interactive stuff in the world is derived from
29class WorldEntity : public PNode
30{
31public:
32  WorldEntity();
33  virtual ~WorldEntity ();
34
35  virtual void loadParams(const TiXmlElement* root);
36
37  void loadModel(const std::string& fileName, float scaling = 1.0f, unsigned int modelNumber = 0, unsigned int obbTreeDepth = 4);
38  void setModel(Model* model, unsigned int modelNumber = 0);
39  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
40
41  inline void loadMD2Texture(const std::string& fileName) { this->md2TextureFileName = fileName; }
42
43  /** @param visibility if the Entity should be visible (been draw) */
44  void setVisibiliy (bool visibility) { this->bVisible = visibility; };
45  /** @returns true if the entity is visible, false otherwise */
46  inline bool isVisible() const { return this->bVisible; };
47
48  virtual void reset();
49
50  virtual void postSpawn ();
51  virtual void leaveWorld ();
52  virtual void destroy() {};
53
54  virtual void tick (float time);
55  virtual void draw () const;
56
57  bool buildObbTree(int depth);
58  virtual void collidesWith (WorldEntity* entity, const Vector& location);
59  /** @returns a reference to the obb tree of this worldentity */
60  inline BVTree* getOBBTree() const { return this->obbTree; };
61  void drawBVTree(int depth, int drawMode) const;
62
63  void debugWE() { this->debugEntity(); }
64  ;  ///FIXME
65  void debugEntity() const;
66
67
68  /* @returns the Count of Faces on this WorldEntity */
69  //unsigned int getFaceCount () const { return (this->model != NULL)?this->model->getFaceCount():0; };
70  //  void addAbility(Ability* ability);
71  //  void removeAbility(Ability* ability);
72  //  void setCharacterAttributes(CharacterAttributes* charAttr);
73  //  CharacterAttributes* getCharacterAttributes();
74
75  void toList(OM_LIST list);
76
77
78  /** @returns a Reference to the objectListNumber to set. */
79  OM_LIST& getOMListNumber() { return this->objectListNumber; }
80  /** @returns a Reference to the Iterator */
81  ObjectManager::EntityList::iterator& getEntityIterator() { return this->objectListIterator; }
82
83  int       writeState(const byte* data, int length, int sender);
84  int       readState(byte* data, int maxLength );
85
86  /** @returns the Energy of the entity */
87  float getHealth() const { return this->health; };
88  /** @returns the Maximum energy this entity can be charged with */
89  float getHealthMax() const { return this->healthMax; }
90  float increaseHealth(float health);
91  float decreaseHealth(float health);
92  void increaseHealthMax(float increaseHealth);
93  GLGuiWidget* getHealthWidget();
94  bool hasHealthWidget() const { return this->healthWidget; };
95
96protected:
97  void setHealth(float health) { this->health = health; this->updateHealthWidget();};
98  void setHealthWidgetVisibilit(bool visibility);
99  void setHealthMax(float healthMax);
100  void createHealthWidget();
101
102  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
103private:
104  void updateHealthWidget();
105
106private:
107  /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
108  float                   health;             //!< The Energy of this Entity, if the Entity has any energy at all.
109  float                   healthMax;          //!< The Maximal energy this entity can take.
110  GLGuiBar*               healthWidget;       //!< The Slider (if wanted).
111
112  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
113  std::string             md2TextureFileName; //!< the file name of the md2 model texture, only if this
114  std::string             modelLODName;       //!< the name of the model lod file
115  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
116
117  bool                    bCollide;           //!< If it should be considered for the collisiontest.
118  bool                    bVisible;           //!< If it should be visible.
119
120  OM_LIST                           objectListNumber;   //!< The ObjectList from ObjectManager this Entity is in.
121  ObjectManager::EntityList::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
122
123  float                   scaling;
124
125
126};
127
128#endif /* _WORLD_ENTITY_H */
Note: See TracBrowser for help on using the repository browser.