- Timestamp:
- Jun 26, 2006, 3:18:08 PM (18 years ago)
- Location:
- trunk/src/world_entities/environments
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/environments/mapped_water.cc
r8719 r8792 19 19 #include "util/loading/resource_manager.h" 20 20 #include "state.h" 21 #include "math.h" 21 22 22 23 … … 44 45 /// initialization of the shaders 45 46 this->initShaders(); 47 48 tempcounter = 0; 46 49 } 47 50 … … 53 56 delete shader; 54 57 delete cam_uni; 58 delete color_uni; 59 delete light_uni; 60 delete shine_uni; 55 61 } 56 62 … … 68 74 this->setWaterAngle(0); 69 75 this->setNormalMapScale(0.25f); 76 this->setWaterColor(0.1f, 0.2f, 0.4f); 77 this->setShininess(128); 70 78 71 79 // initialization of the texture coords, speeds etc... … … 75 83 this->move = 0; 76 84 this->move2 = this->move * this->kNormalMapScale; 85 86 77 87 } 78 88 … … 132 142 Shader::Uniform(shader, "depthMap").set(2); 133 143 // Give the variable "waterColor" a blue color 134 Shader::Uniform(shader, "waterColor").set(0.1f, 0.2f, 0.4f, 1.0f); 144 color_uni = new Shader::Uniform(shader, "waterColor"); 145 color_uni->set(waterColor.x, waterColor.y, waterColor.z, 1.0f); 135 146 // Give the variable "lightPos" our hard coded light position 136 Shader::Uniform(shader, "lightPos").set(lightPos.x, lightPos.y, lightPos.z, 1.0f); 147 light_uni = new Shader::Uniform(shader, "lightPos"); 148 light_uni->set(lightPos.x, lightPos.y, lightPos.z, 1.0f); 149 // Set the variable "shine" 150 shine_uni = new Shader::Uniform(shader, "kShine"); 151 shine_uni->set(this->shininess); 137 152 // uniform for the camera position 138 153 cam_uni = new Shader::Uniform(shader, "cameraPos"); … … 140 155 this->shader->deactivateShader(); 141 156 } 157 158 /** 159 * @brief resets the waterColor in the Shader 160 * @param r new value for red 161 * @param g new value for green 162 * @param b new value for blue 163 */ 164 void MappedWater::resetWaterColor(float r, float g, float b) 165 { 166 this->shader->activateShader(); 167 this->waterColor = Vector(r, g, b); 168 169 // Give the variable "waterColor" a color 170 color_uni->set(waterColor.x, waterColor.y, waterColor.z, 1.0f); 171 172 this->shader->deactivateShader(); 173 }; 174 175 /** 176 * @brief resets the shininess in the Shader 177 * @param shine new value for the shininess 178 */ 179 void MappedWater::resetShininess(float shine) 180 { 181 this->shader->activateShader(); 182 this->shininess = shine; 183 184 // Set the variable "shine" 185 shine_uni->set(this->shininess); 186 187 this->shader->deactivateShader(); 188 }; 189 190 /** 191 * @brief resets the lightPos in the Shader 192 * @param x new x value 193 * @param y new y value 194 * @param z new z value 195 */ 196 void MappedWater::resetLightPos(float x, float y, float z) 197 { 198 this->shader->activateShader(); 199 this->lightPos = Vector(x, y, z); 200 201 // Give the variable "lightPos" our hard coded light position 202 light_uni->set(lightPos.x, lightPos.y, lightPos.z, 1.0f); 203 204 this->shader->deactivateShader(); 205 }; 142 206 143 207 /** … … 156 220 LoadParam(root, "normalmapscale", this, MappedWater, setNormalMapScale); 157 221 LoadParam(root, "waterangle", this, MappedWater, setWaterAngle); 222 LoadParam(root, "watercolor", this, MappedWater, setWaterColor); 223 LoadParam(root, "shininess", this, MappedWater, setShininess); 158 224 } 159 225 … … 224 290 this->move += this->waterFlow * dt; 225 291 this->move2 = this->move * this->kNormalMapScale; 292 293 294 // if(this->tempcounter == 200) { 295 // this->resetWaterColor(1, 0, 0); 296 // resetShininess(1); 297 // resetLightPos(0, 50, 0); 298 // PRINTF(0)("test waterchangecolor "); 299 // } 300 // tempcounter++; 301 226 302 } 227 303 -
trunk/src/world_entities/environments/mapped_water.h
r8719 r8792 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 --> 15 <watercolor>0.1, 0.2, 0.4</watercolor> 14 16 </MappedWater> 15 17 */ … … 49 51 void setWaterFlow(float flow) { this->waterFlow = flow; }; 50 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); }; 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); 64 void fadeShininess(float shine, float time); 65 void fadeLightPos(float x, float y, float z, float time); 51 66 52 67 private: … … 60 75 Vector lightPos; //!< position of the light that is used to render the reflection 61 76 float waterAngle; //!< defines how much the water will be turned around the point waterPos 62 77 Vector waterColor; //!< color of the water 63 78 float move; //!< textures coords, speeds, positions for the shaded textures.... 64 79 float move2; … … 67 82 float normalUV; 68 83 float kNormalMapScale; 84 float shininess; //!< the bigger the value, the smaller the specular reflection point 69 85 70 86 int textureSize; //!< height and width of the texture … … 72 88 Shader* shader; 73 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; 74 96 }; 75 97
Note: See TracChangeset
for help on using the changeset viewer.