Page 1 of 1

Rotating a model

Posted: Thu Apr 23, 2009 6:00 pm
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());

Posted: Thu Apr 23, 2009 11:52 pm
by B@z
i dont understand, why you just dont use setRotation?

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

is it too easy? xD

Posted: Fri Apr 24, 2009 1:40 am
by rakkar
That sets the absolute rotation. I want to rotate by a certain amount.

Posted: Fri Apr 24, 2009 2:07 am
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.

Posted: Fri Apr 24, 2009 3:57 pm
by vipergc
no.. setRotation() sets the rotation relative to the parent... not absolutely

Posted: Fri Apr 24, 2009 6:02 pm
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".