Changeset 8617 in orxonox.OLD for branches/water/src
- Timestamp:
- Jun 20, 2006, 12:58:02 PM (18 years ago)
- 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 31 31 this->setClassID(CL_MAPPED_WATER, "MappedWater"); 32 32 this->toList(OM_ENVIRON); 33 34 // the NormalMapScale will be overwritten if its also set in the oxw file 35 this->setNormalMapScale(0.25f); 33 36 34 37 if (root != NULL) … … 57 60 58 61 // set the size of the refraction and reflection textures 59 62 60 63 61 64 // 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() 62 68 this->move = 0.0f; 63 this->kNormalMapScale = 0.25f; 69 this->move2 = this->move * this->kNormalMapScale; 70 64 71 65 72 //unsigned int channels = 32; … … 174 181 LoadParam(root, "wateruv", this, MappedWater, setWaterUV); 175 182 LoadParam(root, "waterflow", this, MappedWater, setWaterFlow); 183 LoadParam(root, "normalmapscale", this, MappedWater, setNormalMapScale); 176 184 } 177 185 … … 198 206 glBegin(GL_QUADS); 199 207 // The back left vertice for the water 200 glMultiTexCoord2f(GL_TEXTURE0, 0.0f, g_WaterUV); // Reflection texture201 glMultiTexCoord2f(GL_TEXTURE1, 0.0f, refrUV - move); // Refraction texture208 glMultiTexCoord2f(GL_TEXTURE0, 0.0f, waterUV); // Reflection texture 209 glMultiTexCoord2f(GL_TEXTURE1, 0.0f, waterUV - move); // Refraction texture 202 210 glMultiTexCoord2f(GL_TEXTURE2, 0.0f, normalUV + move2); // Normal map texture 203 211 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture … … 212 220 213 221 // The front right vertice for the water 214 glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, 0.0f); // Reflection texture215 glMultiTexCoord2f(GL_TEXTURE1, refrUV, 0.0f - move); // Refraction texture222 glMultiTexCoord2f(GL_TEXTURE0, waterUV, 0.0f); // Reflection texture 223 glMultiTexCoord2f(GL_TEXTURE1, waterUV, 0.0f - move); // Refraction texture 216 224 glMultiTexCoord2f(GL_TEXTURE2, normalUV, 0.0f + move2); // Normal map texture 217 225 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture … … 219 227 220 228 // The back right vertice for the water 221 glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, g_WaterUV); // Reflection texture222 glMultiTexCoord2f(GL_TEXTURE1, refrUV, refrUV - move); // Refraction texture229 glMultiTexCoord2f(GL_TEXTURE0, waterUV, waterUV); // Reflection texture 230 glMultiTexCoord2f(GL_TEXTURE1, waterUV, waterUV - move); // Refraction texture 223 231 glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2); // Normal map texture 224 232 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture … … 230 238 mat.unselect(); 231 239 232 /*if(pos.y < this->waterPos.y)233 {234 // draw some fog235 this->fog->activate();236 }237 else238 {239 this->fog->deactivate();240 }*/241 242 240 glPopMatrix(); 243 241 } … … 249 247 { 250 248 // 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; 253 250 this->move2 = this->move * this->kNormalMapScale; 254 this->refrUV = this->g_WaterUV;255 this->normalUV = this->g_WaterUV * this->kNormalMapScale;256 251 } 257 252 -
branches/water/src/world_entities/environments/mapped_water.h
r8484 r8617 44 44 void setWaterPos(float x, float y, float z) { this->waterPos = Vector(x,y,z); }; 45 45 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; }; 48 49 49 50 private: … … 56 57 57 58 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; 64 64 65 65 int textureSize; //!< height and width of the texture … … 67 67 Shader* shader; 68 68 Shader::Uniform* cam_uni; //!< uniform that is used for the camera position 69 70 //FogEffect* fog;71 72 69 }; 73 70 74 #endif /* _MAPPED_WATER_H */71 #endif
Note: See TracChangeset
for help on using the changeset viewer.