core::matrix4 m;
m.setRotationDegrees(core::vector3df(0,140,0));
std::cout<<"debug : "<<m.getRotationDegrees().Y<<std::endl;
Output :
debut : 40
With other rotation angles, here is what I get:
set rot ---- get rot
10 --------- 10
90 --------- 90
180 ------- 5*10^-6
250 ------- 290
360 ------- 1*10^-5
Err?
Last edited by stefbuet on Tue Mar 09, 2010 7:02 pm, edited 1 time in total.
have you looked at the other angles (x,z) it generates? Euler angles aren't great at defining a rotation; different values can give the same result. For example, the (0,180,0) could be done with (180,0,180) too. Also they will be looped within [0,360), hence the 360->~0.
For the 250 and 140 angles I can't say with certainty that this is what's happening, but it's very likely. You should store the values yourself if you need to use them later, or use quaternions for more control.
I got it's parent position/rotation.
And I got the child position/rotation.
Without adding the child to the parent, I want to be able to calculate the child position/rotation as if it were a real child of the parent node.
So basicaly what I did is creating 2 matrices, first one for the parent in which I used setTranslation and setRotationDegrees functions, and second one for the child with translation/rotation informations added too.
Once matrices are filled by translation/rotation data, to get the resulting child position, I was just multiplying matrices like that :
But as you see, my proper way is not really working.
How could I use matrices to do that? Is there a really need or quaternion?
Or the only way is to do it myself with cos/sin attacks ? :p
core::matrix4 m,n;
parent->updateAbsolutePosition();
m = parent->getAbsoluteTransformation();
n = child->getTransformation();
core::vector3df pos = child->getPosition();
m.translateVect(pos);
m.rotateVect(pos);
child->setPosition(pos);
n *= m;
child->setRotation(n.getRotationDegrees());
I don't know what scale would do to that code so be careful.