Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/world_entities/world_entity.h @ 7444

Last change on this file since 7444 was 7444, checked in by rennerc, 18 years ago

new network system implemented. yet with a lot of empty function bodys

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