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@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to