World Location to Entity-centered Local Position
Posted: Sun May 10, 2015 5:37 am
Let's say I have a point in world space.
This point is roughly 3 units to the left of a box.
I want to get this point's "local" point relative to the box. (EG, (3,0,0))
I want to then render something at that local point.
That way, if the entity moves or rotates, the point stays at the correct location relative to it...
and thus the rendered item appears to be part of the entity, rather than moving about on its own.
My end goal is the above, a rendered-only item appearing to be attached to an entity (the item initially is added in world space and then is attached to the entity from there)
The solution I came from is the world->local and local->world position conversions... but this doesn't account rotating the item, rather just moving it about in space.
How should I go about accomplishing this?
The best method I can come up with involves using the worldtransform/inverse of worldtransform to transform the point around and converting the quaternion to euler angles and adding/subtracting relative amounts... neither of which are particularly quick calculations, and I'd ideally want to do this for a lot of items at a pleasant 60 FPS.
(Sorry for bugging you with so many questions here, particularly when this question is not incredibly BEPU-specific... just, you're quick and helpful, and stackoverflow is neither... particularly when physics engines get involved)
This point is roughly 3 units to the left of a box.
I want to get this point's "local" point relative to the box. (EG, (3,0,0))
I want to then render something at that local point.
That way, if the entity moves or rotates, the point stays at the correct location relative to it...
and thus the rendered item appears to be part of the entity, rather than moving about on its own.
My end goal is the above, a rendered-only item appearing to be attached to an entity (the item initially is added in world space and then is attached to the entity from there)
The solution I came from is the world->local and local->world position conversions... but this doesn't account rotating the item, rather just moving it about in space.
How should I go about accomplishing this?
The best method I can come up with involves using the worldtransform/inverse of worldtransform to transform the point around and converting the quaternion to euler angles and adding/subtracting relative amounts... neither of which are particularly quick calculations, and I'd ideally want to do this for a lot of items at a pleasant 60 FPS.
(Sorry for bugging you with so many questions here, particularly when this question is not incredibly BEPU-specific... just, you're quick and helpful, and stackoverflow is neither... particularly when physics engines get involved)