Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 26, 2006, 2:39:31 PM (18 years ago)
Author:
bensch
Message:

Water is better now (but still quite Bad)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/environments/water.cc

    r6766 r6771  
    8585}
    8686
     87/**
     88 * @brief rebuilds the Grid below the WaterSurface, killing all hight information
     89 *
     90 * This should be called on all subGrid changes except wave and tick.
     91 */
    8792void Water::rebuildGrid()
    8893{
     
    118123}
    119124
     125/**
     126 * after this a rebuild() must be called
     127 */
    120128void Water::setResolution(unsigned int resX, unsigned int resY)
    121129{
     
    124132}
    125133
     134/**
     135 * after this a rebuild() must be called
     136 */
    126137void Water::setSize(float sizeX, float sizeY)
    127138{
     
    136147
    137148
     149/**
     150 * @brief calculated the Position in the Grid, this Point is nearest to
     151 * @param x, the x-position over the Grid
     152 * @param z: the z-Position(or y) over the Grid
     153 * @param row returns the row if not out of range
     154 * @param column returns the column if not out of range
     155 * @returns true if a valid point is found, false if any x or y are out of range
     156 */
    138157bool Water::posToGridPoint(float x, float z, unsigned int& row, unsigned int& column)
    139158{
     
    152171void Water::draw() const
    153172{
    154   if (this->grid != NULL)
    155   {
    156     //SkyBox::enableCubeMap();
    157     WorldEntity::draw();
    158     glBindTexture(GL_TEXTURE_2D, 15);
    159     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    160 
    161     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    162     glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    163     glEnable(GL_TEXTURE_GEN_S);
    164     glEnable(GL_TEXTURE_GEN_T);
    165 
    166     glEnable(GL_BLEND);
     173  assert (this->grid != NULL);
     174  {
     175    glMatrixMode(GL_MODELVIEW);
     176    glPushMatrix();
     177
     178    /* translate */
     179    glTranslatef (this->getAbsCoor ().x,
     180                  this->getAbsCoor ().y,
     181                  this->getAbsCoor ().z);
     182    Vector tmpRot = this->getAbsDir().getSpacialAxis();
     183    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     184
     185    if (State::getSkyBox())
     186    {
     187      glBindTexture(GL_TEXTURE_2D, State::getSkyBox()->getTexture(SKY_TOP));
     188      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
     189
     190      glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
     191      glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
     192      glEnable(GL_TEXTURE_GEN_S);
     193      glEnable(GL_TEXTURE_GEN_T);
     194    }
    167195    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     196    this->grid->draw();
    168197    // this->waterShader->activateShader();
    169198    //  this->waterMaterial->select();
Note: See TracChangeset for help on using the changeset viewer.