Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: collada model and positions

  1. #1

    collada model and positions

    Hy.
    I'm still creating a collada importer in c++.
    I'm at struggling with a multi mesh file.
    Now the problem is that some of the meshes in the collada file appear little and the position is wrong.
    I see that in collada file there are some element like this:
    Code :
    <node id="Cylinder12-node" name="Cylinder12" type="NODE">
    <translate>0.618008 -0.674383 0.225838</translate>
    <rotate>0.57735 0.57735 0.57735 -240</rotate>
    <scale>0.873267 0.873267 0.873267</scale>
    <instance_geometry url="#Cylinder12-mesh">
    <bind_material>
    <technique_common>
    <instance_material symbol="ColorMaterial_B1581A00" target="#ColorMaterial_B1581A00"/>
    </technique_common>
    </bind_material>
    </instance_geometry>
    </node>
    that is under the <library_visual_scenes>
    is possible thath i must apply the scale rotate and translate transformation to my mesh?
    How do the visual scene node?
    I try to apply those tranformation , but the positions are the same , wrong.
    THanks.

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771
    A <node> is COLLADA is a "place", i.e. a local coordinate system.

    You example describes a geometry that is instantiated in that place with a transformation of M=TRS.

  3. #3
    Member
    Join Date
    Feb 2005
    Location
    San Jose, CA
    Posts
    63
    You could apply your <translate> <rotate> <scale> to your meshes, but those elements are optional elements, not required.
    Try to break your collada file into simpler case. take off your <rotate> and <scale> elements and test them one at a time.

    remember that node is not directly under library_visual_scenes, it is under visual_scene.
    <library_visual_scenes>
    <visual_scene>
    <node> ... </node>
    </visual_scene>
    </library_visual_scenes>

    You could also draw a small cube at (0,0,0) so that you can have a relative position and size to compare your objects at your transform, because your camera orientation could affect the final object's position and size on the screen.

    BTW, the <rotate> values are wrong.
    It should be something like <rotate>1 0 0 -240</rotate> for rotating -240 on x-axis only.

  4. #4
    this is a part of the xml:

    Code :
    <node id="F430-node" name="F430" type="NODE">
            <translate>0.642309 -0.148944 0.442514</translate>
            <rotate>0.57735 0.57735 0.57735 -240</rotate>
            <instance_geometry url="#F430-mesh">
              <bind_material>
                <technique_common>
                  <instance_material symbol="body_color" target="#body_color">
                    <bind_vertex_input semantic="CHANNEL1" input_semantic="TEXCOORD" input_set="1"/>
                  </instance_material>
                  <instance_material symbol="black_rear" target="#black_rear">
                    <bind_vertex_input semantic="CHANNEL1" input_semantic="TEXCOORD" input_set="1"/>
                  </instance_material>
                  <instance_material symbol="difusor" target="#difusor"/>
                  <instance_material symbol="glass" target="#glass"/>
                </technique_common>
              </bind_material>
            </instance_geometry>
          </node>
     
    ..
    ...
          <node id="B-floor-node" name="B-floor" type="NODE">
            <translate>0.234062 -1.04631 0.148801</translate>
            <rotate>0.57735 0.57735 0.57735 -240</rotate>
            <instance_geometry url="#B-floor-mesh">
              <bind_material>
                <technique_common>
                  <instance_material symbol="floor" target="#floor"/>
                </technique_common>
              </bind_material>
            </instance_geometry>
          </node>
    The meshes appareance is ok , but the position is wrong
    I use this code (directx):
    Code :
     
       D3DXMATRIX mxRotate;
       D3DXMATRIX mxScale;
       D3DXMATRIX mxTranslate;	
       D3DXMATRIX mxRotate1;
       D3DXMATRIX mxScale1;
       D3DXMATRIX mxTranslate1;	
    //B-floor-mesh
    D3DXMatrixRotationX(&mxRotate,-240);
    				D3DXMatrixTranslation(&mxTranslate,0.234062,-1.04631,0.148801);
    				D3DXMATRIX World1= mxTranslate  * mxRotate1 ;
    				Device->SetTransform(D3DTS_WORLD, &World1);
     
    				pfloormesh>DrawSubset(0);
     
    //f430
    D3DXMatrixRotationX(&mxRotate1,-240);
    				D3DXMatrixTranslation(&mxTranslate1,0.642309, -0.148944 ,0.442514);
    				D3DXMATRIX World2= mxTranslate1 * mxRotate1; 
    				Device->SetTransform(D3DTS_WORLD, &World2);
     
    				pf430mesh->DrawSubset(0);

    the position are not precise.

  5. #5
    nobody?
    for rotate...
    i have :<rotate>0.57735 0.57735 0.57735 -240</rotate>
    the angle ok , but the 0.57735 0.57735 0.57735 are the component?
    and in directx what i must transform and how for this rotation?
    and.. i must to apply the transformation for each poly from last to begin or i can do as in the my example code ( only 2 poly of 254 poly)?
    thanks.

  6. #6
    Member
    Join Date
    Feb 2005
    Location
    San Jose, CA
    Posts
    63
    I am not very good in DirectX, but I will try my best to help you.

    Please try this to draw it a (0, 0, 0) without rotation.
    D3DXMatrixTranslation(&mxTranslate, 0.0, 0.0, 0.0);
    D3DXMATRIX World1= mxTranslate;
    Let's make sure that there are nothing in the transform stack.

    If that's okay, try to draw only with the translate.
    D3DXMatrixTranslation(&mxTranslate,0.234062,-1.04631,0.148801);
    D3DXMATRIX World1= mxTranslate;

    If that's okay, then something might be wrong in the rotate for rotate matrix multiplication.


    For the Rotation:
    if you want to do x-axis rotation
    D3DXMatrixRotationX(&mxRotate,-240);
    your collada <rotate> element should be
    <rotate>1 0 0 -240</rotate>

    Thanks,
    Herbert

  7. #7
    Quote Originally Posted by uclahklaw
    I am not very good in DirectX, but I will try my best to help you.

    Please try this to draw it a (0, 0, 0) without rotation.
    D3DXMatrixTranslation(&mxTranslate, 0.0, 0.0, 0.0);
    D3DXMATRIX World1= mxTranslate;
    Let's make sure that there are nothing in the transform stack.
    I use vs 2005,
    what is and where i can read the transform stack in vs?
    Thanks

  8. #8
    Member
    Join Date
    Feb 2005
    Location
    San Jose, CA
    Posts
    63
    I don't know much about DirectX, I know OpenGL.

    In OpengGL:
    glLoadIdentity() is the API to clear the transform stack,
    You add a transformation matrix to the transform stack by some API like glTranslatef, glRotatef, and glScalef, etc.

    Someone who knows about DirectX and OpenGL might be able to explain better.

    Thanks,
    Herbert

  9. #9
    Junior Member
    Join Date
    Jun 2006
    Location
    Morrison, CO
    Posts
    22
    I don't know much about DirectX, I know OpenGL.
    And I don't know much about either But this is probably a good place to start for the DirectX answers:

    http://msdn.microsoft.com/en-us/library/bb147181(VS.85).aspx

  10. #10
    Quote Originally Posted by marcus
    A <node> is COLLADA is a "place", i.e. a local coordinate system.

    You example describes a geometry that is instantiated in that place with a transformation of M=TRS.
    But I have a collada file with 200 meshes and i would render only 3 meshes, and i ask you if these meshes are "linked" or indipendent.
    Linked if i must apply all the 200 transformation and render all 200 meshes or indipendent if i can apply only the 3 transformation of the 3 meshes nodes.
    Thanks.

Page 1 of 2 12 LastLast

Posting Permissions

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