#### Archived

This topic is now archived and is closed to further replies.

# Interacting objects with water

This topic is 5641 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I''ve implemented a simple water engine ( using FFT ) and have a height map. What would be a good way to have an object interact with the water? Would a standard collision detection work in this case (ie. after collision, the object would be above water .. just decrease it''s height a bit so that it will be partly underwater)? Anyone have any ideas or recommendations? Thanks.

##### Share on other sites
I''d go for realistic physics, as always. I don''t mean that everything has to be exact. Just check your local physics book about how things float. Liquids, lift, Archimedes''s Law. Should get you started.

It is easy to implement, and would give nice results. Rocks would sink, wood would float, balloons would float even more. If your water surface has waves, the objects would play nicely with them too.

Here is the whole thing in a nutshell:

Archimedes''s law:
An object in water is pushed upwards by a force that is equal to the weight of the water it displaces.

(That probably is not proper scientific english. I only have a finnish physics book here.)

So,
d is the density of water
V is the volume of the object (the part of it that is underwater)
g is gravitational acceleration
F is the lift-force

F = dVg

That, and gravity (G=mg), and you are ready to float.

##### Share on other sites

I''m trying to implement the method you described. After further researched, I found a paper called "Interactive Simulation of Water Surfaces" in Game Programming Gems. It uses the same concepts as your description. Thanks for pointing me to the right direction.

##### Share on other sites
Hello,

Regarding the formula below:

F = dVg

d is the density of water
V is the volume of the object (the part of it that is underwater)
g is gravitational acceleration
F is the lift-force

That, and gravity (G=mg), and you are ready to float.

Force acting on object is F_g (gravity) + F_b (buoyant force).

Let''s say I have a 2x2x2 cube object that weighs 100 kg.

F_g = 100 * -9.8 = -980

Let half of the object be underwater ( volume = 2 x 1 x 2 )
and assuming density of water is 1000 kg/m^3

F_b = dVg
= (1000)*(-2*1*2)*(-9.8)
= 39200

F_g + F_b >> 0 so my object will fly off into the sky ... am I doing something wrong with my calculations here? Also, volume of the object (the part of it that is underwater) should be negative since F_b should always be positive ( f_b = dVg = (+ve)(-ve)(-ve) ), right? .. Any help would be greatly appreciated.

Thanks.

##### Share on other sites
it should self-balance. If the object moves up, the boyancy will decrease (less volume underwater). If it sinks, the boyancy will increase (more volume under water). The down force is gravity * mass, the up force is Fb(volume under water). If the object is heavy with little volume, it will sink slowly. If the object is very light, it should stay on the surface, although it migh pop up and down wildely, due the numerical inacurracies of the integration you are using (euler probably not recommended), and the innacurracies of the calculation of the volume that is actually under water (it would be based on columns of water, right?). There is also maybe the pressure from the column of air above, but I think we can forget about that. And you can model wind lik that on the water surface, with waves of varying air pressures on the water. How about an FFT wave for that too?

Hell, you can even make the object rotate and bob around, by applying the boyancy as a upward force along each column of water under the object. could be fun.

##### Share on other sites
Hi .. thanks for the reply. If I start off a with a cube with volume = 1 and mass = 100 ( density = 100 ), if half of cube is in water then:

F_b = dVg = 1000*0.5*9.8 = 4900 >> 980 = 100*9.8 = mg = F_g

Note that Object density = 100, Water Density = 1000 so 10% of object should be underwater at equilibrium.

It seems that F_b is much higher that F_g. As you mentioned, this will make it pop up and down very widely. What do you recommend besides euler integration?? I''ve tried to dampen my velocity which helps a bit but is there any other way?

Wow .. I think I''ll just stick with the simple FFT wave first =) After I manage to figure out buoyancy with the help of you guys of course, then maybe the fancy stuff =)

##### Share on other sites
How do i calculate the volume of mesh under water. BTW first how to calculate the volume of mesh.

[edited by - DirectXXX on June 24, 2003 12:59:41 PM]

##### Share on other sites
Hello,

Currently, I''m just using a box for buoyancy so calculating the volume of the box is just length * width * height. For calculating volume that''s underwater, you use columns of water as suggested by oliii. There is an approximation of the volume displaced in "Interactive Simulation of Water Surfaces" in Game Programming Gems 1.

1. 1
2. 2
3. 3
Rutin
24
4. 4
5. 5
khawk
14

• 11
• 11
• 23
• 10
• 9
• ### Forum Statistics

• Total Topics
633651
• Total Posts
3013128
×