Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6457 in orxonox.OLD for trunk/src/world_entities


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

water works

Location:
trunk/src/world_entities/environments
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.