| 1 | /*! | 
|---|
| 2 |  * @file water.h | 
|---|
| 3 |  *  Definition of the SkyBox, that handles the Display of an atmosphere for orxonox. | 
|---|
| 4 |  * | 
|---|
| 5 |  * A SkyBox is always centered at the current working Camera, and will only obey the cameras | 
|---|
| 6 |  * movment but not its rotation. | 
|---|
| 7 | */ | 
|---|
| 8 |  | 
|---|
| 9 | #ifndef _WATER_H | 
|---|
| 10 | #define _WATER_H | 
|---|
| 11 |  | 
|---|
| 12 | /* INCLUDES */ | 
|---|
| 13 | #include "world_entity.h" | 
|---|
| 14 | #include "material.h" | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | /* FORWARD DECLARATION */ | 
|---|
| 18 | class Grid; | 
|---|
| 19 | class Shader; | 
|---|
| 20 |  | 
|---|
| 21 | //! A Class to handle a WaterEffects | 
|---|
| 22 | class Water : public WorldEntity | 
|---|
| 23 | { | 
|---|
| 24 |  public: | 
|---|
| 25 |    Water(const TiXmlElement* root = NULL); | 
|---|
| 26 |    virtual ~Water(); | 
|---|
| 27 |  | 
|---|
| 28 |    void loadParams(const TiXmlElement* root); | 
|---|
| 29 |  | 
|---|
| 30 |    void setResolution(unsigned int resX, unsigned int resY); | 
|---|
| 31 |    void setSize(float sizeX, float sizeY); | 
|---|
| 32 |    void setHeight(float height); | 
|---|
| 33 |    void rebuildGrid(); | 
|---|
| 34 |  | 
|---|
| 35 |    void wave(float x, float y, float z, float force); | 
|---|
| 36 |    inline void wave(Vector pos, float force) { this->wave(pos.x, pos.y, pos.z, force); }; | 
|---|
| 37 |  | 
|---|
| 38 |    void draw() const; | 
|---|
| 39 |    void tick(float dt); | 
|---|
| 40 |  | 
|---|
| 41 |    virtual int writeBytes(const byte* data, int length, int sender); | 
|---|
| 42 |    virtual int readBytes(byte* data, int maxLength, int * reciever); | 
|---|
| 43 |  | 
|---|
| 44 |    int writeState( const byte * data, int length, int sender ); | 
|---|
| 45 |    int readState( byte * data, int maxLength ); | 
|---|
| 46 |  | 
|---|
| 47 |   private: | 
|---|
| 48 |     bool posToGridPoint(float x, float z, unsigned int& row, unsigned int& column); | 
|---|
| 49 |  | 
|---|
| 50 |   private: | 
|---|
| 51 |     Grid*           grid;            //!< The water-surface-model to render with | 
|---|
| 52 |     float**         velocities;      //!< Velocities. | 
|---|
| 53 |     float           viscosity;       //!< Viscosity (bigger more like honey, smaller more like water). | 
|---|
| 54 |     float           cohesion;        //!< Cohesion. | 
|---|
| 55 |  | 
|---|
| 56 |     Material        waterMaterial; | 
|---|
| 57 |     Shader*         waterShader; | 
|---|
| 58 |     float           height;          //!< The hight of the Water | 
|---|
| 59 |  | 
|---|
| 60 |     unsigned int    resX, resY; | 
|---|
| 61 |     float           sizeX, sizeY; | 
|---|
| 62 |  | 
|---|
| 63 |     float phase; | 
|---|
| 64 | }; | 
|---|
| 65 |  | 
|---|
| 66 | #endif  /* _WATER_H */ | 
|---|
| 67 |  | 
|---|
| 68 |  | 
|---|
| 69 |  | 
|---|