Maarten Baert's website

Game Maker / C++ projects

Home Model Creator ExtremePhysics Game Maker DLLs SimpleScreenRecorder AlterPCB Quadcopters   Recent comments Search

Last modified: Sat, 6 Sep 2014
Refresh

Water


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

Dark_master4

Comment #1: Wed, 14 Mar 2012, 14:19 (GMT+1, DST)

Quote


Does your engine simulate air resistance?

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

Maarten Baert

Administrator

Comment #2: Fri, 16 Mar 2012, 21:39 (GMT+1, DST)

Quote


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.

Dark_master4

Comment #3: Sat, 17 Mar 2012, 17:46 (GMT+1, DST)

Quote


Yeah, problem with damping is that it acts the same no matter your speed so it's not very realistic at lower speeds. Will try and tell you what the performance drop is.

Edit: I'm losing permanent 2fps when I use ep_water for air simulation. I'll stick to damping.

Last modified: Sat, 17 Mar 2012, 17:56 (GMT+1, DST)

Earacher

Comment #4: Tue, 3 Sep 2013, 4:42 (GMT+1, DST)

Quote


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?

Last modified: Tue, 3 Sep 2013, 8:58 (GMT+1, DST)

Maarten Baert

Administrator

Comment #5: Tue, 3 Sep 2013, 21:27 (GMT+1, DST)

Quote


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

Comment #6: Fri, 5 Sep 2014, 9:14 (GMT+1, DST)

Quote


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

Maarten Baert

Administrator

Comment #7: Fri, 5 Sep 2014, 16:13 (GMT+1, DST)

Quote


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

Comment #8: Fri, 5 Sep 2014, 23:04 (GMT+1, DST)

Quote


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

Administrator

Comment #9: Sat, 6 Sep 2014, 17:38 (GMT+1, DST)

Quote


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.

Brunoxzx

Comment #10: Sat, 6 Sep 2014, 19:44 (GMT+1, DST)

Quote


Wow, you're fast. I see what you did on the SimulateWater file!.

You saved me, I think it was going to take me a few days to add those simple lines of code, I get easily distracted so I was already checking all the source, I don't know why but I expended hours looking at the UpdateContacts code...

Anyway thank you!

P.D: I'll show you my game when I progress a bit more on it. I think that I'll post a comment here with the link...

Edit: Hi maarten, just came to saw that I've tested the function and it works perfectly!.

P.D2:In the function water_set_rectangle, the rectangle has to be defined in order, so the x1 and y1 need to be lesser than the x2,y2, which is disappointing, I think that if they are like that the arguments should be be "x1,y1,width,height)". Is something really simple to solve and I don't need it at xD all but I think that you could solve it for future versions xD.

Last modified: Sun, 7 Sep 2014, 8:16 (GMT+1, DST)

Write a comment