Wow. That article is like 13 years old. I think I wrote it with VC4 and OpenGL 1.1. As a debugging technique, try to separate the heightfield population algorithm from the rendering issue. For example, try populating the heightfield with an array of linearly increasing values and see if it renders as you would expect. If it still renders wrong, then you know the fractal algorithm isn't to blame and the problem is probably with how you are using OSG. As a result, you'll have a much simpler example to post here. I'd also suggest using Geometry instead of some other Drawable, as Geometry is more flexible (you can run them through the Simplifier, for example). Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com <http://www.skew-matrix.com/> +1 303 859 9466
_____ From: [email protected] [mailto:[email protected]] On Behalf Of ami guru Sent: Sunday, March 22, 2009 7:46 AM To: OpenSceneGraph Users Subject: [osg-users] generate height map using fractal Hello forum, I have been using the Paul's article about generating terrain using fractals http://gameprogrammer.com/fractal.html I am populating the values in the osg height map structure. But The rendering is giving me a flat surface. I hope that Paul sees that as well. ******************************************** osg::ref_ptr<osg::Geode> myTerrain = new osg::Geode; //Now load the terrain /* osg::ref_ptr<osg::Node> terrainNode (osgDB::readNodeFile("Terrain2.3ds")); terrainScaleMat->addChild(terrainNode.get()); */ //generate the 2D fractal float *heightData = alloc2DFractArray(512); //Define some constants for the fractal terrain static const float DEF_HEIGHT_SCALE = 0.1f; static float TILING_SURFACE = 3; int randomSeed = 1; float H = 0.3; float iteration = 10; fill2DFractArray (heightData,512, randomSeed,DEF_HEIGHT_SCALE,H); //using the height field osg::ref_ptr<osg::HeightField> heightMap = new osg::HeightField; //allocate the space for the height field heightMap->allocate(512,512); //populate the height map for(unsigned int i = 0; i < heightMap->getNumColumns();i++) { for(unsigned int j = 0; j < heightMap->getNumRows();j++) { int size = heightMap->getNumRows(); heightMap->setHeight(i,j,heightData[(i*size)+j]); //std::cout << heightMap->getHeight(i,j) << std::endl; } } //now add the drawable to the terain myTerrain->addDrawable(new osg::ShapeDrawable(heightMap.get())); ******************************************** Regards, Sajjad
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

