Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6457 in orxonox.OLD


Ignore:
Timestamp:
Jan 10, 2006, 12:39:08 AM (18 years ago)
Author:
bensch
Message:

water works

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/grid.h

    r6454 r6457  
    2626  unsigned int columns() const { return this->_columns; };
    2727
    28   float& height(unsigned int row, unsigned int column) { return this->vertex(row*_columns + row).y;};
     28  float& height(unsigned int row, unsigned int column) { return this->vertex(row*this->_columns + column).y;};
     29
     30
     31  void rebuidNormals();
    2932
    3033private:
  • trunk/src/story_entities/game_world.cc

    r6434 r6457  
    328328
    329329    this->tick(this->dataTank->objectManager->getObjectList(OM_DEAD_TICK), this->dtS);
     330    this->tick(this->dataTank->objectManager->getObjectList(OM_ENVIRON), this->dtS);
    330331    this->tick(this->dataTank->objectManager->getObjectList(OM_COMMON), this->dtS);
    331332    this->tick(this->dataTank->objectManager->getObjectList(OM_GROUP_00), this->dtS);
  • trunk/src/world_entities/environments/water.cc

    r6456 r6457  
    2121
    2222#include "grid.h"
     23#include "material.h"
    2324
    2425using namespace std;
     
    3031{
    3132  this->setClassID(CL_WATER, "Water");
    32   this->toList(OM_ENVIRON_NOTICK);
     33  this->toList(OM_ENVIRON);
    3334
    3435  this->resX = this->resY = 10;
     
    4041
    4142  this->rebuildGrid();
     43  this->waterMaterial = new Material();
    4244}
    4345
     
    4547{
    4648  delete this->grid;
    47 
     49  delete this->waterMaterial;
    4850}
    4951
     
    6769  this->grid = new Grid(this->sizeX, this->sizeY, this->resX, this->resY);
    6870
     71  this->grid->debug();
    6972  this->setModel(this->grid, 0);
    7073}
     
    7881void Water::setSize(float sizeX, float sizeY)
    7982{
    80   printf("%f %f\n", sizeX, sizeY);
    81 
    8283  this->sizeX = sizeX;
    8384  this->sizeY = sizeY;
    8485}
    8586
     87void Water::draw() const
     88{
     89  this->waterMaterial->select();
     90  WorldEntity::draw();
     91}
    8692
    8793void Water::tick(float dt)
    8894{
    89 
     95  phase += dt *.1;
     96  for (unsigned int i = 0; i < this->grid->rows(); i++)
     97  {
     98    for (unsigned int j = 0; j < this->grid->columns(); j++)
     99    {
     100      this->grid->height(i,j) = 15.0*sin(((float)i/(float)this->grid->rows() *phase)+
     101          15*cos((float)j/(float)this->grid->columns()) * phase);
     102    }
     103  }
    90104}
  • trunk/src/world_entities/environments/water.h

    r6456 r6457  
    3030   void rebuildGrid();
    3131
     32   void draw() const;
    3233   void tick(float dt);
    3334
    3435  private:
    3536    Grid*           grid;            //!< The water-surface-model to render with
     37    Material*       waterMaterial;
    3638
    3739    unsigned int    resX, resY;
    3840    float           sizeX, sizeY;
     41
     42    float phase;
    3943};
    4044
Note: See TracChangeset for help on using the changeset viewer.