Holds information about a mesh. Used as a basis to render 3d models.
More...
Holds information about a mesh. Used as a basis to render 3d models.
See MeshManager::createOrRetrieve() or Mesh::create() for instantiation.
◆ ~Mesh()
virtual nkGraphics::Mesh::~Mesh |
( |
| ) |
|
|
virtual |
◆ getBounds()
const BoundingBox& nkGraphics::Mesh::getBounds |
( |
| ) |
const |
- Returns
- The bounds of the meshes, for reading purpose.
◆ getVertexBuffer()
Gives access to a given vertex buffer CPU memory.
- Parameters
-
index | The index of the buffer to query the memory from. |
- Returns
- A view over the buffer memory.
◆ getVertexBufferStride()
unsigned int nkGraphics::Mesh::getVertexBufferStride |
( |
unsigned int |
index | ) |
const |
Gives access to the stride of a given vertex buffer.
- Parameters
-
index | The index of the vertex buffer to query from. |
- Returns
- The stride of given vertex buffer. It will either be the one specified when adding the buffer, or the automatically computed one if not.
◆ getVertexBufferCount()
unsigned int nkGraphics::Mesh::getVertexBufferCount |
( |
| ) |
const |
- Returns
- The vertex buffer count.
◆ getIndexBuffer()
Gives access to the index buffer CPU memory.
- Returns
- A view over the buffer memory.
◆ getInputLayout()
Gives access to the input layout of the mesh, for reading purposes.
- Returns
- The input layout currently used by the mesh.
◆ getId()
unsigned int nkGraphics::Mesh::getId |
( |
| ) |
const |
- Returns
- The id of the mesh.
◆ getVertexCount()
unsigned int nkGraphics::Mesh::getVertexCount |
( |
| ) |
const |
- Returns
- The number of vertices.
◆ getIndexCount()
unsigned int nkGraphics::Mesh::getIndexCount |
( |
| ) |
const |
- Returns
- The number of indices.
◆ getTopology()
- Returns
- The topology used by the mesh.
◆ getIndexFormat()
- Returns
- The index data format used.
◆ getAutoComputeBounds()
bool nkGraphics::Mesh::getAutoComputeBounds |
( |
| ) |
const |
- Returns
- Whether the mesh auto-computes its bounds (true) or not (false).
◆ setBounds()
void nkGraphics::Mesh::setBounds |
( |
const BoundingBox & |
value | ) |
|
Allows to override the bounds of the mesh.
- Parameters
-
value | The bounds for the mesh to use. |
◆ addVertexBuffer()
void nkGraphics::Mesh::addVertexBuffer |
( |
nkMemory::BufferView< unsigned char > |
view, |
|
|
unsigned int |
stride = 0 |
|
) |
| |
Adds a vertex buffer, by referencing memory.
- Parameters
-
view | The memory to reference. |
stride | The stride of the buffer given (number of bytes to advance to get to next vertex information). If left to 0, it will be automatically computed from the layout, assuming tightly packed data. |
◆ addVertexBufferCopy()
void nkGraphics::Mesh::addVertexBufferCopy |
( |
nkMemory::BufferView< unsigned char > |
view, |
|
|
unsigned int |
stride = 0 |
|
) |
| |
Adds a vertex buffer, by copying memory.
- Parameters
-
view | The memory to copy. |
stride | The stride of the buffer given (number of bytes to advance to get to next vertex information). If left to 0, it will be automatically computed from the layout, assuming tightly packed data. |
◆ addVertexBufferForward()
void nkGraphics::Mesh::addVertexBufferForward |
( |
nkMemory::Buffer && |
buffer, |
|
|
unsigned int |
stride = 0 |
|
) |
| |
Adds a vertex buffer, by forwarding memory.
- Parameters
-
buffer | The memory to forward. |
stride | The stride of the buffer given (number of bytes to advance to get to next vertex information). If left to 0, it will be automatically computed from the layout, assuming tightly packed data. |
◆ removeVertexBuffer()
void nkGraphics::Mesh::removeVertexBuffer |
( |
unsigned int |
index | ) |
|
Removes a vertex buffer.
- Parameters
-
index | The index of the vertex buffer to remove from memory. |
◆ setIndexBuffer()
Sets the index buffer the mesh should use, by referencing it.
- Parameters
-
view | The memory to reference. |
◆ setIndexBufferCopy()
Sets the index buffer the mesh should use, by copying memory.
- Parameters
-
view | The memory to copy over. |
◆ setIndexBufferForward()
Sets the index buffer the mesh should use, by forwarding memory.
- Parameters
-
buffer | The buffer to get memory from. |
◆ setInputLayout()
Sets the input layout describing mesh data.
- Parameters
-
layout | The layout to use to interpret the mesh data. |
◆ setId()
void nkGraphics::Mesh::setId |
( |
unsigned int |
value | ) |
|
Sets the id of the mesh. Used internally for tracking.
- Parameters
-
◆ setVertexCount()
void nkGraphics::Mesh::setVertexCount |
( |
int |
value | ) |
|
Sets the number of vertices of the mesh.
- Parameters
-
value | The number of vertices to use. |
◆ setIndexCount()
void nkGraphics::Mesh::setIndexCount |
( |
int |
value | ) |
|
Sets the number of indices of the mesh.
- Parameters
-
value | The number of indices to use. |
◆ setTopology()
Sets the topology to use.
- Parameters
-
value | The primitive topology the mesh should use. |
◆ setIndexFormat()
Sets the format of indices stored in the index buffer.
- Parameters
-
value | The index format to use. |
◆ setAutoComputeBounds()
void nkGraphics::Mesh::setAutoComputeBounds |
( |
bool |
value | ) |
|
Sets whether the loading step should compute the bounds of the mesh.
- Parameters
-
value | If the bounds should be computed (true) or not (false). |
◆ computeBounds()
Manually triggers a bound computing.
- Parameters
-
positionAttributeName | The name of the position attribute within the layout to find back position data for bounds computing. |
◆ load()
virtual bool nkGraphics::Mesh::load |
( |
| ) |
|
|
overridevirtual |
Loading function. A resource goes into different states through its lifetime.
-
Created. It is awaiting configuration by external code. At this point, the resource can already be used everywhere, but it will have default values, often resulting in a no-op.
-
Loading. The configuration has been made and the load function has been called. For some resources, this status is bypassed.
-
Loaded. The resource has been loaded and all memory has been populated. At this point, the resource should operate as described.
It is possible to loop through these states during the resource lifetime, if needed.
- Returns
- Whether the loading went well (true) or not (false).
Implements nkGraphics::Resource.
◆ freeShadowBuffers()
virtual void nkGraphics::Mesh::freeShadowBuffers |
( |
| ) |
|
|
virtual |
Frees the shadow buffers, aka the CPU buffers (vertex buffers and index buffer).
Can be called after loading the mesh to free requested memory.
◆ exportClassToTree()
virtual void nkGraphics::Mesh::exportClassToTree |
( |
nkExport::Node * |
rootNode | ) |
|
|
overridevirtual |
Exports an item into a tree describing its structure and its data.
- Parameters
-
rootNode | The node into which the object has to write its related information. |
Implements nkExport::Exportable.
◆ importClassFromTree()
virtual void nkGraphics::Mesh::importClassFromTree |
( |
nkExport::Node * |
rootNode | ) |
|
|
overridevirtual |
Imports information from a tree which is supposed to describe its structure and data.
- Parameters
-
rootNode | The root node of the tree holding the information. |
Implements nkExport::Exportable.
◆ create()
Creates a standalone resource, linking it to a system, but no manager. This method can be used to allocate a resource and manually manage its lifetime.
- Parameters
-
system | The system to create the resource into. If left to nullptr, then the Singleton instance will be used. |
- Returns
- The created resource instance.
The documentation for this class was generated from the following file:
- Documentation/Headers/NilkinsGraphics/Meshes/Mesh.h