OGRE convertWorldtoLocalPosition

Get answers to all your basic programming questions. No Ogre questions, please!
robel
Halfling
Posts: 97
Joined: Fri Sep 28, 2012 4:12 pm

OGRE convertWorldtoLocalPosition

Post by robel »

Hi,
i have just one question : what it done exactelly when we make

Code: Select all

Node->convertWorldtoLocalPosition(PosA)
i know that we calculate with that the local coordiante space of Node BUT how ogre do that ?
any idea ?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 535

Re: OGRE convertWorldtoLocalPosition

Post by Kojack »

Code: Select all

return mDerivedOrientation.Inverse() * (worldPos - mDerivedPosition) / mDerivedScale;
It finds the vector offset from the node's derived position to the worldPos you want to convert, rotates it by the inverse of the node's derived orientation and scales it by the inverse of the node's derived scale.
robel
Halfling
Posts: 97
Joined: Fri Sep 28, 2012 4:12 pm

Re: OGRE convertWorldtoLocalPosition

Post by robel »

i did not understand those parameters
mDerivedPosition):vector offset from the node's derived position
derived position is not worldpos?
mDerivedScale :the inverse of the node's derived scale
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 535

Re: OGRE convertWorldtoLocalPosition

Post by Kojack »

derived position is world position. The full name could be derived world position, because that's what it does. It doesn't store a user specified world position, instead it derives it from the node's parent.
Same for scale and orientation.
robel
Halfling
Posts: 97
Joined: Fri Sep 28, 2012 4:12 pm

Re: OGRE convertWorldtoLocalPosition

Post by robel »

derived position is world position
if derived position is worl pos that mean (worldPos - mDerivedPosition) =0 no ?

i di not understand this :
It doesn't store a user specified world position,
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 535

Re: OGRE convertWorldtoLocalPosition

Post by Kojack »

mDerivedPosition is the effective world position of the node.
worldPos is the parameter you pass to convertWorldtoLocalPosition, it's the position you want to convert from world to local space. In your top post it's called PosA (the actual parameter name is worldPos, I just copied/pasted it from the source code).
So (worldPos - mDerivedPosition) is really doing (your world pos - node's world pos), which is the offset from the node to your PosA.
i di not understand this :
It doesn't store a user specified world position,
What I mean is that if people looked at the node and saw there's a member called something like mWorldPosition they might think it can be set directly, such as putting a value in there and thinking that's the new world pos. But mDerivedPosition is calculated from all the parent nodes right back to the root. So you never actually set that value directly, you can only set local offsets from a parent node.