Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: loadParams is now virtual.
ALL THE CLASSES HAVE TO CALL

SuperClass::loadParams(root);

isntead of:
static_cast<SuperClass*>(this)→loadParams(root);

which was quite stupid anyways

File size: 4.3 KB
RevLine 
[4680]1/*!
[4885]2 * @file world_entity.h
3 * Definition of the basic WorldEntity
[2190]4*/
[2036]5
[3224]6#ifndef _WORLD_ENTITY_H
7#define _WORLD_ENTITY_H
[2036]8
[3365]9#include "p_node.h"
[5996]10#include "synchronizeable.h"
11#include "model.h"
[2036]12
[6142]13#include "object_manager.h"
[5511]14#include "glincl.h"
[5995]15#include <vector>
[5511]16
[4885]17// FORWARD DECLARATION
[4504]18class SoundBuffer;
19class SoundSource;
[5143]20class BVTree;
[5511]21class Model;
[6440]22
23class GLGuiWidget;
[6430]24class GLGuiBar;
[4504]25
[5498]26//class CharacterAttributes;
[4682]27
[5498]28
[4885]29//! Basis-class all interactive stuff in the world is derived from
[6498]30class WorldEntity : public PNode
[4680]31{
[6430]32public:
33  WorldEntity();
[3221]34  virtual ~WorldEntity ();
[3365]35
[6512]36  virtual void loadParams(const TiXmlElement* root);
[5994]37
[5995]38  void loadModel(const char* fileName, float scaling = 1.0f, unsigned int modelNumber = 0);
[5994]39  void setModel(Model* model, unsigned int modelNumber = 0);
[6440]40  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
[5994]41
[6222]42  inline void loadMD2Texture(const char* fileName) { this->md2TextureFileName = fileName; }
43
[5061]44  bool buildObbTree(unsigned int depth);
[5994]45  /** @returns a reference to the obb tree of this worldentity */
46  BVTree* getOBBTree() const { return this->obbTree; };
[5057]47
[4885]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 */
[5511]51  inline bool isVisible() const { return this->bVisible; };
[5026]52
[3583]53
[5026]54
[3229]55  virtual void postSpawn ();
[3583]56  virtual void leftWorld ();
57
[5501]58  virtual void tick (float time);
[6005]59
[5501]60  virtual void draw () const;
[6005]61
[5029]62  virtual void collidesWith (WorldEntity* entity, const Vector& location);
[5510]63  void drawBVTree(unsigned int depth, int drawMode) const;
[5501]64
[6424]65
[6430]66  void debugWE() { this->debugEntity(); }
67  ;  ///FIXME
[6424]68  void debugEntity() const;
69
70
[5510]71  /* @returns the Count of Faces on this WorldEntity */
72  //unsigned int getFaceCount () const { return (this->model != NULL)?this->model->getFaceCount():0; };
73  //  void addAbility(Ability* ability);
74  //  void removeAbility(Ability* ability);
75  //  void setCharacterAttributes(CharacterAttributes* charAttr);
76  //  CharacterAttributes* getCharacterAttributes();
[4680]77
[6142]78  void toList(OM_LIST list);
[4680]79
[6142]80  /** @returns a Reference to the objectListNumber to set. */
81  OM_LIST& getOMListNumber() { return this->objectListNumber; }
82  /** @returns a Reference to the Iterator */
83  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
[6222]84
[6341]85  int       writeState(const byte* data, int length, int sender);
86  int       readState(byte* data, int maxLength );
[6222]87
[6430]88  /** @returns the Energy of the entity */
89  float getEnergy() const { return this->energy; };
90  /** @returns the Maximum energy this entity can be charged with */
91  float getMaxEnergy() const { return this->energyMax; }
92  float addEnergy(float energy);
93  float removeEnergy(float energy);
94  void setMaxEnergy(float maxEnergy);
[6440]95  GLGuiWidget* getEnergyWidget();
[6430]96
97protected:
98  void setEnergy(float energy) { this->energy = energy; };
99  void setEnergyWidgetVisibilit(bool visibility);
100  void createEnergyWidget();
[5994]101  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
[6430]102private:
103  void updateEnergyWidget();
[5994]104
[6430]105private:
106  /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
107  float                   energy;             //!< The Energy of this Entity, if the Entity has any energy at all.
108  float                   energyMax;          //!< The Maximal energy this entity can take.
109  GLGuiBar*               energyWidget;       //!< The Slider (if wanted).
[6341]110
[6142]111  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
[6222]112  const char*             md2TextureFileName; //!< the file name of the md2 model texture, only if this
[6142]113  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
[4680]114
[6142]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
[6341]121  float                   scaling;
122
123
[2036]124};
125
[3224]126#endif /* _WORLD_ENTITY_H */
Note: See TracBrowser for help on using the repository browser.