transform and rotate

Started by
12 comments, last by giugio 15 years, 4 months ago
Hy. I'm still creating a collada importer. My first problem is when i must rotate a collada mesh,i have a collada rotation like this: <rotate>0.57735 0.57735 0.57735 -240</rotate> How i can rotate the mesh? 240 is the degrees ok, but the other components are the axes of the rotation? and how in directx i can rotate around an axes? the secod doubt is this: when i rotate or translate two mesh ,the second mesh inerith a rotation from the first mesh? in this case i have to apply a 0 coordinate matrix? thanks.
Advertisement
Hi giugio,

use Quaternion,
with these you can rotate around a single axis and afterwards convert it into a rotation matrix (or euler angles, whatever you prefer), this you then can use for your rotation.
(Also the "games gems (1 or so)" should have a chapter about them)

gamedev ref:
quaternion

greets,
thaligar
thanks a lot , and for this doubt?
Quote:Original post by giugio
the secod doubt is this:
when i rotate or translate two mesh ,the second mesh inerith a rotation from the first mesh?
in this case i have to apply a 0 coordinate matrix?
thanks.


?
nobody?
What do you mean?

Normally each game object has its own World Matrix, so you have to scale-rotate-translate (in this order) everything alone.

Or maybe you're using some kind of engine that uses scene nodes? In this case everything that is applied to a parent node is applied to the child nodes.
is a collada importer,and in the scene section there is a node element transformation for mesh.
but I have more than one mesh, i have 200 meshes, and 200 node transformation element.
I don't know how those 200 meshes are arranged in your collada scene, but..
Let's say you have two meshes, two cubes.

If the second cube is somehow "linked" to the first, then you should:
Take the first cube matrix.
Apply it to the world matrix.
Render the first cube.
Take the world matrix as it is now.
Multiply it by the SECOND cube matrix.
Render the second cube.

If the two cubes are two independent meshes, then you just:
Take the first cube matrix.
Apply it to the world matrix.
Render the first cube.
Take the second cube matrix.
Apply it to the world matrix.
Render the second cube.

2 cents of advice: probably you should play a bit more with basic stuff like quaternions and matrix multiplication before adventuring into complex things like a collada importer :)

a.
..so we ate rare animals, we spent the night eating rare animals..
AFAIK, in COLLADA a node element may be marked with transform elements (like rotate) to define a co-ordinate frame of the node. The sequence of arcs (that's COLLADA's name of edges between the nodes) gone from the root until reaching the current node may hit as many co-ordinate frames as nodes are visited, since each node can have its own frame. The frame hit last before coming to the current node defines the parental frame.

Hence for each node the current global transform can be determined as usual by multiplying the current local transform (as given by the node's transform elements) with the parental global transform. This is what resle has described above.

However, as can be seen here, computing the current global transformation is done in a mixture of all allowed transform elements, and hence is best done by using matrices. Especially representing the rotation temporarily by a quaternion is a waste, but only a very small one (it requires just 5 more ADDs compared to directly converting axis/angle to matrix, if done right and I've counted the operations correctly).
I'm not understand all , then the nodes in collada are linked(in the resle definition)?
And if i would display only 2 meshes i must apply all the transformations from the last to the displayed node?
Thanks.
Giugio, since we're both from Italy, contact me over msn. Resle77 chiocciola hotmail punto com. So I can better explain everything to you in our native language.

a.
..so we ate rare animals, we spent the night eating rare animals..

This topic is closed to new replies.

Advertisement