Changeset 6457 in orxonox.OLD for trunk/src/world_entities/environments
- Timestamp:
- Jan 10, 2006, 12:39:08 AM (19 years ago)
- Location:
- trunk/src/world_entities/environments
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/environments/water.cc
r6456 r6457 21 21 22 22 #include "grid.h" 23 #include "material.h" 23 24 24 25 using namespace std; … … 30 31 { 31 32 this->setClassID(CL_WATER, "Water"); 32 this->toList(OM_ENVIRON _NOTICK);33 this->toList(OM_ENVIRON); 33 34 34 35 this->resX = this->resY = 10; … … 40 41 41 42 this->rebuildGrid(); 43 this->waterMaterial = new Material(); 42 44 } 43 45 … … 45 47 { 46 48 delete this->grid; 47 49 delete this->waterMaterial; 48 50 } 49 51 … … 67 69 this->grid = new Grid(this->sizeX, this->sizeY, this->resX, this->resY); 68 70 71 this->grid->debug(); 69 72 this->setModel(this->grid, 0); 70 73 } … … 78 81 void Water::setSize(float sizeX, float sizeY) 79 82 { 80 printf("%f %f\n", sizeX, sizeY);81 82 83 this->sizeX = sizeX; 83 84 this->sizeY = sizeY; 84 85 } 85 86 87 void Water::draw() const 88 { 89 this->waterMaterial->select(); 90 WorldEntity::draw(); 91 } 86 92 87 93 void Water::tick(float dt) 88 94 { 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 } 90 104 } -
trunk/src/world_entities/environments/water.h
r6456 r6457 30 30 void rebuildGrid(); 31 31 32 void draw() const; 32 33 void tick(float dt); 33 34 34 35 private: 35 36 Grid* grid; //!< The water-surface-model to render with 37 Material* waterMaterial; 36 38 37 39 unsigned int resX, resY; 38 40 float sizeX, sizeY; 41 42 float phase; 39 43 }; 40 44
Note: See TracChangeset
for help on using the changeset viewer.