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:
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.
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.
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.
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>
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.
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.
I call loadidentity before apply the transform and the rotation result is ok ,but there is an error in the location of the 2 meshes
i already test that the values of the translate is correct.
I must use translate or translatelocal?
thanks.
COLLADA nodes are local coordinate systems that are hierarchical when representing a transformation stack. The composition of the hierarchical transforms from the root node to a given node represents the placement of geometry that is instantiated in that node’s space. In your example the geometry with id of “Cylinder12-mesh” is in that space. This composition is repeated for each instantiation.
So depending on what you mean by your question, probably I will answer “independent”.
COLLADA is 'Rhc" (like OpenGL). DirectX is normally “Lhc” but supports RH functions too (see D3DXMatrixPerspectiveRH). I think this explanation about Direct3D Coordinate Systems from Microsoft will help you understand what approach you will want to take.
1)I think that i find the error:
The vectors that collada use for the transform in the scene node must be flipped!
I’m flip the indexes 2 with 3 when import the meshes and i think that i must flip the y with the z in the vector, may be?
for example:
this are two collada position vector:
<translate>0.642309 -0.148944 0.442514</translate>
<rotate>0.57735 0.57735 0.57735 -240</rotate>
i trasform the world coord for those vectors.
how i flip the values?
I must change also the sign?
2)i must use the rh functions(D3DXMatrixPerspectiveRH ecc…)?