Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/mountain_lake/src/world_entities/environments/mapped_water.h @ 8848

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

mountain_lake: added coords for all 4 verts…

File size: 4.0 KB
Line 
1/*!
2 * @file mapped_water.h
3 *  worldentity for flat, cool looking, mapped water
4*/
5/*! example input in .oxw file with the standard values
6<MappedWater>
7  <waterpos>0,0,0</waterpos>
8  <watersize>100,100</watersize>
9  <wateruv>9</wateruv><!-- size of the waves -->
10  <waterflow>0.08</waterflow>
11  <lightpos>0,10,0</lightpos>
12  <waterangle>0</waterangle>
13  <normalmapscale>0.25</normalmapscale><!-- you won't see a big differnce if you change that -->
14  <shininess>128</shininess><!-- the bigger the value, the smaller the specular reflection point -->
15  <watercolor>0.1, 0.2, 0.4</watercolor>
16</MappedWater>
17*/
18
19
20#ifndef _MAPPED_WATER_H
21#define _MAPPED_WATER_H
22
23#include "world_entity.h"
24#include "material.h"
25#include "shader.h"
26
27
28class MappedWater : public WorldEntity
29{
30public:
31  MappedWater(const TiXmlElement* root = NULL);
32  virtual ~MappedWater();
33
34  void loadParams(const TiXmlElement* root);
35
36  void draw() const;
37  void tick(float dt);
38
39  // function to prepare renderpaths for creation of refleaction and reflaction textures
40  void activateReflection();
41  void deactivateReflection();
42  void activateRefraction();
43  void deactivateRefraction();
44
45  // functions to set parameters for the water, usually they're called through loadparam
46  void setLightPos(float x, float y, float z) { this->lightPos = Vector(x,y,z); }
47  void setWaterPos(float x, float y, float z) { this->waterPos = Vector(x,y,z); }
48  void setWaterSize(float x, float z) { this->xWidth = x; this->zWidth = z; }
49  void setWaterAngle(float angle) { this->waterAngle = angle; }
50  void setWaterUV(float uv) { this->waterUV = uv; }
51  void setWaterFlow(float flow) { this->waterFlow = flow; };
52  void setNormalMapScale(float scale) { this->kNormalMapScale = scale; }
53  void setShininess(float shine) { this->shininess = shine; }
54  void setWaterColor(float r, float g, float b) { this->waterColor = Vector(r,g,b); this->newWaterColor = this->waterColor; }
55
56  // functions to change water parameters during runtime
57  // to reset waterUV and waterFlow just use the normal set functions
58  void resetWaterColor(float r, float g, float b);
59  void resetShininess(float shine);
60  void resetLightPos(float x, float y, float z);
61
62  // fade functions
63  void fadeWaterColor(float r, float g, float b, float time) {this->newWaterColor = Vector(r, g, b); this->colorFadeTime = time; }
64  void fadeShininess(float shine, float time);
65  void fadeLightPos(float x, float y, float z, float time);
66
67private:
68  void initParams();
69  void initTextures();
70  void initShaders();
71
72private:
73  Vector              waterPos;               //!< position of the water
74  float               xWidth, zWidth;         //!< size of the water quad
75  float               waterVerts[8];       //!< coords of the 4 vertexes of the water quad
76  Vector              lightPos;               //!< position of the light that is used to render the reflection
77  float               waterAngle;             //!< defines how much the water will be turned around the point waterPos
78  Vector              waterColor;             //!< color of the water
79
80  Vector              newWaterColor;          //!< used to fade the water color
81  float               colorFadeTime;
82
83  float               move;
84  float               move2;
85  float               waterUV;                //!< size of the waves
86  float               waterFlow;              //!< speed of the water
87  float               normalUV;
88  float               kNormalMapScale;
89  float               shininess;              //!< the bigger the value, the smaller the specular reflection point
90
91  int                 textureSize;            //!< height and width of the texture
92  Material            mat;
93  Shader*             shader;
94  Shader::Uniform*    cam_uni;                //!< uniform that is used for the camera position
95  Shader::Uniform*    light_uni;              //!< uniform that is used for the light position
96  Shader::Uniform*    color_uni;              //!< uniform that is used for the watercolor
97  Shader::Uniform*    shine_uni;              //!< uniform that is used for the specular shininessd of the water
98 
99 
100  int tempcounter;
101};
102
103#endif
Note: See TracBrowser for help on using the repository browser.