reddozen Posted January 11, 2015 Share Posted January 11, 2015 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. Quote Link to comment Share on other sites More sharing options...
jahow Posted January 11, 2015 Share Posted January 11, 2015 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, usingrefreshBoundingInfo()and then<static>Center() on a BABYLON.Mesh object should do precisely what you want Quote Link to comment Share on other sites More sharing options...
reddozen Posted January 11, 2015 Author Share Posted January 11, 2015 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, Quote Link to comment Share on other sites More sharing options...
jahow Posted January 11, 2015 Share Posted January 11, 2015 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 addscene.debugLayer.show();in your code. Hope this helps! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 11, 2015 Share Posted January 11, 2015 Translation is saved into mesh.position. The bounding boxes are updated on the first render. So if you are checking the bounding boxes right after loading without waiting for a render, you will have to force the update Quote Link to comment Share on other sites More sharing options...
reddozen Posted January 12, 2015 Author Share Posted January 12, 2015 DK,Does this mean that I need to have physically seen them in the scene, or am I fine to wait until after I have confirmed that all the verts are loaded? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 12, 2015 Share Posted January 12, 2015 if you do not want to wait, callingmesh.computeWorldMatrix(true) is fineelse you have to wait for a frame to be physically rendered Quote Link to comment Share on other sites More sharing options...
reddozen Posted January 12, 2015 Author Share Posted January 12, 2015 Sounds good. thanks! GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.