Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8018 in orxonox.OLD


Ignore:
Timestamp:
May 31, 2006, 12:25:16 PM (18 years ago)
Author:
stefalie
Message:

branches/water: under/over water?

File:
1 edited

Legend:

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

    r7993 r8018  
    203203void MappedWater::activateReflection()
    204204{
     205  // save viewport matrix and change the viewport size
    205206  glPushAttrib(GL_VIEWPORT_BIT);
    206 
    207 
    208   //glLoadIdentity();
    209207  glViewport(0,0, textureSize, textureSize);
    210208
    211209  glPushMatrix();
    212   // Clear the color and depth bits, reset the matrix and position our camera.
    213 
    214   //g_Camera.Look();
    215 
    216210
    217211  // If our camera is above the water we will render the scene flipped upside down.
    218212  // In order to line up the reflection nicely with the world we have to translate
    219213  // the world to the position of our reflected surface, multiplied by two.
    220   //if(g_Camera.Position().y > waterHeight)
    221   //{
    222   // Translate the world, then flip it upside down
    223   glTranslatef(0.0f, this->waterHeight*2.0f, 0.0f);
    224   glScalef(1.0, -1.0, 1.0);
    225 
    226   // Since the world is updside down we need to change the culling to FRONT
    227   //glCullFace(GL_FRONT);
    228 
    229   // Set our plane equation and turn clipping on
    230   //double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
    231   //glEnable(GL_CLIP_PLANE0);
    232   //glClipPlane(GL_CLIP_PLANE0, plane);
    233 
    234   // Render the world upside down and clipped (only render the top flipped).
    235   // If we don't turn OFF caustics for the reflection texture we get horrible
    236   // artifacts in the water.  That is why we set bRenderCaustics to FALSE.
    237   //RenderWorld(false);
    238 
    239   // Turn clipping off
    240   // glDisable(GL_CLIP_PLANE0);
    241 
    242   // Restore back-face culling
    243   //  glCullFace(GL_BACK);
    244   //}
    245   /*else
     214  Vector pos = State::getCameraNode()->getAbsCoor();
     215  if(pos.y > waterHeight)
    246216  {
    247       // If the camera is below the water we don't want to flip the world,
    248       // but just render it clipped so only the top is drawn.
    249       double plane[4] = {0.0, 1.0, 0.0, waterHeight};
    250       glEnable(GL_CLIP_PLANE0);
    251       glClipPlane(GL_CLIP_PLANE0, plane);
    252       RenderWorld(true);
    253       glDisable(GL_CLIP_PLANE0);
    254   }*/
     217    // Translate the world, then flip it upside down
     218    glTranslatef(0.0f, waterHeight*2.0f, 0.0f);
     219    glScalef(1.0, -1.0, 1.0);
     220
     221    // Since the world is updside down we need to change the culling to FRONT
     222    glCullFace(GL_FRONT);
     223
     224    // Set our plane equation and turn clipping on
     225    double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
     226    glEnable(GL_CLIP_PLANE0);
     227    glClipPlane(GL_CLIP_PLANE0, plane);
     228  }
     229  else
     230  {
     231    // If the camera is below the water we don't want to flip the world,
     232    // but just render it clipped so only the top is drawn.
     233    double plane[4] = {0.0, 1.0, 0.0, waterHeight};
     234    glEnable(GL_CLIP_PLANE0);
     235    glClipPlane(GL_CLIP_PLANE0, plane);
     236  }
    255237}
    256238
     
    258240void MappedWater::deactivateReflection()
    259241{
    260 //  glBindTexture(GL_TEXTURE_2D, texture.getTexture()); //is done by mat.select();
    261   //glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
    262 
    263   //mat.setDiffuseMap(&texture, 0);
     242  glDisable(GL_CLIP_PLANE0);
     243  glCullFace(GL_BACK);
    264244
    265245  mat.select();
    266246  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
    267   //glDisable(GL_CLIP_PLANE0);
    268247
    269248  glPopMatrix();
    270 
    271249  glPopAttrib();
    272250}
Note: See TracChangeset for help on using the changeset viewer.