Jump to content

Calculate interior mesh volume?


Recommended Posts


As the title say. I want to know if i can find in some way how much space has one mesh inside.

My first thought was: "It's impossible" :) The second one was, ok, maybe it's not posibile, but I should try something and ask maybe someone has a better idea.
My idea is to calculate this like bounding box, just that bounding box is the smallest box which inculde a specific mesh, my bounding box will be the biggest box included in a specific mesh. Therefore i took a look at http://doc.babylonjs.com/how_to/how_to_use_facetdata#mesh-partitioning which seems to be broke :( 

I created a playground for this. Till now only with this partitioning function.

Any ideas or links for research are welcome! ;) 

Link to comment
Share on other sites

Have an idea but have not given it a go yet. It would only work with convex shapes. It goes like this

bounding box is known is volume of bounding box is known.

depending on facet position form a truncated triangular prism from each facet to the top surface or bottom surface of bounding box. Find volume of each prism, sum all volumes, subtract sum from volume of bounding box.

Link to comment
Share on other sites

Hi. It's me again, with something new.

I think this will be expensive for bigger meshes, but what I'm trying to archieve is to create a 3d matrix of boxes and check if 'intersect' the mesh or not.

But this tell me that the box intersect the mesh even if the box is inside mesh, and I want if it's posible to tell me that it intersect the mesh only if it intersect a face of mesh, not when it's inside and doesn't intersect the mesh geometry :) 
It seems with intersectPoint doesn't work. Any ideas?

Link to comment
Share on other sites

Hey. Great idea @Sebavan. Thank you.
I managed it to work in some way, maybe not the best, but it's almost what i need :)
Only one thing left ?
I got mesh surface, but I want if it's possible to fill mesh interior too.  
As example here https://playground.babylonjs.com/#J71TH6#16 boxes which intersect the surface has outline but inside not (expected) and I would like to be able to make them too.

Link to comment
Share on other sites

Here is another way but is very expensive on time. It uses CSG and when a box is completely subtracted it must be inside the mesh. Making the count on line 12 bigger than 15 can quickly lead to 'browser is busy' Perhaps some aspect of the CSG code could be utilised to check if any entries are made in the polygon array and once one entry is made skip as you know the box is outside the mesh.


Link to comment
Share on other sites

Hihihi :ph34r:?

https://playground.babylonjs.com/#J71TH6#20. I think this was.
Yes, if the mesh is not a convex shape, or its pivot is wrong positioned this won't work.

But in most of our cases it should work.

Thanks for support, you was great as usually.
PS: If you have suggestions to improve it, you're welcome :)


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.

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...