Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/current_cd/src/world_entities/world_entity.h @ 6910

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

cd: one conflict overseen

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