Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8617 in orxonox.OLD


Ignore:
Timestamp:
Jun 20, 2006, 12:58:02 PM (18 years ago)
Author:
stefalie
Message:

water: minor cleanup and the waterflow doesnt depend on the framerate anymore

Location:
branches/water/src/world_entities/environments
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/water/src/world_entities/environments/mapped_water.cc

    r8587 r8617  
    3131  this->setClassID(CL_MAPPED_WATER, "MappedWater");
    3232  this->toList(OM_ENVIRON);
     33
     34  // the NormalMapScale will be overwritten if its also set in the oxw file
     35  this->setNormalMapScale(0.25f);
    3336
    3437  if (root != NULL)
     
    5760
    5861  // set the size of the refraction and reflection textures
    59  
     62
    6063
    6164  // initialization of the texture coords, speeds etc...
     65  // normalUV wont change anymore
     66  this->normalUV = this->waterUV * this->kNormalMapScale;
     67  // move and move2 are used for the reflection and refraction, the values are changed in tick()
    6268  this->move = 0.0f;
    63   this->kNormalMapScale = 0.25f;
     69  this->move2 = this->move * this->kNormalMapScale;
     70
    6471
    6572  //unsigned int channels = 32;
     
    174181  LoadParam(root, "wateruv", this, MappedWater, setWaterUV);
    175182  LoadParam(root, "waterflow", this, MappedWater, setWaterFlow);
     183  LoadParam(root, "normalmapscale", this, MappedWater, setNormalMapScale);
    176184}
    177185
     
    198206  glBegin(GL_QUADS);
    199207  // The back left vertice for the water
    200   glMultiTexCoord2f(GL_TEXTURE0, 0.0f, g_WaterUV);            // Reflection texture
    201   glMultiTexCoord2f(GL_TEXTURE1, 0.0f, refrUV - move);        // Refraction texture
     208  glMultiTexCoord2f(GL_TEXTURE0, 0.0f, waterUV);            // Reflection texture
     209  glMultiTexCoord2f(GL_TEXTURE1, 0.0f, waterUV - move);        // Refraction texture
    202210  glMultiTexCoord2f(GL_TEXTURE2, 0.0f, normalUV + move2);     // Normal map texture
    203211  glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                       // DUDV map texture
     
    212220
    213221  // The front right vertice for the water
    214   glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, 0.0f);             // Reflection texture
    215   glMultiTexCoord2f(GL_TEXTURE1, refrUV, 0.0f - move);         // Refraction texture
     222  glMultiTexCoord2f(GL_TEXTURE0, waterUV, 0.0f);             // Reflection texture
     223  glMultiTexCoord2f(GL_TEXTURE1, waterUV, 0.0f - move);         // Refraction texture
    216224  glMultiTexCoord2f(GL_TEXTURE2, normalUV, 0.0f + move2);      // Normal map texture
    217225  glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                        // DUDV map texture
     
    219227
    220228  // The back right vertice for the water
    221   glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, g_WaterUV);        // Reflection texture
    222   glMultiTexCoord2f(GL_TEXTURE1, refrUV, refrUV - move);       // Refraction texture
     229  glMultiTexCoord2f(GL_TEXTURE0, waterUV, waterUV);        // Reflection texture
     230  glMultiTexCoord2f(GL_TEXTURE1, waterUV, waterUV - move);       // Refraction texture
    223231  glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2);  // Normal map texture
    224232  glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                        // DUDV map texture
     
    230238  mat.unselect();
    231239
    232   /*if(pos.y < this->waterPos.y)
    233   {
    234     // draw some fog
    235     this->fog->activate();
    236   }
    237   else
    238   {
    239     this->fog->deactivate();
    240   }*/
    241 
    242240  glPopMatrix();
    243241}
     
    249247{
    250248  // makes the water flow
    251   // TODO change it so that the waterflow doesnt depend on the frame rate
    252   this->move += this->g_WaterFlow;
     249  this->move += this->waterFlow * dt;
    253250  this->move2 = this->move * this->kNormalMapScale;
    254   this->refrUV = this->g_WaterUV;
    255   this->normalUV = this->g_WaterUV * this->kNormalMapScale;
    256251}
    257252
  • branches/water/src/world_entities/environments/mapped_water.h

    r8484 r8617  
    4444    void setWaterPos(float x, float y, float z) { this->waterPos = Vector(x,y,z); };
    4545    void setWaterSize(float x, float z) { this->xWidth = x; this->zWidth = z; };
    46     void setWaterUV(float uv) { this->g_WaterUV = uv; };
    47     void setWaterFlow(float flow) { this->g_WaterFlow = flow; };
     46    void setWaterUV(float uv) { this->waterUV = uv; };
     47    void setWaterFlow(float flow) { this->waterFlow = flow; };
     48    void setNormalMapScale(float scale) { this->kNormalMapScale = scale; };
    4849
    4950  private:
     
    5657
    5758    float               move;                       //!< textures coords, speeds, positions for the shaded textures....
    58     float               move2;                      //!<
    59     float               g_WaterUV;                  //!<
    60     float               g_WaterFlow;                //!<
    61     float               refrUV;                     //!<
    62     float               normalUV;                   //!<
    63     float               kNormalMapScale;            //!<
     59    float               move2;
     60    float               waterUV;                    //!< size of the waves
     61    float               waterFlow;                  //!< speed of the water
     62    float               normalUV;
     63    float               kNormalMapScale;
    6464
    6565    int                 textureSize;                //!< height and width of the texture
     
    6767    Shader*             shader;
    6868    Shader::Uniform*    cam_uni;                    //!< uniform that is used for the camera position
    69 
    70     //FogEffect*          fog;
    71 
    7269};
    7370
    74 #endif  /* _MAPPED_WATER_H */
     71#endif
Note: See TracChangeset for help on using the changeset viewer.