Hi
Looks like your geometry does not have any texture coordinates, and you not using texgen. TexMat just transforms texture coordinates, not generate them.
Cheers.
18.03.2013, 12:04, "Elistain" <[email protected]>:
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 namestd::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:(the terrain without texture)(the triangle grids after textured,the whole terrain is a signal triangle strip)(the original texture image)(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
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

