Hi,

i got this little piece of code, with which i wanna display a heightfield. I 
read that for performance reasons one should use terrainTile and add the 
heightfield to it, but i dont get it to display in the viewer? i know the 
osgTerrain example, but i find it is too big for starting. i hope someone could 
help me? 
Here is the small code:

int main() {
        osg::ref_ptr<osgTerrain::TerrainTile> terrainTile;
        osg::ref_ptr<osg::HeightField> hf;
        osg::ref_ptr<osgTerrain::HeightFieldLayer> hfl;
        osg::ref_ptr<osg::Group> group;
        osg::ref_ptr<osgViewer::Viewer> viewer;

        group                           = new osg::Group();
        terrainTile             = new osgTerrain::TerrainTile();
        hf                                      = new osg::HeightField();
        hfl                             = new osgTerrain::HeightFieldLayer();
        viewer                          = new osgViewer::Viewer();


        hf.get()->allocate(100, 100);
        hf.get()->setXInterval(10.0);
        hf.get()->setYInterval(10.0);

        for(unsigned int r=0;r<100;++r)
        {
           for(unsigned int c=0;c<100;++c)
           {
                   hf.get()->setHeight(c,r,400);
           }
        }

        hfl.get()->setHeightField(hf.get());
        terrainTile.get()->setElevationLayer(hfl.get());
        group.get()->addChild(terrainTile.get());


        viewer.get()->setSceneData(group.get());
        viewer.get()->realize();
        viewer.get()->run();
}



Thank you!

Cheers,
Thomas

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=20758#20758





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to