I have some kind of stupid problem. I'd like to set an absolute position of a child where the parent has been rotated.
Example:
My parent is at 0,0,10.
My child shall be at 5,0,10 (absolute)
So for setting an absolute position I do the following (where absPosition is the wanted absolute position vector):
Code: Select all
ISceneNode* parent = node->getParent();
if( parent )
{
parent->updateAbsolutePosition();
matrix4 m = parent->getAbsoluteTransformation();
matrix4 n = node->getAbsoluteTransformation();
vector3df t = m.getTranslation();
vector3df p = absPosition - t;
node->setPosition( p );
node->setRotation( n.getRotationDegrees() );
node->setScale( n.getScale() );
}
Here come two screenshots to show what I mean:
1)
Cube 1 is created.
Cube 2 is created with cube 1 as parent
Cube 1 is rotated.
set absolute position for cube 1 at 0,0,10 (via setPosition)
set absolute position for cube 2 at 5,0,10 (function above)
Now I expect to see it like this (both cubes are rotated as cube 2 is the child of cube 1):

But actually it looks like this (it looks like the setPosition function from above just uses the new rotation values from cube 1 for positioning instead of setting it to the wanted absolute world coordinates of 5,0,10):

THANKS!
