Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8792 in orxonox.OLD


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

merged water branche back to trunk

Location:
trunk/src/world_entities/environments
Files:
2 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
  • trunk/src/world_entities/environments/mapped_water.h

    r8719 r8792  
    1212  <waterangle>0</waterangle>
    1313  <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>
    1416</MappedWater>
    1517*/
     
    4951  void setWaterFlow(float flow) { this->waterFlow = flow; };
    5052  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);
    5166
    5267private:
     
    6075  Vector              lightPos;               //!< position of the light that is used to render the reflection
    6176  float               waterAngle;             //!< defines how much the water will be turned around the point waterPos
    62 
     77  Vector              waterColor;             //!< color of the water
    6378  float               move;                   //!< textures coords, speeds, positions for the shaded textures....
    6479  float               move2;
     
    6782  float               normalUV;
    6883  float               kNormalMapScale;
     84  float               shininess;              //!< the bigger the value, the smaller the specular reflection point
    6985
    7086  int                 textureSize;            //!< height and width of the texture
     
    7288  Shader*             shader;
    7389  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;
    7496};
    7597
Note: See TracChangeset for help on using the changeset viewer.