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
getting center of the objects placed on a scene
-
- Halfling
- Posts: 41
- Joined: Sun Oct 27, 2013 11:57 pm
- x 1
- spacegaier
- 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
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):
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 .
Code: Select all
pRootNode->getAABB().center()
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...
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
-
- Halfling
- Posts: 41
- Joined: Sun Oct 27, 2013 11:57 pm
- x 1
Re: getting center of the objects placed on a scene
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):
EDIT: Just found this thread, which suggests that is does not always work: http://ogre3d.org/forums/viewtopic.php?f=2&t=49858Code: Select all
pRootNode->getAABB().center()
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
- spacegaier
- 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
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?levan wrote:Just was thinking that may be its already done.
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...
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
-
- Halfling
- Posts: 41
- Joined: Sun Oct 27, 2013 11:57 pm
- x 1
Re: getting center of the objects placed on a scene
Well I just scripted own method. But will test existing opportunities when have more time.spacegaier wrote: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?levan wrote:Just was thinking that may be its already done.