Hi

for cube you have 8 vertices, and you provide only 4 tex coord values. Besides 
that, to do what you want, you need to duplicate vertices for different faces, 
as you need different tex coord values for same vertex position on different 
faces. Easy way is to not use indexed DrawElements for first try, and just 
provide vertices and tex coords for each face by values (so total of 24 
position-texcoord pairs, 4 per face).

Cheers.

14.02.2013, 12:23, "Sajjadul Islam" <[email protected]>:
> 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
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to