Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/environments/water.cc @ 6456

Last change on this file since 6456 was 6456, checked in by bensch, 19 years ago

Water draws itself

File size: 1.7 KB
Line 
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
24using namespace std;
25
26CREATE_FACTORY(Water, CL_WATER);
27
28
29Water::Water(const TiXmlElement* root)
30{
31  this->setClassID(CL_WATER, "Water");
32  this->toList(OM_ENVIRON_NOTICK);
33
34  this->resX = this->resY = 10;
35  this->sizeX = this->sizeY = 1.0;
36  this->grid = NULL;
37
38  if (root != NULL)
39    this->loadParams(root);
40
41  this->rebuildGrid();
42}
43
44Water::~Water()
45{
46  delete this->grid;
47
48}
49
50void Water::loadParams(const TiXmlElement* root)
51{
52  WorldEntity::loadParams(root);
53
54  LoadParam(root, "size", this, Water, setSize)
55      .describe("the size of the WaterSurface")
56      .defaultValues(2, 1.0f, 1.0f);
57
58  LoadParam(root, "resolution", this, Water, setResolution)
59      .describe("sets the resolution of the water surface")
60      .defaultValues(2, 10, 10);
61}
62
63void Water::rebuildGrid()
64{
65  if (this->grid != NULL)
66    delete this->grid;
67  this->grid = new Grid(this->sizeX, this->sizeY, this->resX, this->resY);
68
69  this->setModel(this->grid, 0);
70}
71
72void Water::setResolution(unsigned int resX, unsigned int resY)
73{
74  this->resX = resX;
75  this->resY = resY;
76}
77
78void Water::setSize(float sizeX, float sizeY)
79{
80  printf("%f %f\n", sizeX, sizeY);
81
82  this->sizeX = sizeX;
83  this->sizeY = sizeY;
84}
85
86
87void Water::tick(float dt)
88{
89
90}
Note: See TracBrowser for help on using the repository browser.