- Timestamp:
- May 20, 2006, 11:42:28 AM (19 years ago)
- Location:
- branches/water/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/water/src/story_entities/game_world.cc
r7692 r7740 490 490 mw->activateReflection(); 491 491 492 //camera and light 493 this->dataTank->localCamera->apply (); 494 this->dataTank->localCamera->project (); 495 LightManager::getInstance()->draw(); 492 496 // draw everything to be included in the reflection 493 497 for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i) -
branches/water/src/world_entities/environments/mapped_water.cc
r7700 r7740 28 28 this->setClassID(CL_MAPPED_WATER, "MappedWater"); 29 29 this->toList(OM_ENVIRON); 30 30 31 31 if (root != NULL) 32 32 this->loadParams(root); 33 33 34 34 35 mat.setDiffuseMap(&this->texture, 0); 36 // Change the view port to be the size of the texture we will render to 37 // HACK 38 this->textureSize = 512; 35 39 } 36 40 37 41 MappedWater::~MappedWater() 38 42 { 39 43 40 44 } 41 45 … … 50 54 void MappedWater::draw() const 51 55 { 52 glPushMatrix(); 53 56 glPushMatrix(); 57 54 58 /* 55 59 glTranslatef (this->getAbsCoor ().x, … … 61 65 //glEnable(GL_LIGHTING); 62 66 63 67 64 68 //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 1); 65 69 //mat.setTransparency(1.0); 66 70 //mat.setDiffuse(1.0, 0, .1); 67 68 71 72 69 73 // HACK 70 74 … … 106 110 void MappedWater::activateReflection() 107 111 { 108 // Change the view port to be the size of the texture we will render to109 // HACK110 int textureSize = 512;111 112 glPushAttrib(GL_VIEWPORT_BIT); 113 glPushMatrix(); 114 112 115 glViewport(0,0, textureSize, textureSize); 113 116 114 117 // Clear the color and depth bits, reset the matrix and position our camera. 115 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);116 //glLoadIdentity();118 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 119 glLoadIdentity(); 117 120 //g_Camera.Look(); 118 121 119 // So we don't affect any other objects in the world we push on a new matrix120 //glPushMatrix();121 122 122 123 // If our camera is above the water we will render the scene flipped upside down. … … 164 165 // Bind the current scene to our reflection texture 165 166 //glBindTexture(GL_TEXTURE_2D, g_Texture[REFLECTION_ID]); 166 167 168 169 glBindTexture(GL_TEXTURE_2D, texture.getTexture()); 170 // ; 171 // mat.setDiffuseMap(&texture, 0); 172 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); 173 174 glPopAttrib(); 167 168 169 170 175 171 } 176 172 177 173 void MappedWater::deactivateReflection() 178 174 { 175 glBindTexture(GL_TEXTURE_2D, texture.getTexture()); 179 176 177 mat.setDiffuseMap(&texture, 0); 178 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); 179 180 glPopAttrib(); 181 glPopMatrix(); 180 182 } 181 183 -
branches/water/src/world_entities/environments/mapped_water.h
r7700 r7740 23 23 void activateReflection(); 24 24 void deactivateReflection(); 25 25 26 26 void activateRefraction(); 27 27 void deactivateRefraction(); 28 28 29 29 void draw() const; 30 30 void tick(float dt); … … 36 36 float waterHeight; //!< y-coord of the Water 37 37 Material mat; 38 38 39 39 Texture texture; 40 int textureSize; //!< size of the texture 40 41 41 42 };
Note: See TracChangeset
for help on using the changeset viewer.