Use a matrix for position / rotation & scale

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Use a matrix for position / rotation & scale

Post by Valmond »

Hi again!

Can you just 'set' the matrix of a scene node(didn't find any accessors)?

The output from the terrain editor I'm using gives a matrix for any (static) object placed on the map, do I
have to extract position, rotation and scale and use setPosition(...) etc. in the node or is there a way to use the matrix directly?

If not, is there a simple way to extract those information from the matrix (my math is a bit rusty^^)?
(BTW right side of matrix isn't clogged by the editor so seems it's always 0,0,0,1)


Thanks!
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Post by Valmond »

I can also export the data with position, scale and a quaternion, maybe I should go with that instead...
jpoag
Posts: 25
Joined: Mon Aug 10, 2009 1:00 am

Post by jpoag »

CMatrix4 seems to have the necessary 'get' methods. I looked at getRotation codeand it seems to get the rotation directly from the matrix (instead of a stored rotation variable).

getTranslation (position) looks like it does the same (although than one is easy). So does getScale....

So maybe load up your matrix from your tool into a CMatrix4 and use the 'get' functions to get the transforms for the scene node?
-James
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

rotation and scale are interleaved, so you have to apply some more math than what is currently in the matrix class. Going via separated values is definitely simpler.
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Post by Valmond »

Thanks!

Hybrid, what exactly do you mean by "separated values"?

I thought that to get the values I'd use some vectors that I'll transform by the
matrix and then extract rotation, position and scale from them, is that what you have in mind?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Valmond wrote:I can also export the data with position, scale and a quaternion, maybe I should go with that instead...
I meant these separated values!
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Post by Valmond »

Yes that's probably the way to go, thanks!
cheshirekow
Posts: 105
Joined: Mon Jul 27, 2009 4:06 pm
Location: Cambridge, MA

Post by cheshirekow »

Put a dummytransformationscenenode as the parent ofthe node you want to transform. You can access the matrix of that node directly. There is a getter method that returns a reference to the underlying transformation matrix.
Post Reply