Hi,
I'm trying to texture a triangle strip based terrain by a tif image, I use the
following codes but it does not work:
//get the texture file name
std::string textureFile = _fileName.substr(0, _fileName.length() -3) +
"tif";
std::string textureFileName = osgDB::findDataFile(textureFile, options);
if(!textureFileName.empty())
{
osg::ref_ptr<osg::Image> image =
osgDB::readImageFile(textureFileName);
osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet;
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
texture->setDataVariance(osg::Object::DYNAMIC);
texture->setImage(image.get());
osg::ref_ptr<osg::TexMat> texMat = new osg::TexMat;
texMat->setScaleByTextureRectangleSize(true);
stateSet->setTextureAttributeAndModes(0, texMat.get(),
osg::StateAttribute::ON);
stateSet->setTextureAttributeAndModes(0, texture.get(),
osg::StateAttribute::ON);
geode->setStateSet(stateSet);
}
Here is the screen shot:
http://s1354.beta.photobucket.com/user/Elistain/media/1_zps9a5eb0e3.png.html
(the terrain without texture)
http://s1354.beta.photobucket.com/user/Elistain/media/3_zpsdd2234a7.png.html
(the triangle grids after textured,the whole terrain is a signal triangle strip)
http://s1354.beta.photobucket.com/user/Elistain/media/2_zpsbf7e2902.png.html
(the original texture image)
http://s1354.beta.photobucket.com/user/Elistain/media/4_zps4209eb26.png.html
(the terrain after textured,obviously it's not correct!)
I'm looking forward for your reply!
Thanks !
Elistain
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org