| [4744] | 1 | /* | 
|---|
| [1853] | 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. | 
|---|
| [1855] | 10 |  | 
|---|
|  | 11 | ### File Specific: | 
|---|
|  | 12 | main-programmer: ... | 
|---|
|  | 13 | co-programmer: ... | 
|---|
| [1853] | 14 | */ | 
|---|
|  | 15 |  | 
|---|
| [3955] | 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ | 
|---|
| [1853] | 17 |  | 
|---|
| [6446] | 18 | #include "grid.h" | 
|---|
| [1853] | 19 |  | 
|---|
| [1856] | 20 | using namespace std; | 
|---|
| [1853] | 21 |  | 
|---|
| [1856] | 22 |  | 
|---|
| [3245] | 23 | /** | 
|---|
| [4838] | 24 | * standard constructor | 
|---|
|  | 25 | * @todo this constructor is not jet implemented - do it | 
|---|
| [3245] | 26 | */ | 
|---|
| [6446] | 27 | Grid::Grid(float sizeX, float sizeY, unsigned int rows, unsigned int columns) | 
|---|
| [3365] | 28 | { | 
|---|
| [6454] | 29 | this->planeModel(sizeX, sizeY, rows, columns); | 
|---|
| [4320] | 30 |  | 
|---|
| [6446] | 31 | this->_rows = rows; | 
|---|
|  | 32 | this->_columns = columns; | 
|---|
|  | 33 | this->_sizeX = sizeX; | 
|---|
|  | 34 | this->_sizeY = sizeY; | 
|---|
| [6467] | 35 | this->_gridSpacingX = sizeX / (float)rows; | 
|---|
|  | 36 | this->_gridSpacingY = sizeY / (float)columns; | 
|---|
| [3365] | 37 | } | 
|---|
| [1853] | 38 |  | 
|---|
|  | 39 |  | 
|---|
| [3245] | 40 | /** | 
|---|
| [4838] | 41 | * standard deconstructor | 
|---|
| [3245] | 42 | */ | 
|---|
| [6446] | 43 | Grid::~Grid () | 
|---|
| [3543] | 44 | { | 
|---|
|  | 45 | // delete what has to be deleted here | 
|---|
|  | 46 | } | 
|---|
| [6458] | 47 |  | 
|---|
|  | 48 |  | 
|---|
|  | 49 | void Grid::rebuildNormals(float maxHeight) | 
|---|
|  | 50 | { | 
|---|
|  | 51 | for (unsigned int i = 1; i < this->_rows-1; i++) | 
|---|
|  | 52 | { | 
|---|
|  | 53 | for (unsigned int j = 1; j < this->_columns-1; j++) | 
|---|
|  | 54 | { | 
|---|
| [6467] | 55 | /* | 
|---|
|  | 56 | Vector test( this->_gridSpacingX/(this->vertex(i*_columns+j).y - this->vertex(i*_columns+j-1).y) + | 
|---|
|  | 57 | this->_gridSpacingX/(this->vertex(i*_columns+j+1).y - this->vertex(i*_columns+j).y) | 
|---|
|  | 58 | , | 
|---|
|  | 59 | _gridSpacingX, | 
|---|
|  | 60 | this->_gridSpacingY/(this->vertex(i*_columns+j).y - this->vertex((i-1)*_columns+j).y) + | 
|---|
|  | 61 | this->_gridSpacingX/(this->vertex((i+1)*_columns+j).y - this->vertex(i*_columns+j).y) | 
|---|
|  | 62 | );*/ | 
|---|
|  | 63 |  | 
|---|
|  | 64 |  | 
|---|
|  | 65 |  | 
|---|
|  | 66 | Vector test  ( | 
|---|
|  | 67 | (-this->vertex(i*_columns+j-1).y - this->vertex(i*_columns+j+1).y)/maxHeight, | 
|---|
|  | 68 | 1.0, | 
|---|
|  | 69 | (-this->vertex((i-1)*_columns+j).y - this->vertex((i+1)*_columns+j).y)/maxHeight | 
|---|
|  | 70 | ); | 
|---|
|  | 71 |  | 
|---|
|  | 72 |  | 
|---|
|  | 73 | //      Vector test( | 
|---|
|  | 74 | //           (this->vertex(i*_columns+j).y + this->vertex((i-1)*_columns+j).y - this->vertex((i+1)*_columns+j).y ) /maxHeight, | 
|---|
|  | 75 | //           1.0, | 
|---|
|  | 76 | //           (this->vertex(i*_columns+j).y - this->vertex(i*_columns+j-1).y + this->vertex(i*_columns+j+1).y)/maxHeight | 
|---|
|  | 77 | //                 ); | 
|---|
| [6458] | 78 | this->normal( i*_columns+j) = test.getNormalized(); | 
|---|
|  | 79 | } | 
|---|
|  | 80 |  | 
|---|
|  | 81 | } | 
|---|
|  | 82 |  | 
|---|
|  | 83 | } | 
|---|