Simulate objects in water.
-
- Posts: 2
- Joined: Sat Sep 12, 2009 4:34 am
- Contact:
Simulate objects in water.
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?
-
- Posts: 157
- Joined: Mon Aug 20, 2007 12:53 pm
- Location: London, UK
- Contact:
Re: Simulate objects in water.
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
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
-
- Posts: 2
- Joined: Sat Sep 12, 2009 4:34 am
- Contact:
Re: Simulate objects in water.
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?
-
- Posts: 157
- Joined: Mon Aug 20, 2007 12:53 pm
- Location: London, UK
- Contact:
Re: Simulate objects in water.
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
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
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Simulate objects in water.
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/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 3 guests