Hi Wang, Most image plugins are not built to read images as height fields, then just read images as osg::Image so will only respond to osgDB::readImageFile() and return NULL if you attempt a readHeightFieldFile or a readNodeFile.
There are some specialist plugins that can read height fields, the one most likely of interest to you will be the gdal plugin. Try appending .gdal to your file names i.e. osg::ref_ptr<osg::HeightField> heightfield = osgDB::readHeightField(filename+".gdal"); You will of course need to compile the OSG against gdal to do this. Robert. On Sun, Nov 28, 2010 at 7:55 AM, wang junchao <[email protected]> wrote: > Hi, > > I've got a problem about "osgDB::readHeightField". > Now I am using the 2.9.5 version of OSG and the frequentely used plugins have > already been built when building the source code. > > As I am reading the source code of VirtualPlanetBuilder, I find it is > necessary to read the height field from the file with a suffix of ".tif". > And of course, when using the osgdem command line , nothing special happened. > However, when I am testing the scentence which reads height field I get some > trouble. > > The source code is as follows: > > #include <osg/io_utils> > #include <osgDB/ReadFile> > #include <osgDB/FileNameUtils> > > void main() > { > osg::ref_ptr<osg::HeightField> hf = > osgDB::readHeightFieldFile("test.tif"); > } > > > The question is: while executing the program , the hf returns NULL, which is > very confusing. > > If you get any idea about this, please write your answer. > Thank you very much. > ... > > Thank you! > > Cheers, > wang > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=34186#34186 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

