template<typename Vertex>
Graphics::GeneratedMesh class

Base classes

class DefaultRefCounted
The default implementation of a reference counted class.

Constructors, destructors, conversion operators

GeneratedMesh(int numVertices = 0, int numTriangles = 0)
~GeneratedMesh() virtual

Public functions

auto GetVertexCount() const -> int
Returns how many vertices there are in this mesh.
auto GetIndexCount() const -> int
Returns how many indices there are in this mesh.
auto GetTriangleCount() const -> int
Returns how many triangles this mesh has.
auto AddVertex(const Vertex& vertex) -> int
Adds a new vertex to this mesh, increasing the vertex count by one.
void SetVertex(int index, const Vertex& vertex)
Sets the data of a particular vertex in the mesh.
auto GetVertex(int index) const -> Vertex
Returns the vertex data of the vertex at the specified index.
void SetTriangle(int tindex, int i, int j, int k)
Sets the indices of a triangle, this can be used if the number of triangles has been specified beforehand in the constructor.
auto AddTriangle(int i, int j, int k) -> int
Adds a triangle into this mesh, given its 3 vertex indices.
void GetTriangle(int tindex, int& i, int& j, int& k) const
Used to get the indices of the triangle identified by tindex, which is the value returned by AddTriangle()
auto AddMaterial(uint32_t materialID, int start = 0, int indexCount = -1, int minVertex = 0) -> int
Assigns a material to a portion of this mesh.
auto GetMaterialCount() const -> int
Returns the amount of materials assigned to this mesh.
void ClearMaterials()
Removes all materials from the mesh. Nothing will be rendered after this.
void GetMaterial(int index, uint32_t& materialID, int& start, int& indexCount, int& minVertex) const
Gets the information about a material assigned to this mesh.
void SetTexture(int materialIndex, int samplerIndex, RenderWare::Raster* raster, int compiledStateIndex = 0)
Changes a texture for one of the materials used in this mesh.
auto GetTexture(int materialIndex, int samplerIndex, int compiledStateIndex = 0) const -> RenderWare::Raster*
Returns the raster texture that is being used for a certain material in this mesh.
auto GetTransform(int materialIndex) -> const Matrix4&
Returns the 4x4 matrix transformation that gets applied to a certain material of this mesh.
void SetTransform(int materialIndex, const Matrix4& transform)
Sets the 4x4 matrix transformation that gets applied to a certain material of this mesh.
auto GetColor(int materialIndex) -> const ColorRGBA&
Returns the color that gets applied to a certain material of this mesh.
void SetColor(int materialIndex, const ColorRGBA& color)
Sets the color that gets applied to a certain material of this mesh.
auto GetBoundingBox() -> BoundingBox
void SubmitGeometry()
void UnloadGeometry()
void Render()

Protected variables

RenderWare::VertexBuffer mVertexBuffer
RenderWare::IndexBuffer mIndexBuffer
RenderWare::VertexDescription<sizeof(Vertex::ELEMENTS)/sizeof(RenderWare::VertexElement)> mVertexDesc
vector<Vertex> mVertices
vector<uint16_t> mIndices
vector<RenderWare::Mesh> mMeshes
vector<MaterialPtr> mMaterials
vector<ColorRGBA> mColors
vector<Matrix4> mTransforms
BoundingBox mBounds
bool mBoundsValid

Function documentation

template<typename Vertex>
int Graphics::GeneratedMesh<Vertex>::GetIndexCount() const

Returns how many indices there are in this mesh.

The triangle count will be this quantity divided by 3.

template<typename Vertex>
int Graphics::GeneratedMesh<Vertex>::GetTriangleCount() const

Returns how many triangles this mesh has.

The triangle count is just the index count divided by 3.

template<typename Vertex>
int Graphics::GeneratedMesh<Vertex>::AddVertex(const Vertex& vertex)

Adds a new vertex to this mesh, increasing the vertex count by one.

Parameters
vertex The vertex data that will be added.
Returns The index of this vertex.

Returns the index of the new vertex.

template<typename Vertex>
void Graphics::GeneratedMesh<Vertex>::SetVertex(int index, const Vertex& vertex)

Sets the data of a particular vertex in the mesh.

Parameters
index The index of the vertex to set.
vertex

The index is expected to be between 0 and the vertex count.

template<typename Vertex>
Vertex Graphics::GeneratedMesh<Vertex>::GetVertex(int index) const

Returns the vertex data of the vertex at the specified index.

Parameters
index The index of the vertex.

template<typename Vertex>
void Graphics::GeneratedMesh<Vertex>::SetTriangle(int tindex, int i, int j, int k)

Sets the indices of a triangle, this can be used if the number of triangles has been specified beforehand in the constructor.

Parameters
tindex Index of the triangle
i
j
k

template<typename Vertex>
int Graphics::GeneratedMesh<Vertex>::AddTriangle(int i, int j, int k)

Adds a triangle into this mesh, given its 3 vertex indices.

Parameters
i
j
k
Returns The index of the triangle.

template<typename Vertex>
void Graphics::GeneratedMesh<Vertex>::GetTriangle(int tindex, int& i, int& j, int& k) const

Used to get the indices of the triangle identified by tindex, which is the value returned by AddTriangle()

Parameters
tindex Index of the triangle, as returned by AddTriangle()
i
j
k

template<typename Vertex>
int Graphics::GeneratedMesh<Vertex>::AddMaterial(uint32_t materialID, int start = 0, int indexCount = -1, int minVertex = 0)

Assigns a material to a portion of this mesh.

The material is only assigned to the triangles made with the indices between start and start + indexCount; with the default parameters, the material will be assigned to all the mesh. minVertex is used for performance purposes, and is the lowest vertex index that will have the material.

The method returns the index of this material, which can be used to later assign textures.

template<typename Vertex>
int Graphics::GeneratedMesh<Vertex>::GetMaterialCount() const

Returns the amount of materials assigned to this mesh.

This can be used to iterate them using GetMaterial().

template<typename Vertex>
void Graphics::GeneratedMesh<Vertex>::GetMaterial(int index, uint32_t& materialID, int& start, int& indexCount, int& minVertex) const

Gets the information about a material assigned to this mesh.

Parameters
index The index of the material, between 0 and GetMaterialCount()
materialID out The ID of the material.
start out
indexCount out
minVertex out

For a given material index, it gets the parameters with which it was assigned.

template<typename Vertex>
void Graphics::GeneratedMesh<Vertex>::SetTexture(int materialIndex, int samplerIndex, RenderWare::Raster* raster, int compiledStateIndex = 0)

Changes a texture for one of the materials used in this mesh.

Parameters
materialIndex The index of the material to change, as returned by AddMaterial().
samplerIndex The index of the sampler where the texture will be assigned.
raster The raster object to assign.
compiledStateIndex For materials that have more than one compiled state, which one will be changed.

The raster object will NOT be memory managed by this mesh.

template<typename Vertex>
RenderWare::Raster* Graphics::GeneratedMesh<Vertex>::GetTexture(int materialIndex, int samplerIndex, int compiledStateIndex = 0) const

Returns the raster texture that is being used for a certain material in this mesh.

Parameters
materialIndex The index of the material, as returned by AddMaterial().
samplerIndex The index of the sampler of the texture inside the material.
compiledStateIndex For materials that have more than one compiled state.
Returns The raster texture used in the material.

template<typename Vertex>
const Matrix4& Graphics::GeneratedMesh<Vertex>::GetTransform(int materialIndex)

Returns the 4x4 matrix transformation that gets applied to a certain material of this mesh.

Parameters
materialIndex The index of the material, as returned by AddMaterial().
Returns The 4x4 matrix transformation

By default it's the identity, that is, no transform.

template<typename Vertex>
void Graphics::GeneratedMesh<Vertex>::SetTransform(int materialIndex, const Matrix4& transform)

Sets the 4x4 matrix transformation that gets applied to a certain material of this mesh.

Parameters
materialIndex The index of the material, as returned by AddMaterial().
transform
Returns The 4x4 matrix transformation

By default it's the identity, that is, no transform.

template<typename Vertex>
const ColorRGBA& Graphics::GeneratedMesh<Vertex>::GetColor(int materialIndex)

Returns the color that gets applied to a certain material of this mesh.

Parameters
materialIndex The index of the material, as returned by AddMaterial().
Returns The material color.

By default it's white.

template<typename Vertex>
void Graphics::GeneratedMesh<Vertex>::SetColor(int materialIndex, const ColorRGBA& color)

Sets the color that gets applied to a certain material of this mesh.

Parameters
materialIndex The index of the material, as returned by AddMaterial().
color
Returns The material color.

By default it's white.