Hello community,

I've been playing around with manually creating terrain tiles (as opposed to
letting VPB do it) and noticed what to me seems like strange behavior, and I
was wondering if anyone else had noticed a similar issue - or could point
out what I'm doing wrong.  I'm using osg2.8.2 on Windows 7 64-bit, stripped
down code is below.

Basically, I've been following the osgterrain example code but creating a
HeightField manually instead of loading it from a file.  If I create a tile
with < ~64100 elements, everything looks fine.  If I go above this (256*256,
for example), something looks like it goes wacky with how the vertices are
turned into triangles - but only the first so many of them (~64k ish), and
beyond that the terrain looks right.  Either creating a viewer
programatically or saving to a .osg file and using osgviewer.exe looks the
same.

To test whether the problem is in HeightField or somewhere in the
TerrainTile, I added the heightfield to a geode - and it looked fine at all
sizes.

I realize that VPB generates 64*64 tiles, and this is a non-issue when using
tiles of that size, but I thought I'd see if there was an explanation out
there.  I have looked through the forums, but may have missed something
about this issue (or feature?), so my apologies if this has been discussed
already.

Thanks,
Tom


    osg::ref_ptr<osgTerrain::TerrainTile> terrainTile = new
osgTerrain::TerrainTile;
    osg::ref_ptr<osgTerrain::Locator> locator = new osgTerrain::Locator;
    osg::ref_ptr<osgTerrain::ValidDataOperator> validDataOperator = new
osgTerrain::NoDataValue(-100.0);
    osg::ref_ptr<osgTerrain::Layer> lastAppliedLayer;

locator->setCoordinateSystemType(osgTerrain::Locator::PROJECTED);
locator->setTransformAsExtents(-100., -100., 100., 100.);

osg::Texture::FilterMode filter = osg::Texture::LINEAR;

unsigned int layerNum = 0;

osg::ref_ptr<osg::HeightField> hf = new osg::HeightField();
hf->allocate(254,254);//looks as expected
//hf->allocate(256,256);//funny triangles
//hf->allocate(256,512);//funny triangles over first half
hf->setOrigin(osg::Vec3(-50., -50., 0.));
    hf->setXInterval(1.0f);
    hf->setYInterval(1.0f);
    hf->setSkirtHeight(1.0f);
for (int c=0; c<hf->getNumColumns(); c++)
{
for (int r=0; r<hf->getNumRows(); r++)
{
if(r%20 == 0) hf->setHeight(c, r, 20.0f);
else hf->setHeight(c, r, 0.0f);
}
}

osg::ref_ptr<osgTerrain::HeightFieldLayer> hfl = new
osgTerrain::HeightFieldLayer(hf.get());

hfl->setLocator(locator.get());
hfl->setValidDataOperator(validDataOperator.get());
hfl->setMagFilter(filter);

terrainTile->setElevationLayer(hfl.get());
    lastAppliedLayer = hfl.get();
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to