tags:

views:

152

answers:

1

Hello. I am having a real headache trying to set a node's local position to match a given world position.

I was given a solution but, AFAICS, it only takes into account orientation and position but NOT scaling :

node_new_local_position = node_parent.derivedOrientation().Inverse() * ( world_position_to_match - node_parent.derivedPosition() );

The node in question is a child of node_parent; node_parent local and derived properties (orientation, position and scaling) are known, as well as its full matrix transform.

All the positions are 3d vectors; the orientation is a quaternion; the full transform is a 4x4 matrix.

Could someone please help me to modify the solution to support scaling in the node hierarchy?

Many thanks in advance,

Bill

+1  A: 

I'm no expert in ogre3d but I guess you would need something like:

 node_new_local_position =  node_parent._getFullTransform ().inverse() * world_position_to_match;

where _getFullTransform ().inverse() is a full 4 x 4 inverse of node_parents transform.

EDIT: It looks like maybe you should just use _setDerivedPosition which does exactly what you're trying to accomplish.

Andreas Brinck
I didn't imagine it would be that simple! Thanks!
Bill Kotsias
@Bill Sometimes you get lucky ;)
Andreas Brinck