Changeset 8792 in orxonox.OLD for trunk/src/world_entities/environments/mapped_water.cc
- Timestamp:
- Jun 26, 2006, 3:18:08 PM (19 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.