Texture coordinates

I’m working on some directx application and want to read meshes from collada. I create geometry by reading info about vertex position and indices, and everything is ok, i can render correct objects, but when i want to apply textures on object i got problem with texture coordinates.

the image below shows how my object looks in 3dsmax (a simple example with plane):

here is the part of the code after exporting it from max:

      <geometry id="Plane01-obj" name="Plane01">
            <source id="Plane01-obj-position">
               <float_array id="Plane01-obj-position-array" count="12">-0.500000 -0.500000 0 0.500000 -0.500000 0 -0.500000 0.500000 0 0.500000 0.500000 0</float_array>
                  <accessor source="#Plane01-obj-position-array" count="4" stride="3">
                     <param name="X" type="float"></param>
                     <param name="Y" type="float"></param>
                     <param name="Z" type="float"></param>
            <source id="Plane01-obj-normal">
               <float_array id="Plane01-obj-normal-array" count="12">0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000</float_array>
                  <accessor source="#Plane01-obj-normal-array" count="4" stride="3">
                     <param name="X" type="float"></param>
                     <param name="Y" type="float"></param>
                     <param name="Z" type="float"></param>
            <source id="Plane01-obj-mapchan-1">
               <float_array id="Plane01-obj-mapchan-1-array" count="12">0 0 0 1.000000 0 0 0 1.000000 0 1.000000 1.000000 0</float_array>
                  <accessor source="#Plane01-obj-mapchan-1-array" count="4" stride="3">
                     <param name="S" type="float"></param>
                     <param name="T" type="float"></param>
                     <param name="R" type="float"></param>
            <vertices id="Plane01-obj-vertex">
               <input semantic="POSITION" source="#Plane01-obj-position"></input>
            <triangles material="_01_-_Default" count="2">
               <input semantic="VERTEX" source="#Plane01-obj-vertex" offset="0"></input>
               <input semantic="NORMAL" source="#Plane01-obj-normal" offset="1"></input>
               <input semantic="TEXCOORD" source="#Plane01-obj-mapchan-1" offset="2" set="1"></input>

0 0 0 1 1 1 3 2 3 3 2 3 2 3 2 0 0 0 </p>

i thought that every vertex (x,y,z) got corresponding (u,v,w) coords. This is how i think:

x y z u v w
-0.500000 -0.500000 0 0 0 0
0.500000 -0.500000 0 1.000000 0 0
-0.500000 0.500000 0 0 1.000000 0
0.500000 0.500000 0 1.000000 1.000000 0

indices for vertices
0 1 3 3 2 0

as you can see the (0,0) texture coords goes for vertex 0 which is different with that what i got in 3dsmax.

i understad the vertex positions but don’t understand the way how collada define texture coordinates. maybe you could give me some links where i can read about it. :oops: :cry:

i think i’ve just solved it, 3dsmax texture coordinates differ from those in dx :oops: omg :stuck_out_tongue:

TEXCOORD semantic is using “Plane01-obj-mapchan-1” source.
Reading the <accessor> you will find that:

STR[0]= (0,0,0)
STR[1]= (1,0,0)
STR[2]= (0,1,0)
STR[3]= (1,1,0)

If you look at the VERTEX and TEXCOORD for the triangles, you will find in that particular case that the texcoord index is always identical to the vertex index.

So your interpretation is corect.

Please note that COLLADA will give you the same result weither it is exported from Max or Maya or XSI …

(newbie question)

Do S,T TEXCOORDS behave as they do in VRML, and are generally scaled from 0.0 -> 1.0? must they be in relation to size of the the source image (say, a 150x237 .gif would have S range to 150, etc) , or something else? Can they be negative?

thanks in advance
newbie Chris

There is no relation between the texture coordinates and the size of the image.
Texture coordinates can be negatives, and the absolute value can be larger than one if you want to repeat the same image several times on the same geometry.