Changeset 7983 in orxonox.OLD for branches/water/src/world_entities/environments
- Timestamp:
- May 30, 2006, 4:48:20 PM (18 years ago)
- Location:
- branches/water/src/world_entities/environments
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/water/src/world_entities/environments/mapped_water.cc
r7982 r7983 43 43 mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2); 44 44 // load dudv map 45 mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3);45 mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3); 46 46 // set up depth texture 47 mat.setDiffuseMap("pictures/sky-replace.jpg", 4);47 // mat.setDiffuseMap("pictures/sky-replace.jpg", 4); 48 48 49 49 // set the size of the refraction and reflection textures … … 58 58 unsigned int* pTextureReflection = new unsigned int [this->textureSize * this->textureSize * channels]; 59 59 memset(pTextureReflection, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int)); 60 unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels];61 memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));60 // unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels]; 61 // memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int)); 62 62 // Register the texture with OpenGL and bind it to the texture ID 63 63 mat.select(); … … 70 70 71 71 //the same for the refraction 72 glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1));73 glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureRefraction);72 // glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1)); 73 // glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureRefraction); 74 74 75 75 // Set the texture quality … … 81 81 // Since we stored the texture space with OpenGL, we can delete the image data 82 82 delete [] pTextureReflection; 83 delete [] pTextureRefraction;83 // delete [] pTextureRefraction; 84 84 85 85 … … 91 91 this->kNormalMapScale = 0.25f; 92 92 this->g_WaterFlow = 0.0015f; 93 94 /// Initialization of the shaders 95 this->shader->activateShader(); 96 // Set the variable "reflection" to correspond to the first texture unit 97 Shader::Uniform(shader, "reflection").set(0); 98 99 // Set the variable "refraction" to correspond to the second texture unit 100 //this->uni = new Shader::Uniform (shader, "refraction"); 101 //this->uni->set(1); 102 103 // Set the variable "normalMap" to correspond to the third texture unit 104 Shader::Uniform(shader, "normalMap").set(2); 105 106 // Set the variable "dudvMap" to correspond to the fourth texture unit 107 Shader::Uniform(shader, "dudvMap").set(3); 108 109 // Set the variable "depthMap" to correspond to the fifth texture unit 110 //this->uni = new Shader::Uniform (shader, "depthMap"); 111 //this->uni->set(4); 112 this->shader->activateShader(); 93 113 } 94 114 … … 111 131 glTranslatef(0,this->waterHeight,0); 112 132 113 //HACK114 115 //glEnable(GL_LIGHTING);116 117 118 //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 1);119 //mat.setTransparency(1.0);120 //mat.setDiffuse(1.0, 0, .1);121 122 123 // HACK124 125 //glActiveTexture(GL_TEXTURE0);126 //glBindTexture(GL_TEXTURE_2D, this->texture);127 133 mat.unselect(); 128 134 mat.select(); 129 //glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0)); 135 130 136 131 137 … … 133 139 this->shader->activateShader(); 134 140 GLint uniform; 135 Shader::Uniform* uni; 136 137 // Set the variable "reflection" to correspond to the first texture unit 138 uni = new Shader::Uniform (shader, "reflection"); 139 uni->set(0); 140 //uniform = glGetUniformLocationARB(shader->getProgram(), "reflection"); 141 //glUniform1iARB(uniform, 0); //second paramter is the texture unit 142 143 // Set the variable "refraction" to correspond to the second texture unit 144 // uni = new Shader::Uniform (shader, "refraction"); 145 // uni->set(1); 146 //uniform = glGetUniformLocationARB(shader->getProgram(), "refraction"); 147 //glUniform1iARB(uniform, 1); 148 149 // Set the variable "normalMap" to correspond to the third texture unit 150 uni = new Shader::Uniform (shader, "normalMap"); 151 uni->set(2); 152 //uniform = glGetUniformLocationARB(shader->getProgram(), "normalMap"); 153 //glUniform1iARB(uniform, 2); 154 155 // Set the variable "dudvMap" to correspond to the fourth texture unit 156 uni = new Shader::Uniform (shader, "dudvMap"); 157 uni->set(3); 158 //uniform = glGetUniformLocationARB(shader->getProgram(), "dudvMap"); 159 //glUniform1iARB(uniform, 3); 160 161 // Set the variable "depthMap" to correspond to the fifth texture unit 162 // uni = new Shader::Uniform (shader, "depthMap"); 163 // uni->set(4); 164 //uniform = glGetUniformLocationARB(shader->getProgram(), "depthMap"); 165 //glUniform1iARB(uniform, 4); 166 // FIXME we dont have a depthMap yet :-( 141 142 143 144 167 145 168 146 // Give the variable "waterColor" a blue color … … 192 170 glBegin(GL_QUADS); 193 171 // The back left vertice for the water 194 glMultiTexCoord2f ARB(GL_TEXTURE0_ARB, 0.0f, g_WaterUV); // Reflection texture195 glMultiTexCoord2f ARB(GL_TEXTURE1_ARB, 0.0f, refrUV - move); // Refraction texture196 glMultiTexCoord2f ARB(GL_TEXTURE2_ARB, 0.0f, normalUV + move2); // Normal map texture197 glMultiTexCoord2f ARB(GL_TEXTURE3_ARB, 0, 0); // DUDV map texture198 glMultiTexCoord2f ARB(GL_TEXTURE4_ARB, 0, 0); // Depth texture172 glMultiTexCoord2f(GL_TEXTURE0, 0.0f, g_WaterUV); // Reflection texture 173 glMultiTexCoord2f(GL_TEXTURE1, 0.0f, refrUV - move); // Refraction texture 174 glMultiTexCoord2f(GL_TEXTURE2, 0.0f, normalUV + move2); // Normal map texture 175 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 176 glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture 199 177 glVertex3f(0.0f, waterHeight, 0.0f); 200 178 201 179 // The front left vertice for the water 202 glMultiTexCoord2f ARB(GL_TEXTURE0_ARB, 0.0f, 0.0f); // Reflection texture203 glMultiTexCoord2f ARB(GL_TEXTURE1_ARB, 0.0f, 0.0f - move); // Refraction texture204 glMultiTexCoord2f ARB(GL_TEXTURE2_ARB, 0.0f, 0.0f + move2); // Normal map texture205 glMultiTexCoord2f ARB(GL_TEXTURE3_ARB, 0, 0); // DUDV map texture206 glMultiTexCoord2f ARB(GL_TEXTURE4_ARB, 0, 0); // Depth texture180 glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); // Reflection texture 181 glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f - move); // Refraction texture 182 glMultiTexCoord2f(GL_TEXTURE2, 0.0f, 0.0f + move2); // Normal map texture 183 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 184 glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture 207 185 glVertex3f(0.0f, waterHeight, 1000.0f); 208 186 209 187 // The front right vertice for the water 210 glMultiTexCoord2f ARB(GL_TEXTURE0_ARB, g_WaterUV, 0.0f); // Reflection texture211 glMultiTexCoord2f ARB(GL_TEXTURE1_ARB, refrUV, 0.0f - move); // Refraction texture212 glMultiTexCoord2f ARB(GL_TEXTURE2_ARB, normalUV, 0.0f + move2); // Normal map texture213 glMultiTexCoord2f ARB(GL_TEXTURE3_ARB, 0, 0); // DUDV map texture214 glMultiTexCoord2f ARB(GL_TEXTURE4_ARB, 0, 0); // Depth texture188 glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, 0.0f); // Reflection texture 189 glMultiTexCoord2f(GL_TEXTURE1, refrUV, 0.0f - move); // Refraction texture 190 glMultiTexCoord2f(GL_TEXTURE2, normalUV, 0.0f + move2); // Normal map texture 191 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 192 glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture 215 193 glVertex3f(1000.0f, waterHeight, 1000.0f); 216 194 217 195 // The back right vertice for the water 218 glMultiTexCoord2f ARB(GL_TEXTURE0_ARB, g_WaterUV, g_WaterUV); // Reflection texture219 glMultiTexCoord2f ARB(GL_TEXTURE1_ARB, refrUV, refrUV - move); // Refraction texture220 glMultiTexCoord2f ARB(GL_TEXTURE2_ARB, normalUV, normalUV + move2); // Normal map texture221 glMultiTexCoord2f ARB(GL_TEXTURE3_ARB, 0, 0); // DUDV map texture222 glMultiTexCoord2f ARB(GL_TEXTURE4_ARB, 0, 0); // Depth texture196 glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, g_WaterUV); // Reflection texture 197 glMultiTexCoord2f(GL_TEXTURE1, refrUV, refrUV - move); // Refraction texture 198 glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2); // Normal map texture 199 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 200 glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture 223 201 glVertex3f(1000.0f, waterHeight, 0.0f); 224 202 glEnd(); … … 226 204 this->shader->deactivateShader(); 227 205 228 229 Material::unselect(); 206 mat.unselect(); 230 207 231 208 glPopMatrix(); … … 234 211 void MappedWater::tick(float dt) 235 212 { 236 this->move += this->g_WaterFlow = 0.004; 213 // makes the water flow 214 this->move += this->g_WaterFlow; 237 215 this->move2 = this->move * this->kNormalMapScale; 238 216 this->refrUV = this->g_WaterUV; … … 248 226 { 249 227 glPushAttrib(GL_VIEWPORT_BIT); 250 228 251 229 252 230 //glLoadIdentity(); … … 269 247 270 248 // Since the world is updside down we need to change the culling to FRONT 271 glCullFace(GL_FRONT);249 //glCullFace(GL_FRONT); 272 250 273 251 // Set our plane equation and turn clipping on 274 double plane[4] = {0.0, 1.0, 0.0, -waterHeight};252 //double plane[4] = {0.0, 1.0, 0.0, -waterHeight}; 275 253 //glEnable(GL_CLIP_PLANE0); 276 254 //glClipPlane(GL_CLIP_PLANE0, plane); … … 306 284 307 285 //mat.setDiffuseMap(&texture, 0); 286 308 287 mat.select(); 309 288 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); -
branches/water/src/world_entities/environments/mapped_water.h
r7982 r7983 10 10 #include "world_entity.h" 11 11 #include "material.h" 12 #include "texture.h"13 12 #include "shader.h" 14 13 … … 34 33 35 34 private: 36 float waterHeight; //!< y-coord of the Water 37 Material mat; 38 float move; 39 float g_WaterUV; //!< The scale for the water textures 40 float kNormalMapScale; 41 float g_WaterFlow; 42 float move2; 43 float refrUV; 44 float normalUV; 35 float waterHeight; //!< y-coord of the Water 45 36 46 int textureSize; //!< size of the texture 47 Shader* shader; 37 float move; //!< textures coords, speeds, positions for the shaded textures.... 38 float move2; //!< 39 float g_WaterUV; //!< 40 float g_WaterFlow; //!< 41 float refrUV; //!< 42 float normalUV; //!< 43 float kNormalMapScale; //!< 44 45 int textureSize; //!< size of the texture 46 Material mat; 47 Shader* shader; 48 Shader::Uniform* uni; 48 49 49 50 };
Note: See TracChangeset
for help on using the changeset viewer.