Changeset 6766 in orxonox.OLD for trunk/src/world_entities/environments
- Timestamp:
- Jan 26, 2006, 12:54:16 PM (19 years ago)
- Location:
- trunk/src/world_entities/environments
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/environments/water.cc
r6756 r6766 27 27 28 28 #include "skybox.h" 29 #include "state.h" 30 29 31 30 32 #include "network_game_manager.h" … … 56 58 this->waterShader = (Shader*)ResourceManager::getInstance()->load("shaders/water.vert", SHADER, RP_GAME, "shaders/water.frag"); 57 59 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); 59 62 } 60 63 … … 107 110 } 108 111 112 void 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 109 120 void Water::setResolution(unsigned int resX, unsigned int resY) 110 121 { … … 122 133 { 123 134 this->height = height; 135 } 136 137 138 bool 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; 124 149 } 125 150 … … 151 176 void Water::tick(float dt) 152 177 { 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 153 187 if (unlikely(this->velocities == NULL)) 154 188 return; … … 180 214 4 * this->grid->height(i, j); 181 215 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; 183 218 } 184 219 } -
trunk/src/world_entities/environments/water.h
r6695 r6766 32 32 void rebuildGrid(); 33 33 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 34 37 void draw() const; 35 38 void tick(float dt); … … 41 44 int readState( byte * data, int maxLength ); 42 45 46 private: 47 bool posToGridPoint(float x, float z, unsigned int& row, unsigned int& column); 43 48 44 49 private:
Note: See TracChangeset
for help on using the changeset viewer.