# DXGfxLib.Terrain Class Reference

Terrain2 class manage a full 3D Terrain2. The Terrain2 will be built from a 2D grey level bitmap, which size need to be 259*259 nad which format need to be bmp. At loading time you need to provide a D3ddevice and a ref to an outdoor scene. The Terrain2 will be build of a multitude of tiles that will be registered to the outdoor scene graph. The current implementation of OutDoorScene feature a Quadtree for efficient culling of a Terrain2 outdoor scene. The quadtree struture is also used to optimize intersection methods. The Terrain2 is multi textured. The method used is to render at max two texture per pass which should accomodate even very old 3D cards. More...

List of all members.

## Public Member Functions
| Terrain ()
| Terrain (float desiredWidth, float desiredHeigth)
| Default constructor for Terrain. After that you won't have much until you effectively load a bitmap to really build the terrain.
void | Initialize ()
void | Initialize (float desiredWidth, float desiredHeigth)
void | DeviceChanged (Device d3ddevice, OutDoorScene scene)
| If your device has changed you need to call this one.
void | Load (Device d3ddevice, OutDoorScene scene, string ressourceName)
| This method is the most CPU intensive method of this class. It will use the bitmap to generate the terrain tiles geometry. Also each newly generated tile is going to be attached to the provided Outdoorscene. With our base implementation of Ourdoorscene this means that position in the quadtree will be determine for each newly created tile.
void | LoadFromFile (Device d3ddevice, OutDoorScene scene, string fileName)
| Load the terrain from a bitmap image used as an heigthmap. In Eter 3D Control the Terrain class will then load two texture grass.bmp and snow.bmp as well as an alphamap lightmap.dds and used those to texture the terrain. As in your specific situation I expect that your textured might be named differently, you should consider using the other load method. The lightmap.dds is used only for alpha value to know where on the terrain the snow texture should be applied. The grass texture is applied everywhere.
void | Load (Device d3ddevice, OutDoorScene scene, string fileName, string baseTextureFile, string secondTextureFile)
| Load the terrain from the bitmap in the filename file. base texture will be loaded then and applied everywhere. Then the secondtexture will also be tiled on the terrain geometry based on the alpha information in the alphamap dds file. As far as I am concerned I made up the dds file with the texture tool in the directx sdk.
float | GetHeigth (OutDoorScene scene, float x, float z)
| This method return the heigth of the terrain at the specified x and z coordinate. Remember that the z coordinate is going far away with directx default convention. The y is pointing up.
float | GetHeigth (OutDoorScene scene, float x, float y, float z)
| This method return the heigth of the terrain at the specified x and z coordinate and below the y value provided. In DX the ray intersection with a mesh is sensible to the distance between the point from which the ray is cast and the mesh here using an y value allow us to have a better precision than by cast the ray from a very high point in the sky :). This will also be consistant with a world getheigth that would be able to deal with houses with several level.
float | GetHeigth (OutDoorScene scene, Vector3 underPoint)
| Get the heigth of the tile under the point given in parameter. If the point is under the terrain level at that x and z 65536 is returned.
void | AddInstances (OutDoorScene scene, FrameworkMesh mesh, InstanceInfo[] instancesInfo)
| Terrain ()
| Terrain (float desiredWidth, float desiredHeigth)
| Default constructor for Terrain. After that you won't have much until you effectively load a bitmap to really build the terrain.
void | Initialize ()
void | Initialize (float desiredWidth, float desiredHeigth)
void | DeviceChanged (Device d3ddevice, OutDoorScene scene)
| If your device has changed you need to call this one.
void | Load (Device d3ddevice, OutDoorScene scene, string ressourceName)
| This method is the most CPU intensive method of this class. It will use the bitmap to generate the terrain tiles geometry. Also each newly generated tile is going to be attached to the provided Outdoorscene. With our base implementation of Ourdoorscene this means that position in the quadtree will be determine for each newly created tile.
void | LoadFromFile (Device d3ddevice, OutDoorScene scene, string fileName)
| Load the terrain from a bitmap image used as an heigthmap. In Eter 3D Control the Terrain class will then load two texture grass.bmp and snow.bmp as well as an alphamap lightmap.dds and used those to texture the terrain. As in your specific situation I expect that your textured might be named differently, you should consider using the other load method. The lightmap.dds is used only for alpha value to know where on the terrain the snow texture should be applied. The grass texture is applied everywhere.
void | Load (Device d3ddevice, OutDoorScene scene, string fileName, string baseTextureFile, string secondTextureFile)
| Load the terrain from the bitmap in the filename file. base texture will be loaded then and applied everywhere. Then the secondtexture will also be tiled on the terrain geometry based on the alpha information in the alphamap dds file. As far as I am concerned I made up the dds file with the texture tool in the directx sdk.
float | GetHeigth (OutDoorScene scene, float x, float z)
| This method return the heigth of the terrain at the specified x and z coordinate. Remember that the z coordinate is going far away with directx default convention. The y is pointing up.
float | GetHeigth (OutDoorScene scene, float x, float y, float z)
| This method return the heigth of the terrain at the specified x and z coordinate and below the y value provided. In DX the ray intersection with a mesh is sensible to the distance between the point from which the ray is cast and the mesh here using an y value allow us to have a better precision than by cast the ray from a very high point in the sky :). This will also be consistant with a world getheigth that would be able to deal with houses with several level.
float | GetHeigth (OutDoorScene scene, Vector3 underPoint)
| Get the heigth of the tile under the point given in parameter. If the point is under the terrain level at that x and z 65536 is returned.
void | AddInstances (OutDoorScene scene, FrameworkMesh mesh, InstanceInfo[] instancesInfo)
## Public Attributes
Texture | texture = null
| Our terrain is going to use a default texture.
Material | material
| It is also going to use a default material.
string | heightmapFile
| For some obscure reason we want to keep the filename of the bitmap used to build the terrain.
string | baseTextureFile
| The filename of the 'default' texture.
string | secondTextureFile
| Filename of a second texture that will be rendered only on the areas specified through the alphamap.
float | maxTerrainHeigth
| Out Terrain has a maximum heigth.
float | minTerrainHeigth
| A minimal height.
float | secondTexHeigth
| Not used. :).
Texture | secondTexture = null
| The second texture texture. Will be used for areas specified through the alphaMap texture.
Texture | alphaMap = null
| Used to specify where the secondTexture should be used.
float | desiredWidth
| We certainly want our terrain to have a specific width. This can be specified upon terrain creation and we keep the value in this member variable.
float | desiredHeigth
| We certainly want our terrain to have a specific heigth. This can be specified upon terrain creation and we keep the value in this member variable.
int | width
| Number of tiles along X.
int | heigth
| Number of tiles along Z (remember Z is looking far away, y is up and x is looking to the right).
float | xSpacing
| Dimension of a tile along x axis.
float | zSpacing
| Dimension of a tile along z axis.
float | stretchFactor
## Static Public Attributes
static string | terrainEffectFile = "terrainTile.fx"
| The effect file used for Terrain2 tiles. We load it once in the Terrain2 class and we pass a reference to the newly created effectGroup to all Terrain2 tiles.

## Detailed Description

Terrain2 class manage a full 3D Terrain2. The Terrain2 will be built from a 2D grey level bitmap, which size need to be 259*259 nad which format need to be bmp. At loading time you need to provide a D3ddevice and a ref to an outdoor scene. The Terrain2 will be build of a multitude of tiles that will be registered to the outdoor scene graph. The current implementation of OutDoorScene feature a Quadtree for efficient culling of a Terrain2 outdoor scene. The quadtree struture is also used to optimize intersection methods. The Terrain2 is multi textured. The method used is to render at max two texture per pass which should accomodate even very old 3D cards.

Definition at line 39 of file Terrain.cs.

## Constructor & Destructor Documentation

DXGfxLib.Terrain.Terrain | ( |  | ) |

Definition at line 144 of file Terrain.cs.

Here is the call graph for this function:

DXGfxLib.Terrain.Terrain | ( | float | desiredWidth,
|  | float | desiredHeigth |
| ) |  |  |

Default constructor for Terrain. After that you won't have much until you effectively load a bitmap to really build the terrain.

Parameters:

  | desiredWidth |
  | desiredHeigth |

Definition at line 155 of file Terrain.cs.

Here is the call graph for this function:

DXGfxLib.Terrain.Terrain | ( |  | ) |

Definition at line 144 of file Terrain.cs.

Here is the call graph for this function:

DXGfxLib.Terrain.Terrain | ( | float | desiredWidth,
|  | float | desiredHeigth |
| ) |  |  |

Default constructor for Terrain. After that you won't have much until you effectively load a bitmap to really build the terrain.

Parameters:

  | desiredWidth |
  | desiredHeigth |

Definition at line 155 of file Terrain.cs.

Here is the call graph for this function:

## Member Function Documentation

void DXGfxLib.Terrain.AddInstances | ( | OutDoorScene | scene,
|  | FrameworkMesh | mesh,
|  | InstanceInfo[] | instancesInfo |
| ) |  |  |

Definition at line 546 of file Terrain.cs.

Here is the call graph for this function:

void DXGfxLib.Terrain.AddInstances | ( | OutDoorScene | scene,
|  | FrameworkMesh | mesh,
|  | InstanceInfo[] | instancesInfo |
| ) |  |  |

Definition at line 546 of file Terrain.cs.

Here is the call graph for this function:

void DXGfxLib.Terrain.DeviceChanged | ( | Device | d3ddevice,
|  | OutDoorScene | scene |
| ) |  |  |

If your device has changed you need to call this one.

Parameters:

  | d3ddevice |
  | scene |

Definition at line 197 of file Terrain.cs.

Here is the call graph for this function:

void DXGfxLib.Terrain.DeviceChanged | ( | Device | d3ddevice,
|  | OutDoorScene | scene |
| ) |  |  |

If your device has changed you need to call this one.

Parameters:

  | d3ddevice |
  | scene |

Definition at line 197 of file Terrain.cs.

Here is the call graph for this function:

Here is the caller graph for this function:

float DXGfxLib.Terrain.GetHeigth | ( | OutDoorScene | scene,
|  | Vector3 | underPoint |
| ) |  |  |

Get the heigth of the tile under the point given in parameter. If the point is under the terrain level at that x and z 65536 is returned.

Parameters:

  | underPoint |

Returns:

Definition at line 341 of file Terrain.cs.

Here is the call graph for this function:

float DXGfxLib.Terrain.GetHeigth | ( | OutDoorScene | scene,
|  | float | x,
|  | float | y,
|  | float | z |
| ) |  |  |

This method return the heigth of the terrain at the specified x and z coordinate and below the y value provided. In DX the ray intersection with a mesh is sensible to the distance between the point from which the ray is cast and the mesh here using an y value allow us to have a better precision than by cast the ray from a very high point in the sky :). This will also be consistant with a world getheigth that would be able to deal with houses with several level.

Parameters:

  | x |
  | y |
  | z |

Returns:

Definition at line 328 of file Terrain.cs.

Here is the call graph for this function:

float DXGfxLib.Terrain.GetHeigth | ( | OutDoorScene | scene,
|  | float | x,
|  | float | z |
| ) |  |  |

This method return the heigth of the terrain at the specified x and z coordinate. Remember that the z coordinate is going far away with directx default convention. The y is pointing up.

Parameters:

  | x |
  | z |

Returns:
  the heigth of the terrain at the specified x and z position.

Definition at line 311 of file Terrain.cs.

Here is the call graph for this function:

float DXGfxLib.Terrain.GetHeigth | ( | OutDoorScene | scene,
|  | Vector3 | underPoint |
| ) |  |  |

Get the heigth of the tile under the point given in parameter. If the point is under the terrain level at that x and z 65536 is returned.

Parameters:

  | underPoint |

Returns:

Definition at line 341 of file Terrain.cs.

Here is the call graph for this function:

float DXGfxLib.Terrain.GetHeigth | ( | OutDoorScene | scene,
|  | float | x,
|  | float | y,
|  | float | z |
| ) |  |  |

This method return the heigth of the terrain at the specified x and z coordinate and below the y value provided. In DX the ray intersection with a mesh is sensible to the distance between the point from which the ray is cast and the mesh here using an y value allow us to have a better precision than by cast the ray from a very high point in the sky :). This will also be consistant with a world getheigth that would be able to deal with houses with several level.

Parameters:

  | x |
  | y |
  | z |

Returns:

Definition at line 328 of file Terrain.cs.

Here is the call graph for this function:

float DXGfxLib.Terrain.GetHeigth | ( | OutDoorScene | scene,
|  | float | x,
|  | float | z |
| ) |  |  |

This method return the heigth of the terrain at the specified x and z coordinate. Remember that the z coordinate is going far away with directx default convention. The y is pointing up.

Parameters:

  | x |
  | z |

Returns:
  the heigth of the terrain at the specified x and z position.

Definition at line 311 of file Terrain.cs.

Here is the call graph for this function:

Here is the caller graph for this function:

void DXGfxLib.Terrain.Initialize | ( | float | desiredWidth,
|  | float | desiredHeigth |
| ) |  |  |

Definition at line 165 of file Terrain.cs.

void DXGfxLib.Terrain.Initialize | ( |  | ) |

Definition at line 160 of file Terrain.cs.

Here is the call graph for this function:

void DXGfxLib.Terrain.Initialize | ( | float | desiredWidth,
|  | float | desiredHeigth |
| ) |  |  |

Definition at line 165 of file Terrain.cs.

void DXGfxLib.Terrain.Initialize | ( |  | ) |

Definition at line 160 of file Terrain.cs.

Here is the caller graph for this function:

void DXGfxLib.Terrain.Load | ( | Device | d3ddevice,
|  | OutDoorScene | scene,
|  | string | fileName,
|  | string | baseTextureFile,
|  | string | secondTextureFile |
| ) |  |  |

Load the terrain from the bitmap in the filename file. base texture will be loaded then and applied everywhere. Then the secondtexture will also be tiled on the terrain geometry based on the alpha information in the alphamap dds file. As far as I am concerned I made up the dds file with the texture tool in the directx sdk.

Parameters:

  | fileName |
  | baseTexture |
  | secondTexture |
  | alphaMap |

Definition at line 254 of file Terrain.cs.

void DXGfxLib.Terrain.Load | ( | Device | d3ddevice,
|  | OutDoorScene | scene,
|  | string | ressourceName |
| ) |  |  |

This method is the most CPU intensive method of this class. It will use the bitmap to generate the terrain tiles geometry. Also each newly generated tile is going to be attached to the provided Outdoorscene. With our base implementation of Ourdoorscene this means that position in the quadtree will be determine for each newly created tile.

Parameters:

  | d3ddevice |
  | scene |
  | ressourceName |

Definition at line 211 of file Terrain.cs.

Here is the call graph for this function:

void DXGfxLib.Terrain.Load | ( | Device | d3ddevice,
|  | OutDoorScene | scene,
|  | string | fileName,
|  | string | baseTextureFile,
|  | string | secondTextureFile |
| ) |  |  |

Load the terrain from the bitmap in the filename file. base texture will be loaded then and applied everywhere. Then the secondtexture will also be tiled on the terrain geometry based on the alpha information in the alphamap dds file. As far as I am concerned I made up the dds file with the texture tool in the directx sdk.

Parameters:

  | fileName |
  | baseTexture |
  | secondTexture |
  | alphaMap |

Definition at line 254 of file Terrain.cs.

void DXGfxLib.Terrain.Load | ( | Device | d3ddevice,
|  | OutDoorScene | scene,
|  | string | ressourceName |
| ) |  |  |

This method is the most CPU intensive method of this class. It will use the bitmap to generate the terrain tiles geometry. Also each newly generated tile is going to be attached to the provided Outdoorscene. With our base implementation of Ourdoorscene this means that position in the quadtree will be determine for each newly created tile.

Parameters:

  | d3ddevice |
  | scene |
  | ressourceName |

Definition at line 211 of file Terrain.cs.

Here is the call graph for this function:

Here is the caller graph for this function:

void DXGfxLib.Terrain.LoadFromFile | ( | Device | d3ddevice,
|  | OutDoorScene | scene,
|  | string | fileName |
| ) |  |  |

Load the terrain from a bitmap image used as an heigthmap. In Eter 3D Control the Terrain class will then load two texture grass.bmp and snow.bmp as well as an alphamap lightmap.dds and used those to texture the terrain. As in your specific situation I expect that your textured might be named differently, you should consider using the other load method. The lightmap.dds is used only for alpha value to know where on the terrain the snow texture should be applied. The grass texture is applied everywhere.

Parameters:

  | fileName | The bitmap used as heigthmap

Definition at line 225 of file Terrain.cs.

Here is the call graph for this function:

void DXGfxLib.Terrain.LoadFromFile | ( | Device | d3ddevice,
|  | OutDoorScene | scene,
|  | string | fileName |
| ) |  |  |

Load the terrain from a bitmap image used as an heigthmap. In Eter 3D Control the Terrain class will then load two texture grass.bmp and snow.bmp as well as an alphamap lightmap.dds and used those to texture the terrain. As in your specific situation I expect that your textured might be named differently, you should consider using the other load method. The lightmap.dds is used only for alpha value to know where on the terrain the snow texture should be applied. The grass texture is applied everywhere.

Parameters:

  | fileName | The bitmap used as heigthmap

Definition at line 225 of file Terrain.cs.

Here is the call graph for this function:

Here is the caller graph for this function:

## Member Data Documentation

Texture DXGfxLib.Terrain::alphaMap = null

Used to specify where the secondTexture should be used.

Definition at line 100 of file Terrain.cs.

string DXGfxLib.Terrain::baseTextureFile

The filename of the 'default' texture.

Definition at line 70 of file Terrain.cs.

float DXGfxLib.Terrain::desiredHeigth

We certainly want our terrain to have a specific heigth. This can be specified upon terrain creation and we keep the value in this member variable.

Definition at line 112 of file Terrain.cs.

float DXGfxLib.Terrain::desiredWidth

We certainly want our terrain to have a specific width. This can be specified upon terrain creation and we keep the value in this member variable.

Definition at line 106 of file Terrain.cs.

string DXGfxLib.Terrain::heightmapFile

For some obscure reason we want to keep the filename of the bitmap used to build the terrain.

Definition at line 65 of file Terrain.cs.

int DXGfxLib.Terrain::heigth

Number of tiles along Z (remember Z is looking far away, y is up and x is looking to the right).

Definition at line 122 of file Terrain.cs.

Material DXGfxLib.Terrain::material

It is also going to use a default material.

Definition at line 60 of file Terrain.cs.

float DXGfxLib.Terrain::maxTerrainHeigth

Out Terrain has a maximum heigth.

Definition at line 80 of file Terrain.cs.

float DXGfxLib.Terrain::minTerrainHeigth

A minimal height.

Definition at line 85 of file Terrain.cs.

float DXGfxLib.Terrain::secondTexHeigth

Not used. :).

Definition at line 90 of file Terrain.cs.

Texture DXGfxLib.Terrain::secondTexture = null

The second texture texture. Will be used for areas specified through the alphaMap texture.

Definition at line 95 of file Terrain.cs.

string DXGfxLib.Terrain::secondTextureFile

Filename of a second texture that will be rendered only on the areas specified through the alphamap.

Definition at line 75 of file Terrain.cs.

float DXGfxLib.Terrain::stretchFactor

Definition at line 137 of file Terrain.cs.

static string DXGfxLib.Terrain::terrainEffectFile = "terrainTile.fx"`[static]`

The effect file used for Terrain2 tiles. We load it once in the Terrain2 class and we pass a reference to the newly created effectGroup to all Terrain2 tiles.

Definition at line 45 of file Terrain.cs.

Texture DXGfxLib.Terrain::texture = null

Our terrain is going to use a default texture.

Definition at line 55 of file Terrain.cs.

int DXGfxLib.Terrain::width

Number of tiles along X.

Definition at line 117 of file Terrain.cs.

float DXGfxLib.Terrain::xSpacing

Dimension of a tile along x axis.

Definition at line 127 of file Terrain.cs.

float DXGfxLib.Terrain::zSpacing

Dimension of a tile along z axis.

Definition at line 132 of file Terrain.cs.

The documentation for this class was generated from the following files:

- D:/guillaume/guillara/3D/DXGfx/Backup/DXGfxLib/Terrain.cs
- D:/guillaume/guillara/3D/DXGfx/DXGfxLib/Terrain.cs