Results 1 to 4 of 4

Thread: Texture coordinates

  1. #1
    Junior Member
    Join Date
    Apr 2006
    Posts
    14

    Texture coordinates

    Hello
    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:
    Code :
       <library_geometries>
          <geometry id="Plane01-obj" name="Plane01">
             <mesh>
                <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>
                   <technique_common>
                      <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>
                      </accessor>
                   </technique_common>
                </source>
                <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>
                   <technique_common>
                      <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>
                      </accessor>
                   </technique_common>
                </source>
                <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>
                   <technique_common>
                      <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>
                      </accessor>
                   </technique_common>
                </source>
                <vertices id="Plane01-obj-vertex">
                   <input semantic="POSITION" source="#Plane01-obj-position"></input>
                </vertices>
                <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>
                </triangles>
             </mesh>
          </geometry>
       </library_geometries>

    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.

    i think i've just solved it, 3dsmax texture coordinates differ from those in dx omg :P

  2. #2
    Senior Member
    Join Date
    Jul 2004
    Location
    Santa Clara
    Posts
    356
    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 ..

  3. #3
    Junior Member
    Join Date
    Jun 2006
    Location
    Alameda, CA
    Posts
    7

    Re: texture coordinates

    (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

  4. #4
    Senior Member
    Join Date
    Jul 2004
    Location
    Santa Clara
    Posts
    356
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •