Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/preferences/src/world_entities/world_entity.h @ 6383

Last change on this file since 6383 was 6341, checked in by bensch, 19 years ago

orxonox/trunk: merged the network branche back to the trunk, so we do not get away from each other to fast

File size: 3.4 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
23//class CharacterAttributes;
24
25
26//! Basis-class all interactive stuff in the world is derived from
27class WorldEntity : public PNode, public Synchronizeable
28{
29 public:
30  WorldEntity(const TiXmlElement* root = NULL);
31  virtual ~WorldEntity ();
32
33  void loadParams(const TiXmlElement* root);
34
35  void loadModel(const char* fileName, float scaling = 1.0f, unsigned int modelNumber = 0);
36  void setModel(Model* model, unsigned int modelNumber = 0);
37  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
38
39  inline void loadMD2Texture(const char* fileName) { this->md2TextureFileName = fileName; }
40
41  bool buildObbTree(unsigned int depth);
42  /** @returns a reference to the obb tree of this worldentity */
43  BVTree* getOBBTree() const { return this->obbTree; };
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
51
52  virtual void postSpawn ();
53  virtual void leftWorld ();
54
55  virtual void tick (float time);
56
57  virtual void draw () const;
58
59  virtual void collidesWith (WorldEntity* entity, const Vector& location);
60  void drawBVTree(unsigned int depth, int drawMode) const;
61
62  /* @returns the Count of Faces on this WorldEntity */
63  //unsigned int getFaceCount () const { return (this->model != NULL)?this->model->getFaceCount():0; };
64  //  void addAbility(Ability* ability);
65  //  void removeAbility(Ability* ability);
66  //  void setCharacterAttributes(CharacterAttributes* charAttr);
67  //  CharacterAttributes* getCharacterAttributes();
68
69  void toList(OM_LIST list);
70
71  /** @returns a Reference to the objectListNumber to set. */
72  OM_LIST& getOMListNumber() { return this->objectListNumber; }
73  /** @returns a Reference to the Iterator */
74  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
75
76  int       writeState(const byte* data, int length, int sender);
77  int       readState(byte* data, int maxLength );
78
79 protected:
80  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
81
82
83 private:
84  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
85  const char*             md2TextureFileName; //!< the file name of the md2 model texture, only if this
86  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
87
88  bool                    bCollide;           //!< If it should be considered for the collisiontest.
89  bool                    bVisible;           //!< If it should be visible.
90
91  OM_LIST                           objectListNumber;   //!< The ObjectList from ObjectManager this Entity is in.
92  std::list<WorldEntity*>::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
93
94  float                   scaling;
95
96
97};
98
99#endif /* _WORLD_ENTITY_H */
Note: See TracBrowser for help on using the repository browser.