Changeset 8025 in orxonox.OLD for branches/water/src/world_entities
- Timestamp:
- May 31, 2006, 2:08:04 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/water/src/world_entities/environments/mapped_water.cc
r8018 r8025 94 94 /// initialization of the shaders 95 95 // 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"); 97 97 98 98 this->shader->activateShader(); … … 114 114 cam_uni = new Shader::Uniform(shader, "cameraPos"); 115 115 116 this->shader->deactivateShader(); 116 this->shader->deactivateShader();*/ 117 117 } 118 118 119 119 MappedWater::~MappedWater() 120 120 { 121 delete shader;122 delete cam_uni;121 //delete shader; 122 //delete cam_uni; 123 123 } 124 124 … … 140 140 mat.select(); 141 141 142 this->shader->activateShader();142 ///this->shader->activateShader(); 143 143 144 144 // reset the camera uniform to the current cam position 145 145 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); 147 147 148 148 glBegin(GL_QUADS); … … 180 180 glEnd(); 181 181 182 this->shader->deactivateShader();182 ///this->shader->deactivateShader(); 183 183 184 184 mat.unselect(); … … 212 212 // In order to line up the reflection nicely with the world we have to translate 213 213 // the world to the position of our reflected surface, multiplied by two. 214 glEnable(GL_CLIP_PLANE0); 214 215 Vector pos = State::getCameraNode()->getAbsCoor(); 215 216 if(pos.y > waterHeight) … … 224 225 // Set our plane equation and turn clipping on 225 226 double plane[4] = {0.0, 1.0, 0.0, -waterHeight}; 226 glEnable(GL_CLIP_PLANE0);227 227 glClipPlane(GL_CLIP_PLANE0, plane); 228 228 } … … 232 232 // but just render it clipped so only the top is drawn. 233 233 double plane[4] = {0.0, 1.0, 0.0, waterHeight}; 234 glEnable(GL_CLIP_PLANE0);235 234 glClipPlane(GL_CLIP_PLANE0, plane); 236 235 } … … 251 250 252 251 void 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 }*/ 254 284 } 255 285 256 286 void 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.