Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 26, 2006, 3:18:08 PM (19 years ago)
Author:
patrick
Message:

merged water branche back to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/environments/mapped_water.cc

    r8719 r8792  
    1919#include "util/loading/resource_manager.h"
    2020#include "state.h"
     21#include "math.h"
    2122
    2223
     
    4445  /// initialization of the shaders
    4546  this->initShaders();
     47 
     48  tempcounter = 0;
    4649}
    4750
     
    5356  delete shader;
    5457  delete cam_uni;
     58  delete color_uni;
     59  delete light_uni;
     60  delete shine_uni;
    5561}
    5662
     
    6874  this->setWaterAngle(0);
    6975  this->setNormalMapScale(0.25f);
     76  this->setWaterColor(0.1f, 0.2f, 0.4f);
     77  this->setShininess(128);
    7078
    7179  // initialization of the texture coords, speeds etc...
     
    7583  this->move = 0;
    7684  this->move2 = this->move * this->kNormalMapScale;
     85
     86
    7787}
    7888
     
    132142  Shader::Uniform(shader, "depthMap").set(2);
    133143  // 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);
    135146  // 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);
    137152  // uniform for the camera position
    138153  cam_uni = new Shader::Uniform(shader, "cameraPos");
     
    140155  this->shader->deactivateShader();
    141156}
     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 */
     164void 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 */
     179void 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 */
     196void 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};
    142206
    143207/**
     
    156220  LoadParam(root, "normalmapscale", this, MappedWater, setNormalMapScale);
    157221  LoadParam(root, "waterangle", this, MappedWater, setWaterAngle);
     222  LoadParam(root, "watercolor", this, MappedWater, setWaterColor);
     223  LoadParam(root, "shininess", this, MappedWater, setShininess);
    158224}
    159225
     
    224290  this->move += this->waterFlow * dt;
    225291  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   
    226302}
    227303
Note: See TracChangeset for help on using the changeset viewer.