1 | /* |
---|
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: |
---|
12 | main-programmer: Benjamin Grauer |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
17 | |
---|
18 | #include "water.h" |
---|
19 | #include "factory.h" |
---|
20 | #include "load_param.h" |
---|
21 | |
---|
22 | #include "grid.h" |
---|
23 | |
---|
24 | using namespace std; |
---|
25 | |
---|
26 | CREATE_FACTORY(Water, CL_WATER); |
---|
27 | |
---|
28 | |
---|
29 | Water::Water(const TiXmlElement* root) |
---|
30 | { |
---|
31 | this->resX = this->resY = 10; |
---|
32 | this->sizeX = this->sizeY = 1.0; |
---|
33 | this->grid = NULL; |
---|
34 | |
---|
35 | if (root != NULL) |
---|
36 | this->loadParams(root); |
---|
37 | } |
---|
38 | |
---|
39 | Water::~Water() |
---|
40 | { |
---|
41 | |
---|
42 | } |
---|
43 | |
---|
44 | void Water::loadParams(const TiXmlElement* root) |
---|
45 | { |
---|
46 | WorldEntity::loadParams(root); |
---|
47 | |
---|
48 | LoadParam(root, "size", this, Water, setSize) |
---|
49 | .describe("the size of the WaterSurface") |
---|
50 | .defaultValues(2, 1.0f, 1.0f); |
---|
51 | |
---|
52 | LoadParam(root, "resolution", this, Water, setResolution) |
---|
53 | .describe("sets the resolution of the water surface") |
---|
54 | .defaultValues(2, 10, 10); |
---|
55 | } |
---|
56 | |
---|
57 | void Water::rebuildGrid() |
---|
58 | { |
---|
59 | if (this->grid != NULL) |
---|
60 | delete this->grid; |
---|
61 | this->grid = new Grid(this->sizeX, this->sizeY, this->resX, this->resY); |
---|
62 | |
---|
63 | } |
---|
64 | |
---|
65 | void Water::setResolution(unsigned int resX, unsigned int resY) |
---|
66 | { |
---|
67 | this->resX = resX; |
---|
68 | this->resY = resY; |
---|
69 | } |
---|
70 | |
---|
71 | void Water::setSize(float sizeX, float sizeY) |
---|
72 | { |
---|
73 | this->sizeX = sizeX; |
---|
74 | this->sizeY = sizeY; |
---|
75 | } |
---|
76 | |
---|