Crystal Space 2.0.0: 4.10.18 Watermesh Mesh Object

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 4.10.18 Watermesh Mesh Object

Written by Pavel Krajcevski, 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.

#### Basic Structure

The following SCF class names are used (for `csLoadPlugin`):

- Type plugin: `crystalspace.mesh.object.watermesh`
- Loader plugin: `crystalspace.mesh.loader.watermesh`
- Factory loader plugin: `crystalspace.mesh.loader.factory.watermesh`

Objects in this plugin implement the following SCF interfaces, which you can retrieve with `scfQueryInterface`:

- MeshObject
  - Implements `‘iMeshObject’`
  - Implements `‘iWaterMeshState’`
- MeshObjectFactory
  - Implements `‘iMeshObjectFactory’`
  - Implements `‘iWaterFactoryState’`
- MeshObjectType
  - Implements `‘iMeshObjectType’`

#### Factory State Interface

Use the `‘iWaterFactoryState’` SCF interface to access settings for a watermesh factory. The definition of this interface can be found in `‘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.

#### Factory Loader

Here is a list of all the tags supported by a watermesh factory and their meaning:

- `‘width’` Determine the width of the watermesh in the x direction. This must be an integer.
- `‘length’` Determine the length of the watermesh in the z direction. This must be an integer.
- `‘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.
- `‘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.
- `‘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 `‘width’`, `‘length’`, and `‘gran’` are ignored.

#### Object State Interface

`‘iWaterMeshState’` (residing in `‘CS/include/imesh/watermesh.h’`) is the 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.

#### Object Loader

Here is a list of all the tags supported by a watermesh object and their meaning:

- `‘factory’` The name of the factory to use.
- `‘material’` For this object, override the material from the factory.

#### 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 `‘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 `‘CS/data/water/’`

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated using texi2html 1.76.