Changeset 7986 in orxonox.OLD for branches/water/src/world_entities/environments
- Timestamp:
- May 30, 2006, 6:32:51 PM (19 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
r7983 r7986 34 34 this->loadParams(root); 35 35 36 //! todo: rename texture to reflection texture 36 PRINTF(0)("MaxTextureUnits: %i\n", Material::getMaxTextureUnits()); 37 38 // TODO rename texture to reflection texture 39 /// loads the textures 37 40 // set up refleciton texture 38 41 // FIXME mat.setDiffuseMap(this->texture, 0); doesnt work, 39 42 mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 0); 40 43 // load refraction texture 41 // mat.setDiffuseMap("pictures/sky-replace.jpg", 1);44 mat.setDiffuseMap("pictures/error_texture.png", GL_TEXTURE_2D, 1); 42 45 // load normal map 43 46 mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2); 44 47 // load dudv map 45 48 mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3); 46 49 // set up depth texture 47 // mat.setDiffuseMap("pictures/sky-replace.jpg", 4); 48 50 //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 2); 51 52 53 54 /// MAKE THE MAPPING TEXTURE. 55 // THIS IS A HACK AND SHOULD BE IN TEXTURE SOMEWHERE 49 56 // set the size of the refraction and reflection textures 50 51 52 53 /// MAKE THE MAPPING TEXTURE.54 // THIS IS A HACK AND SHOULD BE IN TEXTURE SOMEWHERE.55 57 this->textureSize = 512; 56 58 unsigned int channels = 32; … … 58 60 unsigned int* pTextureReflection = new unsigned int [this->textureSize * this->textureSize * channels]; 59 61 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));62 unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels]; 63 memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int)); 62 64 // Register the texture with OpenGL and bind it to the texture ID 63 65 mat.select(); … … 70 72 71 73 //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);74 glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1)); 75 glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureRefraction); 74 76 75 77 // Set the texture quality … … 81 83 // Since we stored the texture space with OpenGL, we can delete the image data 82 84 delete [] pTextureReflection; 83 // delete [] pTextureRefraction; 84 85 86 //shader = new Shader( "/home/stefalie/svn/orxonox/data/trunk/shaders/water.vert", "/home/stefalie/svn/orxonox/data/trunk/shaders/mapped_water.frag"); 87 shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag"); 88 85 delete [] pTextureRefraction; 86 87 88 /// initialization of the texture coords, speeds etc... 89 89 this->move = 0.0f; 90 90 this->g_WaterUV = 35.0f; … … 92 92 this->g_WaterFlow = 0.0015f; 93 93 94 /// Initialization of the shaders 94 /// initialization of the shaders 95 // load shader files 96 shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag"); 97 95 98 this->shader->activateShader(); 96 99 // Set the variable "reflection" to correspond to the first texture unit 97 100 Shader::Uniform(shader, "reflection").set(0); 98 99 101 // 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 102 Shader::Uniform(shader, "refraction").set(1); 103 103 // Set the variable "normalMap" to correspond to the third texture unit 104 104 Shader::Uniform(shader, "normalMap").set(2); 105 106 105 // Set the variable "dudvMap" to correspond to the fourth texture unit 107 106 Shader::Uniform(shader, "dudvMap").set(3); 108 109 107 // 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(); 108 //Shader::Uniform(shader, "depthMap").set(4); 109 // Give the variable "waterColor" a blue color 110 Shader::Uniform(shader, "waterColor").set(0.1f, 0.2f, 0.4f, 1.0f); 111 // Give the variable "lightPos" our hard coded light position 112 Shader::Uniform(shader, "lightPos").set(lightPos.x, lightPos.y, lightPos.z, 1.0f); 113 // uniform for the camera position 114 cam_uni = new Shader::Uniform(shader, "cameraPos"); 115 116 this->shader->deactivateShader(); 113 117 } 114 118 115 119 MappedWater::~MappedWater() 116 120 { 117 //delete shader; 121 delete shader; 122 delete cam_uni; 118 123 } 119 124 … … 123 128 124 129 LoadParam(root, "waterHeight", this, MappedWater, setHeight); 130 LoadParam(root, "lightPos", this, MappedWater, setLightPosition); 125 131 } 126 132 … … 134 140 mat.select(); 135 141 136 137 138 // Shader init139 142 this->shader->activateShader(); 140 GLint uniform; 141 142 143 144 145 146 // Give the variable "waterColor" a blue color 147 uniform = glGetUniformLocationARB(shader->getProgram(), "waterColor"); 148 glUniform4fARB(uniform, 0.1f, 0.2f, 0.4f, 1.0f); 149 150 // FIXME set camera and light information 151 Vector lightPos(100.0f, 600.0f, 100.0f); 152 Vector vPosition = State::getCameraNode()->getAbsCoor(); 153 // Store the camera position in a variable 154 //CVector3 vPosition = g_Camera.Position(); 155 //Vector vPosition(50.0f, 50.0f, 50.0f); 156 157 // Give the variable "lightPos" our hard coded light position 158 uniform = glGetUniformLocationARB(shader->getProgram(), "lightPos"); 159 glUniform4fARB(uniform, lightPos.x, lightPos.y, lightPos.z, 1.0f); 160 161 // Give the variable "cameraPos" our camera position 162 uniform = glGetUniformLocationARB(shader->getProgram(), "cameraPos"); 163 glUniform4fARB(uniform, vPosition.x, vPosition.y, vPosition.z, 1.0f); 164 165 166 167 168 143 144 // reset the camera uniform to the current cam position 145 Vector pos = State::getCameraNode()->getAbsCoor(); 146 cam_uni->set(pos.x, pos.y, pos.z, 1.0f); 169 147 170 148 glBegin(GL_QUADS); -
branches/water/src/world_entities/environments/mapped_water.h
r7983 r7986 20 20 void loadParams(const TiXmlElement* root); 21 21 22 22 23 void activateReflection(); 23 24 void deactivateReflection(); … … 30 31 31 32 private: 33 void setLightPosition(float x, float y, float z) { this->lightPos = Vector(x,y,z); }; 32 34 void setHeight(float height); 33 35 … … 44 46 45 47 int textureSize; //!< size of the texture 48 Vector lightPos; 46 49 Material mat; 47 50 Shader* shader; 48 Shader::Uniform* uni;51 Shader::Uniform* cam_uni; //!< uniform that is used for the camera position 49 52 50 53 };
Note: See TracChangeset
for help on using the changeset viewer.