one question about position.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
hzsyber
Posts: 52
Joined: Tue Apr 01, 2008 2:21 pm
Location: Canton,China.

one question about position.

Post by hzsyber »

getAbsolutePosition() and getPosition() return values difference.

thanks!
nathanf534
Posts: 199
Joined: Tue Dec 09, 2008 2:55 am

Post by nathanf534 »

I believe getAbsolutePosition returns the position from the origin (0,0,0), while getPosition() returns the position relative to its parent.
while(signatureEmpty){cout<<wittyComment();}
hzsyber
Posts: 52
Joined: Tue Apr 01, 2008 2:21 pm
Location: Canton,China.

Post 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.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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.
hzsyber
Posts: 52
Joined: Tue Apr 01, 2008 2:21 pm
Location: Canton,China.

Post by hzsyber »

ObjNodes->getAbsolutePosition();

reutrn Position always (0,0,0).
not my want.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

getAbsolutePosition() returns global (world) position regardless of what you want.
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post 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.
Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You may have to call updateAbsolutePosition() before getAbsolutePosition() will return the actual world position.
hzsyber
Posts: 52
Joined: Tue Apr 01, 2008 2:21 pm
Location: Canton,China.

Post 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!
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post 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....
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post 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.
Post Reply