grire974

Detect collision for nested mesh

Recommended Posts

Hi All,

 

I'm working on something I'd like for my project; specifically I want to nest one mesh inside another and have collision detection (e.g. like the dice in a dome in the trouble board game http://www.boardgamescritic.com/wp-content/uploads/2010/10/trouble-board-game-board.jpg ).

 

I've read all the physics related tutorials for cannon and Oimo, seemed to get further (not far) with Oimo; so sticking with that so far.  Have also looked at all of the relevant demos I could find.  I have a playground which illustrates the efforts I've made so far: 

 

http://www.babylonjs-playground.com/#1SZYKZ#2

 

As you'll see; gravity affects the cube.  However I'd like the cube to stop when it collides with the sphere;  so it never leaves the sphere.  I'd like the sphere to remain static (or at least not move) which is why i've set its mass to 0 per the tutorials.  Eventually if I shake the sphere, the cube would bounce around inside the sphere (first things first).  Any advice would be greatly appreciated!

Share this post


Link to post
Share on other sites

Hmm.. you can keep it in the sphere with moveWithCollisions if you sue a hollow sphere: http://www.babylonjs-playground.com/#1UQFFF

 

... but doesn't look like it will achieve the desired end result.. would be cooler with physics.

 

What about building a fake sphere out of physics planes that form a sphere like shape. Then hide the planes and just show the sphere mesh. Collisions bounce of the (hidden) planes and for the user it looks like it bounces of the sphere?

Share this post


Link to post
Share on other sites

WOW!  I think this is the most response I've ever had from a post on any discussion forum EVER (tried to like everyone's posts - but apparently I'm being too positive).  Thanks all - @iiceman Interesting you say that; my end goal is to actually build a snow globe for my company's christmas mail out this year; thought I'd start with something simple and then move into a solid particle system; but I probably should have mentioned my end goal rather than comparing it to the trouble board game.  @RaananW - I'll give you the solved vote as this gives me a lot to consider + answers my initial question; even though it doesn't look like it can power a snow globe (which stupidly I didn't mention).  Will keep playing with this and post back if I come up with any enhancements.  Thanks again!  @Vousk-prod ; lol  :)

Share this post


Link to post
Share on other sites

Yep, only one mesh

 

You can access to every particle and its own position, rotation, scale (even its previous and next neighbour in the particles array) within the global mesh... but it's only a mesh.

So you need to compute your own physics if you want to apply it to the SPS particles.

Share this post


Link to post
Share on other sites

Hi All,

Just to follow up with my final outcome; I did get something kinda working.  The tangental plane idea is a good one; however as noted - its a leaky collider (esp if you want small snow flake sized physics particles); I ended up getting something working more reliable by setting overlapping tangental spheres - which wasn't leaky at all.  Outer cube colliders also work; but its the whole square peg round hole thing; just make sure the edges of your cubes are overlapping.

The main problem for me in the end was performance; my mac pro tower started to chug with more than 100 snow flakes; which even then looked sparse.  Here's a quick and dirty example of it working though (sorry code is not clean whatsoever):

http://proofing.tbadigital.com/xmas2015/model.html

In the end - the thoughtfulness of the solution was lost on my colleagues who just wanted more snow; so this is what we finished with (#copout) (and no - I didn't write the poem if that's what you're wondering ;):

http://xmas.tbadigital.com/

Thanks for all of your help!

 

Share this post


Link to post
Share on other sites

Just wanted to share a nice experiment:

http://www.babylonjs-playground.com/#1SZYKZ#13

This is what you can achieve using the newly added MeshImpostor (using cannon.js) - a doublesided sphere uses the mesh impostor and can now contain other spheres inside of it. 

Expect some more physics surprises in 2.4 :) 

Share this post


Link to post
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.

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

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.