Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/world_entity.h @ 7902

Last change on this file since 7902 was 7779, checked in by bensch, 18 years ago

3088 linews changed :): trunk: namespaces

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; }
19namespace OrxGui { class GLGuiWidget; class GLGuiBar; };
20
21class BVTree;
22class Model;
23
24//class CharacterAttributes;
25
26
27//! Basis-class all interactive stuff in the world is derived from
28class WorldEntity : public PNode
29{
30public:
31  WorldEntity();
32  virtual ~WorldEntity ();
33
34  virtual void loadParams(const TiXmlElement* root);
35
36  void loadModel(const std::string& fileName, float scaling = 1.0f, unsigned int modelNumber = 0, unsigned int obbTreeDepth = 4);
37  void setModel(Model* model, unsigned int modelNumber = 0);
38  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
39
40  inline void loadMD2Texture(const std::string& fileName) { this->md2TextureFileName = fileName; }
41
42  /** @param visibility if the Entity should be visible (been draw) */
43  void setVisibiliy (bool visibility) { this->bVisible = visibility; };
44  /** @returns true if the entity is visible, false otherwise */
45  inline bool isVisible() const { return this->bVisible; };
46
47  virtual void reset();
48
49  virtual void postSpawn ();
50  virtual void leaveWorld ();
51  virtual void destroy() {};
52
53  virtual void tick (float time);
54  virtual void draw () const;
55
56  bool buildObbTree(int depth);
57  virtual void collidesWith (WorldEntity* entity, const Vector& location);
58  /** @returns a reference to the obb tree of this worldentity */
59  inline BVTree* getOBBTree() const { return this->obbTree; };
60  void drawBVTree(int depth, int drawMode) const;
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  ObjectManager::EntityList::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  OrxGui::GLGuiWidget* getHealthWidget();
93  bool hasHealthWidget() const { return this->healthWidget; };
94
95protected:
96  void setHealth(float health) { this->health = health; this->updateHealthWidget();};
97  void setHealthWidgetVisibilit(bool visibility);
98  void setHealthMax(float healthMax);
99  void createHealthWidget();
100
101  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
102private:
103  void updateHealthWidget();
104
105private:
106  /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
107  float                   health;             //!< The Energy of this Entity, if the Entity has any energy at all.
108  float                   healthMax;          //!< The Maximal energy this entity can take.
109  OrxGui::GLGuiBar*       healthWidget;       //!< The Slider (if wanted).
110
111  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
112  std::string             md2TextureFileName; //!< the file name of the md2 model texture, only if this
113  std::string             modelLODName;       //!< the name of the model lod file
114  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
115
116  bool                    bCollide;           //!< If it should be considered for the collisiontest.
117  bool                    bVisible;           //!< If it should be visible.
118
119  OM_LIST                           objectListNumber;   //!< The ObjectList from ObjectManager this Entity is in.
120  ObjectManager::EntityList::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
121
122  float                   scaling;
123
124
125};
126
127#endif /* _WORLD_ENTITY_H */
Note: See TracBrowser for help on using the repository browser.