Drawing water

Apr 29, 2009 at 3:02 AM
Hi

Ive just got waves and water working,  but I dont know how to draw them.

Im using DirectX, and Im trying to draw the shape filled with a semitransparent color. Ive tried using TriangleFans, but when the triangles overlap, from a wave higher than the previous one, the colour gets blended twice, making ugly darker triangles.

I could also painstakingly go through every point and work out a method to make triangles that dont overlap, but that might be hard :)

Anyone with ideas, please help.
Apr 29, 2009 at 5:47 AM
Hi I found a solution. Im not sure how fast it is, running real time but it seems OK on my pc. There are probably better ways though.

You pass an array of points making a shape and it will transform it into an array of triangles for rendering. Usefull for anyone wanting to draw complex shapes without using textures.

http://xnawiki.com/index.php?title=Polygon_Triangulation
(note: You must apply the fixes noted in the discussion or there are errors)

Theres also this:

http://www.codeplex.com/triangulator

It was on Ziggyware (I think someone also mentioned it in a previous post somewhere) and it does the same thing but has some extras too, like cutting out a hole in a shape.

Something else that would be helpfull that Id like to see is the ability to pass 2 overlapping shapes and have it make 1 shape. It might be a good addition to the engine too, to combine geometries into one shape.

Anyway hope this helps someone too


Apr 29, 2009 at 8:26 AM
I'm not using water in my project, but I just want to let you know that there are a lot of us bookmarking your solutions for future reference (this was an issue I was asking myself about a few weeks ago), just in case if you wonder about not having too many answers in the thread :)

In other words: Thanks for this post.
Apr 30, 2009 at 1:24 AM
I agree with Pnick,
I was wondering how to do a sort of mask on a texture to fill polygons,
also it will be great for future reference for games i may wanna make with water
also there is a demo in the farseer samples that can do unions, subtractions, combinations, and simplifications on multiple geometries,
its awesome : )
I havent bothered learning it though, its just really cool
Apr 30, 2009 at 4:06 AM
That sort of thing is coming in 2.1 as i recall...
Apr 30, 2009 at 5:46 AM
Well theres a demo that does it already,
i think its like the last one in advanced samples
Coordinator
Apr 30, 2009 at 3:03 PM
Edited Apr 30, 2009 at 3:15 PM
Only the source control contains the demo with polygon cutting and adding. It is a nice bunch of tools to have, and combined with the SAT algorithm in 2.1, it opens up whole new possibility.

Edit: And yes, XNA water sample will come. It's on the Farseer Physics 2.2 development list, but it might come a little sooner (read 2.1) if Matt has the time to hookup his wave drawing to the demo in the source control.
He is quite busy at the moment, I hope he gets some vacation soon to work on FP.
May 1, 2009 at 1:35 AM
Hi Where can I find the demo with polygon cutting and adding?
genbox says its in the source control, does this mean one of the files under Source Code? Please tell me where I can find it.

Thanks
May 1, 2009 at 2:02 AM
It should be in the advanced sample in one of the recent check-ins,
i saw it a while back so unless they removed it it should be in any recent checkins
And yes those downloads are under source code.