/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: ... co-programmer: ... */ //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ #include "grid.h" /** * standard constructor * @todo this constructor is not jet implemented - do it */ Grid::Grid(float sizeX, float sizeY, unsigned int rows, unsigned int columns) { this->planeModel(sizeX, sizeY, rows, columns); this->_rows = rows; this->_columns = columns; this->_sizeX = sizeX; this->_sizeY = sizeY; this->_gridSpacingX = sizeX / (float)rows; this->_gridSpacingY = sizeY / (float)columns; } /** * standard deconstructor */ Grid::~Grid () { // delete what has to be deleted here } void Grid::rebuildNormals(float maxHeight) { for (unsigned int i = 1; i < this->_rows-1; i++) { for (unsigned int j = 1; j < this->_columns-1; j++) { /* Vector test( this->_gridSpacingX/(this->vertex(i*_columns+j).y - this->vertex(i*_columns+j-1).y) + this->_gridSpacingX/(this->vertex(i*_columns+j+1).y - this->vertex(i*_columns+j).y) , _gridSpacingX, this->_gridSpacingY/(this->vertex(i*_columns+j).y - this->vertex((i-1)*_columns+j).y) + this->_gridSpacingX/(this->vertex((i+1)*_columns+j).y - this->vertex(i*_columns+j).y) );*/ Vector test ( (-this->vertex(i*_columns+j-1).y - this->vertex(i*_columns+j+1).y)/maxHeight, 1.0, (-this->vertex((i-1)*_columns+j).y - this->vertex((i+1)*_columns+j).y)/maxHeight ); // Vector test( // (this->vertex(i*_columns+j).y + this->vertex((i-1)*_columns+j).y - this->vertex((i+1)*_columns+j).y ) /maxHeight, // 1.0, // (this->vertex(i*_columns+j).y - this->vertex(i*_columns+j-1).y + this->vertex(i*_columns+j+1).y)/maxHeight // ); this->normal( i*_columns+j) = test.getNormalized(); } } }