Hello,
I am a bit confused with calculation center of AABB box. All my nodes are round balls of the same size. For the comparison I am calculating and outputting centers of AABB for the same nodes and there Derived positions like following:
// Steady object
Ogre::AxisAlignedBox box1 = node2->_getWorldAABB();
Ogre::Vector3 MyBox1 = box1.getCenter();
results<<"BoxCenter:"<< MyBox1 << endl;
Ogre::Vector3 Possition1 = node2R->_getDerivedPosition();
results<<"Possition:"<< Possition1 << endl;
// moving object
Ogre::AxisAlignedBox box = node1->_getWorldAABB();
MyBox = box.getCenter();
results<<"BoxCenter:"<< MyBox << endl;
Ogre::Vector3 Possition = node1->_getDerivedPosition();
results<<"Possition:"<< Possition << endl;
For the node that is not moving AABB center and its Position is constantly the same, but for the node that is moving AABB center and derived position are interchanging the values. Below is output file:
// First Frame
BoxCenter:Vector3(-0.18, -0.34, 0.3)
Possition:Vector3(-0.18, -0.34, 0.3)
BoxCenter:Vector3(-4.88006, 9.68, 2.3599)
Possition:Vector3(-4.88017, 9.68001, 2.3597)
// Second Frame
BoxCenter:Vector3(-0.18, -0.34, 0.3)
Possition:Vector3(-0.18, -0.34, 0.3)
BoxCenter:Vector3(-4.88017, 9.68001, 2.3597)
Possition:Vector3(-4.88033, 9.68003, 2.3594)
// Third Frame
BoxCenter:Vector3(-0.18, -0.34, 0.3)
Possition:Vector3(-0.18, -0.34, 0.3)
BoxCenter:Vector3(-4.88033, 9.68003, 2.3594)
Possition:Vector3(-4.88056, 9.68004, 2.35901)
That is happening for any kind of moves that I am performing on any scene object. Why is it happening like that ?
Thanks
AABB getCenter
- tod
- Troll
- Posts: 1394
- Joined: Wed Aug 02, 2006 9:41 am
- Location: Bucharest
- x 94
- Contact:
Re: AABB getCenter
There is a small difference related, probably, to floating point precision. Is that what you are referring to?
-
- Kobold
- Posts: 30
- Joined: Sat Mar 08, 2014 12:47 am
Re: AABB getCenter
tod wrote:There is a small difference related, probably, to floating point precision. Is that what you are referring to?
Well, just the thing is that I need to know precise center and once its round ball and for steady one Ogre is giving same values for the position of the the node itself and position of the center of AABB as well I was expecting that when objects are moving nothing will be changed as well. But If you take a look, there is something more strange in there, Vector3s of the AABB center and _getDerivedPossition are interchanging values, For example on frame one Position was (-4.88017, 9.68001, 2.3597) then on frame two Center of the Box is (-4.88017, 9.68001, 2.3597). And so on. And that is happening for any kind of motion of the nodes that is done.
Do you know how to compile Ogre with a double precision ?
Thanks.
- Faranwath
- Halfling
- Posts: 93
- Joined: Mon Jul 09, 2012 2:19 pm
- Location: Cuba
- x 7
Re: AABB getCenter
The CMake-based build system exposes an option for this:olbr wrote:Do you know how to compile Ogre with a double precision ?
Code: Select all
option(OGRE_CONFIG_DOUBLE "Use doubles instead of floats in Ogre" FALSE)
- tod
- Troll
- Posts: 1394
- Joined: Wed Aug 02, 2006 9:41 am
- Location: Bucharest
- x 94
- Contact:
Re: AABB getCenter
Maybe the AABB is computed after the frame render or something, as it seems to trail one frame behind the position. I think you can force it to be computed yourself.
For double precision there is a define in some header file, ogre config or something, can't remember right now. Of course, a rebuild will be needed.
For double precision there is a define in some header file, ogre config or something, can't remember right now. Of course, a rebuild will be needed.
- Faranwath
- Halfling
- Posts: 93
- Joined: Mon Jul 09, 2012 2:19 pm
- Location: Cuba
- x 7
Re: AABB getCenter
Yep, it's inside of OgrePrerequisites.h, under a #if featuring OGRE_DOUBLE_PRECISION.tod wrote:For double precision there is a define in some header file, ogre config or something, can't remember right now. Of course, a rebuild will be needed.