changing the axis of rotation?

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
scotchfaster
Posts: 15
Joined: Sun Feb 24, 2008 4:27 am

changing the axis of rotation?

Post by scotchfaster »

Total n00b question, but I haven't been able to figure this out.

It appears that ISceneNode::setRotation() rotates the object around the center of the bounding box (as near as I can tell). How do I go about changing this, so it rotates around some other arbitrary point?

Thanks in advance!
Jgoldnight
Posts: 31
Joined: Thu Jun 07, 2007 6:23 pm
Location: New York
Contact:

Post by Jgoldnight »

What type of visual effect are you trying to achieve? I'm not following your question exactly; a rotation about a point in space (outside of the mesh's BB) or a rotation about a different point within a mesh's BB?
Computer scientist by day...
http://www.mrjoelkemp.com
scotchfaster
Posts: 15
Joined: Sun Feb 24, 2008 4:27 am

Post by scotchfaster »

Jgoldnight wrote:What type of visual effect are you trying to achieve? I'm not following your question exactly; a rotation about a point in space (outside of the mesh's BB) or a rotation about a different point within a mesh's BB?
The second one, rotation around a different point within the mesh (not necessarily a vertex).

Basically, the mesh is a head. When it nods forward (rotating along the X axis), the origin it rotates around should be the base of the spine, not the center of the head.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Re: changing the axis of rotation?

Post by Acki »

scotchfaster wrote:It appears that ISceneNode::setRotation() rotates the object around the center of the bounding box (as near as I can tell).
that's not correct...
it rotates around it's origin !!! ;)
the origin is a point you define in your 3d modeling tool...
but this also depends on the tool you're using, for example with Milkshape3d the origin of the mesh is the point at 0,0,0 in the space of Milkshape, or with 3DSMax you can define the origin at any point in space you want... ;)

the easiest way for what you want to do is to create the mesh so its origin is at the point where the neck shall rotate...
or you create one or more bones, one bone should be at the desired position so you can rotate the bone to rotate the head around this point...
of course you also can rotate a node around any point in space you want, for an algorythm to do this search the forum, there are some threads about this... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
scotchfaster
Posts: 15
Joined: Sun Feb 24, 2008 4:27 am

Post by scotchfaster »

Hmmm...I'm not creating these meshes myself, but importing them. They are in 3DS format, but I don't see an "origin" field anywhere.

In any case, it does appear that it rotates around (0,0,0), and so my very simple solution is to offset the vertices of the mesh.

And yes, I realize that a better model would involve a torso with the head attached and using a hinge, but that's overkill for this application.

Thanks for the help!
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

scotchfaster wrote:Hmmm...I'm not creating these meshes myself, but importing them. They are in 3DS format, but I don't see an "origin" field anywhere.

In any case, it does appear that it rotates around (0,0,0), and so my very simple solution is to offset the vertices of the mesh.
right, (0,0,0) of the mesh is it's pivot/origin, but it must not be the centre of the mesh/bounding box... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply