开发者

3D World to Local transformation

开发者 https://www.devze.com 2022-12-24 06:30 出处:网络
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 sca

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号