Nov 4, 2008 at 6:48 PM
is there an example for water in xna NOT SILVERLIGHT?
Nov 4, 2008 at 7:23 PM
We currently only have a water sample for silverlight. The same basic usage applies to XNA as Silverlight is only used for drawing.
Take a look at the Silverlight sample, understand the use of water and apply it to XNA.
Nov 4, 2008 at 11:45 PM
I am taking a look at the silverlight sample. Would I have to code a texture with the texture2d.setdata method?
Nov 5, 2008 at 4:21 PM
Talking about the waves?  You may be better off rendering them using 3D faces rather than sprites, and just moving the verts up and down.
Nov 10, 2008 at 7:52 AM
I had a look at converting the silverlight sample last week and came to the conclusion that the easiest way to draw the waves, with the best performance, would be to use a 'cookie-cutter' pixel-shader. However, my HLSL isn't great and I'm focusing what little time I have on the poly-union functions at the moment.
Nov 10, 2008 at 10:18 PM
what do u mean by cookie cutter Shader?
Nov 10, 2008 at 10:52 PM
How would I do this?
Nov 11, 2008 at 4:18 AM
@Jgame - You have to actually set up a vertex buffer, convert the values from CurrentWave and XPosition into a valid polygon (actually a triangle strip) in the vertex buffers format. Then render that vertex buffer with DrawUserPrimitives().


You could redraw a texture every frame. But I think that will be a lot slower than drawing a triangle strip. Plus with the triangle strip you can always add a custom water effect very easily with a custom shader.

I will say this. Jeff used all sprites in all his line drawing routines. This is terribly inefficent for the graphics card, but who cares it's just a debug view. If you end up drawing the water with the first method you will be knee deep in mostly 3D stuff. So if your only comfortable with sprites then just redraw a texture every frame. There is examples of how to draw to textures with code in the DrawingSystem.DrawingHelper namespace from the demos. I wish I could help more, but I don't have time right now. Oh, don't create a whole new texture every frame. Make one bigger then you need (big eanough to contain the tallest wave) and just rewrite the data with SetData every time the wave gets updated.
Nov 11, 2008 at 3:28 PM
@mattbettcher - I want to thank you for your recomendation but i tried this code. I think the water doesn't update so the triangle stays still.


(EffectPass pass in this.defaultEffect.CurrentTechnique.Passes)






// Draw the triangle using the XNA default shader









new VertexPositionColor[] {




new VertexPositionColor(new Vector3(wm.WaveController.XPosition[1], wm.WaveController.CurrentWave[1], 0), Color.Red),



new VertexPositionColor(new Vector3(0,1, 0), Color.Green),



new VertexPositionColor(new Vector3(-1, 0, 0), Color.Blue),



new VertexPositionColor(new Vector3(2, 0, 0), Color.Blue)




// vertexOffset



// primitiveCount





Nov 11, 2008 at 9:05 PM
@Jgame - Can you send me your project? Your going in the right direction but you need to render a triangle strip of something like 20-30 triangles. Are you setting up all the appropriate Matrix's before trying to render?

Also are you updating the wave? Based on my quick overview of the example you need to call Update for the wave every frame too.

My email is mattbettcher@gmail.com. Clean your project and send it to me if your can. I'll see what I can do.
Nov 11, 2008 at 9:48 PM
I will send my project in a few minutes