- Timestamp:
- Jun 22, 2006, 2:13:18 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/menu/game_menu.cc
r8717 r8719 178 178 image->setWidgetSize( 250, 200); 179 179 image->setAbsCoor2D(400, 150); 180 image->setForegroundColor(Color( 1,1,1,.6));180 image->setForegroundColor(Color( 1,1,1,.6)); 181 181 182 182 const std::list<BaseObject*>* storyEntities = ClassList::getList(CL_STORY_ENTITY); -
trunk/src/world_entities/environments/mapped_water.cc
r8619 r8719 21 21 22 22 23 24 25 23 CREATE_FACTORY(MappedWater, CL_MAPPED_WATER); 26 24 27 25 /** 26 * @brief constructor 27 * @param root xml data 28 */ 28 29 MappedWater::MappedWater(const TiXmlElement* root) 29 30 { … … 31 32 this->toList(OM_ENVIRON); 32 33 34 /// sets start values and parameters 35 this->initParams(); 36 // now the standard values were loaded, if the values are specified in the .oxw file 37 // loadParams will overwrite the standard values with the specified values 33 38 if (root != NULL) 34 39 this->loadParams(root); 35 40 36 PRINTF(0)("MaxTextureUnits: %i\n", Material::getMaxTextureUnits()); 37 38 // TODO rename texture to reflection texture 39 /// loads the textures 41 /// initialization of the textures 42 this->initTextures(); 43 44 /// initialization of the shaders 45 this->initShaders(); 46 } 47 48 /** 49 * @brief deltes shader and the uniform used by the camera 50 */ 51 MappedWater::~MappedWater() 52 { 53 delete shader; 54 delete cam_uni; 55 } 56 57 /** 58 * @brief initialization of loadable parameters, sets start standard values 59 */ 60 void MappedWater::initParams() 61 { 62 // those standardvalues will be overwritten if they're also set in the oxw file 63 this->setWaterPos(0, 0, 0); 64 this->setWaterSize(100, 100); 65 this->setWaterUV(9); 66 this->setWaterFlow(0.08); 67 this->setLightPos(0, 10, 0); 68 this->setWaterAngle(0); 69 this->setNormalMapScale(0.25f); 70 71 // initialization of the texture coords, speeds etc... 72 // normalUV wont change anymore 73 this->normalUV = this->waterUV * this->kNormalMapScale; 74 // move and move2 are used for the reflection and refraction, the values are changed in tick() 75 this->move = 0; 76 this->move2 = this->move * this->kNormalMapScale; 77 } 78 79 /** 80 * @brief initialization of the textures 81 */ 82 void MappedWater::initTextures() 83 { 84 // sets parameters for the textures 85 this->textureSize = 512; 86 unsigned int channels = 32; 87 GLenum type = GL_RGBA; 88 40 89 // set up refleciton texture 41 //mat.setDiffuseMap(this->texture, 0); 42 mat.setDiffuseMap("pictures/refl.bmp", GL_TEXTURE_2D, 0); 43 // load refraction texture 44 mat.setDiffuseMap("pictures/refr.bmp", GL_TEXTURE_2D, 1); 90 Texture reflTex(GL_TEXTURE_2D, this->textureSize, this->textureSize, channels, type); 91 mat.setDiffuseMap(reflTex, 0); 92 // set up refraction texture 93 Texture refrTex(GL_TEXTURE_2D, this->textureSize, this->textureSize, channels, type); 94 mat.setDiffuseMap(refrTex, 1); 45 95 // load normal map 46 96 mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2); 47 97 // load dudv map 48 98 mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3); 49 // set up depth texture 50 //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 4); 51 52 53 54 /// MAKE THE MAPPING TEXTURE. 55 // THIS IS A HACK AND SHOULD BE IN TEXTURE SOMEWHERE 56 // set the size of the refraction and reflection textures 57 this->textureSize = 512; 58 //unsigned int channels = 32; 59 //GLenum type = GL_RGBA; 60 //unsigned int* pTextureReflection = new unsigned int [this->textureSize * this->textureSize * channels]; 61 //memset(pTextureReflection, 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)); 64 // Register the texture with OpenGL and bind it to the texture ID 65 //mat.select(); 66 //glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0)); 67 68 // Create the texture and store it on the video card 69 //glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureReflection); 70 71 //gluBuild2DMipmaps(GL_TEXTURE_2D, channels, this->textureSize, this->textureSize, type, GL_UNSIGNED_INT, pTexture); 72 73 //the same for the refraction 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); 76 77 unsigned int channels = 32; 78 GLenum type = GL_RGBA; 79 unsigned int* pTextureReflection = new unsigned int [this->textureSize * this->textureSize * channels]; 80 memset(pTextureReflection, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int)); 81 //mat.select(); 99 100 // sets texture parameters for reflection texture 82 101 glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(0)); 83 102 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); … … 85 104 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 86 105 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 87 glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureReflection); 88 89 90 unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels]; 91 memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int)); 106 // sets texture parameters for refraction texture 92 107 glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(1)); 93 108 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); … … 95 110 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 96 111 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 97 glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureRefraction); 98 99 // Set the texture quality 100 101 102 // Since we stored the texture space with OpenGL, we can delete the image data 103 //delete [] pTextureReflection; 104 //delete [] pTextureRefraction; 105 106 107 /// initialization of the texture coords, speeds etc... 108 this->move = 0.0f; 109 this->g_WaterUV = 35.0f; 110 this->kNormalMapScale = 0.25f; 111 this->g_WaterFlow = 0.0015f; 112 113 /// initialization of the shaders 112 } 113 114 /** 115 * @brief initialization of the shaders 116 */ 117 void MappedWater::initShaders() 118 { 114 119 // load shader files 115 120 shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag"); … … 136 141 } 137 142 138 MappedWater::~MappedWater() 139 { 140 //delete shader; 141 //delete cam_uni; 142 } 143 143 /** 144 * @brief ends the refraction and saves the graphic buffer into a texture 145 * @param root xml data 146 */ 144 147 void MappedWater::loadParams(const TiXmlElement* root) 145 148 { 146 149 WorldEntity::loadParams(root); 147 150 148 LoadParam(root, "waterHeight", this, MappedWater, setHeight); 149 LoadParam(root, "lightPos", this, MappedWater, setLightPosition); 150 } 151 152 151 LoadParam(root, "waterpos", this, MappedWater, setWaterPos); 152 LoadParam(root, "watersize", this, MappedWater, setWaterSize); 153 LoadParam(root, "lightpos", this, MappedWater, setLightPos); 154 LoadParam(root, "wateruv", this, MappedWater, setWaterUV); 155 LoadParam(root, "waterflow", this, MappedWater, setWaterFlow); 156 LoadParam(root, "normalmapscale", this, MappedWater, setNormalMapScale); 157 LoadParam(root, "waterangle", this, MappedWater, setWaterAngle); 158 } 159 160 /** 161 * @brief activates the water shader and draws a quad with four textures on it 162 */ 153 163 void MappedWater::draw() const 154 164 { … … 156 166 157 167 glPushMatrix(); 158 glTranslatef(0,this->waterHeight,0);159 160 mat.unselect(); 168 // don't use a glTranslate here, the reflection point won't be at the right place anymore 169 glRotatef(this->waterAngle, 0, 1, 0); 170 161 171 mat.select(); 162 172 … … 167 177 cam_uni->set(pos.x, pos.y, pos.z, 1.0f); 168 178 169 //glDisable(GL_BLEND);179 glDisable(GL_BLEND); 170 180 171 181 glBegin(GL_QUADS); 172 182 // The back left vertice for the water 173 // glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0);//g_WaterUV); // Reflection texture 174 // glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0);//refrUV - move); // Refraction texture 175 glMultiTexCoord2f(GL_TEXTURE0, 0.0f, g_WaterUV); // Reflection texture 176 glMultiTexCoord2f(GL_TEXTURE1, 0.0f, refrUV - move); // Refraction texture 177 glMultiTexCoord2f(GL_TEXTURE2, 0.0f, normalUV + move2); // Normal map texture 183 glMultiTexCoord2f(GL_TEXTURE0, 0, waterUV); // Reflection texture 184 glMultiTexCoord2f(GL_TEXTURE1, 0, waterUV - move); // Refraction texture 185 glMultiTexCoord2f(GL_TEXTURE2, 0, normalUV + move2); // Normal map texture 178 186 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 179 //glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture 180 glVertex3f(0.0f, waterHeight, 0.0f); 187 glVertex3f(this->waterPos.x, this->waterPos.y, this->waterPos.z); 181 188 182 189 // The front left vertice for the water 183 // glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 1);//0.0f); // Reflection texture 184 // glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1);//0.0f - move); // Refraction texture 185 glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); // Reflection texture 186 glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f - move); // Refraction texture 187 glMultiTexCoord2f(GL_TEXTURE2, 0.0f, 0.0f + move2); // Normal map texture 190 glMultiTexCoord2f(GL_TEXTURE0, 0, 0); // Reflection texture 191 glMultiTexCoord2f(GL_TEXTURE1, 0, -move); // Refraction texture 192 glMultiTexCoord2f(GL_TEXTURE2, 0, move2); // Normal map texture 188 193 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 189 //glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture 190 glVertex3f(0.0f, waterHeight, 1000.0f); 194 glVertex3f(this->waterPos.x, this->waterPos.y, this->waterPos.z + this->zWidth); 191 195 192 196 // The front right vertice for the water 193 // glMultiTexCoord2f(GL_TEXTURE0, 1,1); //g_WaterUV, 0.0f); // Reflection texture 194 // glMultiTexCoord2f(GL_TEXTURE1, 1,1);//refrUV, 0.0f - move); // Refraction texture 195 glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, 0.0f); // Reflection texture 196 glMultiTexCoord2f(GL_TEXTURE1, refrUV, 0.0f - move); // Refraction texture 197 glMultiTexCoord2f(GL_TEXTURE2, normalUV, 0.0f + move2); // Normal map texture 197 glMultiTexCoord2f(GL_TEXTURE0, waterUV, 0); // Reflection texture 198 glMultiTexCoord2f(GL_TEXTURE1, waterUV, -move); // Refraction texture 199 glMultiTexCoord2f(GL_TEXTURE2, normalUV, move2); // Normal map texture 198 200 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 199 //glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture 200 glVertex3f(1000.0f, waterHeight, 1000.0f); 201 glVertex3f(this->waterPos.x + this->xWidth, this->waterPos.y, this->waterPos.z + this->zWidth); 201 202 202 203 // The back right vertice for the water 203 // glMultiTexCoord2f(GL_TEXTURE0, 1,0);//g_WaterUV, g_WaterUV); // Reflection texture 204 // glMultiTexCoord2f(GL_TEXTURE1, 1,0);//refrUV, refrUV - move); // Refraction texture 205 glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, g_WaterUV); // Reflection texture 206 glMultiTexCoord2f(GL_TEXTURE1, refrUV, refrUV - move); // Refraction texture 204 glMultiTexCoord2f(GL_TEXTURE0, waterUV, waterUV); // Reflection texture 205 glMultiTexCoord2f(GL_TEXTURE1, waterUV, waterUV - move); // Refraction texture 207 206 glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2); // Normal map texture 208 207 glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture 209 //glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture 210 glVertex3f(1000.0f, waterHeight, 0.0f); 208 glVertex3f(this->waterPos.x + this->xWidth, this->waterPos.y, this->waterPos.z); 211 209 glEnd(); 212 210 … … 218 216 } 219 217 218 /** 219 * @brief tick tack, calculates the flow of the water 220 */ 220 221 void MappedWater::tick(float dt) 221 222 { 222 223 // makes the water flow 223 this->move += this-> g_WaterFlow;224 this->move += this->waterFlow * dt; 224 225 this->move2 = this->move * this->kNormalMapScale; 225 this->refrUV = this->g_WaterUV; 226 this->normalUV = this->g_WaterUV * this->kNormalMapScale; 227 } 228 229 void MappedWater::setHeight(float height) 230 { 231 this->waterHeight = height; 232 } 233 226 } 227 228 /** 229 * @brief prepares everything to render the reflection texutre 230 */ 234 231 void MappedWater::activateReflection() 235 232 { 233 // To create the reflection texture we just need to set the view port 234 // to our texture map size, then render the current scene our camera 235 // is looking at to the already allocated texture unit. Since this 236 // is a reflection of the top of the water surface we use clipping 237 // planes to only render the top of the world as a reflection. If 238 // we are below the water we don't flip the reflection but just use 239 // the current view of the top as we are seeing through the water. 240 // When you look through water at the surface it isn't really reflected, 241 // only when looking down from above the water on the surface. 242 236 243 // save viewport matrix and change the viewport size 237 244 glPushAttrib(GL_VIEWPORT_BIT); … … 246 253 glEnable(GL_CLIP_PLANE0); 247 254 Vector pos = State::getCameraNode()->getAbsCoor(); 248 //pos.debug(); 249 //PRINTF(0)("waterheight: %f\n", waterHeight); 250 if(pos.y > waterHeight) 255 256 if(pos.y > waterPos.y) 251 257 { 252 258 // Translate the world, then flip it upside down 253 glTranslatef(0 .0f, waterHeight*2.0f, 0.0f);254 glScalef(1 .0, -1.0, 1.0);259 glTranslatef(0, waterPos.y*2, 0); 260 glScalef(1, -1, 1); 255 261 256 262 // Since the world is updside down we need to change the culling to FRONT … … 258 264 259 265 // Set our plane equation and turn clipping on 260 double plane[4] = {0 .0, 1.0, 0.0, -waterHeight};266 double plane[4] = {0, 1, 0, -waterPos.y}; 261 267 glClipPlane(GL_CLIP_PLANE0, plane); 262 268 } … … 265 271 // If the camera is below the water we don't want to flip the world, 266 272 // but just render it clipped so only the top is drawn. 267 double plane[4] = {0 .0, 1.0, 0.0, waterHeight};273 double plane[4] = {0, 1, 0, waterPos.y}; 268 274 glClipPlane(GL_CLIP_PLANE0, plane); 269 275 } 270 276 } 271 277 272 278 /** 279 * @brief ends the reflection and saves the graphic buffer into a texture 280 */ 273 281 void MappedWater::deactivateReflection() 274 282 { … … 276 284 glCullFace(GL_BACK); 277 285 278 //mat.select();279 /////glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);280 ///mat.renderToTexture(0, GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);281 ///282 283 glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(0));284 285 286 // Create the texture and store it on the video card 286 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); 287 287 mat.renderToTexture(0, GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); 288 288 289 289 glPopMatrix(); … … 291 291 } 292 292 293 /** 294 * @brief prepares everything to render the refraction texutre 295 */ 293 296 void MappedWater::activateRefraction() 294 {/* 295 // save viewport matrix and change the viewport size 296 glPushAttrib(GL_VIEWPORT_BIT); 297 glViewport(0,0, textureSize, textureSize); 298 299 glMatrixMode(GL_MODELVIEW); 300 glPushMatrix(); 301 302 // If our camera is above the water we will render the scene flipped upside down. 303 // In order to line up the reflection nicely with the world we have to translate 304 // the world to the position of our reflected surface, multiplied by two. 305 glEnable(GL_CLIP_PLANE0); 306 Vector pos = State::getCameraNode()->getAbsCoor(); 307 //pos.debug(); 308 //PRINTF(0)("waterheight: %f\n", waterHeight); 309 if(pos.y > waterHeight) 310 { 311 // Translate the world, then flip it upside down 312 glTranslatef(0.0f, waterHeight*2.0f, 0.0f); 313 glScalef(1.0, -1.0, 1.0); 314 315 // Since the world is updside down we need to change the culling to FRONT 316 glCullFace(GL_FRONT); 317 318 // Set our plane equation and turn clipping on 319 double plane[4] = {0.0, 1.0, 0.0, -waterHeight}; 320 glClipPlane(GL_CLIP_PLANE0, plane); 321 } 322 else 323 { 324 // If the camera is below the water we don't want to flip the world, 325 // but just render it clipped so only the top is drawn. 326 double plane[4] = {0.0, 1.0, 0.0, waterHeight}; 327 glClipPlane(GL_CLIP_PLANE0, plane); 328 } 329 */ 330 297 { 331 298 // To create the refraction and depth textures we do the same thing 332 299 // we did for the reflection texture, except we don't need to turn … … 349 316 glEnable(GL_CLIP_PLANE0); 350 317 Vector pos = State::getCameraNode()->getAbsCoor(); 351 if(pos.y > water Height)318 if(pos.y > waterPos.y) 352 319 { 353 double plane[4] = {0 .0, -1.0, 0.0, waterHeight};320 double plane[4] = {0, -1, 0, waterPos.y}; 354 321 glClipPlane(GL_CLIP_PLANE0, plane); 355 356 322 } 357 323 // If the camera is below the water, only render the data above the water … … 359 325 { 360 326 glCullFace(GL_FRONT); 361 double plane[4] = {0 .0, 1.0, 0.0, -waterHeight};327 double plane[4] = {0, 1, 0, -waterPos.y}; 362 328 glClipPlane(GL_CLIP_PLANE0, plane); 363 329 } 364 330 } 365 331 332 /** 333 * @brief ends the refraction and saves the graphic buffer into a texture 334 */ 366 335 void MappedWater::deactivateRefraction() 367 336 { … … 369 338 glCullFace(GL_BACK); 370 339 371 372 glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(1));373 374 340 // Create the texture and store it on the video card 375 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);341 mat.renderToTexture(1, GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); 376 342 377 343 glPopMatrix(); 378 344 glPopAttrib(); 379 380 // Bind the current scene to our refraction texture 381 // glBindTexture(GL_TEXTURE_2D, g_Texture[REFRACTION_ID]); 382 // glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); 383 384 // Bind the current scene to our depth texture 385 // glBindTexture(GL_TEXTURE_2D, g_Texture[DEPTH_ID]); 386 // glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, textureSize, textureSize, 0); 387 388 } 345 } -
trunk/src/world_entities/environments/mapped_water.h
r8037 r8719 1 1 /*! 2 2 * @file mapped_water.h 3 * 3 * worldentity for flat, cool looking, mapped water 4 4 */ 5 /*! example input in .oxw file with the standard values 6 <MappedWater> 7 <waterpos>0,0,0</waterpos> 8 <watersize>100,100</watersize> 9 <wateruv>9</wateruv><!-- size of the waves --> 10 <waterflow>0.08</waterflow> 11 <lightpos>0,10,0</lightpos> 12 <waterangle>0</waterangle> 13 <normalmapscale>0.25</normalmapscale><!-- you won't see a big differnce if you change that --> 14 </MappedWater> 15 */ 16 5 17 6 18 #ifndef _MAPPED_WATER_H 7 19 #define _MAPPED_WATER_H 8 20 9 /* INCLUDES */10 21 #include "world_entity.h" 11 22 #include "material.h" 12 23 #include "shader.h" 13 24 25 14 26 class MappedWater : public WorldEntity 15 27 { 16 17 18 28 public: 29 MappedWater(const TiXmlElement* root = NULL); 30 virtual ~MappedWater(); 19 31 20 32 void loadParams(const TiXmlElement* root); 21 33 34 void draw() const; 35 void tick(float dt); 22 36 23 void activateReflection(); 24 void deactivateReflection(); 37 // function to prepare renderpaths for creation of refleaction and reflaction textures 38 void activateReflection(); 39 void deactivateReflection(); 40 void activateRefraction(); 41 void deactivateRefraction(); 25 42 26 void activateRefraction(); 27 void deactivateRefraction(); 43 // functions to set parameters for the water, usually they're called through loadparam 44 void setLightPos(float x, float y, float z) { this->lightPos = Vector(x,y,z); }; 45 void setWaterPos(float x, float y, float z) { this->waterPos = Vector(x,y,z); }; 46 void setWaterSize(float x, float z) { this->xWidth = x; this->zWidth = z; }; 47 void setWaterAngle(float angle) { this->waterAngle = angle; }; 48 void setWaterUV(float uv) { this->waterUV = uv; }; 49 void setWaterFlow(float flow) { this->waterFlow = flow; }; 50 void setNormalMapScale(float scale) { this->kNormalMapScale = scale; }; 28 51 29 void draw() const; 30 void tick(float dt); 52 private: 53 void initParams(); 54 void initTextures(); 55 void initShaders(); 31 56 32 private: 33 void setLightPosition(float x, float y, float z) { this->lightPos = Vector(x,y,z); }; 34 void setHeight(float height); 57 private: 58 Vector waterPos; //!< position of the water 59 float xWidth, zWidth; //!< size of the water quad 60 Vector lightPos; //!< position of the light that is used to render the reflection 61 float waterAngle; //!< defines how much the water will be turned around the point waterPos 35 62 36 private: 37 float waterHeight; //!< y-coord of the Water 63 float move; //!< textures coords, speeds, positions for the shaded textures.... 64 float move2; 65 float waterUV; //!< size of the waves 66 float waterFlow; //!< speed of the water 67 float normalUV; 68 float kNormalMapScale; 38 69 39 float move; //!< textures coords, speeds, positions for the shaded textures.... 40 float move2; //!< 41 float g_WaterUV; //!< 42 float g_WaterFlow; //!< 43 float refrUV; //!< 44 float normalUV; //!< 45 float kNormalMapScale; //!< 46 47 int textureSize; //!< size of the texture 48 Vector lightPos; 49 Material mat; 50 Shader* shader; 51 Shader::Uniform* cam_uni; //!< uniform that is used for the camera position 52 70 int textureSize; //!< height and width of the texture 71 Material mat; 72 Shader* shader; 73 Shader::Uniform* cam_uni; //!< uniform that is used for the camera position 53 74 }; 54 75 55 #endif /* _MAPPED_WATER_H */76 #endif -
trunk/src/world_entities/space_ships/hover.cc
r8362 r8719 99 99 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 100 100 this->setClassID(CL_HOVER, "Hover"); 101 this->toReflectionList(); 101 102 102 103 this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
Note: See TracChangeset
for help on using the changeset viewer.