Changeset 8859 in orxonox.OLD for branches/mountain_lake/src/world_entities/environments/mapped_water.cc
- Timestamp:
- Jun 28, 2006, 3:07:55 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mountain_lake/src/world_entities/environments/mapped_water.cc
r8848 r8859 47 47 48 48 /// calculation of the 4 verts of the water quad 49 this->waterVerts[0] = this->waterPos.x; 50 this->waterVerts[1] = this->waterPos.z; 51 this->waterVerts[2] = this->waterVerts[0] + cos(this->waterAngle) * this->xWidth; 52 this->waterVerts[3] = this->waterVerts[1] + sin(this->waterAngle) * this->xWidth; 53 this->waterVerts[2] = this->waterVerts[0] - sin(this->waterAngle) * this->zWidth; 54 this->waterVerts[3] = this->waterVerts[1] + cos(this->waterAngle) * this->zWidth; 55 this->waterVerts[2] = this->waterVerts[0] + cos(this->waterAngle) * this->xWidth - sin(this->waterAngle) * this->zWidth; 56 this->waterVerts[3] = this->waterVerts[1] + sin(this->waterAngle) * this->xWidth + cos(this->waterAngle) * this->zWidth; 49 this->calcVerts(); 57 50 58 51 tempcounter = 0; … … 167 160 168 161 /** 162 * @brief initialization of the shaders 163 */ 164 void MappedWater::calcVerts() 165 { 166 float deg2radtemp = this->waterAngle / 180 * PI; 167 168 this->waterVerts[2] = this->waterVerts[0] + cos(deg2radtemp) * this->xWidth; 169 this->waterVerts[3] = this->waterVerts[1] + sin(deg2radtemp) * this->xWidth; 170 this->waterVerts[4] = this->waterVerts[0] + cos(deg2radtemp) * this->xWidth - sin(deg2radtemp) * this->zWidth; 171 this->waterVerts[5] = this->waterVerts[1] + sin(deg2radtemp) * this->xWidth + cos(deg2radtemp) * this->zWidth; 172 this->waterVerts[6] = this->waterVerts[0] - sin(deg2radtemp) * this->zWidth; 173 this->waterVerts[7] = this->waterVerts[1] + cos(deg2radtemp) * this->zWidth; 174 } 175 176 /** 169 177 * @brief resets the waterColor in the Shader 170 178 * @param r new value for red … … 240 248 { 241 249 glMatrixMode(GL_MODELVIEW); 242 243 250 glPushMatrix(); 244 // don't use a glTranslate here, the reflection point won't be at the right place anymore 245 glRotatef(this->waterAngle, 0, 1, 0);251 252 // don't use glRotate or glTranslate here... the shader won't work anymore 246 253 247 254 mat.select(); … … 261 268 glMultiTexCoord2f(GL_TEXTURE2, 0, normalUV + move2); // Normal map texture 262 269 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 263 glVertex3f(this->water Pos.x, this->waterPos.y, this->waterPos.z);270 glVertex3f(this->waterVerts[0], this->waterHeight, this->waterVerts[1]); 264 271 265 272 // The front left vertice for the water … … 268 275 glMultiTexCoord2f(GL_TEXTURE2, 0, move2); // Normal map texture 269 276 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 270 glVertex3f(this->water Pos.x, this->waterPos.y, this->waterPos.z + this->zWidth);277 glVertex3f(this->waterVerts[2], this->waterHeight, this->waterVerts[3]); 271 278 272 279 // The front right vertice for the water … … 275 282 glMultiTexCoord2f(GL_TEXTURE2, normalUV, move2); // Normal map texture 276 283 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 277 glVertex3f(this->water Pos.x + this->xWidth, this->waterPos.y, this->waterPos.z + this->zWidth);284 glVertex3f(this->waterVerts[4], this->waterHeight, this->waterVerts[5]); 278 285 279 286 // The back right vertice for the water … … 282 289 glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2); // Normal map texture 283 290 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 284 glVertex3f(this->water Pos.x + this->xWidth, this->waterPos.y, this->waterPos.z);291 glVertex3f(this->waterVerts[6], this->waterHeight, this->waterVerts[7]); 285 292 glEnd(); 286 293 … … 357 364 Vector pos = State::getCameraNode()->getAbsCoor(); 358 365 359 if(pos.y > water Pos.y)366 if(pos.y > waterHeight) 360 367 { 361 368 // Translate the world, then flip it upside down 362 glTranslatef(0, water Pos.y*2, 0);369 glTranslatef(0, waterHeight * 2, 0); 363 370 glScalef(1, -1, 1); 364 371 … … 367 374 368 375 // Set our plane equation and turn clipping on 369 double plane[4] = {0, 1, 0, -water Pos.y};376 double plane[4] = {0, 1, 0, -waterHeight}; 370 377 glClipPlane(GL_CLIP_PLANE0, plane); 371 378 } … … 374 381 // If the camera is below the water we don't want to flip the world, 375 382 // but just render it clipped so only the top is drawn. 376 double plane[4] = {0, 1, 0, water Pos.y};383 double plane[4] = {0, 1, 0, waterHeight}; 377 384 glClipPlane(GL_CLIP_PLANE0, plane); 378 385 } … … 419 426 glEnable(GL_CLIP_PLANE0); 420 427 Vector pos = State::getCameraNode()->getAbsCoor(); 421 if(pos.y > water Pos.y)428 if(pos.y > waterHeight) 422 429 { 423 double plane[4] = {0, -1, 0, water Pos.y};430 double plane[4] = {0, -1, 0, waterHeight}; 424 431 glClipPlane(GL_CLIP_PLANE0, plane); 425 432 } … … 428 435 { 429 436 glCullFace(GL_FRONT); 430 double plane[4] = {0, 1, 0, -water Pos.y};437 double plane[4] = {0, 1, 0, -waterHeight}; 431 438 glClipPlane(GL_CLIP_PLANE0, plane); 432 439 }
Note: See TracChangeset
for help on using the changeset viewer.