Game Development Community

water block shape

by Roger D Vargas · in Torque 3D Beginner · 04/23/2014 (9:31 am) · 6 replies

Is it possible to adapt the water blocks to other shapes than square? i have a rounded fountain and cant make the water patch fit precisely inside it (obviously, thats impossible).

#1
04/23/2014 (4:30 pm)
I came across this issue as well for future puddles and water fountains and I think the best thing is to make an animated shape that may have triggers that allow for there to be different animations depending on what is happening. The waterblock is amazingly done, but I think it only works effectively with terrain scenarios.
#2
04/23/2014 (4:59 pm)
I ran into the same issue. I put it aside but when I saw your post I decided it was time to take a stab at it. My solution: a water hexagon. It was a simpler solution than a water circle and accomplished the same result. At the moment it only works visually. If you walk where the corners would be it still plays water effects, etc. I'll make an attempt to fix that later. This is only ~2 hours old so there may be even more bugs I'm unaware of, but it looks nice :D

The code:
gist.github.com/andr3wmac/11236602

A screen of it in action:
i.imgur.com/u9oltMp.png
And here's what it looks like raised out of the fountain:
i.imgur.com/zCnUcil.png
#3
04/23/2014 (7:27 pm)
@Andrew,

That looks perfect for what I would need. Not that it matters but out of curiosity, why is it a hexagon. Does it have something to do with the mathematics that you are using? The reason I am asking is because I am needing to also put the ability to have moving planets and such that remain at a constant distance from the player, and I am going to need to get into the source code to do this. I do well with scripting, but I have to get as many clues as possible in order to take the next challenge which is coding for the core engine.
#4
04/23/2014 (7:44 pm)
The water block is just a plane made up of a bunch of vertices and it's broken up into square chunks. It's generated in setupVertexBlock().

My first thought was to replace it with circle generating code, however then I remembered the turbulence and waves are done by moving the verts up and down so having 1 vert in the center and a bunch around the outside wasn't going to work well with water movement. So I scraped the circle.

Then I thought the simplest way may be to just grab the corner verts and move them in toward the center. I just needed to adjust the positions of the corner verts before its sent off to the vertex buffer. This gives it the hexagon shape. After a few tweaks it looked pretty good. You need to work both the scale and the grid size to get it to fit perfect but it wasn't too hard.

I think the last step will be to edit the functions getWaterCoverage() and getSurfaceHeight() to return -1 if the point is within the corners. I'm hoping that will stop the splash effects from playing when I walk through the corners.
#5
04/24/2014 (6:51 am)
I remember playing Balder's Gate on the PS3 and how amazed I was when walking through the puddles. I think the idea you have will create some great visuals for game dev. Thank you for going over all of that.
#6
04/24/2014 (6:51 am)
I like the circle generation idea, but you can't (for reasons you are already aware of) use the normal solution for it. You'd have to create a plane and "fill in" the rounded portions. You could just model a plane and then use it as a template for the circle - or you could create custom decimation code to break arbitrary polygons into "grids with fillers" - a more robust, useful, and interesting solution, but a little more complicated.

I keep having these ideas but I don't have any time to play with them.... Makes me sad.