Jump to content

Any way to show combined computed BoundingBox of multiple meshes ?


Recommended Posts

I have computed minWorld and maxWorld of BoundingBox of multiple meshes combined . As if those multiple meshes were one single mesh. 


Now I wanted display this new BoundingBox in the scene. Is there any way to do this?


Or only way is to  generate vertexdata of 36 vertices (required for box/cube) and then generate mesh from vertex data ?  

Link to comment
Share on other sites

Good answer, T!   And hi to both of you.

Another possibility... http://playground.babylonjs.com/#CTHIE#1

In line 35, I get the scene's boundingBoxRenderer... and I send it to console in line 38.

In the dev tools of most browsers, you can click on the bbr object, and an object inspector opens.  There is a _vb property on that object (virtual buffer), and the _vb has a property on it... called _data.  Notice that it is an array of length 72.  (two objects showing bounding boxes)

You could "adjust" the contents of that vbo positionKind data.  *shrug*  No guarantees.  I've never tried this.  You'll need to do this carefully so you don't get in the way of later-added mesh wanting their boundingBoxes to show.  Keep us posted.  :)

Link to comment
Share on other sites

Run with it, my friend!  Always.  And that's a great idea, Jahow.  A guy could even pass (bubble) intersect events up to the ghost mesh, if wanted.  Group events.  :)  Maybe even overload it with a .groupedMeshes and a .calcGroupBoundingMinMax() on-board. 

'Round these parts, it's probably computeGroupBoundingMinMax().


Starts with a base class of Babylon.Area, eh?  Later, our camera frustums and renderingGroup objects will also be subClasses of .Area, right?  (ahem)  These Area objects will also be important when Microsoft finishes our Babylon Bay virtual world server.  They keep track of what objects are on "your" land(s) and allow you to @kick objects that others left laying in your Area.  :)  (dream/drool)


But ya know... if you "bubble" (up) intersect events from group members, then you should also "cascade" (down) group intersect events... to group members. 


And you'll need some new actionManager triggers...  onGroupIntersectTrigger (for member AM's) and onMemberIntersectTrigger (for grouper AM's)... and and and...  how 'bout a nice bottle of Parade Rain, soft drink of the disappointed.  :D


What's that?  Ohhh... you weren't planning on creating the Babylon.group class?  You were just going to DISPLAY a user-settable bounding area?  ohhhh.  ;)


Are we prepared for a user positioning/dragging a member mesh outside of this 3D bounding area... and wanting the bounding area to widen to re-encompass the moved mesh... REAL TIME?  omg - me scared.


Oh that's right I forgot... it's not a group, it's a displayed box... with a .visibility of .000001 and a .showBoundingBox = true;  *nod*  I keep forgetting.  Sorry.  heh.

Link to comment
Share on other sites



It's not clear to me how dsman would like to apply these bounding models (boxes.)  Understanding the application would help a great deal in finding a solution to his querry. In the meantime, I have a comment on this topic, although it's not necessarily specific to his question.  


I personally haven't seen any posts on the use of bounding models to embellish detailed texure maps, so I thought I'd mention this for anyone new to game development. This takes me back to developing games on consoles such as the Phillips CDI game console (way back), where we had vertex limits that would make you cry - often in the hundreds for an entire scene, depending on the engine we were using (which was always custom to each game.)  We would create very high resolution detailed models in our modelling software, and render a single frame from the game camera (which was generally static for gameplay) baking in all complex lighting,  We would then delete the geometry and save the simple bounding models we created with our compex objects.  Then we would map the rendered image of our complex model(s) to a simple planar object, and parent our bounding boxes to this image plane.  This would provide us with all of the collision, intersection, and other object data necessary for gameplay. This is still the method used in games today for much of these types of computations.


And if we required any lighting effects, we'd create a simple animated image sequence to map onto a portion of the plane texture using either photoshop or our original 3D model using the original 3D software renderer (for complex lighting effects.)  Of course, always design the in game lighting to avoid casting shadows on complex models that are simply textured planes.  This was the primary method for building rich environments for game engines with huge limitations.  I'm sure this is EXTREMELY remedial for many people reading this, but it's not often obvious when developing your first game.  This is evident when we see developers post scenes and links to scenes in which we see models many times more complex than necessary with no benefit to the scene - only overhead.  And, many game engines today run similar processes in real-time unseen by the player and even the developer.


I just thought I'd mention this process as one application (rendering complex models as textures to map on planes) that many developers use bounding models for and what some refer to as "ghost objects" in optimizing scene overhead.  And just for fun (and to yank my own chain and expose my age, ) I've included the "win" endings for each character in a game I was the Animation Supervisor for on the Playstation 1 console. The game was "Tobal #2" and was one of the first "real" fighting games with a story mode. So if your character won the entire championship, they were rewarded with their own ending.  Remember, excluding characters, the limit for all polys in each scene was 9000, and this was one of the very first run time rendered cinematic games. I was the Supervisor for these cinematics, but also had to create my own cinematics. Each artist was assigned one cinematic which had to be modelled, textured, lit, and set up in the render engine by that single artist alone. This was the method on those days which was great - as the cinematic belonged ENTIRELY to the artist - which was difficult but something to either take pride in or to crash and burn.  Due to the tight schedule and lack of available people - I was short one artist, so I took two cinematic endings - the characters named "ILL" and "Dr. V".  We all had 8 weeks total production time from pre-pro to delivery, so it is what it is. But I hope that understanding the polygon limit for the total scene and looking at the result might demonstrate the use of bounding models to dramatically reduce polygons and other scene overhead, while rendering detailed environments. So I thought this would be fun to post (it is for me), and we did win the award that year for best game cinematics.  And yes, it is entirely in Japanese, however, we created all of the work in Studio City, CA.  Ahhh... those were the days.  B)


Link to comment
Share on other sites

@jahow  This was so simple and indigenous. That's precisely what I wanted to do. 


@dbawel  BoundingBox apart from all other things, tells us how much space a mesh is occupying. In my scene some object are made of multiple meshes. I simply wanted to know how much space these object are occupying. For that I needed to find combined bounding box of all meshes. 

Link to comment
Share on other sites

Hi dsman,


I'm very curious as to what you will use the bounding box volume info for?  Also, as bounding boxes are relative to the geometry in calculating volume and not generally a good measure, is this level of accuracy sufficient for your use?  This must be something I haven't considered.


Sorry to take advantage of your post, but I was wondering what your application might be, and looked back at when bounding models were life itself in a highly limited world.  I came across this old work, and couldn't resist posting for nostalgia.  But, I got it out there to relive for a moment - and now it goes back into the file marked "real old."



Link to comment
Share on other sites

Well, I thought I would use bounding box to measure dimension (Height, width , depth) of any object comprising of multiple meshes. This is related to some interior/architectural related application. 


Is this bad idea ?

Link to comment
Share on other sites

Actually, that's a unique idea for calculating info such as square footage and living space - as well as possibly defining how much physical materials might be needed for the construction of a building or structure.  Thanks for the info on your usage, as it's always good to look at new approaches to simplifying more complex problem solving.



Link to comment
Share on other sites

Hi guys!  Um, dsman... let's pretend that http://playground.babylonjs.com/?2 is a model made-up of multiple mesh.  Do you have an algorithm that will accurately 'sum?' those mesh, so you can calculate the size-of, and properly position a bounding box around that group? It's a 3-step process, as best I can tell.

1. Somehow gather a list of mesh that are to be included in this u-haul bounding box.

2. Run a computeBounds() that gives you some good numbers, derived from analyzing the bounds of all mesh in .includedMesh array.

3. Draw the box and/or return a boundingInfo object to the user, or otherwise make it available... getBoundingInfo().

Are you suggesting someone code it?  Or are you suggesting it as a future feature?  Are YOU going to try it? 

It will need a list of mesh that are to be included (members), right?  As soon as you add those two things...  .computeBounds() and .includedMesh (an array)... you are speaking about a tool that is very close to being a grouping object. 

So, while dbawel is curious about what you want to use this for, I am curious HOW you are going to code it?  Some modeling programs use features like "measure" and "show ruler", and other modelers do tri-grids (where you can easily see that a group of mesh uses 12 grid cells, by 4 grid cells, by 23 grid cells, etc).

Back to dbawel's questions, do you think you will want to drag, rotate, position, transform, or scale... this new bounding area (and have memberMesh be included)?

And this is also related to making bounding boxes around children of a parent.  For example, 'airplane' might be an invisible box... it has the direct descendents (children) of leftwing, rightwing, fuselage, tail, nose, gear.  Gear has two children... left pedestal and right pedestal, which have children called left wheel/right wheel, etc. 

You see, ds... displaying a box around a group of mesh.... may be fairly easy, using a great "compute" function.  But you KNOW that a user will visit you someday, and say "Hey, I saw that bounding box that you had around that compound mesh... that was cool.  Can I rotate that?"  (and have member mesh come-along yet keep their orientation relationship with other group members)

At that point... you are going to understand WHY Wingnut and Dbawel are asking so many questions.  We want to know if you are going to stop-at a box drawing, or if this thing needs some more intelligence... like how to act as a parent, if needed. (to rotate, position, or scale the group/box).  How much "smart" does this container need?  How much will other users WANT/REQUEST?  *shrug*

I say try it, why not?  The worst thing that could happen is that you lose some sleep.  :)

Use the playground/2 above... try to box-up everything but the ribbonMesh in the back. I'd love to see the code that calcs the size and placement of that "container".  I'm glad it's not ME writing that code.  :)  Let's see... the min/max of THIS mesh, plus the min/max of THAT mesh, etc.  phew.  But I have been fooled before, and recently  (where I thought something was going to be real difficult, and it turned out to be super easy).  :)

Link to comment
Share on other sites

  • 1 year later...

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.

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.


  • Recently Browsing   0 members

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