<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16809" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=197202122-22032009><FONT face=Arial
size=2>Wow. That article is like 13 years old. I think I wrote it with VC4 and
OpenGL 1.1.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=197202122-22032009><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=197202122-22032009><FONT face=Arial
size=2>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=197202122-22032009><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=197202122-22032009><FONT face=Arial
size=2>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).</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV align=left><FONT face=Helvetica size=2>Paul Martz</FONT></DIV>
<DIV align=left><FONT face=Helvetica><STRONG>Skew Matrix Software
LLC</STRONG></FONT></DIV>
<DIV align=left><FONT face=Helvetica size=2><A
href="http://www.skew-matrix.com/">http://www.skew-matrix.com</A></FONT></DIV>
<DIV align=left><FONT face=Helvetica size=2>+1 303 859 9466</FONT></DIV>
<DIV> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> osg-users-bounces@lists.openscenegraph.org
[mailto:osg-users-bounces@lists.openscenegraph.org] <B>On Behalf Of </B>ami
guru<BR><B>Sent:</B> Sunday, March 22, 2009 7:46 AM<BR><B>To:</B> OpenSceneGraph
Users<BR><B>Subject:</B> [osg-users] generate height map using
fractal<BR></FONT><BR></DIV>
<DIV></DIV>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></BODY></HTML>