Set scene node transformation

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
luke

Set scene node transformation

Post by luke »

Hello!

There seems not to be way to set the relative transformation matrix directly to a scene node. How do you recommend my to do this, I try to use Irrlicht with my self made rigid body physics. I just need to set the rotation part right. I can set position easily, but how do I set the rotation part to scene node?

// Set position works
vec3 t = mat.getTranslate();
body_node->setPosition( core::vector3df(t.x, t.y, t.z) );

// Sertting rotation to scene node (just trying something)
quat q; q.set(mat3(mat));
vec3 r;
q.to_rotation_vector(r); // quaternion to rotation operator
r *= 180.0 / PI;
body_node->setRotation( core::vector3df(r.x, r.y, r.z) );

Not very good result. It is somehow correct on certin angles, but far from correct :(

Thank you if you can (try to) help me :D
Luke923
Posts: 59
Joined: Wed Nov 05, 2003 5:26 am

Re: Set scene node transformation

Post by Luke923 »

I don't know if this would work, but this is how I would approach this. I'm assuming that your relative transformation matrix is a typical 4X4 matrix. If that's the case, what you might want to do is:

Code: Select all

core::matrix4 IrrMat = (core::matrix4)mat;
body_node->setRotation(IrrMat.getRotationDegrees());
"Object-oriented programming is an exceptionally bad idea which could only have originated in California."
- E.W. Dijkstra
luke

Post by luke »

Yes, it works! Though rotation around some exis is wrong way but it was easy to flip. And there seems to be dead lock situatuion initially, so I think I need to find more accurate way. I don't really like doing rotation around axis, would be much better ifthere was way to use quaternion to set rotation.

I thought of writing a Scene node with such property, but it seemed to get very complicted. How is this done with ODE or Tokamak integrations? (I haven't yet looked at thos..)

But thanks a lot! Now I can go forward now that I see the car running properly :)
luke

Post by luke »

Oops, sorry, I used almost your nick! :o
I will get another nexttime or when I decide to register :D
Guest

Post by Guest »

Yeah, best was that I wrote a scene node.
Post Reply