Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

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

File size: 4.8 KB
RevLine 
[4680]1/*!
[4885]2 * @file world_entity.h
3 * Definition of the basic WorldEntity
[7711]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
[7460]18namespace OrxSound { class SoundBuffer; class SoundSource; }
[7779]19namespace OrxGui { class GLGuiWidget; class GLGuiBar; };
20
[5143]21class BVTree;
[5511]22class Model;
[6440]23
[5498]24//class CharacterAttributes;
[4682]25
[5498]26
[4885]27//! Basis-class all interactive stuff in the world is derived from
[6498]28class WorldEntity : public PNode
[4680]29{
[6430]30public:
31  WorldEntity();
[3221]32  virtual ~WorldEntity ();
[3365]33
[6512]34  virtual void loadParams(const TiXmlElement* root);
[5994]35
[7711]36  void loadModel(const std::string& fileName, float scaling = 1.0f, unsigned int modelNumber = 0, unsigned int obbTreeDepth = 4);
[5994]37  void setModel(Model* model, unsigned int modelNumber = 0);
[6440]38  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
[5994]39
[7221]40  inline void loadMD2Texture(const std::string& fileName) { this->md2TextureFileName = fileName; }
[6222]41
[4885]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 */
[5511]45  inline bool isVisible() const { return this->bVisible; };
[5026]46
[7085]47  virtual void reset();
[3583]48
[3229]49  virtual void postSpawn ();
[6959]50  virtual void leaveWorld ();
[7076]51  virtual void destroy() {};
[3583]52
[5501]53  virtual void tick (float time);
54  virtual void draw () const;
[6005]55
[7711]56  bool buildObbTree(int depth);
[5029]57  virtual void collidesWith (WorldEntity* entity, const Vector& location);
[7711]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;
[5501]61
[6430]62  void debugWE() { this->debugEntity(); }
63  ;  ///FIXME
[6424]64  void debugEntity() const;
65
66
[5510]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();
[4680]73
[6142]74  void toList(OM_LIST list);
[7814]75  void toReflectionList();
76  void removeFromReflectionList();
[4680]77
[6142]78  /** @returns a Reference to the objectListNumber to set. */
79  OM_LIST& getOMListNumber() { return this->objectListNumber; }
80  /** @returns a Reference to the Iterator */
[7370]81  ObjectManager::EntityList::iterator& getEntityIterator() { return this->objectListIterator; }
[6222]82
[6341]83  int       writeState(const byte* data, int length, int sender);
84  int       readState(byte* data, int maxLength );
[6222]85
[6430]86  /** @returns the Energy of the entity */
[6700]87  float getHealth() const { return this->health; };
[6430]88  /** @returns the Maximum energy this entity can be charged with */
[6700]89  float getHealthMax() const { return this->healthMax; }
90  float increaseHealth(float health);
91  float decreaseHealth(float health);
92  void increaseHealthMax(float increaseHealth);
[7779]93  OrxGui::GLGuiWidget* getHealthWidget();
[7064]94  bool hasHealthWidget() const { return this->healthWidget; };
[6430]95
96protected:
[7095]97  void setHealth(float health) { this->health = health; this->updateHealthWidget();};
[6700]98  void setHealthWidgetVisibilit(bool visibility);
99  void setHealthMax(float healthMax);
100  void createHealthWidget();
[7711]101
[5994]102  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
[6430]103private:
[6700]104  void updateHealthWidget();
[5994]105
[6430]106private:
107  /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
[6700]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.
[7779]110  OrxGui::GLGuiBar*       healthWidget;       //!< The Slider (if wanted).
[6341]111
[6142]112  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
[7221]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
[6142]115  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
[4680]116
[6142]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.
[7370]121  ObjectManager::EntityList::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
[6142]122
[6341]123  float                   scaling;
124
125
[2036]126};
127
[3224]128#endif /* _WORLD_ENTITY_H */
Note: See TracBrowser for help on using the repository browser.