Hi forum,
I have a textue2D object with a image and i want to warp each face of the cube
with the same texture.
In OpenGL, i generate the texture coordinates for each of the cube faces.
How do it OSG? I have been trying the following, but getting the distorted
result:
Code:
osg::ref_ptr<osg::Vec2Array> texCoords = new osg::Vec2Array;
texCoords->push_back(osg::Vec2(0.0f,0.0f));
texCoords->push_back(osg::Vec2(0.0f,1.0f));
texCoords->push_back(osg::Vec2(1.0f,1.0f));
texCoords->push_back(osg::Vec2(1.0f,0.0f));
geom->setTexCoordArray(0,texCoords.get());
The above snippet works fine for one face only and rest of the faces get
distorted.
I am rendering each element as quad follows:
Code:
// Add primitiveset to draw a cube
osg::ref_ptr<osg::DrawElementsUInt> drawingElements = new
osg::DrawElementsUInt(GL_QUADS);
//front face
drawingElements->push_back(0);
drawingElements->push_back(1);
drawingElements->push_back(5);
drawingElements->push_back(4);
//right face
drawingElements->push_back(1);
drawingElements->push_back(2);
drawingElements->push_back(6);
drawingElements->push_back(5);
...........................................
...........................................
Thanks
Sajjadul
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=52664#52664
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org