Kanzi Framework  3.9.0
Kanzi Engine API
kanzi::Mesh Class Reference

Mesh stores the geometry data for rendering Model3d nodes. More...

#include <kanzi/core.ui/platform/graphics_backend/gl/mesh.hpp>

Inheritance diagram for kanzi::Mesh:
[legend]

Classes

struct  Bone
 Definition of mesh bone, that is used for mesh skinning. More...
 
struct  Cluster
 Cluster has a material, primitive type (currently always triangles), and handle for GPU memory buffer where primitive indices are stored. More...
 
struct  CreateInfo
 Use Mesh::CreateInfo to describe and create meshes. More...
 
class  MappedBuffer
 Mapped buffer is a container for GPU memory that is mapped into CPU memory. More...
 
struct  Skeleton
 Skeleton is for animating mesh with bones. More...
 

Public Types

typedef shared_ptr< BoneBoneSharedPtr
 Shared pointer type for Bone. More...
 
typedef unique_ptr< MappedBufferMappedBufferPtr
 
- Public Types inherited from kanzi::GPUResource
enum  MemoryType { GpuOnly, GpuAndRam, RamOnly }
 Memory upload and RAM preservation strategy for GPU resources. More...
 
- Public Types inherited from kanzi::PropertyObject
typedef PropertyStorageContainer::const_iterator PropertyStorageConstIterator
 
typedef vector< PropertyStoragePtrPropertyStorageContainer
 
typedef PropertyStorageContainer::iterator PropertyStorageIterator
 
typedef intrusive_ptr< AbstractPropertyTypeDescriptor::PropertyStoragePropertyStoragePtr
 
typedef PropertyStorageContainer::reverse_iterator PropertyStorageReverseIterator
 

Public Member Functions

const vector< int > & acquireAttributeMap (ShaderProgramSharedPtr shaderProgram)
 Gets attribute map for given shader program. More...
 
void applySkeleton (Renderer &renderer, Node &baseNode, ShaderProgramSharedPtr shaderProgram)
 Applies bone animation, updating matrix palette transformation uniforms. More...
 
void attach (Node *baseNode)
 Attaches a root node for bone node lookup functions. More...
 
void bind (Renderer &renderer, size_t clusterIndex, ShaderProgramSharedPtr shaderProgram)
 Prepares a cluster from the mesh for rendering with the specified shader. More...
 
void bindAttribute (Renderer &renderer, unsigned int shaderAttributeIndex, size_t meshVertexAttributeIndex)
 Takes one mesh vertex attribute from mesh and makes it usable with (current) shader. More...
 
unsigned int bindAttributes (Renderer &renderer, ShaderProgramSharedPtr shaderProgram)
 Makes all mesh vertex attributes available with a shader program. More...
 
void bindIndices (Renderer &renderer, size_t clusterIndex)
 Makes mesh cluster indices available to the next draw call. More...
 
void detach ()
 Detaches root node, making bone node lookups no longer available. More...
 
Node3DgetBoneChildJoint (size_t boneIndex) const
 Gets child node for skeletal animation bone. More...
 
size_t getBoneCount () const
 Gets number of bones in mesh. More...
 
Node3DgetBoneNode (size_t boneIndex) const
 Gets node for bone. More...
 
Box getBoundingBox () const
 Returns the bounding box of a mesh. More...
 
size_t getClusterCount () const
 Gets the number of clusters in the mesh. More...
 
size_t getClusterIndexCount (size_t clusterIndex) const
 Gets the number of indices in a specified cluster. More...
 
const uint16_t * getClusterIndexData (size_t clusterIndex) const
 Gets index data for given cluster. More...
 
MaterialSharedPtr getClusterMaterial (size_t clusterIndex) const
 Gets the cluster material. More...
 
GraphicsPrimitiveType getClusterPrimitiveType (size_t clusterIndex) const
 Gets the primitive type for the cluster. More...
 
const MeshVertexAttributegetVertexAttribute (int index) const
 Gets mesh vertex attribute with given mesh attribute index. More...
 
size_t getVertexAttributeCount () const
 Gets the number of the vertex attributes in the mesh. More...
 
size_t getVertexCount () const
 Returns the vertex count of the mesh. More...
 
const void * getVertexData () const
 Gets raw vertex data. More...
 
size_t getVertexSize () const
 Gets size of one vertex in bytes. More...
 
MappedBufferPtr mapIndexData (size_t clusterIndex)
 Maps the index data of a cluster in the mesh on the GPU to a CPU memory region. More...
 
MappedBufferPtr mapVertexData ()
 Maps the vertex data of the mesh on the GPU to a CPU memory region. More...
 
void setClusterMaterial (size_t clusterIndex, MaterialSharedPtr material)
 Sets the cluster material. More...
 
void setIndexData (size_t clusterIndex, ConstByteSpan data)
 Sets the index data of a cluster in the mesh. More...
 
void setIndexSubData (size_t clusterIndex, ConstByteSpan data, unsigned int offset)
 Sets a section of the index data of a cluster in the mesh. More...
 
void setVertexData (ConstByteSpan data)
 Sets the vertex data of the mesh. More...
 
void setVertexSubData (ConstByteSpan data, unsigned int offset)
 Sets a section of the vertex data of the mesh. More...
 
optional< Matrix4x4updateBoundingBox (Node3D &baseNode)
 Updates bounding box of mesh with bones from given model. More...
 
- Public Member Functions inherited from kanzi::GPUResource
unsigned int getGPUMemoryUsage () const
 
RenderergetRenderer () const
 
void invalidate ()
 Notify resource that graphics context was lost and all GPU resources are invalid. More...
 
bool isDeployed () const
 
 ~GPUResource () override
 
- Public Member Functions inherited from kanzi::Resource
virtual unsigned int getCPUMemoryUsage () const
 Function for getting the memory usage of a resource. More...
 
const string & getName () const
 Gets the resource name. More...
 
const string & getUrl () const
 Gets the resource URL. More...
 
bool isKeepAlive () const
 Tells if the resource has keep alive flag set. More...
 
void reload ()
 
void reloadFromFile (string_view filePath)
 
void reloadFromKzb (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser)
 
 Resource (Domain *domain, string_view name)
 Constructor. More...
 
void setKeepAlive (bool keepAlive)
 Sets the keep alive flag. More...
 
void setUrl (string_view url)
 Sets the resource URL. More...
 
 ~Resource () override
 Destructor. More...
 
- Public Member Functions inherited from kanzi::Object
AppliedStyleEntrySharedPtr applyObjectStyle (kanzi::StyleSharedPtr style)
 Applies a style to an object. More...
 
void applyObjectStyles ()
 Apply all styles for an object node. More...
 
DomaingetDomain () const
 Returns the domain the object belongs to. More...
 
const MetaclassgetDynamicMetaclass () const override
 Returns the metaclass of the dynamic type of the object. More...
 
MainLoopSchedulergetMainLoopScheduler () const
 Returns the MainLoopScheduler instance of the associated Domain. More...
 
detail::MessageDispatcher * getMessageDispatcher () const
 Returns the message dispatcher of the object. More...
 
ResourceManagergetResourceManager () const
 Returns the resource manager of the object. More...
 
ScriptingContextSharedPtr getScriptingContext () const
 Gets the scripting context of the object. More...
 
 Object (Domain *domain)
 
void setScriptingContext (ScriptingContextSharedPtr context)
 Sets the scripting context of the object. More...
 
void unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry)
 
void unapplyObjectStyles ()
 Unapplies and removes all applied styles. More...
 
 ~Object () override
 
- Public Member Functions inherited from kanzi::MetaObject
bool isTypeOf (const Metaclass *objectType) const
 Determines if the type of this object is the given type or derived from it. More...
 
virtual ~MetaObject ()
 
- Public Member Functions inherited from kanzi::PropertyObject
template<typename DataType >
void addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 
PropertyStorageContainer::iterator beginPropertyStorage ()
 Returns the begin iterator to the internal property storage container. More...
 
PropertyStorageContainer::const_iterator beginPropertyStorage () const
 Returns the begin iterator to the internal property storage container. More...
 
void clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
void copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType)
 Copies local value of single property from another object. More...
 
void copyLocalValues (const PropertyObject &other)
 Copies all local values from another object. More...
 
PropertyStorageContainer::iterator endPropertyStorage ()
 Returns the end iterator to the internal property storage container. More...
 
PropertyStorageContainer::const_iterator endPropertyStorage () const
 Returns the end iterator to the internal property storage container. More...
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractPropertyBase (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalProperty (const PropertyType< DataType > &propertyType) const
 Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. More...
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers, but does not default to the value in property metadata if there are no inputs to the property value. More...
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getProperty (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property type. More...
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers. More...
 
template<typename DataType >
size_t getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) const
 Gets number of current notification handlers for given property type. More...
 
bool hasBaseValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value, disregarding modifiers. More...
 
bool hasLocalValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a local value set for the property. More...
 
bool hasNonClassValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a value of any precedence higher than class default value set for the property. More...
 
bool hasValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value. More...
 
bool isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const
 
virtual void onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason)
 Virtual function to handle property change notifications. More...
 
 PropertyObject ()
 
void removeKzbProperties ()
 
template<typename DataType >
void removeLocalPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer)
 
void removeLocalValue (AbstractPropertyType propertyType)
 Removes the local value associated with the property. More...
 
template<typename DataType >
void removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer)
 
template<typename DataType >
void setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 
template<typename DataType >
void setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 Sets the local value of a property type. More...
 
void setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
void validatePropertyModifiers (AbstractPropertyType propertyType)
 
virtual ~PropertyObject ()
 

Static Public Member Functions

static MeshSharedPtr create (Domain *domain, const CreateInfo &createInfo, string_view name)
 Creates a mesh with specified mesh creation parameters. More...
 
static MeshSharedPtr createBox (Domain *domain, Vector3 size, string_view name, MaterialSharedPtr material=MaterialSharedPtr())
 Creates a mesh with a box shape in a single cluster. More...
 
static ResourceManager::LoadTaskSharedPtr createLoadTask (string_view name, KzbFile *kzbFile, ReadOnlyMemoryFilePtr file)
 
static MeshSharedPtr createPlane (Domain *domain, float width, float height, bool invertU, bool invertV, string_view name, MaterialSharedPtr material=MaterialSharedPtr())
 Creates a plane shape. More...
 
static MeshSharedPtr createSphere (Domain *domain, float radius, unsigned int segmentCount, unsigned int rowCount, string_view name, MaterialSharedPtr material=MaterialSharedPtr())
 Creates a mesh with a sphere shape in a single cluster. More...
 
- Static Public Member Functions inherited from kanzi::Object
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class. More...
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info. More...
 
- Static Public Member Functions inherited from kanzi::MetaObject
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class. More...
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info. More...
 

Protected Member Functions

unsigned int getGPUMemoryUsageOverride () const override
 GpuResource::getGPUMemoryUsageOverride() implementation. More...
 
void invalidateOverride () override
 GPUResource::invalidateOverride() implementation. More...
 
bool isDeployedOverride () const override
 GpuResource::isDeployed() implementation. More...
 
 Mesh (Domain *domain, const CreateInfo &createInfo, string_view name)
 
void reloadFromKzbOverride (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser) override
 Resource::reloadFromKzbOverride() implementation. More...
 
void reloadOverride () override
 Resource::reloadOverride() implementation. More...
 
- Protected Member Functions inherited from kanzi::GPUResource
 GPUResource (Domain *domain, string_view name="")
 Constructor. More...
 
- Protected Member Functions inherited from kanzi::Resource
virtual unsigned int getCPUMemoryUsageOverride () const
 
virtual void reloadFromFileOverride (string_view filePath)
 
- Protected Member Functions inherited from kanzi::Object
void initialize ()
 
void onCopy (const Object &other)
 
- Protected Member Functions inherited from kanzi::MetaObject
void initialize ()
 
 MetaObject ()
 
- Protected Member Functions inherited from kanzi::PropertyObject
AbstractPropertyTypeDescriptor::ValueSourceEntryacquireLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage)
 Acquires a local value source entry that is free for the assignment of a value. More...
 
AbstractPropertyTypeDescriptor::ModifierStorageacquireModifierStorage (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
AbstractPropertyTypeDescriptor::NotificationStorageacquireNotificationStorage (AbstractPropertyTypeDescriptor &descriptor)
 
PropertyStoragePtr acquirePropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 Internally adds a property value source. More...
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 Internally adds a property value source. More...
 
AbstractPropertyTypeDescriptor::ValueSourceEntryconstructLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
PropertyStoragePtr constructPropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
void copyLocalValue (const AbstractPropertyTypeDescriptor::PropertyStorage &otherPropertyStorage)
 Copy local value from property storage. More...
 
AbstractPropertyTypeDescriptor::ModifierStoragefindModifierStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::NotificationStoragefindNotificationStorage (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::PropertyStoragefindPropertyStorage (AbstractPropertyTypeDescriptor &descriptor) const
 Gets the property storage for given property type descriptor. More...
 
PropertyStoragePtr findPropertyStoragePtr (AbstractPropertyTypeDescriptor &descriptor) const
 Gets property storage intrusive pointer which you can use to hold a reference until the end of the operation. More...
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByNameAndDataType (string_view name, PropertyDataType dataType) const
 Finds a property type descriptor by name and data type. More...
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByQualifiedNameAndDataType (string_view qualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with qualified names. More...
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByUnqualifiedNameAndDataType (string_view unqualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with unqualified names. More...
 
AbstractPropertyTypeDescriptor::ValueSourcegetClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetNonClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetTopValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 Gets the top-level value source for a given property descriptor. More...
 
virtual void notifyPropertyHandlers (PropertyStoragePtr &propertyStorage, PropertyNotificationReason reason)
 
void onCopy (const PropertyObject &other)
 
void removeLocalValue (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage)
 Removes a local value from the given property storage. More...
 
void removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner)
 Removes a property value source. More...
 
void validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage)
 

Friends

void swap (Mesh &mesh1, Mesh &mesh2)
 

Additional Inherited Members

- Protected Types inherited from kanzi::Object
typedef vector< AppliedStyleEntrySharedPtrAppliedStyleContainer
 Applied style container. More...
 
- Protected Attributes inherited from kanzi::Object
AppliedStyleContainer m_appliedStyles
 Listing of applied styles applied to this object. More...
 

Detailed Description

Mesh stores the geometry data for rendering Model3d nodes.

Each mesh has one or more clusters. Each cluster has material and primitives. Primitives are typically triangles, they are stored as vertex data and index data.

You can load a mesh resource from a .kzb file or create it with the Mesh::create() function.

Once Mesh has been created with constructor, all primitive data is uploaded to GPU memory and no longer stored in CPU memory in Mesh.

See also
MeshCreateInfo

Member Typedef Documentation

◆ BoneSharedPtr

typedef shared_ptr<Bone> kanzi::Mesh::BoneSharedPtr

Shared pointer type for Bone.

◆ MappedBufferPtr

Constructor & Destructor Documentation

◆ Mesh()

kanzi::Mesh::Mesh ( Domain domain,
const CreateInfo createInfo,
string_view  name 
)
explicitprotected

Member Function Documentation

◆ create()

static MeshSharedPtr kanzi::Mesh::create ( Domain domain,
const CreateInfo createInfo,
string_view  name 
)
static

Creates a mesh with specified mesh creation parameters.

In order to create a mesh, you will need a Mesh::CreateInfo structure that is filled with mesh creation parameters.

Primitive data (vertex and index data) is always deployed to GPU memory when Mesh is created.

Parameters
domainDomain for the mesh.
createInfoMesh creation parameters.
nameName of the mesh.
Returns
Mesh shared pointer.

◆ createSphere()

static MeshSharedPtr kanzi::Mesh::createSphere ( Domain domain,
float  radius,
unsigned int  segmentCount,
unsigned int  rowCount,
string_view  name,
MaterialSharedPtr  material = MaterialSharedPtr() 
)
static

Creates a mesh with a sphere shape in a single cluster.

Parameters
domainThe domain to which the mesh belongs.
radiusRadius of the sphere
segmentCountNumber of segments for the shape
rowCountNumber of rows for the shape
nameName of the mesh.
materialMaterial pointer for the cluster. If set, leave the materialURL parameter empty.
Returns
Mesh shared pointer.

◆ createBox()

static MeshSharedPtr kanzi::Mesh::createBox ( Domain domain,
Vector3  size,
string_view  name,
MaterialSharedPtr  material = MaterialSharedPtr() 
)
static

Creates a mesh with a box shape in a single cluster.

Parameters
domainThe domain to which the mesh belongs.
sizeSize of the box.
nameName of the mesh.
materialMaterial pointer for the cluster. If set, leave the materialURL parameter empty.
Returns
Mesh shared pointer.

◆ createPlane()

static MeshSharedPtr kanzi::Mesh::createPlane ( Domain domain,
float  width,
float  height,
bool  invertU,
bool  invertV,
string_view  name,
MaterialSharedPtr  material = MaterialSharedPtr() 
)
static

Creates a plane shape.

Parameters
domainThe domain to which the mesh belongs.
widthWidth of the plane (size along the x axis)
heightHeight of the plane (size along the y axis)
invertUIf true, the first texture coordinate is inverted
invertVIf true, the second texture coordinate is inverted
nameName of the mesh.
materialMaterial pointer for the cluster. If set, leave the materialURL parameter empty.
Returns
Mesh shared pointer.

◆ bind()

void kanzi::Mesh::bind ( Renderer renderer,
size_t  clusterIndex,
ShaderProgramSharedPtr  shaderProgram 
)

Prepares a cluster from the mesh for rendering with the specified shader.

Parameters
rendererRenderer to use.
clusterIndexWhich cluster to render.
shaderProgramWhich ShaderProgram to render with.

◆ getBoundingBox()

Box kanzi::Mesh::getBoundingBox ( ) const

Returns the bounding box of a mesh.

Returns
Bounding box for the mesh.

◆ getVertexCount()

size_t kanzi::Mesh::getVertexCount ( ) const
inline

Returns the vertex count of the mesh.

Returns
Number of vertices in mesh.

◆ getVertexAttributeCount()

size_t kanzi::Mesh::getVertexAttributeCount ( ) const
inline

Gets the number of the vertex attributes in the mesh.

Returns
Number of vertex attributes in mesh.

◆ getVertexSize()

size_t kanzi::Mesh::getVertexSize ( ) const
inline

Gets size of one vertex in bytes.

Returns
Size of vertex in bytes.

◆ getVertexData()

const void* kanzi::Mesh::getVertexData ( ) const
inline

Gets raw vertex data.

User is responsible for casting the data to proper format for reading.

Returns
Raw vertex data or 0 if data was not preserved in RAM.

◆ getClusterCount()

size_t kanzi::Mesh::getClusterCount ( ) const
inline

Gets the number of clusters in the mesh.

Returns
Number of clusters in the mesh.

◆ getClusterIndexCount()

size_t kanzi::Mesh::getClusterIndexCount ( size_t  clusterIndex) const

Gets the number of indices in a specified cluster.

Parameters
clusterIndexWhich cluster to query
Returns
Number of indices in the cluster.

◆ getClusterPrimitiveType()

GraphicsPrimitiveType kanzi::Mesh::getClusterPrimitiveType ( size_t  clusterIndex) const

Gets the primitive type for the cluster.

Parameters
clusterIndexWhich cluster to query
Returns
The primitive type for the cluster.

◆ getClusterMaterial()

MaterialSharedPtr kanzi::Mesh::getClusterMaterial ( size_t  clusterIndex) const

Gets the cluster material.

Parameters
clusterIndexWhich cluster to query
Returns
The material for the cluster.

◆ setClusterMaterial()

void kanzi::Mesh::setClusterMaterial ( size_t  clusterIndex,
MaterialSharedPtr  material 
)

Sets the cluster material.

Parameters
clusterIndexThe cluster for which to set the material
materialThe material to apply to the cluster

◆ getClusterIndexData()

const uint16_t* kanzi::Mesh::getClusterIndexData ( size_t  clusterIndex) const

Gets index data for given cluster.

Parameters
clusterIndexWhich cluster to query
Returns
Raw cluster index data or 0 if data was not preserved in RAM.

◆ updateBoundingBox()

optional<Matrix4x4> kanzi::Mesh::updateBoundingBox ( Node3D baseNode)

Updates bounding box of mesh with bones from given model.

Parameters
baseNodeNode from which bones are located from.
Returns
Armature root transform if mesh has skinning enable, empty optional otherwise.

◆ getBoneCount()

size_t kanzi::Mesh::getBoneCount ( ) const

Gets number of bones in mesh.

Returns
number of bones in mesh.

◆ getBoneNode()

Node3D* kanzi::Mesh::getBoneNode ( size_t  boneIndex) const

Gets node for bone.

The node is looked up from the latest node that was attached to the mesh with attach() function.

See also
attach()
Parameters
boneIndexindex of bone.
Returns
Node for bone.

◆ getBoneChildJoint()

Node3D* kanzi::Mesh::getBoneChildJoint ( size_t  boneIndex) const

Gets child node for skeletal animation bone.

The node is looked up from the latest node that was attached to the mesh with attach() function.

See also
attach()
Parameters
boneIndexindex of bone.
Returns
Node for bone.

◆ attach()

void kanzi::Mesh::attach ( Node baseNode)

Attaches a root node for bone node lookup functions.

See also
getBoneNode()
getBoneChildJoint()
Parameters
baseNodeRoot node for bone node lookups.

◆ detach()

void kanzi::Mesh::detach ( )

Detaches root node, making bone node lookups no longer available.

See also
attach()

◆ acquireAttributeMap()

const vector<int>& kanzi::Mesh::acquireAttributeMap ( ShaderProgramSharedPtr  shaderProgram)

Gets attribute map for given shader program.

In attribute map keys to are mesh attribute indices and values are shader attribute indices.

Parameters
shaderProgramShader program.
Returns
Attribute map (mesh attribute index -> shader attribute index).

◆ applySkeleton()

void kanzi::Mesh::applySkeleton ( Renderer renderer,
Node baseNode,
ShaderProgramSharedPtr  shaderProgram 
)

Applies bone animation, updating matrix palette transformation uniforms.

Parameters
rendererRenderer to use.
baseNodeRoot node for bones.
shaderProgramShader program in use.

◆ getVertexAttribute()

const MeshVertexAttribute& kanzi::Mesh::getVertexAttribute ( int  index) const

Gets mesh vertex attribute with given mesh attribute index.

Parameters
indexMesh vertex attribute index.
Returns
Mesh vertex attribute.

◆ bindAttribute()

void kanzi::Mesh::bindAttribute ( Renderer renderer,
unsigned int  shaderAttributeIndex,
size_t  meshVertexAttributeIndex 
)

Takes one mesh vertex attribute from mesh and makes it usable with (current) shader.

Parameters
rendererRenderer.
shaderAttributeIndexShader attribute index. This is the target, where attribute data is directed.
meshVertexAttributeIndexMesh attribute index. This is the source, where attibute data is taken from.

◆ bindAttributes()

unsigned int kanzi::Mesh::bindAttributes ( Renderer renderer,
ShaderProgramSharedPtr  shaderProgram 
)

Makes all mesh vertex attributes available with a shader program.

Parameters
rendererRenderer.
shaderProgramShader program.
Returns
Bitfield: nth bit indicates that nth shader attribute was sourced from the mesh.

◆ bindIndices()

void kanzi::Mesh::bindIndices ( Renderer renderer,
size_t  clusterIndex 
)

Makes mesh cluster indices available to the next draw call.

Parameters
rendererRenderer.
clusterIndexIndex of cluster to prepare.

◆ mapVertexData()

MappedBufferPtr kanzi::Mesh::mapVertexData ( )

Maps the vertex data of the mesh on the GPU to a CPU memory region.

Returns
Unique pointer to the mapped buffer if the mapping succeeded, nullptr if failed.

◆ setVertexData()

void kanzi::Mesh::setVertexData ( ConstByteSpan  data)

Sets the vertex data of the mesh.

◆ setVertexSubData()

void kanzi::Mesh::setVertexSubData ( ConstByteSpan  data,
unsigned int  offset 
)

Sets a section of the vertex data of the mesh.

◆ mapIndexData()

MappedBufferPtr kanzi::Mesh::mapIndexData ( size_t  clusterIndex)

Maps the index data of a cluster in the mesh on the GPU to a CPU memory region.

Parameters
clusterIndexIndex of the cluster whose index data to map.
Returns
Unique pointer to the mapped buffer if the mapping succeeded, nullptr if failed.

◆ setIndexData()

void kanzi::Mesh::setIndexData ( size_t  clusterIndex,
ConstByteSpan  data 
)

Sets the index data of a cluster in the mesh.

This is a synchronous call to copy the data to the GPU.

Parameters
clusterIndexIndex of the cluster whose index data to map.
dataData to set to set as a buffer index data.

◆ setIndexSubData()

void kanzi::Mesh::setIndexSubData ( size_t  clusterIndex,
ConstByteSpan  data,
unsigned int  offset 
)

Sets a section of the index data of a cluster in the mesh.

Parameters
clusterIndexIndex of the cluster whose index data to map.
dataData to set to set as a buffer index data.
offsetByte offset from the start of the index data where to start the newly set data.

◆ createLoadTask()

static ResourceManager::LoadTaskSharedPtr kanzi::Mesh::createLoadTask ( string_view  name,
KzbFile kzbFile,
ReadOnlyMemoryFilePtr  file 
)
static

◆ reloadOverride()

void kanzi::Mesh::reloadOverride ( )
overrideprotectedvirtual

Resource::reloadOverride() implementation.

Reimplemented from kanzi::Resource.

◆ reloadFromKzbOverride()

void kanzi::Mesh::reloadFromKzbOverride ( KzbFile kzbFile,
ReadOnlyMemoryFile file,
KzbMemoryParser parser 
)
overrideprotectedvirtual

Resource::reloadFromKzbOverride() implementation.

Reimplemented from kanzi::Resource.

◆ invalidateOverride()

void kanzi::Mesh::invalidateOverride ( )
overrideprotectedvirtual

GPUResource::invalidateOverride() implementation.

Reimplemented from kanzi::GPUResource.

◆ isDeployedOverride()

bool kanzi::Mesh::isDeployedOverride ( ) const
overrideprotectedvirtual

GpuResource::isDeployed() implementation.

Implements kanzi::GPUResource.

◆ getGPUMemoryUsageOverride()

unsigned int kanzi::Mesh::getGPUMemoryUsageOverride ( ) const
overrideprotectedvirtual

GpuResource::getGPUMemoryUsageOverride() implementation.

Reimplemented from kanzi::GPUResource.

Friends And Related Function Documentation

◆ swap

void swap ( Mesh mesh1,
Mesh mesh2 
)
friend

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