Rotating a model

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
rakkar
Posts: 19
Joined: Sun Aug 07, 2005 11:24 pm

Rotating a model

Post by rakkar »

If I want to rotate a model interpThisTickRotation degrees around the Y axis, is this the right way to do it?

Code: Select all

core::matrix4 modelTransformation = model->getRelativeTransformation();
core::matrix4 rotationMat;
rotationMat.setRotationDegrees(core::vector3df(0,interpThisTickRotation,0));
modelTransformation*=rotationMat;
model->setRotation(modelTransformation.getRotationDegrees());
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

i dont understand, why you just dont use setRotation?

model->setRotation(vector3df(0,interpThisTickRotation,0));

is it too easy? xD
Image
Image
rakkar
Posts: 19
Joined: Sun Aug 07, 2005 11:24 pm

Post by rakkar »

That sets the absolute rotation. I want to rotate by a certain amount.
rakkar
Posts: 19
Joined: Sun Aug 07, 2005 11:24 pm

Post by rakkar »

Here it is:

Code: Select all

model->setRotation(model->getRotation()+core::vector3df(0,interpThisTickRotation,0));
I'm used to other engines where you have to do the low-level math on everything.
vipergc
Posts: 27
Joined: Mon Mar 02, 2009 3:33 am
Location: Louisville, KY
Contact:

Post by vipergc »

no.. setRotation() sets the rotation relative to the parent... not absolutely
Co-Inventor of ZIP files.

Hardware - play with it long enough.. it BREAKS
Software - play with it long enough.. it WORKS
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I think this is a mis-understanding. By absolute, rakkar meant not-incrementing, which is just as correct as your statement. However, the method name setRotation does already hint for the fact that it's not accumulating, otherwise it would be "rotate" or "addRotation".
Post Reply