Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/water/src/world_entities/world_entity.h @ 7952

Last change on this file since 7952 was 7814, checked in by stefalie, 19 years ago

branches/water: textures works now, but its at the wrong place

File size: 4.8 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  void toReflectionList();
76  void removeFromReflectionList();
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  OrxGui::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  OrxGui::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.