Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

cd: compiles again

File size: 4.5 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  bool buildObbTree(int depth);
42
43  inline void loadMD2Texture(const char* fileName) { this->md2TextureFileName = fileName; }
44
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 */
48  inline bool isVisible() const { return this->bVisible; };
49
50  virtual void postSpawn ();
51  virtual void leftWorld ();
52
53  virtual void tick (float time);
54  virtual void draw () const;
55
56  virtual void collidesWith (WorldEntity* entity, const Vector& location);
57  void drawBVTree(unsigned int depth, int drawMode) const;
58  /** @returns a reference to the obb tree of this worldentity */
59  inline BVTree* getOBBTree() const { return this->obbTree; };
60
61
62  void debugWE() { this->debugEntity(); }
63  ;  ///FIXME
64  void debugEntity() const;
65
66
67  /* @returns the Count of Faces on this WorldEntity */
68  //unsigned int getFaceCount () const { return (this->model != NULL)?this->model->getFaceCount():0; };
69  //  void addAbility(Ability* ability);
70  //  void removeAbility(Ability* ability);
71  //  void setCharacterAttributes(CharacterAttributes* charAttr);
72  //  CharacterAttributes* getCharacterAttributes();
73
74  void toList(OM_LIST list);
75
76
77  /** @returns a Reference to the objectListNumber to set. */
78  OM_LIST& getOMListNumber() { return this->objectListNumber; }
79  /** @returns a Reference to the Iterator */
80  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
81
82  int       writeState(const byte* data, int length, int sender);
83  int       readState(byte* data, int maxLength );
84
85  /** @returns the Energy of the entity */
86  float getHealth() const { return this->health; };
87  /** @returns the Maximum energy this entity can be charged with */
88  float getHealthMax() const { return this->healthMax; }
89  float increaseHealth(float health);
90  float decreaseHealth(float health);
91  void increaseHealthMax(float increaseHealth);
92  GLGuiWidget* getHealthWidget();
93
94protected:
95  void setHealth(float health) { this->health = health; };
96  void setHealthWidgetVisibilit(bool visibility);
97  void setHealthMax(float healthMax);
98  void createHealthWidget();
99
100  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
101private:
102  void updateHealthWidget();
103
104private:
105  /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
106  float                   health;             //!< The Energy of this Entity, if the Entity has any energy at all.
107  float                   healthMax;          //!< The Maximal energy this entity can take.
108  GLGuiBar*               healthWidget;       //!< The Slider (if wanted).
109
110  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
111  const char*             md2TextureFileName; //!< the file name of the md2 model texture, only if this
112  const char*             modelLODName;       //!< the name of the model lod file
113  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
114
115  bool                    bCollide;           //!< If it should be considered for the collisiontest.
116  bool                    bVisible;           //!< If it should be visible.
117
118  OM_LIST                           objectListNumber;   //!< The ObjectList from ObjectManager this Entity is in.
119  std::list<WorldEntity*>::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
120
121  float                   scaling;
122
123
124};
125
126#endif /* _WORLD_ENTITY_H */
Note: See TracBrowser for help on using the repository browser.