# DXGfxLib.Batch Class Reference

The batch class. This class can be useful if we have many instances of a geometry with a small number of faces. In that specific situation you can make a batch out of these geometries. They will be pre transform and but in one big mesh. At the moment you should use geometries with only one subset, if you have several materials and subsets in your mesh all vertices that will be put in the big mesh will be rendered with first material and texture as if they were all part of subset 0. During my testing I have attempted to use this class for the tress of the demo. I was doing these tests with trees of 1600 faces (quite a lot for a tree but good for testing :)) this did not give good results. In fact it was much better to have each tree as a separate SceneObject. This might change based on which machine you run the program on but there will always be some tradeoff to make. At the moment the limit for the big buffer is 5000. Maybe that's still too high. More...

Inherits DXGfxLib::IDrawable, and DXGfxLib::IDrawable.

Inherited by DXGfxLib.Impostor, and DXGfxLib.Impostor.

Collaboration diagram for DXGfxLib.Batch:

[legend]

List of all members.

## Public Member Functions
| Batch ()
| Our default constructor. Before calling this constructor we need to have initialized DXGfxManager and to have passed a valid D3D device to it.
void | Dispose ()
| The usual Dispose method. We need to dispose our meshes and textures.
void | SetEffectsValues (Device d3ddevice, Effect eff, int pass)
| All classes implementing IDrawable interface have this. In fact this method is called during rendering to leave an opportunity to each class implementing that interface to pass values to the effect that will be used for rendering. This is quite important as a single effect can be used for a lot of different geometries but several parameters are bound to vary. In case we have vertex shader the world mat will change... textures to feed to the various texture stages are also going to change...
void | Draw (Device d3ddevice)
| The name says it all. Don't be lured by the method code. In fact when we build meshes attributesId are lost and thus all vertices appears as part of subset 0.
void | Populate (Mesh initialMesh, Material[] materials, Texture[] textures, Matrix[] matrices)
| This method is called to prepare the Batch for rendering. You pass the mesh for the geometry you want to draw and you pass in your materials, textures and matrices. The only scope of this method is to determine how many instances can be put per BigMesh. The rest of the work is performed in BuildOneBigMeshForStaticInstanciating.
Mesh | BuildOneBigMeshForStaticInstanciating (Matrix[] worldMatrices, int startIndex, int endIndex)
| Called from Populate. This method do perform the real job of pre transforming all the vertices and feeding them in the BigMesh. For pre transforming the vertices we call the Transform method of this class. This method will be called one time per BigMesh we are going to create (obviously with different parameters each time).
CustomVertex.PositionNormalTextured[] | Transform (CustomVertex.PositionNormalTextured[] vertices, Matrix mat)
| This method only perform the pre transformation of the vertices position in 3D space so that they will be displayed with the desired position and orientation even if the Draw call with be performed with a world mat different from what that specific instance world mat would have been. This is needed with batch we render several geometries in one call so the world mat is the same for all instances. (Note that if one day I have time to add shader instanciating methods this won't be true anymore as the positions and orientations could be passed as shader constants.
Int16[] | AddOffset (Int16[] inIndices, int offset)
| Name is pretty explicit. This is simple but needed.
int | CompareTo (Object obj)
| Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.
int | CompareTo (SceneObject sceneObj)
| Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.
int | CompareTo (IDrawable sceneObj)
| Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.
| Batch ()
| Our default constructor. Before calling this constructor we need to have initialized DXGfxManager and to have passed a valid D3D device to it.
void | Dispose ()
| The usual Dispose method. We need to dispose our meshes and textures.
void | SetEffectsValues (Device d3ddevice, Effect eff, int pass)
| All classes implementing IDrawable interface have this. In fact this method is called during rendering to leave an opportunity to each class implementing that interface to pass values to the effect that will be used for rendering. This is quite important as a single effect can be used for a lot of different geometries but several parameters are bound to vary. In case we have vertex shader the world mat will change... textures to feed to the various texture stages are also going to change...
void | Draw (Device d3ddevice)
| The name says it all. Don't be lured by the method code. In fact when we build meshes attributesId are lost and thus all vertices appears as part of subset 0.
void | Populate (Mesh initialMesh, Material[] materials, Texture[] textures, Matrix[] matrices)
| This method is called to prepare the Batch for rendering. You pass the mesh for the geometry you want to draw and you pass in your materials, textures and matrices. The only scope of this method is to determine how many instances can be put per BigMesh. The rest of the work is performed in BuildOneBigMeshForStaticInstanciating.
Mesh | BuildOneBigMeshForStaticInstanciating (Matrix[] worldMatrices, int startIndex, int endIndex)
| Called from Populate. This method do perform the real job of pre transforming all the vertices and feeding them in the BigMesh. For pre transforming the vertices we call the Transform method of this class. This method will be called one time per BigMesh we are going to create (obviously with different parameters each time).
CustomVertex.PositionNormalTextured[] | Transform (CustomVertex.PositionNormalTextured[] vertices, Matrix mat)
| This method only perform the pre transformation of the vertices position in 3D space so that they will be displayed with the desired position and orientation even if the Draw call with be performed with a world mat different from what that specific instance world mat would have been. This is needed with batch we render several geometries in one call so the world mat is the same for all instances. (Note that if one day I have time to add shader instanciating methods this won't be true anymore as the positions and orientations could be passed as shader constants.
Int16[] | AddOffset (Int16[] inIndices, int offset)
| Name is pretty explicit. This is simple but needed.
int | CompareTo (Object obj)
| Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.
int | CompareTo (SceneObject sceneObj)
| Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.
int | CompareTo (IDrawable sceneObj)
| Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.
## Public Attributes
Material[] | meshMaterials
| Our big mesh materials. Only the first one is used at the moment. AttributesId are not correctly populated in the big mesh. This is a potential TODO.
Texture[] | meshTextures
| These are our big mesh textures.
Mesh[] | meshes = null
| Our big meshes (in case we need several because there are too many instances to fit in one single big mesh).
## Protected Attributes
bool | hide = false
| A boolean which allow use to specific if the SceneObject should be displayed or not.
## Properties
EffectGroup | AssociatedEffectGroup`[get, set]`
| The associated effect group accessors.
bool | Hide`[get, set]`
| Accessor for hide boolean. When true the scene object won't be rendered.

## Detailed Description

The batch class. This class can be useful if we have many instances of a geometry with a small number of faces. In that specific situation you can make a batch out of these geometries. They will be pre transform and but in one big mesh. At the moment you should use geometries with only one subset, if you have several materials and subsets in your mesh all vertices that will be put in the big mesh will be rendered with first material and texture as if they were all part of subset 0. During my testing I have attempted to use this class for the tress of the demo. I was doing these tests with trees of 1600 faces (quite a lot for a tree but good for testing :)) this did not give good results. In fact it was much better to have each tree as a separate SceneObject. This might change based on which machine you run the program on but there will always be some tradeoff to make. At the moment the limit for the big buffer is 5000. Maybe that's still too high.

I wanted to test hardware instanciating from the class but I add no time to do that so far. THis is a potential TODO.

Definition at line 51 of file Batch.cs.

## Constructor & Destructor Documentation

DXGfxLib.Batch.Batch | ( |  | ) |

Our default constructor. Before calling this constructor we need to have initialized DXGfxManager and to have passed a valid D3D device to it.

Definition at line 117 of file Batch.cs.

DXGfxLib.Batch.Batch | ( |  | ) |

Our default constructor. Before calling this constructor we need to have initialized DXGfxManager and to have passed a valid D3D device to it.

Definition at line 117 of file Batch.cs.

## Member Function Documentation

Int16 [] DXGfxLib.Batch.AddOffset | ( | Int16[] | inIndices,
|  | int | offset |
| ) |  |  |

Name is pretty explicit. This is simple but needed.

Parameters:

  | inIndices |
  | offset |

Returns:

Definition at line 343 of file Batch.cs.

Int16 [] DXGfxLib.Batch.AddOffset | ( | Int16[] | inIndices,
|  | int | offset |
| ) |  |  |

Name is pretty explicit. This is simple but needed.

Parameters:

  | inIndices |
  | offset |

Returns:

Definition at line 343 of file Batch.cs.

Here is the caller graph for this function:

Mesh DXGfxLib.Batch.BuildOneBigMeshForStaticInstanciating | ( | Matrix[] | worldMatrices,
|  | int | startIndex,
|  | int | endIndex |
| ) |  |  |

Called from Populate. This method do perform the real job of pre transforming all the vertices and feeding them in the BigMesh. For pre transforming the vertices we call the Transform method of this class. This method will be called one time per BigMesh we are going to create (obviously with different parameters each time).

Parameters:

  | worldMatrices |
  | startIndex |
  | endIndex |

Returns:

Definition at line 234 of file Batch.cs.

Here is the call graph for this function:

Mesh DXGfxLib.Batch.BuildOneBigMeshForStaticInstanciating | ( | Matrix[] | worldMatrices,
|  | int | startIndex,
|  | int | endIndex |
| ) |  |  |

Called from Populate. This method do perform the real job of pre transforming all the vertices and feeding them in the BigMesh. For pre transforming the vertices we call the Transform method of this class. This method will be called one time per BigMesh we are going to create (obviously with different parameters each time).

Parameters:

  | worldMatrices |
  | startIndex |
  | endIndex |

Returns:

Definition at line 234 of file Batch.cs.

Here is the call graph for this function:

Here is the caller graph for this function:

int DXGfxLib.Batch.CompareTo | ( | IDrawable | sceneObj | ) |

Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.

Parameters:

  | sceneObj |

Returns:

Definition at line 395 of file Batch.cs.

Here is the call graph for this function:

int DXGfxLib.Batch.CompareTo | ( | SceneObject | sceneObj | ) |

Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.

Parameters:

  | sceneObj |

Returns:

Definition at line 383 of file Batch.cs.

Here is the call graph for this function:

int DXGfxLib.Batch.CompareTo | ( | Object | obj | ) |

Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.

Parameters:

  | obj |

Returns:

Definition at line 364 of file Batch.cs.

Here is the call graph for this function:

int DXGfxLib.Batch.CompareTo | ( | IDrawable | sceneObj | ) |

Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.

Parameters:

  | sceneObj |

Returns:

Definition at line 395 of file Batch.cs.

Here is the call graph for this function:

int DXGfxLib.Batch.CompareTo | ( | SceneObject | sceneObj | ) |

Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.

Parameters:

  | sceneObj |

Returns:

Definition at line 383 of file Batch.cs.

Here is the call graph for this function:

int DXGfxLib.Batch.CompareTo | ( | Object | obj | ) |

Each scene object has an associated effect. We want SceneObject to implement the CompareTo method, thus when they will be added to the sorted list of objects to be rendered, objects are going to be ordered based on the effect filename they use.

Parameters:

  | obj |

Returns:

Definition at line 364 of file Batch.cs.

Here is the call graph for this function:

void DXGfxLib.Batch.Dispose | ( |  | ) |

The usual Dispose method. We need to dispose our meshes and textures.

Definition at line 125 of file Batch.cs.

void DXGfxLib.Batch.Dispose | ( |  | ) |

The usual Dispose method. We need to dispose our meshes and textures.

Definition at line 125 of file Batch.cs.

Here is the caller graph for this function:

void DXGfxLib.Batch.Draw | ( | Device | d3ddevice | ) |

The name says it all. Don't be lured by the method code. In fact when we build meshes attributesId are lost and thus all vertices appears as part of subset 0.

Parameters:

  | d3ddevice |

Definition at line 164 of file Batch.cs.

void DXGfxLib.Batch.Draw | ( | Device | d3ddevice | ) |

The name says it all. Don't be lured by the method code. In fact when we build meshes attributesId are lost and thus all vertices appears as part of subset 0.

Parameters:

  | d3ddevice |

Definition at line 164 of file Batch.cs.

void DXGfxLib.Batch.Populate | ( | Mesh | initialMesh,
|  | Material[] | materials,
|  | Texture[] | textures,
|  | Matrix[] | matrices |
| ) |  |  |

This method is called to prepare the Batch for rendering. You pass the mesh for the geometry you want to draw and you pass in your materials, textures and matrices. The only scope of this method is to determine how many instances can be put per BigMesh. The rest of the work is performed in BuildOneBigMeshForStaticInstanciating.

Parameters:

  | initialMesh |
  | materials |
  | textures |
  | matrices |

Definition at line 191 of file Batch.cs.

Here is the call graph for this function:

void DXGfxLib.Batch.Populate | ( | Mesh | initialMesh,
|  | Material[] | materials,
|  | Texture[] | textures,
|  | Matrix[] | matrices |
| ) |  |  |

This method is called to prepare the Batch for rendering. You pass the mesh for the geometry you want to draw and you pass in your materials, textures and matrices. The only scope of this method is to determine how many instances can be put per BigMesh. The rest of the work is performed in BuildOneBigMeshForStaticInstanciating.

Parameters:

  | initialMesh |
  | materials |
  | textures |
  | matrices |

Definition at line 191 of file Batch.cs.

Here is the call graph for this function:

Here is the caller graph for this function:

void DXGfxLib.Batch.SetEffectsValues | ( | Device | d3ddevice,
|  | Effect | eff,
|  | int | pass |
| ) |  |  |

All classes implementing IDrawable interface have this. In fact this method is called during rendering to leave an opportunity to each class implementing that interface to pass values to the effect that will be used for rendering. This is quite important as a single effect can be used for a lot of different geometries but several parameters are bound to vary. In case we have vertex shader the world mat will change... textures to feed to the various texture stages are also going to change...

Parameters:

  | d3ddevice |
  | eff |
  | pass |

Implements DXGfxLib.IDrawable.

Definition at line 153 of file Batch.cs.

void DXGfxLib.Batch.SetEffectsValues | ( | Device | d3ddevice,
|  | Effect | eff,
|  | int | pass |
| ) |  |  |

All classes implementing IDrawable interface have this. In fact this method is called during rendering to leave an opportunity to each class implementing that interface to pass values to the effect that will be used for rendering. This is quite important as a single effect can be used for a lot of different geometries but several parameters are bound to vary. In case we have vertex shader the world mat will change... textures to feed to the various texture stages are also going to change...

Parameters:

  | d3ddevice |
  | eff |
  | pass |

Implements DXGfxLib.IDrawable.

Definition at line 153 of file Batch.cs.

CustomVertex.PositionNormalTextured [] DXGfxLib.Batch.Transform | ( | CustomVertex.PositionNormalTextured[] | vertices,
|  | Matrix | mat |
| ) |  |  |

This method only perform the pre transformation of the vertices position in 3D space so that they will be displayed with the desired position and orientation even if the Draw call with be performed with a world mat different from what that specific instance world mat would have been. This is needed with batch we render several geometries in one call so the world mat is the same for all instances. (Note that if one day I have time to add shader instanciating methods this won't be true anymore as the positions and orientations could be passed as shader constants.

Parameters:

  | vertices |
  | mat |

Returns:

Definition at line 308 of file Batch.cs.

CustomVertex.PositionNormalTextured [] DXGfxLib.Batch.Transform | ( | CustomVertex.PositionNormalTextured[] | vertices,
|  | Matrix | mat |
| ) |  |  |

This method only perform the pre transformation of the vertices position in 3D space so that they will be displayed with the desired position and orientation even if the Draw call with be performed with a world mat different from what that specific instance world mat would have been. This is needed with batch we render several geometries in one call so the world mat is the same for all instances. (Note that if one day I have time to add shader instanciating methods this won't be true anymore as the positions and orientations could be passed as shader constants.

Parameters:

  | vertices |
  | mat |

Returns:

Definition at line 308 of file Batch.cs.

Here is the caller graph for this function:

## Member Data Documentation

bool DXGfxLib.Batch::hide = false`[protected]`

A boolean which allow use to specific if the SceneObject should be displayed or not.

Definition at line 76 of file Batch.cs.

Mesh [] DXGfxLib.Batch.meshes = null

Our big meshes (in case we need several because there are too many instances to fit in one single big mesh).

Definition at line 101 of file Batch.cs.

Material [] DXGfxLib.Batch.meshMaterials

Our big mesh materials. Only the first one is used at the moment. AttributesId are not correctly populated in the big mesh. This is a potential TODO.

Definition at line 91 of file Batch.cs.

Texture [] DXGfxLib.Batch.meshTextures

These are our big mesh textures.

Definition at line 96 of file Batch.cs.

## Property Documentation

EffectGroup DXGfxLib.Batch::AssociatedEffectGroup`[get, set]`

The associated effect group accessors.

Implements DXGfxLib.IDrawable.

Definition at line 68 of file Batch.cs.

bool DXGfxLib.Batch::Hide`[get, set]`

Accessor for hide boolean. When true the scene object won't be rendered.

Implements DXGfxLib.IDrawable.

Definition at line 82 of file Batch.cs.

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

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