Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7740 in orxonox.OLD for branches


Ignore:
Timestamp:
May 20, 2006, 11:42:28 AM (19 years ago)
Author:
patrick
Message:

water: the stuff is drawn twice now, there where some logical errors in the code. not yet drawn on the texture i'm afraid

Location:
branches/water/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/water/src/story_entities/game_world.cc

    r7692 r7740  
    490490      mw->activateReflection();
    491491
     492      //camera and light
     493      this->dataTank->localCamera->apply ();
     494      this->dataTank->localCamera->project ();
     495      LightManager::getInstance()->draw();
    492496      // draw everything to be included in the reflection
    493497      for (unsigned int i = 0; i < this->dataTank->drawLists.size(); ++i)
  • branches/water/src/world_entities/environments/mapped_water.cc

    r7700 r7740  
    2828  this->setClassID(CL_MAPPED_WATER, "MappedWater");
    2929  this->toList(OM_ENVIRON);
    30  
     30
    3131  if (root != NULL)
    3232    this->loadParams(root);
    33    
     33
     34
    3435    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;
    3539}
    3640
    3741MappedWater::~MappedWater()
    3842{
    39  
     43
    4044}
    4145
     
    5054void MappedWater::draw() const
    5155{
    52   glPushMatrix(); 
    53  
     56  glPushMatrix();
     57
    5458  /*
    5559  glTranslatef (this->getAbsCoor ().x,
     
    6165  //glEnable(GL_LIGHTING);
    6266
    63  
     67
    6468  //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 1);
    6569  //mat.setTransparency(1.0);
    6670  //mat.setDiffuse(1.0, 0, .1);
    67  
    68  
     71
     72
    6973  // HACK
    7074
     
    106110void MappedWater::activateReflection()
    107111{
    108   // Change the view port to be the size of the texture we will render to
    109   // HACK
    110   int textureSize = 512;
    111112  glPushAttrib(GL_VIEWPORT_BIT);
     113  glPushMatrix();
     114
    112115  glViewport(0,0, textureSize, textureSize);
    113116
    114117  // 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();
    117120  //g_Camera.Look();
    118121
    119   // So we don't affect any other objects in the world we push on a new matrix
    120   //glPushMatrix();
    121122
    122123  // If our camera is above the water we will render the scene flipped upside down.
     
    164165    // Bind the current scene to our reflection texture
    165166  //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
    175171}
    176172
    177173void MappedWater::deactivateReflection()
    178174{
     175  glBindTexture(GL_TEXTURE_2D, texture.getTexture());
    179176
     177  mat.setDiffuseMap(&texture, 0);
     178  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
     179
     180  glPopAttrib();
     181  glPopMatrix();
    180182}
    181183
  • branches/water/src/world_entities/environments/mapped_water.h

    r7700 r7740  
    2323    void activateReflection();
    2424    void deactivateReflection();
    25    
     25
    2626    void activateRefraction();
    2727    void deactivateRefraction();
    28    
     28
    2929    void draw() const;
    3030    void tick(float dt);
     
    3636    float           waterHeight;       //!< y-coord of the Water
    3737    Material        mat;
    38    
     38
    3939    Texture         texture;
     40    int             textureSize;       //!< size of the texture
    4041
    4142};
Note: See TracChangeset for help on using the changeset viewer.