kanzi::Mesh Class Reference

Struct which contains all the parameters that are needed for mesh creation. More...

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

Inheritance diagram for kanzi::Mesh:
kanzi::GPUResource kanzi::Resource kanzi::Object kanzi::MetaObject kanzi::PropertyObject

Classes

struct  Bone
 Definition of mesh bone, that is used for mesh skinning. More...
 
struct  Cluster
 Parameters for Mesh::Cluster creation. More...
 
struct  Skeleton
 Skeleton is for animating mesh with bones. More...
 

Public Types

typedef pair< AbstractPropertyType, VariantPropertyEntry
 
typedef vector< PropertyEntryPropertyContainer
 
- 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 intrusive_ptr< AbstractPropertyTypeDescriptor::PropertyStoragePropertyStoragePtr
 
typedef vector< PropertyStoragePtrPropertyStorageContainer
 
typedef PropertyStorageContainer::iterator PropertyStorageIterator
 
typedef PropertyStorageContainer::const_iterator PropertyStorageConstIterator
 
typedef PropertyStorageContainer::reverse_iterator PropertyStorageReverseIterator
 

Public Member Functions

 CreateInfo ()
 Default constructor for mesh create info. More...
 
void bind (size_t clusterIndex, ShaderProgramSharedPtr shaderProgram)
 Prepares a cluster from the mesh for rendering with the specified shader. More...
 
const KzuBoundingVolumegetBoundingVolume () const
 Returns the bounding volume of the mesh. More...
 
size_t getVertexCount () const
 Returns the vertex count of the mesh. More...
 
size_t getVertexAttributeCount () const
 Gets the number of the vertex attributes in the mesh. More...
 
size_t getVertexSize () const
 Gets size of one vertex in bytes. More...
 
const void * getVertexData () const
 Gets raw vertex data. More...
 
size_t getClusterCount () const
 Gets the number of clusters in the mesh. More...
 
size_t getClusterIndexCount (size_t clusterIndex) const
 Gets the number of indices in a specified cluster. More...
 
GraphicsPrimitiveType getClusterPrimitiveType (size_t clusterIndex) const
 Gets the primitive type for the cluster. More...
 
MaterialSharedPtr getClusterMaterial (size_t clusterIndex) const
 Gets the cluster material. More...
 
void setClusterMaterial (size_t clusterIndex, MaterialSharedPtr material)
 Sets the cluster material. More...
 
const uint16_t * getClusterIndexData (size_t clusterIndex) const
 Gets index data for given cluster. More...
 
bool updateBoundingBox (Node3D *baseNode, const KzcDynamicArray *transformedObjectList)
 Updates bounding box of mesh with bones from given model. More...
 
size_t getBoneCount () const
 Gets number of bones in mesh. More...
 
Node3DgetBoneNode (size_t boneIndex) const
 Gets node for bone. More...
 
Node3DgetBoneChildJoint (size_t boneIndex) const
 Gets child node for skeletal animation bone. More...
 
void attach (Node *baseNode)
 Attaches a root node for bone node lookup functions. More...
 
void detach ()
 Detaches root node, making bone node lookups no longer available. More...
 
const vector< int > & acquireAttributeMap (ShaderProgramSharedPtr shaderProgram)
 Gets attribute map for given shader program. More...
 
void applySkeleton (Node *baseNode, const KzcDynamicArray *transformedObjectList)
 Applies bone animation, updating matrix palette transformation uniforms. More...
 
const MeshVertexAttributegetVertexAttribute (int index) const
 Gets mesh vertex attribute with given mesh attribute index. More...
 
void bindAttribute (Renderer *renderer, unsigned int shaderAttributeIndex, int meshVertexAttributeIndex)
 Takes one mesh vertex attribute from mesh and makes it usable with (current) shader. More...
 
unsigned int bindAttributes (ShaderProgramSharedPtr shaderProgram)
 Makes all mesh vertex attributes available with a shader program. More...
 
void bindIndices (size_t clusterIndex)
 Makes mesh cluster indices available to the next draw call. More...
 
- Public Member Functions inherited from kanzi::GPUResource
virtual ~GPUResource () KZ_OVERRIDE
 
void invalidate ()
 Notify resource that graphics context was lost and all GPU resources are invalid. More...
 
unsigned int getGPUMemoryUsage () const
 
RenderergetRenderer () const
 
bool isDeployed () const
 
- Public Member Functions inherited from kanzi::Resource
KzcMemoryManagergetMemoryManager () const
 
 Resource (Domain *domain, string_view name)
 
virtual ~Resource ()
 
virtual void loadFromKZB (const KzuResourceLoaderThreadContext *threadContext, KzcInputStream *inputStream, const KzuBinaryFileInfo *file)
 Function for loading the resource from .KZB. More...
 
virtual void unloadOverride ()
 Unload function for resource. Releases all CPU memory taken by the resource except the resource loader. More...
 
virtual unsigned int getCPUMemoryUsage () const
 Function for getting the memory usage of a resource. More...
 
void setKZB (const KzuBinaryDirectory *binaryDirectory, string_view path)
 Set the binary directory and path of the resource. More...
 
const string & getName () const
 Gets the resource name. More...
 
const string & getUrl () const
 Gets the resource URL. More...
 
void setUrl (string_view url)
 Sets the resource URL. More...
 
void setNotLoaded ()
 
bool isFromKZB () const
 
void reload ()
 
void reloadFromKzb (KzcInputStream *inputStream, const KzuBinaryFileInfo *file)
 
void reloadFromKzb (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser)
 
void reloadFromFile (string_view filePath)
 
void load ()
 
void unload ()
 
bool isLoaded () const
 
void kzuResourceLoad_private (const KzuResourceLoaderThreadContext *threadContext)
 Private function for kzuResourceLoad() with specified thread context. More...
 
void kzuResourceFinishLoading_private (const KzuResourceLoaderThreadContext *threadContext)
 Private function for finishing the loading of the resource. More...
 
bool isKeepAlive () const
 Tells if the resource has keep alive flag set. More...
 
void setKeepAlive (bool keepAlive)
 Sets the keep alive flag. More...
 
- Public Member Functions inherited from kanzi::Object
 Object (Domain *domain)
 
virtual ~Object ()
 
DomaingetDomain () const
 Returns the domain the object belongs to. More...
 
KzuTaskSchedulergetTaskScheduler () const
 Returns the task scheduler of the object. More...
 
KzuMessageDispatchergetMessageDispatcher () const
 Returns the message dispatcher of the object. More...
 
ResourceManagergetResourceManager () const
 Returns the resource manager of the object. More...
 
virtual const MetaclassgetDynamicMetaclass () const KZ_OVERRIDE
 Returns the metaclass of the dynamic type of the object. More...
 
AppliedStyleEntryapplyObjectStyle (kanzi::StyleSharedPtr style)
 Applies a style to an object. More...
 
void unapplyObjectStyle (AppliedStyleEntry *appliedStyleEntry)
 
void applyObjectStyles ()
 Apply all styles for an object node. More...
 
void unapplyObjectStyles ()
 Unapplies and removes all applied styles. More...
 
- Public Member Functions inherited from kanzi::MetaObject
virtual ~MetaObject ()
 
bool isTypeOf (const Metaclass *objectType) const
 Determines if the type of this object is the given type or derived from it. More...
 
- Public Member Functions inherited from kanzi::PropertyObject
 PropertyObject ()
 
virtual ~PropertyObject ()
 
template<typename DataType >
void setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 Sets the local value of a property. More...
 
void removeKzbProperties ()
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getProperty (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property. More...
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalProperty (const PropertyType< DataType > &propertyType) const
 Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. More...
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers. More...
 
template<typename DataType >
void setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 
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
 
void setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
bool isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const
 
void clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
bool hasValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value. More...
 
bool hasBaseValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value, disregarding modifiers. More...
 
bool hasLocalValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a local value set for the property. More...
 
bool hasNonClassValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a value of any precedence higher than class default value set for the property. More...
 
void removeLocalValue (AbstractPropertyType propertyType)
 Removes the local value associated with the property. More...
 
void copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType)
 Copies local value of single property from another object. More...
 
void copyLocalValues (const PropertyObject &other)
 Copies all local values from another object. More...
 
virtual void onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason)
 Virtual function to handle property change notifications. More...
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *owner)
 
template<typename DataType >
void removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *owner)
 
template<typename DataType >
void addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
void validatePropertyModifiers (AbstractPropertyType propertyType)
 
template<typename DataType >
void addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
size_t getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType)
 Gets number of current notification handlers for given property type. More...
 

Static Public Member Functions

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

Public Attributes

MemoryType memoryType
 Memory type for the texture. More...
 
vector< Mesh::CreateInfo::Cluster > clusters
 Clusters. More...
 
Box boundingBox
 Bounding box for mesh. More...
 
Skeleton skeleton
 Mesh skeleton for bone animations. More...
 
MeshAttributeCollection vertexFormat
 Mesh vertex attributes. More...
 
size_t vertexSize
 Size of one vertex in bytes. This is sum of all mesh vertex attributes sizes. More...
 
size_t vertexCount
 Number of vertices in the mesh. More...
 
vector< bytevertexData
 Vertex buffer data. More...
 
PropertyContainer properties
 Properties to copy to the mesh. More...
 
struct KANZI_API CreateInfo
 

Protected Member Functions

virtual void reloadOverride () KZ_OVERRIDE
 Resource::reloadOverride() implementation. More...
 
virtual void reloadFromKzbOverride (KzcInputStream *inputStream, const KzuBinaryFileInfo *file) KZ_OVERRIDE
 Resource::reloadFromKzbOverride() implementation. More...
 
virtual void reloadFromKzbOverride (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser)
 Resource::reloadFromKzbOverride() implementation. More...
 
virtual void invalidateOverride () KZ_OVERRIDE
 GPUResource::invalidateOverride() implementation. More...
 
virtual bool isDeployedOverride () const KZ_OVERRIDE
 GpuResource::isDeployed() implementation. More...
 
virtual unsigned int getGPUMemoryUsageOverride () const KZ_OVERRIDE
 GpuResource::getGPUMemoryUsageOverride() implementation. More...
 
 Mesh (Domain *domain, const CreateInfo &createInfo, string_view name)
 
- Protected Member Functions inherited from kanzi::GPUResource
 GPUResource (Domain *domain, string_view name="")
 
- Protected Member Functions inherited from kanzi::Resource
virtual void reloadFromFileOverride (string_view filePath)
 
virtual unsigned int getCPUMemoryUsageOverride () const
 
- Protected Member Functions inherited from kanzi::Object
void initialize ()
 
void onCopy (const Object &other)
 
- Protected Member Functions inherited from kanzi::MetaObject
 MetaObject ()
 
void initialize ()
 
- Protected Member Functions inherited from kanzi::PropertyObject
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, void *owner)
 
void removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner)
 
AbstractPropertyTypeDescriptor::ValueSourceEntrygetTopValueSourceEntry (AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage) const
 
AbstractPropertyTypeDescriptor::ValueSourceEntrygetTopValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetTopValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetNonClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourceEntryfindLocalValueSourceEntry (AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
AbstractPropertyTypeDescriptor::ValueSourceEntryconstructLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
AbstractPropertyTypeDescriptor::ValueSourceEntryacquireLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::PropertyStoragefindPropertyStorage (AbstractPropertyTypeDescriptor &descriptor) const
 
PropertyStoragePtr findPropertyStoragePtr (AbstractPropertyTypeDescriptor &descriptor) const
 Gets property storage intrusive pointer that can be used to hold a reference until end of operation. More...
 
PropertyStoragePtr constructPropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
PropertyStoragePtr acquirePropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::ModifierStorageacquireModifierStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::ModifierStoragefindModifierStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::NotificationStorageacquireNotificationStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::NotificationStoragefindNotificationStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByUnqualifiedNameAndDataType (string_view unqualifiedName, PropertyDataType dataType)
 
void validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage)
 
void copyLocalValue (const AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 Copy local value from property storage. More...
 
PropertyStorageContainer::iterator beginPropertyStorage ()
 
PropertyStorageContainer::iterator endPropertyStorage ()
 
virtual void notifyPropertyHandlers (PropertyStoragePtr &propertyStorage, PropertyNotificationReason reason)
 
void onCopy (const PropertyObject &other)
 

Friends

void swap (Mesh &mesh1, Mesh &mesh2)
 

Additional Inherited Members

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

Detailed Description

Struct which contains all the parameters that are needed for mesh creation.

Mesh stores the geometry data for rendering Model3d nodes.

See also
Mesh

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

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

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

Examples - Creating Mesh with Kanzi C++ API

To create a mesh with Kanzi C++ API:

float vertexData[] = { -1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f };
uint16_t indexData[] = { 0, 1, 2 };
Mesh::CreateInfo createInfo;
createInfo.vertexFormat.push_back(MeshVertexAttribute("kzPosition", VertexAttribute::SemanticPosition, 0, GraphicsDataTypeSFLOAT32, 3, 0));
createInfo.vertexCount = 3;
createInfo.vertexSize = 3 * sizeof(float);
createInfo.vertexData.resize(createInfo.vertexCount * createInfo.vertexSize);
memcpy(createInfo.vertexData.data(), &vertexData[0], createInfo.vertexCount * createInfo.vertexSize);
Mesh::CreateInfo::Cluster cluster;
cluster.indexData.resize(3);
memcpy(cluster.indexData.data(), &indexData, cluster.indexData.size() * sizeof(uint16_t));
cluster.primitiveType = GraphicsPrimitiveTypeTriangles;
cluster.material = material;
createInfo.boundingBox = calculateBoundingVolume(createInfo);
MeshSharedPtr mesh = Mesh::create(domain, createInfo, "test Mesh");

Member Typedef Documentation

Constructor & Destructor Documentation

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

Member Function Documentation

kanzi::Mesh::CreateInfo ( )
explicit

Default constructor for mesh create info.

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

Creates a mesh with specified mesh creation parameters.

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

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

Parameters
domainDomain for the mesh.
createInfoMesh creation parameters.
nameName for the mesh.
Returns
Mesh shared pointer.
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
radiusRadius of the sphere
segmentCountNumber of segments for the shape
rowCountNumber of rows for the shape
materialMaterial pointer for the cluster. If set, leave the materialURL parameter empty.
materialURLResource address for the cluster material. If set, leave material empty.
Returns
Mesh shared pointer.
static MeshSharedPtr kanzi::Mesh::createBox ( Domain domain,
Vector3  size,
string_view  name,
MaterialSharedPtr  material = MaterialSharedPtr() 
)
static

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

Parameters
widthWidth of the box (size along the x axis)
heightHeight of the box (size along the y axis)
depthDepth of the box (size along z axis)
materialMaterial pointer for the cluster. If set, leave the materialURL parameter empty.
materialURLResource address for the cluster material. If set, leave the material parameter empty.
Returns
Mesh shared pointer.
static MeshSharedPtr kanzi::Mesh::createPlane ( Domain domain,
float  width,
float  height,
bool  invertU,
bool  invertV,
string_view  name,
MaterialSharedPtr  material = MaterialSharedPtr() 
)
static

Creates a plane shape.

Parameters
widthWidth of the plane (size along the x axis)
heightHeight of the plane (size along the y axis)
invertUIf true, the first texture coordinate is inverted
invertVIf true, the second texture coordinate is inverted
materialMaterial pointer for the cluster. If set, leave the materialURL parameter empty.
materialURLResource address for the cluster material. If set, leave the material parameter empty.
Returns
Mesh shared pointer.
void kanzi::Mesh::bind ( size_t  clusterIndex,
ShaderProgramSharedPtr  shaderProgram 
)

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

Parameters
clusterIndexWhich cluster to render.
shaderProgramWhich ShaderProgram to render with.
const KzuBoundingVolume* kanzi::Mesh::getBoundingVolume ( ) const

Returns the bounding volume of the mesh.

Returns
Bounding volume for the mesh.
size_t kanzi::Mesh::getVertexCount ( ) const
inline

Returns the vertex count of the mesh.

Returns
Number of vertices in mesh.
size_t kanzi::Mesh::getVertexAttributeCount ( ) const
inline

Gets the number of the vertex attributes in the mesh.

Returns
Number of vertex attributes in mesh.
size_t kanzi::Mesh::getVertexSize ( ) const
inline

Gets size of one vertex in bytes.

Returns
Size of vertex in bytes.
const void* kanzi::Mesh::getVertexData ( ) const
inline

Gets raw vertex data.

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

Returns
Raw vertex data or 0 if data was not preserved in RAM.
size_t kanzi::Mesh::getClusterCount ( ) const
inline

Gets the number of clusters in the mesh.

Returns
Number of clusters in the mesh.
size_t kanzi::Mesh::getClusterIndexCount ( size_t  clusterIndex) const

Gets the number of indices in a specified cluster.

Parameters
clusterIndexWhich cluster to query
Returns
Number of indices in the cluster.
GraphicsPrimitiveType kanzi::Mesh::getClusterPrimitiveType ( size_t  clusterIndex) const

Gets the primitive type for the cluster.

Parameters
clusterIndexWhich cluster to query
Returns
The primitive type for the cluster.
MaterialSharedPtr kanzi::Mesh::getClusterMaterial ( size_t  clusterIndex) const

Gets the cluster material.

Parameters
clusterIndexWhich cluster to query
Returns
The material for the cluster.
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
const uint16_t* kanzi::Mesh::getClusterIndexData ( size_t  clusterIndex) const

Gets index data for given cluster.

Parameters
clusterIndexWhich cluster to query
Returns
Raw cluster index data or 0 if data was not preserved in RAM.
bool kanzi::Mesh::updateBoundingBox ( Node3D baseNode,
const KzcDynamicArray transformedObjectList 
)

Updates bounding box of mesh with bones from given model.

Parameters
baseNodeNode from which bones are located from.
transformedObjectListList of transformed objects, from which bones are retrieved from.
Returns
True if mesh is skinned, otherwise false.
size_t kanzi::Mesh::getBoneCount ( ) const

Gets number of bones in mesh.

Returns
number of bones in mesh.
Node3D* kanzi::Mesh::getBoneNode ( size_t  boneIndex) const

Gets node for bone.

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

See also
attach()
Parameters
boneIndexindex of bone.
Returns
Node for bone.
Node3D* kanzi::Mesh::getBoneChildJoint ( size_t  boneIndex) const

Gets child node for skeletal animation bone.

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

See also
attach()
Parameters
boneIndexindex of bone.
Returns
Node for bone.
void kanzi::Mesh::attach ( Node baseNode)

Attaches a root node for bone node lookup functions.

See also
getBoneNode()
getBoneChildJoint()
Parameters
baseNodeRoot node for bone node lookups.
void kanzi::Mesh::detach ( )

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

See also
attach()
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).
void kanzi::Mesh::applySkeleton ( Node baseNode,
const KzcDynamicArray transformedObjectList 
)

Applies bone animation, updating matrix palette transformation uniforms.

Parameters
baseNodeRoot node for bones.
transformedObjectListTransformed nodes.
const MeshVertexAttribute& kanzi::Mesh::getVertexAttribute ( int  index) const

Gets mesh vertex attribute with given mesh attribute index.

Parameters
indexMesh vertex attribute index.
Returns
Mesh vertex attribute.
void kanzi::Mesh::bindAttribute ( Renderer renderer,
unsigned int  shaderAttributeIndex,
int  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.
unsigned int kanzi::Mesh::bindAttributes ( ShaderProgramSharedPtr  shaderProgram)

Makes all mesh vertex attributes available with a shader program.

Parameters
shaderProgramShader program
Returns
Bitfield: nth bit indicates that nth shader attribute was sourced from the mesh.
void kanzi::Mesh::bindIndices ( size_t  clusterIndex)

Makes mesh cluster indices available to the next draw call.

Parameters
clusterIndexIndex of cluster to prepare.
static ResourceManager::LoadTaskSharedPtr kanzi::Mesh::createLoadTask ( string_view  name,
KzbFile kzbFile,
unique_ptr< ReadOnlyMemoryFile file 
)
static
virtual void kanzi::Mesh::reloadOverride ( )
protectedvirtual

Resource::reloadOverride() implementation.

Reimplemented from kanzi::Resource.

virtual void kanzi::Mesh::reloadFromKzbOverride ( KzcInputStream inputStream,
const KzuBinaryFileInfo file 
)
protectedvirtual

Resource::reloadFromKzbOverride() implementation.

Reimplemented from kanzi::Resource.

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

Resource::reloadFromKzbOverride() implementation.

Reimplemented from kanzi::Resource.

virtual void kanzi::Mesh::invalidateOverride ( )
protectedvirtual

GPUResource::invalidateOverride() implementation.

Reimplemented from kanzi::GPUResource.

virtual bool kanzi::Mesh::isDeployedOverride ( ) const
protectedvirtual

GpuResource::isDeployed() implementation.

Implements kanzi::GPUResource.

virtual unsigned int kanzi::Mesh::getGPUMemoryUsageOverride ( ) const
protectedvirtual

GpuResource::getGPUMemoryUsageOverride() implementation.

Reimplemented from kanzi::GPUResource.

Friends And Related Function Documentation

void swap ( Mesh mesh1,
Mesh mesh2 
)
friend

Member Data Documentation

MemoryType kanzi::Mesh::memoryType

Memory type for the texture.

If Gpu is not included, texture will not be deployed when created. If Ram is not included, texture will not contain images after it has been deployed. Default value is GpuOnly.

See also
MemoryType
vector<Mesh::CreateInfo::Cluster> kanzi::Mesh::clusters

Clusters.

Box kanzi::Mesh::boundingBox

Bounding box for mesh.

Skeleton kanzi::Mesh::skeleton

Mesh skeleton for bone animations.

MeshAttributeCollection kanzi::Mesh::vertexFormat

Mesh vertex attributes.

size_t kanzi::Mesh::vertexSize

Size of one vertex in bytes. This is sum of all mesh vertex attributes sizes.

size_t kanzi::Mesh::vertexCount

Number of vertices in the mesh.

vector<byte> kanzi::Mesh::vertexData

Vertex buffer data.

PropertyContainer kanzi::Mesh::properties

Properties to copy to the mesh.

Currently they are not used.

struct KANZI_API kanzi::Mesh::CreateInfo

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