The ocean simulation is an interesting and challenging topic in computer graphic rendering that has been covered in many papers and books. In Windows, it is easier to render a decent ocean or water body depending on the GPU HLSL or Cg languages. In Windows Phone 7 XNA, so far, the customized HLSL shader is not supported. The only way to solve the problem is to do the simulation on CPU of Windows Phone 7. In this recipe, you will learn to realize the ocean effect on Windows Phone 7 CPU.
The following steps demonstrate one approach to emulating an ocean on the Windows Phone CPU:
1. Create a Windows Phone Game project named
OceanGenerationCPU
, changeGame1.cs
toOceanGenerationCPUGame.cs
. Then add a new fileOcean.cs
to the project and image file to the content project.2. Define the
Ocean
class in theOcean.cs
file. Add the following lines to the class field as a data member:// The graphics device object GraphicsDevice device; // Ocean width and...