ExtremePhysics: all pages

Water

Last updated 6 September 2014

Hint

This article is not related to the 'fluid simulation' example. This method of simulating water is a lot simpler and less realistic, but also a lot faster than real fluid simulation. Take a look at the 'water' test in testbed.gmk to see the difference.

ep_water_create

ep_water_create(world_id)

Creates a new water object.

Returns the id of the new water object.

  • world_id: The id of the world.

ep_water_destroy

ep_water_destroy(world_id, water_id)

Destroys the water object.

  • world_id: The id of the world.
  • water_id: The id of the water object.

ep_water_exists

ep_water_exists(world_id, water_id)

Returns whether the water object with the given id exists.

  • world_id: The id of the world.
  • water_id: The id of the water object.

ep_water_set_parameters

ep_water_set_parameters(world_id, water_id, density, lineardrag, quadraticdrag, xvel, yvel, gravity_x, gravity_y)

Changes the parameters of the water.

  • world_id: The id of the world.
  • water_id: The id of the water object.
  • density: The density of the water.
  • lineardrag: The amount of linear drag.
  • quadraticdrag: The amount of quadratic drag.
  • xvel: The x component of the velocity of the water.
  • yvel: The y component of the velocity of the water.
  • gravity_x: The x component of the gravity of the water.
  • gravity_y: The y component of the gravity of the water.

ep_water_set_collision

ep_water_set_collision(world_id, water_id, collidemask1, collidemask2, group)

Changes the collision settings of the water object.

  • world_id: The id of the world.
  • water_id: The id of the water object.
  • collidemask1: The first collision mask. This is initially set to 0xffffffff for backward compatibility.
  • collidemask2: The second collision mask. This is initially set to 0xffffffff for backward compatibility.
  • group: The group. Use 0 for no group.

ep_water_set_rectangle

ep_water_set_rectangle(world_id, water_id, x1, y1, x2, y2)

Changes the rectangle of the water object.

  • world_id: The id of the world.
  • water_id: The id of the water object.
  • x1: The x component of the upper left corner of the rectangle.
  • y1: The y component of the upper left corner of the rectangle.
  • x2: The x component of the lower right corner of the rectangle.
  • y2: The y component of the lower right corner of the rectangle.

ep_water_previous

ep_water_previous(world_id, water_id)

Returns the id of the previous water object, or 0 if there is no previous water object.

  • world_id: The id of the world.
  • water_id: The id of the water object.

ep_water_next

ep_water_next(world_id, water_id)

Returns the id of the next water object, or 0 if there is no next water object.

  • world_id: The id of the world.
  • water_id: The id of the water object.

ep_water_set_uservar

ep_water_set_uservar(world_id, water_id, index, value)

Changes the value of the user variable with the given index.

  • world_id: The id of the world.
  • water_id: The id of the water object.
  • index: The index (0-4).
  • value: The value.

ep_water_get_uservar

ep_water_get_uservar(world_id, water_id, index)

Returns the value of the user variable with the given index.

  • world_id: The id of the world.
  • water_id: The id of the water object.
  • index: The index (0-4).

Comments

This page used to have a comment section. It's closed now; what remains are the questions I answered.

Dark_master4 · 14 March 2012, 14:19

Does your engine simulate air resistance?

If not, would using water to achieve this be the good idea?

Maarten Baert author · 16 March 2012, 21:39

Quote: Dark_master4

Does your engine simulate air resistance?

If not, would using water to achieve this be the good idea?

Yes, it can simulate very simple air resistance with ep_body_set_damping. You could also use water, which will probably be more realistic, but also significantly slower.

Earacher · 3 September 2013, 04:42

hi maarten,set water collidemask,help please!

sorry again - -!
but i still want to ask,is that only way create a body with water to test collision?

Maarten Baert author · 3 September 2013, 21:27

Quote: Earacher

hi maarten,set water collidemask,help please!

sorry again - -!
but i still want to ask,is that only way create a body with water to test collision?

What are you trying to do?

  • If you want only some of your bodies to be affected by the water: this is currently not possible, sorry.
  • If you want to test whether a body is touching the water: use the collision test functions for boxes (the water is just a rectangle after all).

Brunoxzx · 5 September 2014, 09:14

Hello, I also need collidemasks for this kind of water, any help?

Maarten Baert author · 5 September 2014, 16:13

Quote: Brunoxzx

Hello, I also need collidemasks for this kind of water, any help?

That's currently not supported, sorry. I don't really want to add new features to this DLL anymore, I'm just answering questions (and fixing bugs if anyone finds one, but luckily this is very rare).

Brunoxzx · 5 September 2014, 23:04

Hello Maarten.

I know that this dll hasn't been improved in a long time, and I understand if you don't want to add anything to this project.

I actually prefer this dll instead of box2d for many reasons (especially the collidemask handling). So, if you can't add this to the dll, I'll do it by myself (I'm already checking the source).

However I think that I might need some advice from you, so if I can somehow contact you on skype or something to chat it would be nice. There are other little things that I think the dll needs, or at least that I need for my current project (which I'm sure you'll like and possibly be proud it was made with your dll).

Thanks.

Maarten Baert author · 6 September 2014, 17:38

Quote: Brunoxzx

Hello Maarten.

I know that this dll hasn't been improved in a long time, and I understand if you don't want to add anything to this project.

I actually prefer this dll instead of box2d for many reasons (especially the collidemask handling). So, if you can't add this to the dll, I'll do it by myself (I'm already checking the source).

However I think that I might need some advice from you, so if I can somehow contact you on skype or something to chat it would be nice. There are other little things that I think the dll needs, or at least that I need for my current project (which I'm sure you'll like and possibly be proud it was made with your dll).

Thanks.

If you need it that badly I guess I can add it :P. Get release 16 and try ep_water_set_collision. I didn't test it but it should work.