Hello forum,<br><br>I have been using the Paul's article about generating terrain using fractals<br><br><a href="http://gameprogrammer.com/fractal.html">http://gameprogrammer.com/fractal.html</a><br><br><br>I am populating the values in the osg height map structure.<br>
<br><br>But The rendering is giving me a flat surface.<br><br><br>I hope that Paul sees that as well.<br><br>********************************************<br><br> osg::ref_ptr<osg::Geode> myTerrain = new osg::Geode;<br>
<br> //Now load the terrain<br><br> /*<br> osg::ref_ptr<osg::Node> terrainNode (osgDB::readNodeFile("Terrain2.3ds"));<br> terrainScaleMat->addChild(terrainNode.get());<br> */<br><br> //generate the 2D fractal<br>
float *heightData = alloc2DFractArray(512);<br><br><br> //Define some constants for the fractal terrain<br> static const float DEF_HEIGHT_SCALE = 0.1f;<br> static float TILING_SURFACE = 3;<br> int randomSeed = 1;<br>
float H = 0.3;<br> float iteration = 10;<br><br><br> fill2DFractArray (heightData,512, randomSeed,DEF_HEIGHT_SCALE,H);<br> <br> //using the height field<br> osg::ref_ptr<osg::HeightField> heightMap = new osg::HeightField;<br>
<br> //allocate the space for the height field<br> heightMap->allocate(512,512);<br><br> //populate the height map<br> for(unsigned int i = 0; i < heightMap->getNumColumns();i++)<br> {<br> for(unsigned int j = 0; j < heightMap->getNumRows();j++)<br>
{<br> int size = heightMap->getNumRows();<br> heightMap->setHeight(i,j,heightData[(i*size)+j]);<br><br> //std::cout << heightMap->getHeight(i,j) << std::endl;<br> }<br> }<br><br>
//now add the drawable to the terain<br> myTerrain->addDrawable(new osg::ShapeDrawable(heightMap.get()));<br><br><br><br><br>********************************************<br><br><br><br>Regards,<br><br>Sajjad<br>