[4597] | 1 | /* |
---|
[3416] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
[4261] | 12 | main-programmer: Benjamin Grauer |
---|
| 13 | co-programmer: ... |
---|
[3411] | 14 | */ |
---|
| 15 | |
---|
[3590] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
| 17 | |
---|
[6455] | 18 | #include "water.h" |
---|
| 19 | #include "factory.h" |
---|
[5356] | 20 | #include "load_param.h" |
---|
[3608] | 21 | |
---|
[6455] | 22 | #include "grid.h" |
---|
| 23 | |
---|
[5356] | 24 | using namespace std; |
---|
[5357] | 25 | |
---|
[6455] | 26 | CREATE_FACTORY(Water, CL_WATER); |
---|
[3608] | 27 | |
---|
[4010] | 28 | |
---|
[6455] | 29 | Water::Water(const TiXmlElement* root) |
---|
[4010] | 30 | { |
---|
[6455] | 31 | this->resX = this->resY = 10; |
---|
| 32 | this->sizeX = this->sizeY = 1.0; |
---|
| 33 | this->grid = NULL; |
---|
[4010] | 34 | |
---|
[6455] | 35 | if (root != NULL) |
---|
| 36 | this->loadParams(root); |
---|
[4010] | 37 | } |
---|
| 38 | |
---|
[6455] | 39 | Water::~Water() |
---|
[4261] | 40 | { |
---|
[4436] | 41 | |
---|
[4261] | 42 | } |
---|
| 43 | |
---|
[6455] | 44 | void Water::loadParams(const TiXmlElement* root) |
---|
[4010] | 45 | { |
---|
[6455] | 46 | WorldEntity::loadParams(root); |
---|
[4620] | 47 | |
---|
[6455] | 48 | LoadParam(root, "size", this, Water, setSize) |
---|
| 49 | .describe("the size of the WaterSurface") |
---|
| 50 | .defaultValues(2, 1.0f, 1.0f); |
---|
[6341] | 51 | |
---|
[6455] | 52 | LoadParam(root, "resolution", this, Water, setResolution) |
---|
| 53 | .describe("sets the resolution of the water surface") |
---|
| 54 | .defaultValues(2, 10, 10); |
---|
[4012] | 55 | } |
---|
[3803] | 56 | |
---|
[6455] | 57 | void Water::rebuildGrid() |
---|
[4012] | 58 | { |
---|
[6455] | 59 | if (this->grid != NULL) |
---|
| 60 | delete this->grid; |
---|
| 61 | this->grid = new Grid(this->sizeX, this->sizeY, this->resX, this->resY); |
---|
[3411] | 62 | |
---|
[6307] | 63 | } |
---|
[3411] | 64 | |
---|
[6455] | 65 | void Water::setResolution(unsigned int resX, unsigned int resY) |
---|
[3803] | 66 | { |
---|
[6455] | 67 | this->resX = resX; |
---|
| 68 | this->resY = resY; |
---|
[3803] | 69 | } |
---|
| 70 | |
---|
[6455] | 71 | void Water::setSize(float sizeX, float sizeY) |
---|
[3803] | 72 | { |
---|
[6455] | 73 | this->sizeX = sizeX; |
---|
| 74 | this->sizeY = sizeY; |
---|
[3803] | 75 | } |
---|
| 76 | |
---|