Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8025 in orxonox.OLD


Ignore:
Timestamp:
May 31, 2006, 2:08:04 PM (18 years ago)
Author:
stefalie
Message:

water: activate texture unit…

Location:
branches/water/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/water/src/lib/graphics/importer/material.h

    r7982 r8025  
    3232
    3333    bool select () const;
     34    bool activateTextureUnit(unsigned int textureNumber);
    3435    static void unselect();
    3536
  • branches/water/src/story_entities/game_world.cc

    r8019 r8025  
    514514void GameWorld::renderPassRefraction()
    515515{
     516/*
    516517    // clear buffer
    517518  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
     
    543544      mw->deactivateRefraction();
    544545    }
    545   }
     546  }*/
    546547}
    547548
  • branches/water/src/world_entities/environments/mapped_water.cc

    r8018 r8025  
    9494  /// initialization of the shaders
    9595  // load shader files
    96   shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
     96/*  shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
    9797
    9898  this->shader->activateShader();
     
    114114  cam_uni = new Shader::Uniform(shader, "cameraPos");
    115115
    116   this->shader->deactivateShader();
     116  this->shader->deactivateShader();*/
    117117}
    118118
    119119MappedWater::~MappedWater()
    120120{
    121   delete shader;
    122   delete cam_uni;
     121  //delete shader;
     122  //delete cam_uni;
    123123}
    124124
     
    140140  mat.select();
    141141
    142   this->shader->activateShader();
     142  ///this->shader->activateShader();
    143143
    144144  // reset the camera uniform to the current cam position
    145145  Vector pos = State::getCameraNode()->getAbsCoor();
    146   cam_uni->set(pos.x, pos.y, pos.z, 1.0f);
     146  ///cam_uni->set(pos.x, pos.y, pos.z, 1.0f);
    147147
    148148  glBegin(GL_QUADS);
     
    180180  glEnd();
    181181
    182   this->shader->deactivateShader();
     182  ///this->shader->deactivateShader();
    183183
    184184  mat.unselect();
     
    212212  // In order to line up the reflection nicely with the world we have to translate
    213213  // the world to the position of our reflected surface, multiplied by two.
     214  glEnable(GL_CLIP_PLANE0);
    214215  Vector pos = State::getCameraNode()->getAbsCoor();
    215216  if(pos.y > waterHeight)
     
    224225    // Set our plane equation and turn clipping on
    225226    double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
    226     glEnable(GL_CLIP_PLANE0);
    227227    glClipPlane(GL_CLIP_PLANE0, plane);
    228228  }
     
    232232    // but just render it clipped so only the top is drawn.
    233233    double plane[4] = {0.0, 1.0, 0.0, waterHeight};
    234     glEnable(GL_CLIP_PLANE0);
    235234    glClipPlane(GL_CLIP_PLANE0, plane);
    236235  }
     
    251250
    252251void MappedWater::activateRefraction()
    253 {
     252{/*
     253  // To create the refraction and depth textures we do the same thing
     254  // we did for the reflection texture, except we don't need to turn
     255  // the world upside down.  We want to find the depth of the water,
     256  // not the depth of the sky and above water terrain.
     257
     258  // save viewport matrix and change the viewport size
     259  glPushAttrib(GL_VIEWPORT_BIT);
     260  glViewport(0,0, textureSize, textureSize);
     261
     262  glPushMatrix();
     263
     264  // If our camera is above the water we will render only the parts that
     265  // are under the water.  If the camera is below the water we render
     266  // only the stuff above the water.  Like the reflection texture, we
     267  // incorporate clipping planes to only render what we need.
     268
     269  // If the camera is above water, render the data below the water
     270  glEnable(GL_CLIP_PLANE0);
     271  Vector pos = State::getCameraNode()->getAbsCoor();
     272  if(pos.y > waterHeight)
     273  {
     274    double plane[4] = {0.0, -1.0, 0.0, waterHeight};
     275    glClipPlane(GL_CLIP_PLANE0, plane);
     276  }
     277  // If the camera is below the water, only render the data above the water
     278  else
     279  {
     280    glCullFace(GL_FRONT);
     281    double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
     282    glClipPlane(GL_CLIP_PLANE0, plane);
     283  }*/
    254284}
    255285
    256286void MappedWater::deactivateRefraction()
    257 {
    258 }
     287{/*
     288  glDisable(GL_CLIP_PLANE0);
     289  glCullFace(GL_BACK);
     290
     291  mat.select();
     292  // Bind the current scene to our refraction texture
     293//  glBindTexture(GL_TEXTURE_2D, g_Texture[REFRACTION_ID]);
     294  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
     295
     296  // Bind the current scene to our depth texture
     297//  glBindTexture(GL_TEXTURE_2D, g_Texture[DEPTH_ID]);
     298  glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, textureSize, textureSize, 0);
     299
     300  glPopMatrix();
     301  glPopAttrib();
     302  */
     303}
Note: See TracChangeset for help on using the changeset viewer.