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, D3DPRIMITIVETYPE primitiveType = D3DPRIMITIVETYPE::D3DPT_TRIANGLELIST)
~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.
auto SetVertex(int index, const Vertex& vertex) -> void
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.
auto ModifyVertex(int index) -> Vertex&
auto SetTriangle(int tindex, int i, int j, int k) -> void
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.
auto GetTriangle(int tindex, int& i, int& j, int& k) const -> void
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.
auto ClearMaterials() -> void
Removes all materials from the mesh. Nothing will be rendered after this.
auto GetMaterial(int index, uint32_t& materialID, int& start, int& indexCount, int& minVertex) const -> void
Gets the information about a material assigned to this mesh.
auto GetMaterial(int index) const -> Material*
auto SetTexture(int materialIndex, int samplerIndex, RenderWare::Raster* raster, int compiledStateIndex = 0) -> void
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 Math::Matrix4&
Returns the 4x4 matrix transformation that gets applied to a certain material of this mesh.
auto SetTransform(int materialIndex, const Math::Matrix4& transform) -> void
Sets the 4x4 matrix transformation that gets applied to a certain material of this mesh.
auto GetColor(int materialIndex) -> const Math::ColorRGBA&
Returns the color that gets applied to a certain material of this mesh.
auto SetColor(int materialIndex, const Math::ColorRGBA& color) -> void
Sets the color that gets applied to a certain material of this mesh.
auto GetBoundingBox() -> Math::BoundingBox
auto SubmitGeometry() -> void
auto UnloadGeometry() -> void
auto Render() -> void

Protected variables

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

Function documentation

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

Returns how many indices there are in this mesh.

The triangle count will be this quantity divided by 3.

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

Returns how many triangles this mesh has.

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

template<typename Vertex _1>
int Graphics::GeneratedMesh<_1>::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 _1>
void Graphics::GeneratedMesh<_1>::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 _1>
Vertex Graphics::GeneratedMesh<_1>::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 _1>
void Graphics::GeneratedMesh<_1>::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 _1>
int Graphics::GeneratedMesh<_1>::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 _1>
void Graphics::GeneratedMesh<_1>::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 _1>
int Graphics::GeneratedMesh<_1>::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 _1>
int Graphics::GeneratedMesh<_1>::GetMaterialCount() const

Returns the amount of materials assigned to this mesh.

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

template<typename Vertex _1>
void Graphics::GeneratedMesh<_1>::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 _1>
void Graphics::GeneratedMesh<_1>::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 _1>
RenderWare::Raster* Graphics::GeneratedMesh<_1>::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 _1>
const Math::Matrix4& Graphics::GeneratedMesh<_1>::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 _1>
void Graphics::GeneratedMesh<_1>::SetTransform(int materialIndex, const Math::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 _1>
const Math::ColorRGBA& Graphics::GeneratedMesh<_1>::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 _1>
void Graphics::GeneratedMesh<_1>::SetColor(int materialIndex, const Math::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.