Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8719 in orxonox.OLD for trunk


Ignore:
Timestamp:
Jun 22, 2006, 2:13:18 PM (18 years ago)
Author:
bensch
Message:

merged the water branche back. conflicts resolved in favour of the trunk

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/menu/game_menu.cc

    r8717 r8719  
    178178      image->setWidgetSize( 250, 200);
    179179      image->setAbsCoor2D(400, 150);
    180       image->setForegroundColor(Color(1,1,1,.6));
     180      image->setForegroundColor(Color( 1,1,1,.6));
    181181
    182182      const std::list<BaseObject*>* storyEntities = ClassList::getList(CL_STORY_ENTITY);
  • trunk/src/world_entities/environments/mapped_water.cc

    r8619 r8719  
    2121
    2222
    23 
    24 
    2523CREATE_FACTORY(MappedWater, CL_MAPPED_WATER);
    2624
    27 
     25/**
     26 * @brief constructor
     27 * @param root xml data
     28 */
    2829MappedWater::MappedWater(const TiXmlElement* root)
    2930{
     
    3132  this->toList(OM_ENVIRON);
    3233
     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
    3338  if (root != NULL)
    3439    this->loadParams(root);
    3540
    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 */
     51MappedWater::~MappedWater()
     52{
     53  delete shader;
     54  delete cam_uni;
     55}
     56
     57/**
     58 * @brief initialization of loadable parameters, sets start standard values
     59 */
     60void 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 */
     82void MappedWater::initTextures()
     83{
     84  // sets parameters for the textures
     85  this->textureSize = 512;
     86  unsigned int channels = 32;
     87  GLenum type = GL_RGBA;
     88
    4089  // 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);
    4595  // load normal map
    4696  mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2);
    4797  // load dudv map
    4898  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
    82101  glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(0));
    83102  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
     
    85104  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    86105  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
    92107  glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(1));
    93108  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
     
    95110  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    96111  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 */
     117void MappedWater::initShaders()
     118{
    114119  // load shader files
    115120  shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
     
    136141}
    137142
    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 */
    144147void MappedWater::loadParams(const TiXmlElement* root)
    145148{
    146149  WorldEntity::loadParams(root);
    147150
    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 */
    153163void MappedWater::draw() const
    154164{
     
    156166
    157167  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
    161171  mat.select();
    162172
     
    167177  cam_uni->set(pos.x, pos.y, pos.z, 1.0f);
    168178
    169   //glDisable(GL_BLEND);
     179  glDisable(GL_BLEND);
    170180
    171181  glBegin(GL_QUADS);
    172182  // 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
    178186  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);
    181188
    182189  // 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
    188193  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);
    191195
    192196  // 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
    198200  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);
    201202
    202203  // 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
    207206  glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2);  // Normal map texture
    208207  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);
    211209  glEnd();
    212210
     
    218216}
    219217
     218/**
     219 * @brief tick tack, calculates the flow of the water
     220 */
    220221void MappedWater::tick(float dt)
    221222{
    222223  // makes the water flow
    223   this->move += this->g_WaterFlow;
     224  this->move += this->waterFlow * dt;
    224225  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 */
    234231void MappedWater::activateReflection()
    235232{
     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
    236243  // save viewport matrix and change the viewport size
    237244  glPushAttrib(GL_VIEWPORT_BIT);
     
    246253  glEnable(GL_CLIP_PLANE0);
    247254  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)
    251257  {
    252258    // 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);
    255261
    256262    // Since the world is updside down we need to change the culling to FRONT
     
    258264
    259265    // 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};
    261267    glClipPlane(GL_CLIP_PLANE0, plane);
    262268  }
     
    265271    // If the camera is below the water we don't want to flip the world,
    266272    // 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};
    268274    glClipPlane(GL_CLIP_PLANE0, plane);
    269275  }
    270276}
    271277
    272 
     278/**
     279 * @brief ends the reflection and saves the graphic buffer into a texture
     280 */
    273281void MappedWater::deactivateReflection()
    274282{
     
    276284  glCullFace(GL_BACK);
    277285
    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 
    285286  // 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);
    288288
    289289  glPopMatrix();
     
    291291}
    292292
     293/**
     294 * @brief prepares everything to render the refraction texutre
     295 */
    293296void 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{
    331298  // To create the refraction and depth textures we do the same thing
    332299  // we did for the reflection texture, except we don't need to turn
     
    349316  glEnable(GL_CLIP_PLANE0);
    350317  Vector pos = State::getCameraNode()->getAbsCoor();
    351   if(pos.y > waterHeight)
     318  if(pos.y > waterPos.y)
    352319  {
    353     double plane[4] = {0.0, -1.0, 0.0, waterHeight};
     320    double plane[4] = {0, -1, 0, waterPos.y};
    354321    glClipPlane(GL_CLIP_PLANE0, plane);
    355 
    356322  }
    357323  // If the camera is below the water, only render the data above the water
     
    359325  {
    360326    glCullFace(GL_FRONT);
    361     double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
     327    double plane[4] = {0, 1, 0, -waterPos.y};
    362328    glClipPlane(GL_CLIP_PLANE0, plane);
    363329  }
    364330}
    365331
     332/**
     333 * @brief ends the refraction and saves the graphic buffer into a texture
     334 */
    366335void MappedWater::deactivateRefraction()
    367336{
     
    369338  glCullFace(GL_BACK);
    370339
    371 
    372   glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(1));
    373 
    374340  // 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);
    376342
    377343  glPopMatrix();
    378344  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  
    11/*!
    22 * @file mapped_water.h
    3  *
     3 *  worldentity for flat, cool looking, mapped water
    44*/
     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
    517
    618#ifndef _MAPPED_WATER_H
    719#define _MAPPED_WATER_H
    820
    9 /* INCLUDES */
    1021#include "world_entity.h"
    1122#include "material.h"
    1223#include "shader.h"
    1324
     25
    1426class MappedWater : public WorldEntity
    1527{
    16   public:
    17     MappedWater(const TiXmlElement* root = NULL);
    18     virtual ~MappedWater();
     28public:
     29  MappedWater(const TiXmlElement* root = NULL);
     30  virtual ~MappedWater();
    1931
    20     void loadParams(const TiXmlElement* root);
     32  void loadParams(const TiXmlElement* root);
    2133
     34  void draw() const;
     35  void tick(float dt);
    2236
    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();
    2542
    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; };
    2851
    29     void draw() const;
    30     void tick(float dt);
     52private:
     53  void initParams();
     54  void initTextures();
     55  void initShaders();
    3156
    32   private:
    33     void setLightPosition(float x, float y, float z) { this->lightPos = Vector(x,y,z); };
    34     void setHeight(float height);
     57private:
     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
    3562
    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;
    3869
    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
    5374};
    5475
    55 #endif  /* _MAPPED_WATER_H */
     76#endif
  • trunk/src/world_entities/space_ships/hover.cc

    r8362 r8719  
    9999  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    100100  this->setClassID(CL_HOVER, "Hover");
     101  this->toReflectionList();
    101102
    102103  this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
Note: See TracChangeset for help on using the changeset viewer.