grire974 Posted August 3, 2016 Share Posted August 3, 2016 I think I've come across a bug with how SceneLoader handles positioning. Not sure yet whether this is BJS 2.4, or the FBXExporter code that is being used to generate a .babylon file from the FBX that I exported from Blender. When I load this file: https://drive.google.com/open?id=0BzfS-gwTfPBtMFp1bzg5N1BLOWM using BABYLON.SceneLoader.load() I can't get the correct BoundingInfo for the lower equalizer bars (38_EQBars001); it provides the same bounding info as the upper equalizer bars (37_EQBars002). e.g. for (i = 0; i < myScene.meshes.length; i++){ myScene.meshes[i].refreshBoundingInfo(); console.log("found mesh with min: id = "+myScene.meshes[i].id+", "+myScene.meshes[i].getBoundingInfo().minimum.y+", and max"+myScene.meshes[i].getBoundingInfo().maximum.y); } returns the same min and max Y values for both equalizer meshes; even though they display correctly (e.g. not the same positions). If you analyze the JSON of the .babylon file; you'll notice the position values for both meshes are almost identical. What is different is the rotation quaternion for both meshes - which makes sense because to create the 2nd set of equalizer bars, I cloned the first set and then rotated them into position; Thus my theory at this stage is that either the FBXConverter or BJS 2.4 aren't taking this into consideration. I also read this forum: However, using setTimeout in conjunction with refreshBoundingInfo() doesn't seem to have any positive effect. The downside of this all is that I can't tangentially position this model next to anything else as I don't have correct bounding info. Any help would be much appreciated. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 4, 2016 Share Posted August 4, 2016 Hey! BoundingInfo are refreshed by rendering a frame. If you want an up to date value, just call mesh.computeWorldMatrix(true) before Quote Link to comment Share on other sites More sharing options...
grire974 Posted August 4, 2016 Author Share Posted August 4, 2016 Hi - Thanks for the reply (sorry to post in the bugs forum if this doesn't appear to be a bug). Still having the same issue; I'd create a sandbox to illustrate this - however I don't see a way to add your own .babylon files to the sandbox..? Any other thoughts? Thanks. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 4, 2016 Share Posted August 4, 2016 For the playground just save your file in a dropbox account like here: http://www.babylonjs-playground.com/#10OJSG#9 Quote Link to comment Share on other sites More sharing options...
grire974 Posted August 9, 2016 Author Share Posted August 9, 2016 Thanks for the pointer.. In trying to demonstrate my problem - I think I figured it out; I was rotating my mesh 90 degrees around the x axis in order to bring it into line; boundingInfo seems to reflect the mesh's original bounds - rather than those after it has been rotated. This is the playground I created: http://www.babylonjs-playground.com/#27IOZS The goal here is to dynamically load a mesh/babylon file (e.g. potentially any mesh from an unknown source); and then position said mesh such that it is tangental to the ground mesh. I ran the for loop again after the rotation was made to see if that would update the boundingInfo - however it doesn't seem to. Perhaps not a bug - still a little confusing I found; spent quite a lot of time scratching my head on this one. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 9, 2016 Share Posted August 9, 2016 I do not see what is wrong with your PG. seems like the mesh is correctly positioned? Quote Link to comment Share on other sites More sharing options...
grire974 Posted August 9, 2016 Author Share Posted August 9, 2016 It is correctly positioned now... However I'm positioning the height of the model based off of the min and max Z values returned from the boundingInfo. My intuition was expecting to use the Y values - but eventually guessed that I had to use the Z values as the model had been rotated 90 degrees around the x axis. The final question I guess is - should boundingInfo automatically represent all translations such as position and rotation (haven't tested for positional changes yet) made to a given mesh; or is it the developer's responsibility to keep track of their changes and apply further calculations to boundingInfo in order to get updated values. Obviously I'd prefer the former - but thought I'd raise the question none the less... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 10, 2016 Share Posted August 10, 2016 Ok gotcha! Bounding box is axis aligned. But you can get the world values (meaning the rotated values) from bbox.minimumWorld and .maximumWorld Quote Link to comment Share on other sites More sharing options...
grire974 Posted August 11, 2016 Author Share Posted August 11, 2016 Ah right - well that makes sense. I've updated my PG to use minimumWorld; however its still showing the pre-rotation values for me. Any ideas as to what I might be doing wrong? Here's my updated PG: http://www.babylonjs-playground.com/#27IOZS#1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 11, 2016 Share Posted August 11, 2016 Don't forget to call mesh.computeWorldMatrix(true) if you want your rotation to be applied immediatly (by default it is applied during rendering phase) Quote Link to comment Share on other sites More sharing options...
grire974 Posted August 11, 2016 Author Share Posted August 11, 2016 Many thanks Delta - as always! Seems I was missing the fact that I had to computeWorldMatrix for my parent node and the child meshes as well. For those interested; heres the final PG in all of its tangental glory: http://www.babylonjs-playground.com/#27IOZS#2 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.