Finding Actual Position

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
HTAPAWASO
Gnoblar
Posts: 16
Joined: Tue Jul 02, 2013 2:15 pm

Finding Actual Position

Post by HTAPAWASO »

Hi,

So I made a bunch of meshes in a single file in Blender, which I then exported and added to my Ogre project.

These meshes are in a specific position in Blender, and they cleverly find that position again in Ogre if I create their sceneNodes at (0,0,0), presumably because the offset is already set in the mesh file.

So that works well.

The problem is that if I call getPosition(), it obviously returns (0,0,0) for all of my sceneNodes. I know that Ogre knows where the models actually are, because rayQueries, bounding boxes etc. all work fine. My question is, how do I get that information? I know I can get the information from Blender and add it in manually, but for obvious reasons I would rather not do that.

Thanks, I hope the question is clear.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Finding Actual Position

Post by scrawl »

You can set a mesh origin in blender. However, if you are just exporting .mesh files, the origin won't be exported and the object will be moved to (0,0,0) when you create the scene node there.
To export the origins of the mesh, you need to use a scene file format that tells Ogre where the meshes should be created. The blender2ogre exporter can export a .scene file. Combine this with the DotSceneLoader for Ogre.
HTAPAWASO
Gnoblar
Posts: 16
Joined: Tue Jul 02, 2013 2:15 pm

Re: Finding Actual Position

Post by HTAPAWASO »

Thanks a lot for the reply, I understand the problem now.

I decided to just include the co-ordinates in my save files rather than use .scene for the time being, as the latter would require rewriting quite a lot of code. Might get 'round to it later though.
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Finding Actual Position

Post by syedhs »

Probably the easiest way is to inquire the world bounding box of the entities, and find the center. You may want the y portion to be the bottom of the world aabb instead the center of it.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
Post Reply