Jump to content
  • Advertisement
Sign in to follow this  
giugio

transform and rotate

This topic is 3605 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.


?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!