Page 1 of 1

one question about position.

Posted: Wed Dec 31, 2008 1:43 pm
by hzsyber
getAbsolutePosition() and getPosition() return values difference.

thanks!

Posted: Wed Dec 31, 2008 2:46 pm
by nathanf534
I believe getAbsolutePosition returns the position from the origin (0,0,0), while getPosition() returns the position relative to its parent.

Posted: Wed Dec 31, 2008 3:55 pm
by hzsyber
thanks nathanf534!

getAbsolutePosition is self origin or world origin?

and,i load a node, getAbsolutePosition and getPosition return value is equally.

how to i get a node position return from world origin?

because i load a node default position no in world origin(0,0,0).

thanks.

Posted: Wed Dec 31, 2008 6:19 pm
by vitek
hzsyber wrote:getAbsolutePosition is self origin or world origin?
World origin or (0, 0, 0) in the the world coordinate system.
hzsyber wrote:and,i load a node, getAbsolutePosition and getPosition return value is equally.
Yes. If a node is created without a parent, both of these functions will return the same value. If the node has a parent, and the parent is not at the world origin (i.e., parent->getAbsolutePosition() returns something other than (0, 0, 0)) then the values will differ.
hzsyber wrote:how to i get a node position return from world origin?
Uh... node->getAbsolutePosition() is the offset from the node position (in world coordinates) to the world origin.

Posted: Sun Jan 04, 2009 7:46 am
by hzsyber
ObjNodes->getAbsolutePosition();

reutrn Position always (0,0,0).
not my want.

Posted: Sun Jan 04, 2009 10:05 am
by arras
getAbsolutePosition() returns global (world) position regardless of what you want.

Posted: Sun Jan 04, 2009 11:14 am
by dlangdev
hzsyber wrote:ObjNodes->getAbsolutePosition();

reutrn Position always (0,0,0).
not my want.


It tells you where node is/was at (0,0,0). Can't argue with that.

Posted: Sun Jan 04, 2009 12:27 pm
by vitek
You may have to call updateAbsolutePosition() before getAbsolutePosition() will return the actual world position.

Posted: Tue Jan 06, 2009 4:42 am
by hzsyber
maybe model design no position on world origin.

i want know model and world origin length.

someone can try my model. tell me how to know?

my code:

Code: Select all

			nodes[k] = smgr->addAnimatedMeshSceneNode(smgr->getMesh(modelfile.c_str()));
//			nodes[k]->setScale(StrToV3df(scale));
			nodes[k]->setMaterialTexture(0, driver->getTexture(texturefile.c_str()));
			nodes[k]->getMaterial(0).Shininess = 50.0f;
			nodes[k]->setLoopMode(false);
			nodes[k]->setMaterialFlag(EMF_LIGHTING, false);
download model:http://www.reqi.com/md2.rar

thanks all!

Posted: Tue Jan 06, 2009 11:04 am
by rogerborg

Code: Select all

const core::aabbox3d<f32>& box = nodes[k]->getBoundingBox();
You can then use the bounding box methods to find the centre and extents of the box.

Posted: Thu Feb 05, 2009 1:14 am
by zillion42
I'm not really sure where to start, but there have been some serious confusions about a sceneNodes position, absolute position, and relative position for me... and as I read in the forum for quite a few other people...

Well as hopefully any sane person would expect a relative position is relative to its parent. If you would call getPosition() on a node with a parent you would get its position relative to its parent. Likewise if you would call getAbsolutePosition() on a node with a parent node, you should get its position relative to (0,0,0), provided you call updateAbsolutePosition() before like vitek stated earlier.
If the node however doesn't have, never had, and never will have a parent node, then getPosition() should also always return its position relative to (0,0,0)
And without stating the obvious much longer, my question would be...
never hesitate stating the obvious...
Is that currently the case ?

because I find myself more often than seldom using getBoundingBox() Methods to determine the absoultePosition of nodes....

Posted: Thu Feb 05, 2009 8:48 am
by hybrid
getPosition and getAbsolutePosition work exactly as you've described. And I also think that's the most intuitive and expected way those functions should work.

Posted: Thu Feb 05, 2009 1:38 pm
by arras
Just as a note ...all scene nodes have some parent. If you don't assign parent yourself then it is root scene node. Since its origin is at global origin than calling getPosition on one of its children will return their absolute position.