Hi, I am new to OSG and I am attempting to port some work that was done in directX over to OSG. I am using some of the basic geometric objects like osg::box and osg::sphere. I got those working like I wanted, but when I tried to add texture mapping to them the results are very different than what I got in DirectX. For example, by default in directX when I mapped a texture to a box then each face got a full copy of the texture. However, when I map the same texture to the box in osg I get some weird stretched lines over the faces.
Do the standard geometric objects not have texture coordinates already defined, or am I doing something simple wrong? I have listed a code snippet below. I have also tried using all of the different texture modes, and none of them really worked. Do I have to set the texture coords up manually? Seems to defeat the purpose of having simple objects predefined if I have to do a bunch of manual texture corrdinate code for each one. I have attached an image example showing the difference between the directx and osg versions. Code: osg::ref_ptr<osg::MatrixTransform> gNode = new osg::MatrixTransform(osg::Matrix::translate(osg::Vec3(0, 0,0))); osg::ref_ptr<osg::ShapeDrawable> boxDrawable = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0,0,0), 10, 10, 10)); osg::ref_ptr<osg::Geode> box = new osg::Geode; box->addDrawable(boxDrawable.get()); gNode->addChild(box.get()); root->addChild(gNode.get()); osg::ref_ptr<osg::Image> image = osgDB::readImageFile("gravel.bmp"); osg::StateSet* state = box->getOrCreateStateSet(); state->setTextureAttributeAndModes(0, new osg::Texture2D(image.get())); Thank you! Cheers, David ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=24516#24516 Attachments: http://forum.openscenegraph.org//files/textureexamples_200.jpg _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org