Kanzi 3.9.10
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.
 
typedef unique_ptr< MappedBufferMappedBufferPtr
 
using SkeletonRuntime
 
using SkeletonRuntimeSharedPtr
 
- 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.
 
void applySkeleton (Renderer &renderer, Node &baseNode, ShaderProgramSharedPtr shaderProgram)
 Applies bone animation, updating matrix palette transformation uniforms.
 
void attachSkeleton (Model3D *model)
 Attaches the mesh skeleton runtime to the node.
 
void bind (Renderer &renderer, size_t clusterIndex, ShaderProgramSharedPtr shaderProgram)
 Prepares a cluster from the mesh for rendering with the specified shader.
 
void bindAttribute (Renderer &renderer, unsigned int shaderAttributeIndex, size_t meshVertexAttributeIndex)
 Takes one mesh vertex attribute from mesh and makes it usable with (current) shader.
 
unsigned int bindAttributes (Renderer &renderer, ShaderProgramSharedPtr shaderProgram)
 Makes all mesh vertex attributes available with a shader program.
 
void bindIndices (Renderer &renderer, size_t clusterIndex)
 Makes mesh cluster indices available to the next draw call.
 
void detachSkeleton (Model3D *model)
 Detaches the mesh skeleton runtime from the node.
 
Box getBoundingBox () const
 Returns the bounding box of a mesh.
 
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.
 
span< const bytegetClusterIndexData (size_t clusterIndex) const
 Gets index data for given cluster.
 
IndexBufferType getClusterIndexType (size_t clusterIndex) const
 Gets the index type 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.
 
size_t getInstanceCount () const
 Returns the instance count of the mesh.
 
span< const bytegetInstanceData () 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.
 
GPUBuffer::NativeHandle getNativeIndexBufferHandle (size_t clusterIndex)
 Gets the native handle for index data of the cluster.
 
GPUBuffer::NativeHandle getNativeInstanceBufferHandle ()
 Gets the native handle for the instance data of the mesh.
 
GPUBuffer::NativeHandle getNativeVertexBufferHandle ()
 Gets the native handle for vertex data of the mesh.
 
const SkeletongetSkeleton () const
 Returns the skeleton of the mesh.
 
const MeshVertexAttributegetVertexAttribute (unsigned int index) const
 Gets a vertex attribute by its index.
 
size_t getVertexAttributeCount () const
 Gets the number of the vertex attributes in the mesh.
 
optional< unsigned intgetVertexAttributeIndex (VertexAttribute::Semantic semantic) const
 Gets a vertex attribute index by semantic.
 
optional< unsigned intgetVertexAttributeIndex (VertexAttribute::Semantic semantic, unsigned int index) const
 Gets a vertex attribute index by semantic and semantic index.
 
size_t getVertexCount () const
 Returns the vertex count of the mesh.
 
span< const bytegetVertexData () const
 Gets raw vertex data.
 
size_t getVertexSize () const
 Gets size of one vertex in bytes.
 
MappedBufferPtr mapIndexData (size_t clusterIndex)
 Maps the index data of a cluster in the mesh on the GPU to a CPU memory region.
 
MappedBufferPtr mapInstanceData ()
 Maps the instance data of the mesh on the GPU to a CPU memory region.
 
MappedBufferPtr mapVertexData ()
 Maps the vertex data of the mesh on the GPU to a CPU memory region.
 
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 (size_t clusterIndex, ConstByteSpan data)
 Sets the index data of a cluster in the mesh.
 
void setIndexSubData (size_t clusterIndex, ConstByteSpan data, unsigned int offset)
 Sets a section of the index data of a cluster in the mesh.
 
void setInstanceData (ConstByteSpan data)
 Sets the instance data of the mesh.
 
void setInstanceSubData (ConstByteSpan data, unsigned int offset)
 Sets a section of the instance data of the mesh.
 
void setVertexData (ConstByteSpan data)
 Sets the vertex data of the mesh.
 
void setVertexSubData (ConstByteSpan data, unsigned int offset)
 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.
 
unsigned int getGPUMemoryUsage () const
 
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
virtual unsigned int getCPUMemoryUsage () const
 Function for getting the memory usage of a 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
template<typename DataType >
void addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
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)
 
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)
 
KZ_DEPRECATED void validatePropertyModifiers (AbstractPropertyType propertyType)
 Validates property modifiers and notifies handlers.
 
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, unsigned int 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, unsigned int 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)
 
static MeshSharedPtr createPlane (Domain *domain, float width, float height, unsigned int subdivisions, bool invertU, bool invertV, string_view name, MaterialSharedPtr material=MaterialSharedPtr())
 Creates a plane shape.
 
static MeshSharedPtr createQuadsphere (Domain *domain, float radius, unsigned int 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, unsigned int segmentCount, unsigned int 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.
 
unsigned int getCPUMemoryUsageOverride () const override
 Resource::getCPUMemoryUsageOverride() implementation.
 
unsigned int getGPUMemoryUsageOverride () const override
 GpuResource::getGPUMemoryUsageOverride() implementation.
 
void invalidateOverride () override
 GPUResource::invalidateOverride() implementation.
 
bool isDeployedOverride () const override
 GpuResource::isDeployed() implementation.
 
 Mesh (Domain *domain, const CreateInfo &createInfo, string_view name)
 
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, PropertyStoragePtr &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)
 
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 them.
 
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)
 
PropertyStoragePtr constructPropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
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 &storagePtr, 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.
 
void removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner)
 Removes a property value source.
 
void validatePropertyModifiers (PropertyStoragePtr &propertyStorage)
 Validates property modifiers without notifying handlers.
 
void validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage)
 Validates property modifiers and notifies handlers.
 

Friends

void swap (Mesh &mesh1, Mesh &mesh2)
 

Additional Inherited Members

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

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.

See also
Mesh::CreateInfo

Member Typedef Documentation

◆ BoneSharedPtr

Shared pointer type for Bone.

◆ SkeletonRuntime

◆ SkeletonRuntimeSharedPtr

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

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.
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.
Returns
Mesh shared pointer.

◆ createIcosphere()

static MeshSharedPtr kanzi::Mesh::createIcosphere ( Domain * domain,
float radius,
unsigned int 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,
unsigned int 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,
unsigned int 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,
unsigned int 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.

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

◆ getVertexAttribute()

const MeshVertexAttribute & kanzi::Mesh::getVertexAttribute ( unsigned int 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< unsigned int > 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< unsigned int > kanzi::Mesh::getVertexAttributeIndex ( VertexAttribute::Semantic semantic,
unsigned int 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 ( ) const
inline

Gets raw vertex data.

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

Returns
Raw vertex data. If data is not preserved in RAM, the returned span is empty.

◆ getInstanceCount()

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

Returns the instance count of the mesh.

Returns
Number of mesh instances.
Since
Kanzi 3.9.8

◆ 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

◆ 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

◆ getClusterIndexType()

IndexBufferType kanzi::Mesh::getClusterIndexType ( size_t clusterIndex) const

Gets the index type for the cluster.

Parameters
clusterIndexThe cluster to query.
Returns
The index type for the cluster.

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

◆ getClusterIndexData()

span< const byte > kanzi::Mesh::getClusterIndexData ( size_t clusterIndex) const

Gets index data for given cluster.

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

Parameters
clusterIndexThe cluster to query.
Returns
Raw cluster index data. If data is not preserved in RAM, the returned span is empty.

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

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

Parameters
dataData to set to as vertex buffer data.

◆ setVertexSubData()

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

Sets a section of the vertex data of the mesh.

Parameters
dataData to set to as vertex buffer data.
offsetByte offset from the start of the vertex data where to start the newly set data.

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

◆ mapInstanceData()

MappedBufferPtr kanzi::Mesh::mapInstanceData ( )

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

Returns
If the mapping succeeds, returns a unique pointer to the mapped buffer. If the mapping fails, returns a nullptr.
Since
Kanzi 3.9.6

◆ 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,
unsigned int 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

◆ createLoadTask()

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

◆ getNativeVertexBufferHandle()

GPUBuffer::NativeHandle kanzi::Mesh::getNativeVertexBufferHandle ( )
inline

Gets the native handle for vertex data of the mesh.

Returns
Native vertex buffer handle if available, otherwise GPUBuffer::NativeHandleInvalid.
Since
Kanzi 3.9.6

◆ getNativeIndexBufferHandle()

GPUBuffer::NativeHandle kanzi::Mesh::getNativeIndexBufferHandle ( size_t clusterIndex)
inline

Gets the native handle for index data of the cluster.

Parameters
clusterIndexIndex of the cluster whose index buffer to get.
Returns
Native index buffer handle if available, otherwise GPUBuffer::NativeHandleInvalid.
Since
Kanzi 3.9.6

◆ getNativeInstanceBufferHandle()

GPUBuffer::NativeHandle kanzi::Mesh::getNativeInstanceBufferHandle ( )
inline

Gets the native handle for the instance data of the mesh.

Returns
Native vertex buffer handle if available, otherwise GPUBuffer::NativeHandleInvalid.
Since
Kanzi 3.9.6

◆ 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()

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

GpuResource::getGPUMemoryUsageOverride() implementation.

Reimplemented from kanzi::GPUResource.

◆ getCPUMemoryUsageOverride()

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

Resource::getCPUMemoryUsageOverride() implementation.

Reimplemented from kanzi::Resource.

Friends And Related Symbol Documentation

◆ swap

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

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