[collada]scale and positions

Started by
9 comments, last by giugio 15 years, 4 months ago
Hy. I'm still creating a collada importer. 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:
<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? THanks. [Edited by - giugio on December 1, 2008 7:26:06 AM]
Advertisement
up up ip !
Yes, it is possible that you need to multiply all positions. To be correct, the rotation element of the transform must also be applied to the normals.
http://www.better-than-real.net/sb/
You need to construct a transformation matrix that does the scale, rotation and translation (in that order), and your model will appear fine.

The Visual Scene Node will tell you which mesh to apply it to, in this case "Cylinder12" I believe. Or the mesh may tell you which Visual Scene Node to pull the information from, which would be "Cylinder12-node" - I can't quite remember the direction of the data flow.
i try this,for only 2 meshes:
this is a part of the xml:

<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):
   D3DXMATRIX mxRotate;   D3DXMATRIX mxScale;   D3DXMATRIX mxTranslate;	   D3DXMATRIX mxRotate1;   D3DXMATRIX mxScale1;   D3DXMATRIX mxTranslate1;	//B-floor-meshD3DXMatrixRotationX(&mxRotate,-240);				D3DXMatrixTranslation(&mxTranslate,0.234062,-1.04631,0.148801);				D3DXMATRIX World1= mxTranslate  * mxRotate1 ;				Device->SetTransform(D3DTS_WORLD, &World1);							pfloormesh>DrawSubset(0);//f430D3DXMatrixRotationX(&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.
thanks in advance.
You need to apply the transformations from down to up in the file, which means from last to first. For D3DX matrices, this would be RotationMatrx * TranslationMatrix, not the other way around.

Have fun with that overengineered mess of indirection that the Collada file format is. I'm also in the process of implementing a Collada loader for the Assimp library at the moment, and it's an experience that keeps me shaking my head about so much needless complexity. This specification is two features short of Turing completeness. The only good message is that any Collada files I encountered upto now are machinally created and use only a very small subset of what's possible within the specification.

----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
Yeah it is a bit complex, but we aren't supposed to be messing with the Collada files themselves (although I do myself) - it was designed to be an interchange format so had to cater for most eventualities. The intention is to use the Collada refinery to convert the data into some proprietary binary form for our engines :)
Thanks , i'm still understand,and for rotate...
<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 meshes of 254 meshes)?
thanks.
Look into the Collada specification. A rotation is given as an axis (3D vector) and an angle (scalar, in degrees). D3DX propably has a helper function that can construct a matrix out of these elements.

Beware that Collada scenes are always in a right-handed coordinate system, but DirectX uses a left-handed coordinate system. You'll have to convert the data for yourself.
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
and..
Quote:Original post by giugio
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 meshes of 254 meshes)?
thanks.


I have again a doubt :
if i apply the transform at 2 meshes:

D3DXMatrixTranslation(&mxTranslate,0.234062,-1.04631,0.148801);D3DXMATRIX World1= mxTranslate  * mxRotate1 ;Device->SetTransform(D3DTS_WORLD, &World1);pfloormesh>DrawSubset(0);//f430D3DXMatrixRotationX(&mxRotate1,-240);D3DXMatrixTranslation(&mxTranslate1,0.642309, -0.148944 ,0.442514);D3DXMATRIX World2= mxTranslate1 * mxRotate1; Device->SetTransform(D3DTS_WORLD, &World2);


the second mesh inherith the position also from the first transform mesh?
or i must apply a 0 transfom matrix?

thanks.

This topic is closed to new replies.

Advertisement