Discussion:
what is setTexCoordArray?
Cory Riddell
2009-01-21 22:49:03 UTC
Permalink
I'm working my way through some of the tutorials. Right now I'm on:
http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/BasicGeometry

In the code on that page is this:

osg::Vec2Array* texcoords = new osg::Vec2Array(5);
(*texcoords)[0].set(0.00f,0.0f);
(*texcoords)[1].set(0.25f,0.0f);
(*texcoords)[2].set(0.50f,0.0f);
(*texcoords)[3].set(0.75f,0.0f);
(*texcoords)[4].set(0.50f,1.0f);
pyramidGeometry->setTexCoordArray(0,texcoords);


Can somebody explain what this is doing?

Thanks,
cr
Vincent Bourdier
2009-01-22 09:16:53 UTC
Permalink
Hi Cory,

Texture coordinates is a basic way to apply a texture on a geometry.
For each vertex, you give a 2D coordinate data to associate a vertex and a
texture point. OpenGl will interpolate the texture pixel between each
vertex, depending on theses coordinates.

The 2D texture coordinate have to be like this in your texture image:

[0,0] [1,0]
|------------|
| |
| |
| |
| |
|------------|
[0,1] [1,1]


In your example, with a single file of texture, you set the texture for each
side.
For each texture you set in OSG, you can set a texCoordinateArray.
The index you set pyramidGeometry->setTexCoordArray(*0*,texcoords);
correspond to the texture index you set before, when setting the texture.

Have a look on Texture coordinate on the web, you'll find a lot of
explanations.

Hope this will help you.

Regards,
Vincent.
Post by Cory Riddell
http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/BasicGeometry
osg::Vec2Array* texcoords = new osg::Vec2Array(5);
(*texcoords)[0].set(0.00f,0.0f);
(*texcoords)[1].set(0.25f,0.0f);
(*texcoords)[2].set(0.50f,0.0f);
(*texcoords)[3].set(0.75f,0.0f);
(*texcoords)[4].set(0.50f,1.0f);
pyramidGeometry->setTexCoordArray(0,texcoords);
Can somebody explain what this is doing?
Thanks,
cr
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Vincent Bourdier
2009-01-22 09:19:15 UTC
Permalink
Sorry, one mistake :

*"Note that OpenGL <http://www.devmaster.net/wiki/Category:OpenGL> and
Direct3D <http://www.devmaster.net/wiki/Direct3D> use different texture
coordinate conventions. In Direct3D, the texture coordinates are (0, 0) at
the top left corner, and the **v coordinate increases as you move down. In
OpenGL, the coordinates are called **s and **t instead of **u and **v, the
(0, 0) point (the origin) is at the bottom-left corner, and the **t
coordinate increases as you move up. *"

So don't consider my little drawing as right.

Vincent.
Post by Vincent Bourdier
Hi Cory,
Texture coordinates is a basic way to apply a texture on a geometry.
For each vertex, you give a 2D coordinate data to associate a vertex and a
texture point. OpenGl will interpolate the texture pixel between each
vertex, depending on theses coordinates.
[0,0] [1,0]
|------------|
| |
| |
| |
| |
|------------|
[0,1] [1,1]
In your example, with a single file of texture, you set the texture for
each side.
For each texture you set in OSG, you can set a texCoordinateArray.
The index you set pyramidGeometry->setTexCoordArray(*0*,texcoords);
correspond to the texture index you set before, when setting the texture.
Have a look on Texture coordinate on the web, you'll find a lot of
explanations.
Hope this will help you.
Regards,
Vincent.
Post by Cory Riddell
http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/BasicGeometry
osg::Vec2Array* texcoords = new osg::Vec2Array(5);
(*texcoords)[0].set(0.00f,0.0f);
(*texcoords)[1].set(0.25f,0.0f);
(*texcoords)[2].set(0.50f,0.0f);
(*texcoords)[3].set(0.75f,0.0f);
(*texcoords)[4].set(0.50f,1.0f);
pyramidGeometry->setTexCoordArray(0,texcoords);
Can somebody explain what this is doing?
Thanks,
cr
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Cory Riddell
2009-01-22 14:09:30 UTC
Permalink
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

Loading...