VulkanEngine 0.1
Graphics engine using Vulkan
Loading...
Searching...
No Matches
VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes > Class Template Reference

#include <Mesh.h>

Inheritance diagram for VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >:
VulkanEngine::MeshBase

Public Types

template<typename T >
using AttributeContainer = std::vector< std::shared_ptr< VertexAttribute< T > > >
 

Public Member Functions

 Mesh ()
 Default constructor.
 
 Mesh (const std::shared_ptr< VertexAttribute< PositionType > > &_positions, const std::shared_ptr< IndexAttribute< IndexType > > &_indices, const std::tuple< AttributeContainer< AdditionalAttributeTypes >... > &_attributes, const std::shared_ptr< Shader > &_shader)
 
virtual ~Mesh ()
 Destructor.
 
void setPositions (const std::shared_ptr< VertexAttribute< PositionType > > &_positions)
 
void setIndices (const std::shared_ptr< IndexAttribute< IndexType > > &_indices)
 
void setAttributes (const std::tuple< AttributeContainer< AdditionalAttributeTypes >... > &_attributes)
 
void setBoundingBox (const PositionType &max, const PositionType &min)
 
virtual const vk::PipelineVertexInputStateCreateInfo & createVkPipelineVertexInputStateCreateInfo ()
 
virtual const vk::PipelineInputAssemblyStateCreateInfo & createVkPipelineInputAssemblyStateCreateInfo ()
 
virtual void transferBuffers (const vk::CommandBuffer &command_buffer=nullptr)
 
virtual void bindVertexBuffers (const vk::CommandBuffer &command_buffer)
 
virtual void bindIndexBuffer (const vk::CommandBuffer &command_buffer)
 
virtual void draw (const vk::CommandBuffer &command_buffer)
 
- Public Member Functions inherited from VulkanEngine::MeshBase
 MeshBase ()
 Constructor.
 
 ~MeshBase ()
 Destructor.
 
virtual const vk::PipelineVertexInputStateCreateInfo & createVkPipelineVertexInputStateCreateInfo ()=0
 
virtual const vk::PipelineInputAssemblyStateCreateInfo & createVkPipelineInputAssemblyStateCreateInfo ()=0
 
virtual void transferBuffers (const vk::CommandBuffer &command_buffer=nullptr)=0
 
virtual void bindVertexBuffers (const vk::CommandBuffer &command_buffer)=0
 
virtual void bindIndexBuffer (const vk::CommandBuffer &command_buffer)=0
 
virtual void draw (const vk::CommandBuffer &command_buffer)=0
 
template<typename PositionType >
const BoundingBox< PositionType > & getBoundingBox () const
 

Additional Inherited Members

- Protected Attributes inherited from VulkanEngine::MeshBase
std::shared_ptr< BoundingBoxBasebounding_box
 The Mesh's bounding box.
 

Detailed Description

template<typename PositionType, typename IndexType, class... AdditionalAttributeTypes>
class VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >

Represents a mesh consisting of VertexAttribute instances. The mesh will at the very least support positions and indices. Any additional types that should be supported can be specified as template arguments. Example: Mesh< Eigen::Vector3f, uint32_t, Eigen::Vector3f, Eigen::Vector3f > represents a mesh which supports Eigen::Vector3f positions, uint32_t indices as well as additional Eigen::Vector3f and Eigen::Vector2f vertex attributes which could for example represent normals and texture coordinates.

Template Parameters
PositionTypeThe scalar type to use for the positions, e.g float, double.
IndexTypeThe type to use for storing indices, e.g uint16_t or uint32_t.
AdditionalAttributeTypesA variadic list of additional VertexAttribute types supported by the mesh.

Member Typedef Documentation

◆ AttributeContainer

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
template<typename T >
using VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::AttributeContainer = std::vector<std::shared_ptr<VertexAttribute<T> >>

Defines the container for storing additional attributes.

Template Parameters
TThe type of the VertexAttribute.

Constructor & Destructor Documentation

◆ Mesh()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::Mesh ( const std::shared_ptr< VertexAttribute< PositionType > > &  _positions,
const std::shared_ptr< IndexAttribute< IndexType > > &  _indices,
const std::tuple< AttributeContainer< AdditionalAttributeTypes >... > &  _attributes,
const std::shared_ptr< Shader > &  _shader 
)

Constructor.

Parameters
_positionsA VertexAttribute giving the positions of the vertices of the mesh.
_indicesAn IndexAttribute giving the indices of the mesh.
_attributeA list of additional VertexAttribute instances which will be used when rendering the mesh.
_shaderThe shader to use when rendering the mesh.

Member Function Documentation

◆ bindIndexBuffer()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
void VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::bindIndexBuffer ( const vk::CommandBuffer &  command_buffer)
virtual

Bind the index buffer of this Mesh.

Parameters
command_bufferThe vk::CommandBuffer to insert the commands into.

Implements VulkanEngine::MeshBase.

◆ bindVertexBuffers()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
void VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::bindVertexBuffers ( const vk::CommandBuffer &  command_buffer)
virtual

Bind VertexBuffers in this Mesh which will be used for rendering.

Parameters
command_bufferThe vk::CommandBuffer to insert the commands into.

Implements VulkanEngine::MeshBase.

◆ createVkPipelineInputAssemblyStateCreateInfo()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
const vk::PipelineInputAssemblyStateCreateInfo & VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::createVkPipelineInputAssemblyStateCreateInfo
virtual
Returns
The vk::PipelineInputAssemblyStateCreateInfo describing how to handle the input assembly stage for the Mesh.

Implements VulkanEngine::MeshBase.

◆ createVkPipelineVertexInputStateCreateInfo()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
const vk::PipelineVertexInputStateCreateInfo & VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::createVkPipelineVertexInputStateCreateInfo
virtual
Returns
The vk::PipelineVertexInputStateCreateInfo instance describing the attributes that constitute the Mesh.

Implements VulkanEngine::MeshBase.

◆ draw()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
void VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::draw ( const vk::CommandBuffer &  command_buffer)
virtual

Insert drawing commands.

Parameters
command_bufferThe vk::CommandBuffer to insert the commands into.

Implements VulkanEngine::MeshBase.

◆ setAttributes()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
void VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::setAttributes ( const std::tuple< AttributeContainer< AdditionalAttributeTypes >... > &  _attributes)

Sets the additional attributes of the Mesh.

Parameters
_additional_attributesA list of additional VertexAttribute instances which will be used when rendering the Mesh.

◆ setBoundingBox()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
void VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::setBoundingBox ( const PositionType &  max,
const PositionType &  min 
)

Set the Mesh's BoundingBox.

Parameters
maxThe maximum position of the bounding box.
minThe minimum position of the bounding box.

◆ setIndices()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
void VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::setIndices ( const std::shared_ptr< IndexAttribute< IndexType > > &  _indices)

Sets the indices of the Mesh.

Parameters
_indicesAn IndexAttribute giving the indices of the Mesh.

◆ setPositions()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
void VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::setPositions ( const std::shared_ptr< VertexAttribute< PositionType > > &  _positions)

Sets the positions of the Mesh.

Parameters
_positionsA VertexAttribute giving the positions of the vertices of the Mesh.

◆ transferBuffers()

template<typename PositionType , typename IndexType , class... AdditionalAttributeTypes>
void VulkanEngine::Mesh< PositionType, IndexType, AdditionalAttributeTypes >::transferBuffers ( const vk::CommandBuffer &  command_buffer = nullptr)
virtual

Start transfer of data belonging to all associated VertexAttribute instances from staging buffer to vertex buffer memory.

Parameters
command_bufferThe vk::CommandBuffer to insert the commands into. If not specified an internal command buffer will be created and submitted to the graphics queue.

Implements VulkanEngine::MeshBase.


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