Added osg::Grid shape class, and added an example of its use into the

hang glide demo.
This commit is contained in:
Robert Osfield
2002-10-31 10:36:11 +00:00
parent 85af8cc4ba
commit 21ee9e4cb7
5 changed files with 176 additions and 20 deletions

View File

@@ -1,5 +1,43 @@
#include <osg/Shape>
#include <algorithm>
using namespace osg;
Grid::Grid()
{
}
Grid::Grid(const Grid& mesh,const CopyOp& copyop):
HeightField(mesh,copyop)
{
_heights = mesh._heights;
}
Grid::~Grid()
{
}
void Grid::allocGrid(unsigned int numColumns,unsigned int numRows, float value)
{
if (_columns!=numColumns || _rows!=numRows)
{
_heights.resize(numColumns*numRows);
}
_columns=numColumns;
_rows=numRows;
//_heights.fill(value);
}
void Grid::populateGrid(float minValue,float maxValue)
{
float offset=minValue;
float gain=(maxValue-minValue)/(float)RAND_MAX;
for(unsigned int row=0;row<_rows;++row)
{
for(unsigned int col=0;col<_columns;++col)
{
setHeight(col,row,rand()*gain+offset);
}
}
}