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 void varChangeHandler( std::list<int> & id ); |
---|
42 | |
---|
43 | private: |
---|
44 | bool posToGridPoint(float x, float z, unsigned int& row, unsigned int& column); |
---|
45 | |
---|
46 | private: |
---|
47 | Grid* grid; //!< The water-surface-model to render with |
---|
48 | float** velocities; //!< Velocities. |
---|
49 | float viscosity; //!< Viscosity (bigger more like honey, smaller more like water). |
---|
50 | float cohesion; //!< Cohesion. |
---|
51 | |
---|
52 | Material waterMaterial; |
---|
53 | Shader* waterShader; |
---|
54 | |
---|
55 | float height; //!< The hight of the Water |
---|
56 | int height_handle; //!< Handle to notify about changes of height |
---|
57 | |
---|
58 | unsigned int resX, resY; //!< Grid resolution |
---|
59 | int resX_handle; //!< Handle to notify about changes of resX |
---|
60 | int resY_handle; //!< Handle to notify about changes of resY |
---|
61 | float sizeX, sizeY; //!< waters size |
---|
62 | int sizeX_handle; //!< Handle to notify about changes of sizeX |
---|
63 | int sizeY_handle; //!< Handle to notify about changes of sizeY |
---|
64 | |
---|
65 | float phase; |
---|
66 | }; |
---|
67 | |
---|
68 | #endif /* _WATER_H */ |
---|
69 | |
---|
70 | |
---|
71 | |
---|