getting center of the objects placed on a scene

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
levan
Halfling
Posts: 41
Joined: Sun Oct 27, 2013 11:57 pm
x 1

getting center of the objects placed on a scene

Post by levan »

Hello,

I have about 1000 objects in my game want to obtain an average center for all of them (that is equal to summing up location vectors3d for all of them and dividing by 1000).
Don't we have some method in Ogre that is doing it ?


Many Thanks

levan
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: getting center of the objects placed on a scene

Post by spacegaier »

First idea: Each node in a scene has a bounding box and I assume that the one from the root node accumulates all the others, so give that a try (pseudo code):

Code: Select all

pRootNode->getAABB().center()
EDIT: Just found this thread, which suggests that is does not always work: http://ogre3d.org/forums/viewtopic.php?f=2&t=49858

But in general, I don't think that this a classical task of a rendering engine, so if the above doesn't work you likely will have too roll your own solution for that. You already stated one approach. Just don't do that every frame (iterating over all objects and retrieving their position) because that might slow down your application ;) .
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
levan
Halfling
Posts: 41
Joined: Sun Oct 27, 2013 11:57 pm
x 1

Re: getting center of the objects placed on a scene

Post by levan »

spacegaier wrote:First idea: Each node in a scene has a bounding box and I assume that the one from the root node accumulates all the others, so give that a try (pseudo code):

Code: Select all

pRootNode->getAABB().center()
EDIT: Just found this thread, which suggests that is does not always work: http://ogre3d.org/forums/viewtopic.php?f=2&t=49858

But in general, I don't think that this a classical task of a rendering engine, so if the above doesn't work you likely will have too roll your own solution for that. You already stated one approach. Just don't do that every frame (iterating over all objects and retrieving their position) because that might slow down your application ;) .

Thanks for Help

yea I will implement own code to be sure. Just was thinking that may be its already done.

cheers
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: getting center of the objects placed on a scene

Post by spacegaier »

levan wrote:Just was thinking that may be its already done.
I am not saying it isn't, I am just saying that if it is, I am not yet aware of it. Did you test the AABB from the root scene node?
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
levan
Halfling
Posts: 41
Joined: Sun Oct 27, 2013 11:57 pm
x 1

Re: getting center of the objects placed on a scene

Post by levan »

spacegaier wrote:
levan wrote:Just was thinking that may be its already done.
I am not saying it isn't, I am just saying that if it is, I am not yet aware of it. Did you test the AABB from the root scene node?
Well I just scripted own method. But will test existing opportunities when have more time.
Post Reply