MarianG Posted September 21, 2018 Share Posted September 21, 2018 Hello! 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! Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 24, 2018 Author Share Posted September 24, 2018 So, I suppose I will come back to my first thought for the moment :)) I'll see, maybe we can put the user to define an area inside of mesh or something like this. Quote Link to comment Share on other sites More sharing options...
Guest Posted September 24, 2018 Share Posted September 24, 2018 Haha..Hope this works! Keep us posted Quote Link to comment Share on other sites More sharing options...
JohnK Posted September 24, 2018 Share Posted September 24, 2018 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. MarianG 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted September 24, 2018 Share Posted September 24, 2018 I agree with JohnK's approach. And you're right, something got broken in the facetData, no idea what or why ... probably related to some latest fix because of the Chrome bug. Well, it seems that things that used to work aren't working any longer MarianG 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted September 24, 2018 Share Posted September 24, 2018 Well fix that asap! @Sebavan is on it Quote Link to comment Share on other sites More sharing options...
Guest Posted September 24, 2018 Share Posted September 24, 2018 This is because the demo was using _properties...And this is not ok Here is the fix: https://www.babylonjs-playground.com/#UZGNA#5 I'm gonna fix the doc as well MarianG and jerome 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted September 25, 2018 Share Posted September 25, 2018 I really to spend some time on the modified code to get what deeply changed Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 25, 2018 Author Share Posted September 25, 2018 Hi. Thank you for sugestion, and for fix this. I'll give a try and I'll update you! Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 25, 2018 Author Share Posted September 25, 2018 Hi. It's me again, with something new. https://playground.babylonjs.com/#J71TH6#1 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? Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 26, 2018 Author Share Posted September 26, 2018 I figure it out, but it's not a good solution For this rectangle is working because boundingbox is the same like mesh, but for a custom doesn't work https://playground.babylonjs.com/#J71TH6#3 https://playground.babylonjs.com/#J71TH6#4 Quote Link to comment Share on other sites More sharing options...
Sebavan Posted September 26, 2018 Share Posted September 26, 2018 Keep it up, you are getting closer. but doing it for the entire mesh would be insanely expensive. As a side idea, you might try to refine your found intersection with Rays ? as they would get more precision ? MarianG 1 Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 27, 2018 Author Share Posted September 27, 2018 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 https://playground.babylonjs.com/#J71TH6#14 https://playground.babylonjs.com/#J71TH6#15 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. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted September 27, 2018 Share Posted September 27, 2018 Maybe you you could ray cast from opposite directions to know if you are inside like rays coming to your point and if both collide outside, you would be inside ? Quote Link to comment Share on other sites More sharing options...
JohnK Posted September 27, 2018 Share Posted September 27, 2018 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. https://playground.babylonjs.com/#J71TH6#17 MarianG 1 Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 28, 2018 Author Share Posted September 28, 2018 Oh @Sebavan I'm not sure I understood . I'll give a try. @JohnK, smart solution. Yes, it's expensive, but I'll take a look at csg source, as you said, maybe I can use something from there. Thank you for hint. Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 28, 2018 Author Share Posted September 28, 2018 Hihihi ? 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. https://playground.babylonjs.com/#J71TH6#21 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 JohnK, GameMonetize and Sebavan 3 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.