How to rotate a Node around a user specific axis ?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
paddy
Posts: 25
Joined: Tue Oct 23, 2007 12:30 pm

How to rotate a Node around a user specific axis ?

Post by paddy »

Hi there,

as my question in the beginners forum isnt solved till now, I'm asking the last part of it here. Is it possible (btw it is) to rotate a Node around an axis != X, Y, Z ?

I'm not that into mathematics. I have the angle and the axis (vector3df). But no idea how to apply this to a Node.

Is there any possibilty to split up the axis vektor so it fits into the normal X / Y / Z Rotation ? But then i need 2 more angles right ?

Maybe its more easier using matrix4 functons ?

paddy3k
doqkhanh
Posts: 158
Joined: Sat Mar 01, 2008 3:14 am
Location: Tokyo, Japan
Contact:

Re: How to rotate a Node around a user specific axis ?

Post by doqkhanh »

paddy wrote:Is it possible (btw it is) to rotate a Node around an axis != X, Y, Z ?
Read a computer graphic course for very basic thing like this..

The answer is: YES

Try apply to your node:

Code: Select all

node->setRotate(core::vector3df(0.0,180.0,0.0));

node->setRotate(core::vector3df(18.0,0.0,0.0));

node->setRotate(core::vector3df(0.0,0.0,18.0));
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

In case you mean custom axis (like rotation relative to already rotated node):

Code: Select all

vector3df axis;
irr::core::matrix4 m;
m.setRotationDegrees(axis);
irr::core::matrix4 n;
n.setRotationDegrees(yourRotation);
m *= n;
vector3df rot = m.getRotationDegrees();
Look at this post if you need it for turn pitch roll: Free Flight
Last edited by arras on Sun Mar 16, 2008 5:44 pm, edited 1 time in total.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: How to rotate a Node around a user specific axis ?

Post by rogerborg »

doqkhanh wrote:
paddy wrote:Is it possible (btw it is) to rotate a Node around an axis != X, Y, Z ?
Read a computer graphic course for very basic thing like this..

The answer is: YES

Try apply to your node:

Code: Select all

node->setRotate(core::vector3df(0.0,180.0,0.0));

node->setRotate(core::vector3df(18.0,0.0,0.0));

node->setRotate(core::vector3df(0.0,0.0,18.0));

Image

Oh, the humanity!
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
doqkhanh
Posts: 158
Joined: Sat Mar 01, 2008 3:14 am
Location: Tokyo, Japan
Contact:

Post by doqkhanh »

axis != X, Y, Z ? :shock:
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

doqkhanh wrote:axis != X, Y, Z ? :shock:
Actually, buddy, it is the X, Y, Z axis that you showed how to rotate around.

He wants to know how you could define an axis of say...{1,1,0} and then rotate the node around that. (X = {1,0,0}; Y = {0,1,0}; Z = {0,0,1}.)
TheQuestion = 2B || !2B
Post Reply