Jump to content

Bounding box center coordinates


reddozen
 Share

Recommended Posts

Is there a good way to find the center point for a models bounding box?

 

My problem is that we're currently loading in models that have been translated before being exported, and their world coordnates are based on this pre translation. This will wreak havok on things like level of detail. So I figure the best way to remove the translations is to use the bounding box center as the actual model coordinates. I'll loop through all the models in the scene and then generate a list of corrected coordinates. then I can just reset them all to 0,0,0.

Link to comment
Share on other sites

Hi,

 

If you use Blender: mesh vertices have coordinates relative to the object origin, so setting that origin thoughtfully may allow you to solve your issue. Probably applies to other modeling software, although I can't say for sure.

 

Apart from that, using

refreshBoundingInfo()

and then

<static>Center()

 on a BABYLON.Mesh object should do precisely what you want :)

Link to comment
Share on other sites

I'll try that, but wouldnt that mean that babylon is ignoring the translation? What I mean is that the translation is saved in 3DS Max, so when it's loaded in Babylon, I would assume that the center of mesh woul include the translation difference, and it would tell me that the center is the center of the translation bounds. That's why I was referring to the bounding boxes. they are kind of absolute,

Link to comment
Share on other sites

Well, I'm not sure about the 3DSMax exporter behaviour, and I don't have this software at my disposal so I can't try it myself.

 

What you can do is try the debug layer feature in BJS 2.0 alpha available on github. This will allow you to display bounding boxes and mesh origins on screen, which may help you check if everything is as you intend it to be.

 

Using this feature is ultra simple, just add

scene.debugLayer.show();

in your code.

 

Hope this helps!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...