Changeset 9006 in orxonox.OLD for trunk/src/world_entities/environments/mapped_water.h
- Timestamp:
- Jul 2, 2006, 2:11:59 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/environments/mapped_water.h
r8792 r9006 1 /*!1 /*! 2 2 * @file mapped_water.h 3 3 * worldentity for flat, cool looking, mapped water … … 12 12 <waterangle>0</waterangle> 13 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 --> 14 <shinesize>128</shinesize><!-- the bigger the value, the smaller the specular reflection point --> 15 <shinestrength>0.7</shinestrength> 16 <reflstrength>1</reflstrength> 17 <refraction>0.009</refraction> 15 18 <watercolor>0.1, 0.2, 0.4</watercolor> 16 19 </MappedWater> … … 25 28 #include "shader.h" 26 29 30 namespace OrxGui { class GLGuiBox; }; 31 32 // forward declaration 33 template <class T> class tAnimation; 27 34 28 35 class MappedWater : public WorldEntity … … 32 39 virtual ~MappedWater(); 33 40 41 // worldentity functions 34 42 void loadParams(const TiXmlElement* root); 35 43 void saveParams(); 36 44 void draw() const; 37 45 void tick(float dt); … … 43 51 void deactivateRefraction(); 44 52 53 // slider gui to edit water params during gameplay 54 void openGui(); 55 void closeGui(); 56 45 57 // 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); }; 58 void setLightPos(float x, float y, float z) { this->lightPos = Vector(x,y,z); } 59 void setWaterPos(float x, float y, float z) { this->waterHeight = y; this->waterVerts[0] = x; this->waterVerts[1] = z; } 60 void setWaterHeight(float y) { this->waterHeight = y; } 61 void setWaterSize(float x, float z) { this->xWidth = x; this->zWidth = z; } 62 void setWaterAngle(float angle) { this->waterAngle = angle; } 63 void setWaterColor(float r, float g, float b) { this->waterColor = Vector(r,g,b); } 64 void setWaterUV(float uv) { this->waterUV = uv; } 65 void setWaterFlow(float flow) { this->waterFlow = flow; } 66 void setNormalMapScale(float scale) { this->kNormalMapScale = scale; } 67 void setShineSize(float shine) { this->shineSize = shine; } 68 void setShineStrength(float strength) { this->shineStrength = strength; } 69 void setReflStrength(float strength) { this->reflStrength = strength; } 70 void setRefraction(float refraction) { this->refraction = refraction; } 55 71 56 72 // functions to change water parameters during runtime 57 73 // to reset waterUV and waterFlow just use the normal set functions 74 // don't reset kNormalMapScale (because it won't change anything) 75 void resetLightPos(float x, float y, float z); 76 void resetLightPosX(float x) { this->resetLightPos(x, this->lightPos.y, this->lightPos.z); } 77 void resetLightPosY(float y) { this->resetLightPos(this->lightPos.x, y, this->lightPos.z); } 78 void resetLightPosZ(float z) { this->resetLightPos(this->lightPos.x, this->lightPos.y, z); } 79 void resetWaterPos(float x, float y, float z) { this->setWaterPos(x, y, z); this->calcVerts(); } 80 void resetWaterSize(float x, float z) { this->setWaterSize(x, z); this->calcVerts(); } 81 void resetWaterAngle(float angle) { this->setWaterAngle(angle); this->calcVerts(); } 58 82 void resetWaterColor(float r, float g, float b); 59 void resetShininess(float shine); 60 void resetLightPos(float x, float y, float z); 83 void resetWaterColorR(float r) { this->resetWaterColor(r, this->waterColor.y, this->waterColor.z); } 84 void resetWaterColorG(float g) { this->resetWaterColor(this->waterColor.x, g, this->waterColor.z); } 85 void resetWaterColorB(float b) { this->resetWaterColor(this->waterColor.x, this->waterColor.y, b); } 86 void resetShineSize(float shine); 87 void resetShineStrength(float strength); 88 void resetReflStrength(float strength); 89 void resetRefraction(float refraction); 61 90 62 // fade functions 63 void fadeWaterColor(float r, float g, float b, float time); 64 void fadeShininess(float shine, float time); 65 void fadeLightPos(float x, float y, float z, float time); 91 // fading functions 92 void fadeWaterUV(float uv, float time) { this->newWaterUV = uv; this->waterUVFadeTime = time; this->bFadeWaterUV = true; } 93 void fadeWaterFlow(float flow, float time) { this->newWaterFlow = flow; this->waterFlowFadeTime = time; this->bFadeWaterFlow = true; } 94 void fadeShineSize(float shine, float time) { this->newShineSize = shine; this->shineSizeFadeTime = time; this->bFadeShineSize = true; } 95 void fadeShineStrength(float strength, float time) { this->newShineStrength = strength; this->shineStrengthFadeTime = time; this->bFadeShineStrength = true; } 96 void fadeReflStrength(float strength, float time) { this->newReflStrength = strength; this->reflStrengthFadeTime = time; this->bFadeReflStrength = true; } 97 void fadeRefraction(float refraction, float time) { this->newRefraction = refraction; this->refractionFadeTime = time; this->bFadeRefraction = true; } 98 void fadeWaterHeight(float y, float time) { this->newWaterHeight = y; this->waterHeightFadeTime = time; this->bFadeWaterHeight = true; } 99 void fadeWaterColor(float r, float g, float b, float time) { this->newWaterColor = Vector(r, g, b); this->waterColorFadeTime = time; this->bFadeWaterColor = true; } 66 100 67 101 private: … … 69 103 void initTextures(); 70 104 void initShaders(); 105 void calcVerts(); 71 106 72 107 private: 73 Vector waterPos; //!< position of the water 74 float xWidth, zWidth; //!< size of the water quad 75 Vector lightPos; //!< position of the light that is used to render the reflection 76 float waterAngle; //!< defines how much the water will be turned around the point waterPos 77 Vector waterColor; //!< color of the water 78 float move; //!< textures coords, speeds, positions for the shaded textures.... 79 float move2; 80 float waterUV; //!< size of the waves 81 float waterFlow; //!< speed of the water 82 float normalUV; 83 float kNormalMapScale; 84 float shininess; //!< the bigger the value, the smaller the specular reflection point 108 Material mat; 109 Shader* shader; 110 OrxGui::GLGuiBox* box; 85 111 86 int textureSize; //!< height and width of the texture 87 Material mat; 88 Shader* shader; 89 Shader::Uniform* cam_uni; //!< uniform that is used for the camera position 90 Shader::Uniform* light_uni; //!< uniform that is used for the light position 91 Shader::Uniform* color_uni; //!< uniform that is used for the watercolor 92 Shader::Uniform* shine_uni; //!< uniform that is used for the specular shininessd of the water 93 94 95 int tempcounter; 112 // water size and position 113 float waterHeight; //!< position of the water 114 float waterVerts[8]; //!< coords of the 4 vertexes of the water quad 115 float xWidth, zWidth; //!< size of the water quad 116 float waterAngle; //!< defines how much the water will be turned around the point waterPos 117 118 // values for texture size, scale, texture coords 119 float move; 120 float move2; 121 float waterUV; //!< size of the waves 122 float waterFlow; //!< speed of the water 123 float normalUV; 124 float kNormalMapScale; 125 int textureSize; //!< height and width of the texture 126 127 // values for the uniforms 128 Vector waterColor; //!< color of the water 129 Vector lightPos; //!< position of the light that is used to render the reflection 130 float shineSize; //!< the bigger the value, the smaller the specular reflection point 131 float shineStrength; 132 float reflStrength; 133 float refraction; 134 135 // uniforms 136 Shader::Uniform* cam_uni; //!< uniform that is used for the camera position 137 Shader::Uniform* light_uni; //!< uniform that is used for the light position 138 Shader::Uniform* color_uni; //!< uniform that is used for the watercolor 139 Shader::Uniform* shineSize_uni; //!< uniform that is used for the specular shininessd of the water 140 Shader::Uniform* shineStrength_uni; //!< uniform that is used for the strenght of the specular reflection 141 Shader::Uniform* reflStrength_uni; //!< uniform that is used for the strength of the reflection 142 Shader::Uniform* refr_uni; //!< uniform that is used for the strength of the refraction 143 144 // fading TODO fix this so it isnt so hacky anymore 145 tAnimation<MappedWater>* waterUVFader; 146 float newWaterUV; 147 float waterUVFadeTime; 148 bool bFadeWaterUV ; 149 tAnimation<MappedWater>* waterFlowFader; 150 float newWaterFlow; 151 float waterFlowFadeTime; 152 bool bFadeWaterFlow; 153 tAnimation<MappedWater>* shineSizeFader; 154 float newShineSize; 155 float shineSizeFadeTime; 156 bool bFadeShineSize; 157 tAnimation<MappedWater>* shineStrengthFader; 158 float newShineStrength; 159 float shineStrengthFadeTime; 160 bool bFadeShineStrength; 161 tAnimation<MappedWater>* reflStrengthFader; 162 float newReflStrength; 163 float reflStrengthFadeTime; 164 bool bFadeReflStrength; 165 tAnimation<MappedWater>* refractionFader; 166 float newRefraction; 167 float refractionFadeTime; 168 bool bFadeRefraction; 169 tAnimation<MappedWater>* waterHeightFader; 170 float newWaterHeight; 171 float waterHeightFadeTime; 172 bool bFadeWaterHeight; 173 tAnimation<MappedWater>* waterColorRFader; 174 tAnimation<MappedWater>* waterColorGFader; 175 tAnimation<MappedWater>* waterColorBFader; 176 Vector newWaterColor; 177 float waterColorFadeTime; 178 bool bFadeWaterColor; 96 179 }; 97 180
Note: See TracChangeset
for help on using the changeset viewer.