Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6766 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jan 26, 2006, 12:54:16 PM (19 years ago)
Author:
bensch
Message:

trunk: splash splash

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/vertex_array_model.cc

    r6695 r6766  
    264264      for (j = 0; j < resolutionX; j++)
    265265        {
    266           this->addVertex(((float)i - (float)resolutionY/2.0)*sizeY, 0.0, ((float)j - (float)resolutionX/2.0)*sizeX);
     266          this->addVertex( ((float)i - (float)resolutionX/2.0)/(float)resolutionX * sizeX,
     267                            0.0,
     268                            ((float)j - (float)resolutionY/2.0)/(float)resolutionY * sizeY);
    267269          this->addNormal(0.0, 1, 0.0);
    268           this->addTexCoor((float)i/(float)resolutionY, (float)j/(float)resolutionY);
     270          this->addTexCoor((float)i/(float)resolutionX, (float)j/(float)resolutionY);
    269271          this->addColor((float)i/20.0, 0.0, (float)j/20.0);
    270272        }
  • trunk/src/world_entities/environments/water.cc

    r6756 r6766  
    2727
    2828#include "skybox.h"
     29#include "state.h"
     30
    2931
    3032#include "network_game_manager.h"
     
    5658  this->waterShader = (Shader*)ResourceManager::getInstance()->load("shaders/water.vert", SHADER, RP_GAME, "shaders/water.frag");
    5759
    58   this->grid->height(this->grid->columns()/2,this->grid->rows()/2) = 100;
     60  // To test the Wave equation
     61  //this->wave(5.0,4.0, 1, 10);
    5962}
    6063
     
    107110}
    108111
     112void Water::wave(float x, float y, float z, float force)
     113{
     114  unsigned int row = 0, column = 0;
     115  if (!this->posToGridPoint( x, z, row, column))
     116    return;
     117  this->grid->height(row, column) -= force / ((y - this->getAbsCoor().y) +.1);
     118}
     119
    109120void Water::setResolution(unsigned int resX, unsigned int resY)
    110121{
     
    122133{
    123134  this->height = height;
     135}
     136
     137
     138bool Water::posToGridPoint(float x, float z, unsigned int& row, unsigned int& column)
     139{
     140  float lower = this->getAbsCoor().y - this->sizeY *.5;
     141  float left = this->getAbsCoor().x - this->sizeX *.5;
     142  if (x > left && x < left + this->sizeX)
     143    row = (unsigned int) ((x- left) / this->grid->gridSpacing());
     144  else return false;
     145  if (z > lower && z < lower + this->sizeY)
     146    column = (unsigned int)((z-lower) / this->grid->gridSpacing());
     147  else return false;
     148  return true;
    124149}
    125150
     
    151176void Water::tick(float dt)
    152177{
     178  std::list<WorldEntity*> entityList = State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ);
     179  std::list<WorldEntity*>::iterator entity = entityList.begin();
     180  while (entity != entityList.end())
     181  {
     182    this->wave((*entity)->getAbsCoor(), 10.0*dt);
     183    entity++;
     184  }
     185
     186
    153187  if (unlikely(this->velocities == NULL))
    154188    return;
     
    180214           4 * this->grid->height(i, j);
    181215      this->velocities[i][j] += dt * this->viscosity * this->viscosity * u / this->height;
    182       this->grid->height(i, j) += dt * this->velocities[i][j] + dt * this->cohesion * u / this->height;;
     216      this->grid->height(i, j) += dt * this->velocities[i][j]  /* + dt * this->cohesion * u / this->height;*/;
     217      this->grid->height(i, j) *= .99;
    183218    }
    184219  }
  • trunk/src/world_entities/environments/water.h

    r6695 r6766  
    3232   void rebuildGrid();
    3333
     34   void wave(float x, float y, float z, float force);
     35   inline void wave(Vector pos, float force) { this->wave(pos.x, pos.y, pos.z, force); };
     36
    3437   void draw() const;
    3538   void tick(float dt);
     
    4144   int readState( byte * data, int maxLength );
    4245
     46  private:
     47    bool posToGridPoint(float x, float z, unsigned int& row, unsigned int& column);
    4348
    4449  private:
Note: See TracChangeset for help on using the changeset viewer.