Kanzi 4.1.0
kanzi::Mesh Class Reference

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

#include <kanzi/core.ui/graphics3d/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...
 
struct  MorphData
 Morph data associated with deforming this mesh. More...
 
struct  Skeleton
 Skeleton is for animating mesh with bones. More...
 
struct  VertexInputStateUsage
 

Public Types

using BoneSharedPtr
 Shared pointer type for Bone.
 
using SkeletonRuntime
 Runtime for the skeleton.
 
using SkeletonRuntimeSharedPtr
 SkeletonRuntime shared pointer type.
 
using VertexBufferContainer
 
using VertexInputStateContainer
 Mapping from shaders to vertex input states create info structures.
 
- 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
using PropertyObjectDestroyCallback
 
using PropertyStorageConstIterator
 
using PropertyStorageContainer
 
using PropertyStorageIterator
 
using PropertyStoragePtr
 
using PropertyStorageReverseIterator
 

Public Member Functions

const vector< int > & acquireAttributeMap (const ShaderProgram &shaderProgram)
 Gets attribute map for given shader program.
 
void applySkeleton (RenderState &renderState, Node &baseNode, const ShaderProgram &shaderProgram)
 Applies bone animation, updating matrix palette transformation uniforms.
 
void attachSkeleton (Model3D *model)
 Attaches the mesh skeleton runtime to the node.
 
void buildClusterAccelerationStructure (size_t clusterIndex)
 Builds the acceleration structure for the cluster.
 
void cleanupShaderReferences ()
 Cleans up obsolete shader references.
 
gfx::BottomLevelAccelerationStructureHandleGuard createClusterAccelerationStructure (size_t clusterIndex)
 Creates the acceleration structure for the cluster.
 
void detachSkeleton (Model3D *model)
 Detaches the mesh skeleton runtime from the node.
 
const MeshVertexAttributefindMeshAttribute (const ShaderVertexAttribute &shaderAttribute) const
 Finds a matching mesh vertex attribute for given shader attribute.
 
const MeshVertexAttributefindMorphAttribute (const ShaderVertexAttribute &shaderAttribute) const
 Finds a matching morph vertex attribute for given shader attribute.
 
Box getBoundingBox () const
 Returns the bounding box of a mesh.
 
gfx::BottomLevelAccelerationStructureHandleGuard getClusterAccelerationStructureHandle (size_t clusterIndex) const
 Gets the handle guard for the cluster acceleration structure.
 
size_t getClusterCount () const
 Gets the number of clusters in the mesh.
 
size_t getClusterIndexCount (size_t clusterIndex) const
 Gets the number of indices in a specified cluster.
 
size_t getClusterIndexOffset (size_t clusterIndex) const
 Gets the index offset for the cluster.
 
MaterialSharedPtr getClusterMaterial (size_t clusterIndex) const
 Gets the cluster material.
 
GraphicsPrimitiveType getClusterPrimitiveType (size_t clusterIndex) const
 Gets the primitive type for the cluster.
 
GPUBufferSharedPtr getIndexBuffer () const
 Gets the GPUBuffer for the index buffer.
 
KZ_DEPRECATED gfx::BufferHandleGuard getIndexBufferHandle () const
 Gets the handle guard for the index buffer.
 
span< const byte > getIndexData () const
 Gets index data for the mesh.
 
IndexBufferType getIndexType () const
 Gets the index type for the mesh.
 
GPUBufferSharedPtr getInstanceBuffer () const
 Gets the GPUBuffer for the instance buffer.
 
KZ_DEPRECATED gfx::BufferHandleGuard getInstanceBufferHandle () const
 Gets the handle guard for the instance buffer.
 
size_t getInstanceCount () const
 Returns the instance count of the mesh.
 
span< const byte > getInstanceData () const
 Returns the raw instance data that you must cast to the proper format for reading.
 
size_t getInstanceSize () const
 Returns the size of one mesh instance in bytes.
 
const vector< Matrix4x4 > & getInstanceTransforms () const
 Returns the instance transforms.
 
GPUBufferSharedPtr getMorphBuffer () const
 Gets the GPUBuffer for the morph buffer.
 
KZ_DEPRECATED gfx::BufferHandleGuard getMorphBufferHandle () const
 Gets the handle guard for the morph buffer.
 
MorphDatagetMorphData () const
 Gets a pointer to the morph data.
 
const SkeletongetSkeleton () const
 Returns the skeleton of the mesh.
 
const MeshVertexAttributegetVertexAttribute (uint32_t index) const
 Gets a vertex attribute by its index.
 
size_t getVertexAttributeCount () const
 Gets the number of the vertex attributes in the mesh.
 
optional< uint32_tgetVertexAttributeIndex (VertexAttribute::Semantic semantic) const
 Gets a vertex attribute index by semantic.
 
optional< uint32_tgetVertexAttributeIndex (VertexAttribute::Semantic semantic, uint32_t index) const
 Gets a vertex attribute index by semantic and semantic index.
 
GPUBufferSharedPtr getVertexBuffer (VertexAttribute::Semantic semantic) const
 Gets the GPUBuffer for the vertex attribute semantic.
 
GPUBufferSharedPtr getVertexBuffer (VertexAttribute::SemanticKey attribute) const
 Gets the GPUBuffer for the vertex attribute.
 
KZ_DEPRECATED gfx::BufferHandleGuard getVertexBufferHandle (VertexAttribute::SemanticKey attribute) const
 Gets the handle guard for the vertex buffer.
 
VertexBufferContainergetVertexBuffers ()
 
size_t getVertexCount () const
 Returns the vertex count of the mesh.
 
span< const byte > getVertexData (VertexAttribute::SemanticKey key) const
 Gets raw vertex data for a single attribute.
 
VertexInputStateUsage getVertexInputState (const ShaderProgramSharedPtr &shader)
 Gets the vertex input configuration.
 
size_t getVertexSize () const
 Gets size of one vertex in bytes.
 
bool hasClusterAccelerationStructure (size_t clusterIndex) const
 Indicates whether or not the cluster acceleration structure exists.
 
bool hasMorphData () const
 Indicates whether or not the mesh has morph data.
 
bool hasMorphDataVertexBuffer () const
 Indicates whether or not the mesh has a vertex buffer to use with morph data.
 
void setClusterMaterial (size_t clusterIndex, MaterialSharedPtr material)
 Sets the cluster material.
 
void setClusterPrimitiveType (size_t clusterIndex, GraphicsPrimitiveType primitiveType)
 Sets the primitive type for the cluster.
 
void setIndexData (ConstByteSpan data)
 Sets the index data of a cluster in the mesh.
 
void setIndexSubData (ConstByteSpan data, uint32_t offset)
 Sets a section of the index data of a cluster in the mesh.
 
void setInstanceBuffer (GPUBufferSharedPtr buffer)
 Sets the instance buffer to the given GPUBuffer.
 
void setInstanceCount (size_t count)
 Sets the count of the instance buffer.
 
void setInstanceData (ConstByteSpan data)
 Sets the instance data of the mesh.
 
void setInstanceSubData (ConstByteSpan data, uint32_t offset)
 Sets a section of the instance data of the mesh.
 
void setInstanceTransforms (vector< Matrix4x4 > instanceTransforms)
 Sets the instance transforms.
 
void setVertexData (ConstByteSpan data, VertexAttribute::SemanticKey attribute)
 Sets the vertex data of the mesh.
 
void setVertexSubData (ConstByteSpan data, uint32_t offset, VertexAttribute::SemanticKey attribute)
 Sets a section of the vertex data of the mesh.
 
optional< Matrix4x4updateSkeletonTransformation (Model3D &model)
 Updates bounding box of mesh with bones from given model and root transformation of the skeleton.
 
- Public Member Functions inherited from kanzi::GPUResource
void destroy ()
 Destroys a GPU resource.
 
size_t getGPUMemoryUsage () const
 Gets the amount of GPU memory used by the resource.
 
RenderergetRenderer () const
 
void invalidate ()
 Notify resource that graphics context was lost and all GPU resources are invalid.
 
bool isDeployed () const
 
 ~GPUResource () override
 
- Public Member Functions inherited from kanzi::Resource
size_t getCPUMemoryUsage () const
 Gets the amount of CPU memory used by the resource.
 
const string & getName () const
 Gets the resource name.
 
const string & getUrl () const
 Gets the resource URL.
 
bool isKeepAlive () const
 Tells if the resource has keep alive flag set.
 
void reload ()
 
void reloadFromFile (string_view filePath)
 
void reloadFromKzb (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser)
 
void setKeepAlive (bool keepAlive)
 Sets the keep alive flag.
 
void setUrl (string_view url)
 Sets the resource URL.
 
 ~Resource () override
 Destructor.
 
- Public Member Functions inherited from kanzi::Object
AppliedStyleEntrySharedPtr applyObjectStyle (kanzi::StyleSharedPtr style)
 Applies a style to an object.
 
void applyObjectStyles ()
 Apply all styles for an object node.
 
DomaingetDomain () const
 Returns the domain the object belongs to.
 
const MetaclassgetDynamicMetaclass () const override
 Returns the metaclass of the dynamic type of the object.
 
MainLoopSchedulergetMainLoopScheduler () const
 Returns the MainLoopScheduler instance of the associated Domain.
 
detail::MessageDispatcher * getMessageDispatcher () const
 Returns the message dispatcher of the object.
 
ResourceManagergetResourceManager () const
 Returns the resource manager of the object.
 
ScriptingContextSharedPtr getScriptingContext () const
 Gets the scripting context of the object.
 
 Object (Domain *domain)
 
void setScriptingContext (ScriptingContextSharedPtr context)
 Sets the scripting context of the object.
 
void unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry)
 
void unapplyObjectStyles ()
 Unapplies and removes all applied styles.
 
 ~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.
 
virtual ~MetaObject ()
 
- Public Member Functions inherited from kanzi::PropertyObject
void addDestroyCallback (PropertyObjectDestroyCallback cb)
 Adds a destroy callback that is called when the object is being destroyed.
 
template<typename DataType >
void addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 Adds a property modifier.
 
template<typename DataType >
void addPropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 Adds a property modifier without notifying handlers.
 
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, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 
PropertyStorageContainer::iterator beginPropertyStorage ()
 Returns the begin iterator to the internal property storage container.
 
PropertyStorageContainer::const_iterator beginPropertyStorage () const
 Returns the begin iterator to the internal property storage container.
 
void clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
void copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType)
 Copies local value of single property from another object.
 
void copyLocalValues (const PropertyObject &other)
 Copies all local values from another object.
 
PropertyStorageContainer::iterator endPropertyStorage ()
 Returns the end iterator to the internal property storage container.
 
PropertyStorageContainer::const_iterator endPropertyStorage () const
 Returns the end iterator to the internal property storage container.
 
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.
 
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.
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getProperty (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property type.
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers.
 
template<typename DataType >
size_t getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) const
 Gets number of current notification handlers for given property type.
 
bool hasBaseValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value, disregarding modifiers.
 
bool hasLocalValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a local value set for the property.
 
bool hasNonClassValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a value of any precedence higher than class default value set for the property.
 
bool hasValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value.
 
bool isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const
 
virtual void onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason)
 Virtual function to handle property change notifications.
 
 PropertyObject ()
 
void removeKzbProperties ()
 Remove all KZB properties.
 
void removeKzbProperties (flat_set< AbstractPropertyType > *keepProperties)
 Remove all KZB properties that are not included in a given set.
 
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.
 
template<typename DataType >
void removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 Removes a property modifier.
 
template<typename DataType >
void removePropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 Removes a property modifier without notifying handlers.
 
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.
 
void setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
void validatePropertyModifiersAndNotifyHandlers (AbstractPropertyType propertyType)
 Validates property modifiers and notifies handlers.
 
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.
 
static MeshSharedPtr createBox (Domain *domain, Vector3 size, uint32_t subdivisions, string_view name, MaterialSharedPtr material=MaterialSharedPtr())
 Creates a mesh with a box shape in a single cluster.
 
static MeshSharedPtr createIcosphere (Domain *domain, float radius, uint32_t subdivisions, string_view name, MaterialSharedPtr material=MaterialSharedPtr())
 Creates a mesh with a sphere shape in a single cluster.
 
static ResourceManager::LoadTaskSharedPtr createLoadTask (string_view name, KzbFile *kzbFile, ReadOnlyMemoryFilePtr file)
 Creates a load task for loading a mesh from a KZB file.
 
static MeshSharedPtr createPlane (Domain *domain, float width, float height, uint32_t subdivisions, bool invertU, bool invertV, string_view name, MaterialSharedPtr material=MaterialSharedPtr())
 Creates a plane shape.
 
static MeshSharedPtr createQuadsphere (Domain *domain, float radius, uint32_t subdivisions, string_view name, MaterialSharedPtr material=MaterialSharedPtr())
 Creates a mesh with a sphere shape in a single cluster.
 
static MeshSharedPtr createSphere (Domain *domain, float radius, uint32_t segmentCount, uint32_t rowCount, string_view name, MaterialSharedPtr material=MaterialSharedPtr())
 Creates a mesh with a sphere shape in a single cluster.
 
- Static Public Member Functions inherited from kanzi::Object
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class.
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info.
 
- Static Public Member Functions inherited from kanzi::MetaObject
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class.
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info.
 

Protected Member Functions

void destroyOverride () override
 GPUResource::destroyOverride() implementation.
 
size_t getCPUMemoryUsageOverride () const override
 Resource::getCPUMemoryUsageOverride() implementation.
 
size_t getGPUMemoryUsageOverride () const override
 GpuResource::getGPUMemoryUsageOverride() implementation.
 
void invalidateOverride () override
 GPUResource::invalidateOverride() implementation.
 
bool isDeployedOverride () const override
 GpuResource::isDeployed() implementation.
 
 Mesh (const Mesh &)=delete
 Deleted copy constructor.
 
 Mesh (Domain *domain, const CreateInfo &createInfo, string_view name)
 Constructor.
 
Meshoperator= (const Mesh &)=delete
 Deleted copy operator.
 
void reloadFromKzbOverride (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser) override
 Resource::reloadFromKzbOverride() implementation.
 
void reloadOverride () override
 Resource::reloadOverride() implementation.
 
- Protected Member Functions inherited from kanzi::GPUResource
 GPUResource (Domain *domain, string_view name="")
 Constructor.
 
- Protected Member Functions inherited from kanzi::Resource
virtual void reloadFromFileOverride (string_view filePath)
 
 Resource (Domain *domain, string_view name)
 Constructor.
 
- 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, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 Acquires a local value source entry that is free for the assignment of a value.
 
AbstractPropertyTypeDescriptor::ModifierStorageacquireModifierStorage (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
AbstractPropertyTypeDescriptor::NotificationStorageacquireNotificationStorage (AbstractPropertyTypeDescriptor &descriptor)
 
PropertyStoragePtr acquirePropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 Acquires a property storage.
 
template<typename DataType >
void addPropertyModifierBase (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner, bool notify)
 Adds a property modifier entry to the property modifier stack and validates the modifiers.
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 Internally adds a property value source.
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 Internally adds a property value source.
 
AbstractPropertyTypeDescriptor::ValueSourceEntryconstructLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 Constructs a new local value source entry.
 
void copyLocalValue (const AbstractPropertyTypeDescriptor::PropertyStorage &otherPropertyStorage)
 Copy local value from property storage.
 
AbstractPropertyTypeDescriptor::ModifierStoragefindModifierStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::NotificationStoragefindNotificationStorage (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::PropertyStoragefindPropertyStorage (AbstractPropertyTypeDescriptor &descriptor) const
 Gets the property storage for given property type descriptor.
 
PropertyStoragePtr findPropertyStoragePtr (AbstractPropertyTypeDescriptor &descriptor) const
 Gets property storage intrusive pointer which you can use to hold a reference until the end of the operation.
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByNameAndDataType (string_view name, PropertyDataType dataType) const
 Finds a property type descriptor by name and data type.
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByQualifiedNameAndDataType (string_view qualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with qualified names.
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByUnqualifiedNameAndDataType (string_view unqualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with unqualified names.
 
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.
 
virtual void notifyPropertyHandlers (PropertyStoragePtr &propertyStorage, PropertyNotificationReason reason)
 Notifies all property handlers on a property storage.
 
void onCopy (const PropertyObject &other)
 
void removeLocalValue (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage)
 Removes a local value from the given property storage.
 
template<typename DataType >
void removePropertyModifierBase (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner, bool notify)
 Removes a property modifier entry from the property modifier stack and validates the remaining modifiers.
 
void removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner)
 Removes a property value source.
 
void validatePropertyModifiers (AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 Validates property modifiers without notifying handlers.
 
void validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage)
 Validates property modifiers and notifies handlers.
 

Protected Attributes

vector< intm_attributeMap
 Map from shader attribute location to mesh attribute index.
 
Box m_boundingBox
 Bounding box for a mesh.
 
vector< Clusterm_clusters
 Array of clusters in mesh.
 
GPUBufferSharedPtr m_indexBuffer
 Index buffer.
 
size_t m_indexCount
 Index count for this index buffer.
 
vector< byte > m_indexData
 Raw index data.
 
IndexBufferType m_indexType
 Index buffer type.
 
GPUBufferSharedPtr m_instanceBuffer
 Instance buffer.
 
size_t m_instanceCount
 Instance count for this instance buffer.
 
vector< byte > m_instanceData
 Raw instance data.
 
vector< Matrix4x4m_instanceTransforms
 Instance transforms.
 
bool m_insufficientBoneCountLogged
 Boolean specifying if insufficient bone count has already been logged.
 
unique_ptr< MorphDatam_morphData
 Morph data.
 
ShaderProgramToAttributeMapSet m_shaderProgramAttributeMaps
 ShaderProgram pointer -> (shader attribute location -> mesh vertex attribute index)
 
Skeleton m_skeleton
 Skeleton (skinned meshes).
 
VertexBufferContainer m_vertexBuffer
 Vertex buffer.
 
size_t m_vertexCount
 Vertex count for this vertex buffer.
 
MeshVertexFormat m_vertexFormat
 Mesh vertex attributes.
 
VertexInputStateContainer m_vertexInputStates
 Mapping from shaders to vertex input states.
 
size_t m_vertexStride
 Vertex attribute stride.
 
- Protected Attributes inherited from kanzi::Object
AppliedStyleContainer m_appliedStyles
 Listing of applied styles applied to this object.
 

Friends

void swap (Mesh &mesh1, Mesh &mesh2)
 Swaps two Mesh objects.
 

Additional Inherited Members

- Protected Types inherited from kanzi::Object
typedef vector< AppliedStyleEntrySharedPtrAppliedStyleContainer
 Applied style container.
 

Detailed Description

Mesh stores the geometry data for rendering Model3D nodes.

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

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

After you create a Mesh with the constructor, Kanzi uploads all primitive data to GPU memory instead of storing the data in CPU memory in the Mesh.

To upload data to a mesh's buffers, prefer to upload via kzgfx commands or the CommandRecorder. To map these buffers, use the Mesh::CreateInfo::cpuAccessFlag property to set their access to gfx::AccessFlag::Write and call gfx::mapBuffer().

See also
Mesh::CreateInfo
Since
Kanzi 4.1.0 removed Mesh::mapVertexData, Mesh::mapIndexData, Mesh::mapInstanceData, and Mesh::MappedBuffer.

Member Typedef Documentation

◆ VertexInputStateContainer

Mapping from shaders to vertex input states create info structures.

◆ VertexBufferContainer

◆ BoneSharedPtr

Shared pointer type for Bone.

◆ SkeletonRuntime

Runtime for the skeleton.

◆ SkeletonRuntimeSharedPtr

SkeletonRuntime shared pointer type.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

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

Constructor.

Parameters
domainDomain to use.
createInfoMesh create info.
nameName of the mesh.

◆ Mesh() [2/2]

kanzi::Mesh::Mesh ( const Mesh & )
protecteddelete

Deleted copy constructor.

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.

To create a mesh, you need a Mesh::CreateInfo structure.

When you create a Mesh, Kanzi deploys the primitive vertex and index data to GPU memory.

Parameters
domainDomain for the mesh.
createInfoMesh creation parameters.
nameName of the mesh.
Precondition
VertexCountZero: createInfo.vertexCount must be non-zero.
VertexDataSizeMismatch: For each vertex attribute, initialData.size() must not exceed createInfo.vertexCount * gfx::getPixelStride(attribute.format). Smaller sizes are legal (partial upload; the remainder can be filled later via setVertexSubData).
InstanceBufferWithoutInstances: If createInfo.instanceBufferHandle is valid, createInfo.instanceCount must be non-zero.
InstanceDataSizeMismatch: The size of createInfo.instanceData must be less than or equal to createInfo.instanceCount * createInfo.vertexFormat.instanceSize.
IndexBufferWithoutIndices: If createInfo.indexBufferHandle is valid, createInfo.indexCount must be non-zero.
IndexDataSizeMismatch: The size of createInfo.indexData must be less than or equal to createInfo.indexCount * getIndexTypeStride(createInfo.indexType).
ClusterExceedsIndexBounds: For each cluster, indexCount + indexOffset/stride must not exceed createInfo.indexCount.
ClusterPrimitiveTypeInvalid: Each cluster's primitiveType must be a valid GraphicsPrimitiveType (not GraphicsPrimitiveTypeInvalid).
IndexOffsetNotAligned: Each cluster's indexOffset must be aligned to getIndexTypeStride(createInfo.indexType).
VertexFormatAttributeOutOfBounds: For each instance attribute (divisor != 0), offset + gfx::getPixelStride(format) must be less than or equal to vertexFormat.instanceSize.
MorphVertexCountZero: If createInfo.morphData is on the vertex-buffer path (morphData.vertexData non-empty or morphData.vertexBufferHandle valid), morphData.vertexCount must be non-zero.
MorphVertexFormatEmpty: If createInfo.morphData is on the vertex-buffer path, morphData.vertexFormat.attributes must be non-empty.
MorphVertexDataSizeMismatch: If createInfo.morphData is on the vertex-buffer path, the size of morphData.vertexData must be less than or equal to morphData.vertexCount * morphData.vertexFormat.vertexSize.
MorphVertexCountMismatch: If createInfo.morphData is on the vertex-buffer path, morphData.vertexCount must equal createInfo.vertexCount.
InstanceAttributeWithoutInstanceSize: If any vertex attribute has a non-zero divisor, createInfo.vertexFormat.instanceSize must be non-zero.
BufferSizeOverflow: All buffer size calculations (count * size) must not overflow or exceed the maximum value of uint32_t.
ClusterCountZero: createInfo.clusters must not be empty.
MaxVertexAttributesExceeded: The number of non-instance vertex attributes must not exceed the device maximum.
MaxVertexAttributeStrideExceeded: createInfo.vertexFormat.vertexSize must not exceed the device maximum vertex attribute stride.
MaxVertexAttributeOffsetExceeded: Each vertex attribute offset must not exceed the device maximum relative offset.
VertexFormatNotSupported: Each vertex attribute format must support VertexAttribute usage as reported by gfx::getFormatFeatures().
InstanceBufferSizeAdequate [not validated]: If createInfo.instanceBufferHandle is valid, it must have been created with a size greater or equal than createInfo.instanceCount * createInfo.vertexFormat.instanceSize.
IndexBufferSizeAdequate [not validated]: If createInfo.indexBufferHandle is valid, it must have been created with a size greater or equal than createInfo.indexCount * getIndexTypeStride(createInfo.indexType).
Postcondition
VertexCountPreserved: getVertexCount() equals createInfo.vertexCount.
VertexSizePreserved: getVertexSize() equals createInfo.vertexFormat.vertexSize.
VertexAttributeCountPreserved: getVertexAttributeCount() equals createInfo.vertexFormat.attributes.size().
VertexAttributePropertiesPreserved: Each vertex attribute's name and format are preserved from createInfo.
VertexSemanticGuessed: Vertex attributes with SemanticInvalid or SemanticCount have their semantic guessed from the attribute name.
VertexBufferCreated: One GPU buffer is created per vertex attribute, keyed by its SemanticKey.
VertexBufferHasVertexUsage: Each per-attribute vertex buffer includes the VertexBuffer usage flag.
VertexDataPreservedInRam: When createInfo.memoryType is not GpuOnly, getVertexData(key) for each attribute key returns the original initialData.
VertexDataEmptyWhenGpuOnly: When createInfo.memoryType is GpuOnly, getVertexData(key) is empty for every attribute.
InstanceCountPreserved: getInstanceCount() equals createInfo.instanceCount.
InstanceSizePreserved: getInstanceSize() equals createInfo.vertexFormat.instanceSize.
InstanceBufferCreated: When instanceSize and instanceCount are both non-zero, getInstanceBuffer() is non-null.
InstanceBufferNullWhenUnused: When instanceSize or instanceCount is zero, getInstanceBuffer() is null.
InstanceDataPreservedInRam: When createInfo.memoryType is not GpuOnly, getInstanceData() contains the original instance data.
IndexTypePreserved: getIndexType() equals createInfo.indexType.
IndexBufferCreated: When indexCount is non-zero, getIndexBuffer() is non-null with IndexBuffer usage flag.
IndexBufferNullWhenUnused: When indexCount is zero, getIndexBuffer() is null.
IndexBufferFormatMatchesType: The index buffer format is R16_UInt for UInt16 indices and R32_UInt for UInt32 indices.
IndexBufferOmitsShaderResourceWhenUnsupported: When the index format does not support FormatFeatureFlag::ShaderResource, the index buffer's usage omits BufferUsageFlag::ShaderResource.
IndexDataPreservedInRam: When createInfo.memoryType is not GpuOnly, getIndexData() contains the original index data.
IndexDataEmptyWhenGpuOnly: When createInfo.memoryType is GpuOnly, getIndexData() is empty.
ClusterCountPreserved: getClusterCount() equals createInfo.clusters.size().
ClusterPropertiesPreserved: Each cluster's primitiveType, indexCount, and indexOffset are preserved from createInfo.
ClusterMaterialPreserved: When a cluster's material is set in createInfo, getClusterMaterial() returns it.
ClusterMaterialAcquiredFromUrl: When a cluster's materialURL is set (and material is null), the material is acquired from the URL.
BoundingBoxPreserved: getBoundingBox() equals createInfo.boundingBox.
SkeletonPreserved: getSkeleton() preserves the bones, bindShapeMatrix, and originalBoundingBox from createInfo.
MorphDataAbsentWhenNotSet: When createInfo.morphData is not set, hasMorphData() returns false.
MorphDataPreserved: When createInfo.morphData is set, hasMorphData() returns true and morph shape count, names, and weights are preserved.
MorphBufferCreated: When morph data has vertex data, getMorphBuffer() is non-null.
MorphDataPreservedInRam: When createInfo.memoryType is not GpuOnly and morph data is present, morph vertex data is preserved.
Returns
Mesh shared pointer.

◆ createSphere()

static MeshSharedPtr kanzi::Mesh::createSphere ( Domain * domain,
float radius,
uint32_t segmentCount,
uint32_t 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.
Returns
Mesh shared pointer.

◆ createIcosphere()

static MeshSharedPtr kanzi::Mesh::createIcosphere ( Domain * domain,
float radius,
uint32_t subdivisions,
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.
subdivisionsNumber of subdivision to apply.
nameName of the mesh.
materialMaterial pointer for the cluster.
Returns
Mesh shared pointer.
Since
Kanzi 3.9.4

◆ createQuadsphere()

static MeshSharedPtr kanzi::Mesh::createQuadsphere ( Domain * domain,
float radius,
uint32_t subdivisions,
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.
subdivisionsNumber of subdivision to apply.
nameName of the mesh.
materialMaterial pointer for the cluster.
Returns
Mesh shared pointer.
Since
Kanzi 3.9.4

◆ createBox()

static MeshSharedPtr kanzi::Mesh::createBox ( Domain * domain,
Vector3 size,
uint32_t subdivisions,
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.
subdivisionsAmount of subdivision to apply.
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,
uint32_t subdivisions,
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, that is, the size along the x axis.
heightHeight of the plane, that is, the size along the y axis.
subdivisionsAmount of subdivision to apply.
invertUWhether to invert the first texture coordinate.
invertVWhether to invert the second texture coordinate.
nameName of the mesh.
materialMaterial pointer for the cluster. If set, leave the materialURL parameter empty.
Returns
Mesh shared pointer.

◆ applySkeleton()

void kanzi::Mesh::applySkeleton ( RenderState & renderState,
Node & baseNode,
const ShaderProgram & shaderProgram )

Applies bone animation, updating matrix palette transformation uniforms.

Parameters
renderStateRender state to write the matrix palette to.
baseNodeRoot node for bones.
shaderProgramShader program in use.
Since
Kanzi 4.0.0
  • Removed the renderer parameter.
  • Added the renderState parameter.
  • Changed the type of the shaderProgram parameter to const ShaderProgram&.

◆ getVertexBufferHandle()

KZ_DEPRECATED gfx::BufferHandleGuard kanzi::Mesh::getVertexBufferHandle ( VertexAttribute::SemanticKey attribute) const
inline

Gets the handle guard for the vertex buffer.

Parameters
attributeAttribute to specify which attribute buffer handle to return.
Returns
Buffer handle guard for the vertex buffer.
Since
Kanzi 4.0.0
Deprecated
In Kanzi 4.1.0

◆ getIndexBufferHandle()

KZ_DEPRECATED gfx::BufferHandleGuard kanzi::Mesh::getIndexBufferHandle ( ) const
inline

Gets the handle guard for the index buffer.

Returns
Buffer handle guard for the index buffer.
Since
Kanzi 4.0.0
Deprecated
In Kanzi 4.1.0

◆ getClusterAccelerationStructureHandle()

gfx::BottomLevelAccelerationStructureHandleGuard kanzi::Mesh::getClusterAccelerationStructureHandle ( size_t clusterIndex) const
inline

Gets the handle guard for the cluster acceleration structure.

Parameters
clusterIndexThe cluster to query.
Returns
Acceleration structure handle guard.
Since
Kanzi 4.1.0

◆ hasClusterAccelerationStructure()

bool kanzi::Mesh::hasClusterAccelerationStructure ( size_t clusterIndex) const
inline

Indicates whether or not the cluster acceleration structure exists.

Parameters
clusterIndexThe cluster to query.
Returns
If the cluster has an acceleration structure, returns true, otherwise false.
Since
Kanzi 4.1.0

◆ createClusterAccelerationStructure()

gfx::BottomLevelAccelerationStructureHandleGuard kanzi::Mesh::createClusterAccelerationStructure ( size_t clusterIndex)

Creates the acceleration structure for the cluster.

Parameters
clusterIndexThe cluster to query.
Returns
Acceleration structure handle guard.
Since
Kanzi 4.1.0

◆ buildClusterAccelerationStructure()

void kanzi::Mesh::buildClusterAccelerationStructure ( size_t clusterIndex)

Builds the acceleration structure for the cluster.

Parameters
clusterIndexThe cluster to query.
Since
Kanzi 4.1.0

◆ getInstanceBufferHandle()

KZ_DEPRECATED gfx::BufferHandleGuard kanzi::Mesh::getInstanceBufferHandle ( ) const
inline

Gets the handle guard for the instance buffer.

Returns
Buffer handle guard for the instance buffer.
Since
Kanzi 4.0.0
Deprecated
In Kanzi 4.1.0

◆ getMorphBufferHandle()

KZ_DEPRECATED gfx::BufferHandleGuard kanzi::Mesh::getMorphBufferHandle ( ) const
inline

Gets the handle guard for the morph buffer.

Returns
Buffer handle guard for the morph buffer.
Since
Kanzi 4.0.0
Deprecated
In Kanzi 4.1.0

◆ getVertexBuffer() [1/2]

GPUBufferSharedPtr kanzi::Mesh::getVertexBuffer ( VertexAttribute::SemanticKey attribute) const
inline

Gets the GPUBuffer for the vertex attribute.

Parameters
attributeAttribute to specify which attribute buffer to return.
Returns
GPUBuffer for the requested vertex buffer attribute.
Since
Kanzi 4.1.0

◆ getVertexBuffer() [2/2]

GPUBufferSharedPtr kanzi::Mesh::getVertexBuffer ( VertexAttribute::Semantic semantic) const
inline

Gets the GPUBuffer for the vertex attribute semantic.

Parameters
semanticSemantic to specify which attribute semantic to attempt to return.
Returns
GPUBuffer for the first instance of the requested vertex attribute semantic.
Since
Kanzi 4.1.0

◆ getVertexBuffers()

VertexBufferContainer & kanzi::Mesh::getVertexBuffers ( )
inline

◆ getIndexBuffer()

GPUBufferSharedPtr kanzi::Mesh::getIndexBuffer ( ) const
inline

Gets the GPUBuffer for the index buffer.

Returns
GPUBuffer for the index buffer.
Since
Kanzi 4.1.0

◆ getInstanceBuffer()

GPUBufferSharedPtr kanzi::Mesh::getInstanceBuffer ( ) const
inline

Gets the GPUBuffer for the instance buffer.

Returns
GPUBuffer for the instance buffer.
Since
Kanzi 4.1.0

◆ getMorphBuffer()

GPUBufferSharedPtr kanzi::Mesh::getMorphBuffer ( ) const
inline

Gets the GPUBuffer for the morph buffer.

Returns
GPUBuffer for the morph buffer. Returns nullptr if there is no morph data.
Since
Kanzi 4.1.0

◆ cleanupShaderReferences()

void kanzi::Mesh::cleanupShaderReferences ( )

Cleans up obsolete shader references.

Since
Kanzi 4.0.0

◆ findMeshAttribute()

const MeshVertexAttribute * kanzi::Mesh::findMeshAttribute ( const ShaderVertexAttribute & shaderAttribute) const

Finds a matching mesh vertex attribute for given shader attribute.

Parameters
shaderAttributeShader attribute to match.
Returns
Matching vertex attribute or nullptr.
Since
Kanzi 4.0.0

◆ findMorphAttribute()

const MeshVertexAttribute * kanzi::Mesh::findMorphAttribute ( const ShaderVertexAttribute & shaderAttribute) const

Finds a matching morph vertex attribute for given shader attribute.

Parameters
shaderAttributeShader attribute to match.
Returns
Matching vertex attribute or nullptr.
Since
Kanzi 4.0.0

◆ getVertexInputState()

VertexInputStateUsage kanzi::Mesh::getVertexInputState ( const ShaderProgramSharedPtr & shader)

Gets the vertex input configuration.

If the input state mapping is modified, obsolete shader references are also evicted.

Parameters
shaderShader to create input state for.
Returns
Vertex input state handle.
Since
Kanzi 4.0.0

◆ 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.

◆ getVertexAttribute()

const MeshVertexAttribute & kanzi::Mesh::getVertexAttribute ( uint32_t index) const
inline

Gets a vertex attribute by its index.

The vertex attribute index must be valid.

Parameters
indexIndex to access.
Returns
Vertex attribute
Since
Kanzi 3.9.7

◆ getVertexAttributeIndex() [1/2]

optional< uint32_t > kanzi::Mesh::getVertexAttributeIndex ( VertexAttribute::Semantic semantic) const
inline

Gets a vertex attribute index by semantic.

Parameters
semanticSemantic to use.
Returns
Vertex attribute index. If there is no matching semantic, returns nullopt.
Since
Kanzi 3.9.7

◆ getVertexAttributeIndex() [2/2]

optional< uint32_t > kanzi::Mesh::getVertexAttributeIndex ( VertexAttribute::Semantic semantic,
uint32_t index ) const
inline

Gets a vertex attribute index by semantic and semantic index.

Parameters
semanticSemantic to use.
indexSemantic index to use.
Returns
Vertex attribute index. If there is no matching semantic and index, returns nullopt.
Since
Kanzi 3.9.7

◆ getVertexSize()

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

Gets size of one vertex in bytes.

Returns
Size of vertex in bytes.

◆ getVertexData()

span< const byte > kanzi::Mesh::getVertexData ( VertexAttribute::SemanticKey key) const
inline

Gets raw vertex data for a single attribute.

The data is preserved only when the mesh was created with memoryType != GpuOnly. User is responsible for casting the data to the attribute's format for reading.

Parameters
keySemantic key identifying the attribute.
Returns
Raw vertex data for the attribute, or an empty span if the key is unknown or the data is not preserved.
Since
Kanzi 4.1.0 replaced the no-arg getVertexData() blob accessor.

◆ getInstanceCount()

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

Returns the instance count of the mesh.

Returns
Number of mesh instances.
See also
Mesh::setInstanceBuffer
Mesh::getInstanceCount
Since
Kanzi 3.9.8

◆ setInstanceCount()

void kanzi::Mesh::setInstanceCount ( size_t count)
inline

Sets the count of the instance buffer.

See also
Mesh::setInstanceBuffer.
Mesh::getInstanceCount
Since
Kanzi 4.1.0

◆ getInstanceSize()

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

Returns the size of one mesh instance in bytes.

Returns
Size of the mesh instance in bytes.
Since
Kanzi 3.9.8

◆ getInstanceData()

span< const byte > kanzi::Mesh::getInstanceData ( ) const
inline

Returns the raw instance data that you must cast to the proper format for reading.

Returns
Raw instance data. If the data is not preserved in RAM, returns an empty span.
Since
Kanzi 3.9.8

◆ getInstanceTransforms()

const vector< Matrix4x4 > & kanzi::Mesh::getInstanceTransforms ( ) const
inline

Returns the instance transforms.

It should always be in sync with raw instance data.

Returns
Array of intance transfroms as matrix 4x4.
Since
Kanzi 4.1.0
Attention
This feature is experimental and is likely to change in future releases.

◆ 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
clusterIndexThe 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
clusterIndexThe cluster to query.
Returns
The primitive type for the cluster.

◆ setClusterPrimitiveType()

void kanzi::Mesh::setClusterPrimitiveType ( size_t clusterIndex,
GraphicsPrimitiveType primitiveType )

Sets the primitive type for the cluster.

Parameters
clusterIndexThe cluster to query.
primitiveTypeThe primitive type for the cluster.
Since
Kanzi 3.9.6

◆ getIndexType()

IndexBufferType kanzi::Mesh::getIndexType ( ) const

Gets the index type for the mesh.

Returns
The index type for the mesh.
Since
Kanzi 4.0.0

◆ getClusterIndexOffset()

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

Gets the index offset for the cluster.

Parameters
clusterIndexThe cluster to query.
Returns
The index offset for the cluster.
Since
Kanzi 4.0.0

◆ getClusterMaterial()

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

Gets the cluster material.

Parameters
clusterIndexThe 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.

◆ getIndexData()

span< const byte > kanzi::Mesh::getIndexData ( ) const

Gets index data for the mesh.

Make sure to cast the data to the correct format for reading. Use getIndexType() to get the correct format.

Returns
Raw index data. If data is not preserved in RAM, the returned span is empty.
Since
Kanzi 4.0.0

◆ updateSkeletonTransformation()

optional< Matrix4x4 > kanzi::Mesh::updateSkeletonTransformation ( Model3D & model)

Updates bounding box of mesh with bones from given model and root transformation of the skeleton.

Parameters
modelNode to update.
Returns
If skinning is enabled for the mesh, armature root transform, otherwise empty optional.

◆ getSkeleton()

const Skeleton & kanzi::Mesh::getSkeleton ( ) const
inline

Returns the skeleton of the mesh.

Returns
The skeleton of the mesh. If the mesh is not skinned, the skeleton has zero bones.

◆ attachSkeleton()

void kanzi::Mesh::attachSkeleton ( Model3D * model)

Attaches the mesh skeleton runtime to the node.

Parameters
modelRoot node for the bone lookups.

◆ detachSkeleton()

void kanzi::Mesh::detachSkeleton ( Model3D * model)

Detaches the mesh skeleton runtime from the node.

Parameters
modelRoot node for the bone lookups.

◆ acquireAttributeMap()

const vector< int > & kanzi::Mesh::acquireAttributeMap ( const ShaderProgram & 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).
Since
Kanzi 4.0.0 changed the type of the shaderProgram parameter to const ShaderProgram&.
Deprecated
In Kanzi 4.0.0

◆ setVertexData()

void kanzi::Mesh::setVertexData ( ConstByteSpan data,
VertexAttribute::SemanticKey attribute )

Sets the vertex data of the mesh.

Parameters
dataData to set to as vertex buffer data for the specified attribute.
attributeAttribute to specify the attribute the data is to be set to.
Since
Kanzi 4.1.0
  • Added the attribute parameter to identify the vertex attribute to modify.

◆ setVertexSubData()

void kanzi::Mesh::setVertexSubData ( ConstByteSpan data,
uint32_t offset,
VertexAttribute::SemanticKey attribute )

Sets a section of the vertex data of the mesh.

Parameters
dataData to set to as vertex buffer data for the specified attribute.
offsetByte offset from the start of the vertex data where to start the newly set data.
attributeAttribute to specify the attribute the data is to be set to.
Since
Kanzi 4.1.0
  • Added the attribute parameter to identify the vertex attribute to modify.

◆ setIndexData()

void kanzi::Mesh::setIndexData ( 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
dataData to set to set as a buffer index data.
Since
Kanzi 4.0.0 removed the clusterIndex parameter.

◆ setIndexSubData()

void kanzi::Mesh::setIndexSubData ( ConstByteSpan data,
uint32_t offset )

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

Parameters
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.
Since
Kanzi 4.0.0 removed the clusterIndex parameter.

◆ setInstanceData()

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

Sets the instance data of the mesh.

Parameters
dataData to set as the instance buffer data.
Since
Kanzi 3.9.6

◆ setInstanceSubData()

void kanzi::Mesh::setInstanceSubData ( ConstByteSpan data,
uint32_t offset )

Sets a section of the instance data of the mesh.

Parameters
dataData to set as the instance buffer data.
offsetByte offset from the start of the instance data where to start the newly set data.
Since
Kanzi 3.9.6

◆ setInstanceBuffer()

void kanzi::Mesh::setInstanceBuffer ( GPUBufferSharedPtr buffer)

Sets the instance buffer to the given GPUBuffer.

Parameters
bufferThe buffer to assign.
See also
Mesh::setInstanceCount
Mesh::getInstanceCount
Since
Kanzi 4.1.0

◆ setInstanceTransforms()

void kanzi::Mesh::setInstanceTransforms ( vector< Matrix4x4 > instanceTransforms)

Sets the instance transforms.

Should be always in sync with raw instance data.

Parameters
instanceTransformsThe array of instance transforms.
Since
Kanzi 4.1.0
Attention
This feature is experimental and is likely to change in future releases.

◆ createLoadTask()

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

Creates a load task for loading a mesh from a KZB file.

Parameters
nameName of the mesh resource.
kzbFileKZB file to load from.
fileMemory file containing mesh data.
Returns
Load task shared pointer.

◆ getMorphData()

MorphData * kanzi::Mesh::getMorphData ( ) const
inline

Gets a pointer to the morph data.

Returns
Pointer to morph data or nullptr if no morph data is present.
Since
Kanzi 4.0.0

◆ hasMorphData()

bool kanzi::Mesh::hasMorphData ( ) const
inline

Indicates whether or not the mesh has morph data.

This function indicates the existence of morph data information in general. The morph data may not have an associated vertex buffer if data textures are in use.

Returns
If the mesh has morph data, returns true, otherwise false.
Since
Kanzi 4.0.0

◆ hasMorphDataVertexBuffer()

bool kanzi::Mesh::hasMorphDataVertexBuffer ( ) const
inline

Indicates whether or not the mesh has a vertex buffer to use with morph data.

Returns
If the mesh has morph data with a vertex buffer, returns true, otherwise false.
Since
Kanzi 4.0.0

◆ 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.

◆ destroyOverride()

void kanzi::Mesh::destroyOverride ( )
overrideprotectedvirtual

GPUResource::destroyOverride() implementation.

Reimplemented from kanzi::GPUResource.

◆ isDeployedOverride()

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

GpuResource::isDeployed() implementation.

Implements kanzi::GPUResource.

◆ getGPUMemoryUsageOverride()

size_t kanzi::Mesh::getGPUMemoryUsageOverride ( ) const
overrideprotectedvirtual

GpuResource::getGPUMemoryUsageOverride() implementation.

Reimplemented from kanzi::GPUResource.

◆ getCPUMemoryUsageOverride()

size_t kanzi::Mesh::getCPUMemoryUsageOverride ( ) const
overrideprotectedvirtual

Resource::getCPUMemoryUsageOverride() implementation.

Reimplemented from kanzi::Resource.

◆ operator=()

Mesh & kanzi::Mesh::operator= ( const Mesh & )
protecteddelete

Deleted copy operator.

Friends And Related Symbol Documentation

◆ swap

void swap ( Mesh & mesh1,
Mesh & mesh2 )
friend

Swaps two Mesh objects.

Parameters
mesh1First mesh to swap.
mesh2Second mesh to swap.

Member Data Documentation

◆ m_clusters

vector<Cluster> kanzi::Mesh::m_clusters
protected

Array of clusters in mesh.

◆ m_boundingBox

Box kanzi::Mesh::m_boundingBox
protected

Bounding box for a mesh.

◆ m_skeleton

Skeleton kanzi::Mesh::m_skeleton
protected

Skeleton (skinned meshes).

◆ m_insufficientBoneCountLogged

bool kanzi::Mesh::m_insufficientBoneCountLogged
protected

Boolean specifying if insufficient bone count has already been logged.

Intended to prevent performance drop caused by logging errors every frame.

◆ m_attributeMap

vector<int> kanzi::Mesh::m_attributeMap
protected

Map from shader attribute location to mesh attribute index.

◆ m_vertexFormat

MeshVertexFormat kanzi::Mesh::m_vertexFormat
protected

Mesh vertex attributes.

◆ m_vertexCount

size_t kanzi::Mesh::m_vertexCount
protected

Vertex count for this vertex buffer.

Since
Kanzi 3.9.7 changed the type to uint32_t.
Kanzi 4.0.0 changed the type to size_t.

◆ m_indexData

vector<byte> kanzi::Mesh::m_indexData
protected

Raw index data.

◆ m_morphData

unique_ptr<MorphData> kanzi::Mesh::m_morphData
protected

Morph data.

Since
Kanzi 4.0.0

◆ m_instanceCount

size_t kanzi::Mesh::m_instanceCount
protected

Instance count for this instance buffer.

Since
Kanzi 3.9.7 changed the type to uint32_t.
Kanzi 4.1.0 changed the type to size_t.

◆ m_instanceData

vector<byte> kanzi::Mesh::m_instanceData
protected

Raw instance data.

◆ m_instanceTransforms

vector<Matrix4x4> kanzi::Mesh::m_instanceTransforms
protected

Instance transforms.

Since
Kanzi 4.1.0.

◆ m_shaderProgramAttributeMaps

ShaderProgramToAttributeMapSet kanzi::Mesh::m_shaderProgramAttributeMaps
protected

ShaderProgram pointer -> (shader attribute location -> mesh vertex attribute index)

◆ m_vertexBuffer

VertexBufferContainer kanzi::Mesh::m_vertexBuffer
protected

Vertex buffer.

◆ m_instanceBuffer

GPUBufferSharedPtr kanzi::Mesh::m_instanceBuffer
protected

Instance buffer.

◆ m_indexCount

size_t kanzi::Mesh::m_indexCount
protected

Index count for this index buffer.

Since
Kanzi 4.0.0

◆ m_indexBuffer

GPUBufferSharedPtr kanzi::Mesh::m_indexBuffer
protected

Index buffer.

◆ m_indexType

IndexBufferType kanzi::Mesh::m_indexType
protected

Index buffer type.

◆ m_vertexStride

size_t kanzi::Mesh::m_vertexStride
protected

Vertex attribute stride.

◆ m_vertexInputStates

VertexInputStateContainer kanzi::Mesh::m_vertexInputStates
protected

Mapping from shaders to vertex input states.

Since
Kanzi 4.0.0

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