Simulate objects in water.

Official forum for the Chipmunk2D Physics Library.

Simulate objects in water.

Postby TomCatFort » Sat Sep 12, 2009 4:53 am

I would like to add water (or other fluids) into my projects. What I need is not fluid simulation, I need simulating objects submerged in fluids, I need objects that floats on the surface of the fluid making platforms. Any idea how I can do that if it's possible?
TomCatFort
 
Posts: 2
Joined: Sat Sep 12, 2009 4:34 am

Re: Simulate objects in water.

Postby maximile » Sat Sep 12, 2009 11:32 am

One of Scott's examples from a while ago demonstrated a way to simulate buoyancy by having a grid of sample points and applying a force based on how far under the water each one is. It works really well for simple simulations; here's a video of a demo I made using the technique (1:10 for the best demo): http://www.youtube.com/watch?v=QTpjyHU_ZqY

I don't know if the demo is in the latest download; you might have to search around for it a bit.

For extra accuracy, you might want to implement something similar to the "tensor damping" found in this demo (click it and press right a few times to get to it): http://personal.boristhebrave.com/proje ... -pack/demo
maximile
 
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK

Re: Simulate objects in water.

Postby TomCatFort » Sat Sep 12, 2009 1:19 pm

The grid of simple points looks enough for me. How should I implement those points? Use small circle bodies? Or there is a better way?
TomCatFort
 
Posts: 2
Joined: Sat Sep 12, 2009 4:34 am

Re: Simulate objects in water.

Postby maximile » Sat Sep 12, 2009 1:38 pm

The points don't have bodies or collision shapes; they're just points on the shapes that get tested for whether or not they're in the water.

Demo8.c has the code, but I don't know if it works with the latest Chipmunk. http://maximile.net/stuff/Chipmunk-rele ... didate.zip
maximile
 
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK

Re: Simulate objects in water.

Postby slembcke » Mon Sep 14, 2009 8:24 am

The buoyancy code should still work OK. The problem with it was that the way I was approximating the drag was not very stable. You could sometimes get the shapes to explode off the screen because of it. I've never quite taken the time to go back and correct that.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron