[osg-users] generate height map using fractal

Robert Osfield robert.osfield at gmail.com
Sun Mar 22 08:23:38 PDT 2009


HI Ajjad,

I don't have time to go chase online articles, but as a general note please
use osgTerrain for rendering terrain, node ShapeDrawable.

Robert.

2009/3/22 ami guru <dosto.walla at gmail.com>

> 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
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090322/73241ca5/attachment-0003.htm>


More information about the osg-users mailing list