Dumb question about coordinates Topic is solved

Problems building or running the engine, queries about how to use features etc.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 339
Joined: Fri May 23, 2025 5:04 pm
x 24

Dumb question about coordinates

Post by slapin »

Hi, all!
Maybe it is too late for questions like that but that is kind of omission I have.
I have scene node like

Code: Select all

Ogre::SceneNode *pNode;

set to some node in scene. For that node I need to get/set

  1. local (parent) space position/orientation
  2. global space position/orientation.
    How can I get these properly? For global space coordinates I can getDerivedPosition()/getDerivedOrientation(). But what about local space?
    what is difference between _getDerivedPosition() and getPosition()?
    Till now I used global space and magic tricks to avoid digging deeper but now it is time to know for sure.
rpgplayerrobin
Bugbear
Posts: 803
Joined: Wed Mar 18, 2009 3:03 am
x 462

Re: Dumb question about coordinates

Post by rpgplayerrobin »

It depends on what you need it for, but first check the actual functions in the source code:

Code: Select all

        /** Gets the position of the node relative to it's parent.
        */
        const Vector3 & getPosition(void) const { return mPosition; }
        
/** Gets the position of the node as derived from all parents. */ const Vector3 & Node::_getDerivedPosition(void) const { if (mNeedParentUpdate) { _updateFromParent(); } return mDerivedPosition; }

But that is not always needed either.
For example, when I get the world position of a bone, I use this code:

Code: Select all

// Gets the world position of a bone
Vector3 CGeneric::GetPosition(Bone* bone, SceneNode* node)
{
	Vector3 p = node->_getFullTransform() * bone->_getDerivedPosition();
	return p;
}

You can also just visualize it yourself by creating an object and placing it at the position of another objects getPosition/_getDerivedPosition to understand the difference.
Many times those might be the exact same position, unless you have hierarchies of nodes.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 339
Joined: Fri May 23, 2025 5:04 pm
x 24

Re: Dumb question about coordinates

Post by slapin »

Thanks, I was concerned I had some wrong understanding of things but now I got my confidence back.