@c -*-texinfo-*-
@node MeshObject Watermesh, Furmesh Mesh, MeshObject Haze, MeshObject
@subsection Watermesh Mesh Object
@cindex MeshObject
@cindex @code{iMeshObject}
@cindex @code{iMeshObjectFactory}
@cindex @code{iMeshObjectType}
@cindex @code{iWaterMeshState}
@cindex @code{iWaterFactoryState}

@emph{Written by Pavel Krajcevski,
@email{Krajcevski@@gmail.com}.}

A watermesh is a simple mesh representing a grid. In its simplest form it can
be used to render a square. It requires a specific shader to make it look like
water. A watermesh is generally preferred since it is very simple to define the
bounds and furthermore it supports ocean creation with very basic LOD calculations.

@subsubheading Basic Structure

The following @sc{scf} class names are used (for @code{csLoadPlugin}):

@itemize @bullet
@item
Type plugin: @code{crystalspace.mesh.object.watermesh}
@item
Loader plugin: @code{crystalspace.mesh.loader.watermesh}
@item
Factory loader plugin: @code{crystalspace.mesh.loader.factory.watermesh}
@end itemize

Objects in this plugin implement the following @sc{scf} interfaces, which you
can retrieve with @code{scfQueryInterface}:

@itemize @bullet
@item
@emph{MeshObject}
@itemize @bullet
@item
Implements @samp{iMeshObject}
@item
Implements @samp{iWaterMeshState}
@end itemize
@item
@emph{MeshObjectFactory}
@itemize @bullet
@item
Implements @samp{iMeshObjectFactory}
@item
Implements @samp{iWaterFactoryState}
@end itemize
@item
@emph{MeshObjectType}
@itemize @bullet
@item
Implements @samp{iMeshObjectType}
@end itemize
@end itemize

@subsubheading Factory State Interface

Use the @samp{iWaterFactoryState} @sc{scf} interface to access settings for
a watermesh factory.  The definition of this interface can be found in
@file{CS/include/imesh/watermesh.h} and that is also the include file you need
to include in your applications to use this plugin.  Using this interface you
can access the material, dimensions, murkiness, and whether or not you want an
ocean for your watermesh factory.

@subsubheading Factory Loader

Here is a list of all the tags supported by a watermesh factory and their
meaning:
@itemize @bullet
@item @samp{width}
Determine the width of the watermesh in the x direction. This must be an integer.
@item @samp{length}
Determine the length of the watermesh in the z direction. This must be an integer.
@item @samp{gran}
Determine the granularity of the mesh, i.e. the amount of vertices per unit length.
For example, a granularity of two would make vertex coordinates at 0, 0.5, 1, 1.5, etc.
@item @samp{murk}
Set the murkiness of the water. This determines how transparent the water is. Must be a number
between zero and one. Default is 0.3.
@item @samp{isocean}
Boolean value for whether or not you want the factory to define an ocean. If the mesh is an
ocean then the values for @samp{width}, @samp{length}, and @samp{gran} are ignored.
@end itemize

@subsubheading Object State Interface

@samp{iWaterMeshState} (residing in @file{CS/include/imesh/watermesh.h}) is
the @sc{scf} interface that you can use to manipulate settings for a watermesh
object.  By using this interface you can access the material for a watermesh object.

@subsubheading Object Loader

Here is a list of all the tags supported by a watermesh object and their
meaning:
@itemize @bullet
@item @samp{factory}
The name of the factory to use.
@item @samp{material}
For this object, override the material from the factory.
@end itemize

@subsubheading Water Shaders

Currently, most of the work into rendering realistic water is determined by the shaders
associated with the mesh. For this there is a predefined shader in 
@file{CS/data/shader/water/water.xml}. Also, the shader currently supports the use of
multisampling a normal map to create a rippling effect on the water. This requires a
normal map defined in tangent space, some of which can be found in @file{CS/data/water/}

