Rotating an Animated mesh scene node

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
halo205
Posts: 5
Joined: Sat Sep 21, 2013 9:54 pm

Rotating an Animated mesh scene node

Post by halo205 »

Hello everyone, i'm very new to 3D engines and Irrlicht.
I did some Tutorials with creating a cube scene node and rotating it.
But if i load a custom 3D Model as an animatedMeshScene Node and try to rotate it,
it does not behave like for example the cube scene node.
I think the reason is that the point of origin from the cube scene node is at its center
and the point of origin from my model is somewhere outside of it, i think bottom left corner.

It there a way to rotate my model so that it will behave like the cube ?


thanks in advance
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Rotating an Animated mesh scene node

Post by mongoose7 »

Combine (translate to centre) x (rotate) x (translate from centre).

Or go back into your modeller and translate it there. The mesh that Irrlicht is loading has absolute vertex positions so you cannot expect it to know where the centre is.
halo205
Posts: 5
Joined: Sat Sep 21, 2013 9:54 pm

Re: Rotating an Animated mesh scene node

Post by halo205 »

Thanks for your answer, mongoose7!

But could you show me some example code snipplet for it ?
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Rotating an Animated mesh scene node

Post by smso »

halo205
Posts: 5
Joined: Sat Sep 21, 2013 9:54 pm

Re: Rotating an Animated mesh scene node

Post by halo205 »

Hello smso,
i just tried your given code snippets
rotateNodeInWorldSpace and
rotateNodeInLocalSpace

and changed them a little so it would work for AnimatedMeshSceneNode.
I Called rotateNodeInWorldSpace(myModel, 90,core::vector3df(0,1,0)) to rotate it around its y axis,
but it still does not rotate around "itself" but around another axis.
the same Happens with rotateNodeinLocalSpace :(
halo205
Posts: 5
Joined: Sat Sep 21, 2013 9:54 pm

Re: Rotating an Animated mesh scene node

Post by halo205 »

or can anyone show me a small and easy program to change the translation of the coordinate system?
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Rotating an Animated mesh scene node

Post by smso »

It seems that your model is not centered at the origin. Try revolveNodeInLocalSpace() instead.

Code: Select all

void revolveNodeInLocalSpace(scene::ISceneNode* node, f32 degs, const core::vector3df& axis, const core::vector3df& pivot)
...
pivot is the offset from the origin

Regards,
smso
halo205
Posts: 5
Joined: Sat Sep 21, 2013 9:54 pm

Re: Rotating an Animated mesh scene node

Post by halo205 »

Thanks a lot!
This method worked for me,
though it was a bit of try and error to find a good pivot vector
Post Reply