Mesh stores the geometry data for rendering Model3d nodes. More...
#include <kanzi/graphics_3d/mesh.hpp>
Public Member Functions | |
Mesh (Domain *domain, string_view name="") | |
virtual | ~Mesh () KZ_OVERRIDE |
void | createBoundingVolume () |
Update bounding volume for the mesh. More... | |
void | initializeFromMemory (unsigned int vertexAttributeCount, const kzString *vertexAttributeNames, const VertexAttribute::Semantic *vertexAttributeSemantics, const GraphicsDataType *vertexAttributeDataTypes, const unsigned int *vertexAttributeDimensions, unsigned int vertexCount, const kzByte *vertexData, unsigned int clusterCount, const unsigned int *clusterIndexCounts, const kzU16 *const *clusterIndices, const GraphicsPrimitiveType *clusterTypes, MaterialSharedPtr const *clusterMaterials) |
Creates a mesh from the data provided in the parameters. More... | |
void | generateSphere (float radius, unsigned int segmentCount, unsigned int rowCount, MaterialSharedPtr material=MaterialSharedPtr(), kzString materialURL="") |
Populates a mesh with a sphere shape in a single cluster. More... | |
void | generateBox (float width, float height, float depth, MaterialSharedPtr material=MaterialSharedPtr(), kzString materialURL="") |
Populates a mesh with a box shape in a single cluster. More... | |
void | generatePlane (float width, float height, bool invertU, bool invertV, MaterialSharedPtr material=MaterialSharedPtr(), kzString materialURL="") |
Generates a plane shape. More... | |
void | bind (unsigned int clusterIndex, ShaderSharedPtr shader) |
Prepares a cluster from the mesh for rendering with the specified shader. More... | |
void | unbind (ShaderSharedPtr shader) |
Cleans up the rendering preparations done in the bind() function. More... | |
KzuBoundingVolumeSharedPtr | getBoundingVolume () |
Returns the bounding volume of the mesh. More... | |
unsigned int | 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... | |
void | getVertexAttributeInfo (unsigned int index, string &out_name, VertexAttribute::Semantic *out_semantic, GraphicsDataType *out_dataType, unsigned int *out_dimension, unsigned int *out_offset, unsigned int *out_size) |
Gets the information about the specific vertex attribute in the mesh. More... | |
unsigned int | getVertexSize () const |
Gets the vertex size. More... | |
const kzByte * | getVertexData () const |
Gets the pointer to the vertex data. More... | |
unsigned int | getClusterCount () const |
Gets the number of clusters in the mesh. More... | |
unsigned int | getIndexCount (unsigned int clusterIndex) const |
Gets the number of indices in a specified cluster. More... | |
const kzU16 * | getIndices (unsigned int clusterIndex) const |
Gets the index data in the specified cluster. More... | |
GraphicsPrimitiveType | getClusterType (unsigned int clusterIndex) const |
Gets the primitive type for the cluster. More... | |
Material * | getMaterial (unsigned int clusterIndex) const |
Gets the cluster material. More... | |
void | setMaterial (unsigned int clusterIndex, MaterialSharedPtr material) |
Sets the cluster material. More... | |
bool | updateBoundingBox (Node3D *baseNode, const KzcDynamicArray *transformedObjectList) |
size_t | getBoneCount () const |
Node3D * | getBoneNode (size_t boneIndex) const |
Node3D * | getBoneChildJoint (size_t boneIndex) const |
void | attach (Node *baseNode) |
void | detach () |
bool | isRenderable () const |
void | setPrimitiveVertexAttributes () |
void | loadVertices (KzcInputStream *inputStream, bool halfFloatSupported) |
void | loadDataFromKZB (const KzuResourceLoaderThreadContext *threadContext, KzcInputStream *inputStream, const KzuBinaryFileInfo *file) |
void | loadPrimitiveFromKZB (const KzuResourceLoaderThreadContext *threadContext, KzcInputStream *inputStream, const KzuBinaryFileInfo *file) |
Loads mesh primitive from KZB. More... | |
int | acquireAttributeIndex (StringToAttributeIndexSharedPtr attributeMap, const string &shaderAttributeName) |
vector< int > const & | acquireAttributeMap (ShaderSharedPtr shader) |
void | interpolateMorphTargets () |
void | applySkeleton (Node *baseNode, const KzcDynamicArray *transformedObjectList) |
VertexAttribute const & | getVertexAttribute (int index) const |
void | bindAttribute (Renderer *renderer, unsigned int shaderAttributeIndex, int meshVertexAttributeIndex) |
Binds the vertex buffer and sets the vertex attribute pointer. More... | |
unsigned int | bindAttributes (ShaderSharedPtr shader) |
void | bindIndices (unsigned int clusterIndex) |
void | bindMorphAttributes (Morph *morph) |
void | removeAttributeMapping (ShaderSharedPtr shader, const string &shaderAttribute) |
void | prepareMorph () |
virtual void | loadFromKZB (const KzuResourceLoaderThreadContext *threadContext, KzcInputStream *inputStream, const KzuBinaryFileInfo *file) KZ_OVERRIDE |
Function for loading the resource from .KZB. More... | |
virtual void | finishLoadingOverride (const KzuResourceLoaderThreadContext *threadContext) KZ_OVERRIDE |
Function for finishing the loading of the resource. More... | |
virtual void | unloadOverride () KZ_OVERRIDE |
Unload function for resource. More... | |
virtual unsigned int | getCPUMemoryUsage () const KZ_OVERRIDE |
Function for getting the memory usage of a resource. More... | |
virtual void | freeCommonData () KZ_OVERRIDE |
Notify resource that graphics context was lost and all GPU resources are invalid. More... | |
![]() | |
virtual | ~GPUResource () KZ_OVERRIDE |
void | deploy () |
Make graphics API object(s) in the resource usable by preparing GPU objects and data in them. More... | |
void | undeploy () |
Free the GPU objects. After this, the resource is not usable for graphics API until deploy() is called again. More... | |
void | invalidate () |
Notify resource that graphics context was lost and all GPU resources are invalid. More... | |
unsigned int | getGPUMemoryUsage () const |
Renderer * | getRenderer () const |
bool | getDeployOnLoad () const |
Returns true if GPUResource is automatically deployed when loaded. More... | |
void | setDeployOnLoad (bool value) |
Sets GPUResource automatic deployment on loade on or orr. More... | |
bool | isDeployed () const |
void | deployed () |
void | undeployed () |
![]() | |
KzcMemoryManager * | getMemoryManager () const |
Resource (Domain *domain, string_view name) | |
virtual | ~Resource () |
void | setKZB (const KzuBinaryDirectory *binaryDirectory, kzString path) |
void | setLoaded () |
kzString | getName () const |
Accessor. More... | |
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... | |
KzuResourceLoadingStrategy | getLoadingStrategy () const |
void | setLoadingStrategy (KzuResourceLoadingStrategy loadingStrategy) |
bool | getKeepAlive () const |
Tells if the resource has keep alive flag set. More... | |
void | setKeepAlive (bool keepAlive) |
Sets the keep alive flag. More... | |
![]() | |
Object (Domain *domain) | |
virtual | ~Object () |
Domain * | getDomain () const |
Returns the domain the object belongs to. More... | |
KzuPropertyManager * | getPropertyManager () const |
Returns the property manager of the object. More... | |
KzuTaskScheduler * | getTaskScheduler () const |
Returns the task scheduler of the object. More... | |
KzuMessageDispatcher * | getMessageDispatcher () const |
Returns the message dispatcher of the object. More... | |
ResourceManager * | getResourceManager () const |
Returns the resource manager of the object. More... | |
virtual const Metaclass * | getDynamicMetaclass () const |
Returns the metaclass of the dynamic type of the object. More... | |
bool | isTypeOf (const Metaclass *objectType) const |
Determines if the type of this object is the given type or derived from it. More... | |
template<typename DataType > | |
void | setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::DataType value) |
Sets the local value of a property. More... | |
void | setProperty (const PropertyType< ResourceID > &propertyType, ResourceSharedPtr value) |
Sets the local value of a resource id property with a resource pointer. More... | |
template<typename DataType > | |
DataType | getProperty (const PropertyType< DataType > &propertyType) const |
Returns the current value of a property. More... | |
template<typename DataType > | |
bool | getProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::DataType &value) 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 > | |
void | setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::DataType value) |
void | setAbstractProperty (AbstractPropertyType abstractPropertyType, ResourceSharedPtr value) |
template<typename DataType > | |
DataType | getAbstractProperty (AbstractPropertyType abstractPropertyType) const |
template<typename DataType > | |
bool | getAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::DataType &value) const |
bool | hasValue (AbstractPropertyType propertyType) const |
Evaluates whether there are any inputs into the property value. More... | |
bool | hasLocalValue (AbstractPropertyType propertyType) const |
Evaluates whether there is a local value set for the property. More... | |
void | removeLocalValue (AbstractPropertyType propertyType) |
Removes the local value associated with the property. More... | |
void | copyLocalValues (const Object &other) |
Copies all local values from another object. More... | |
virtual void | onPropertyChanged (AbstractPropertyType propertyType, KzuPropertyNotificationReason reason) |
Virtual function to handle property change notifications. More... | |
AppliedStyleEntry * | applyObjectStyle (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... | |
Static Public Member Functions | |
static MeshSharedPtr | create (Domain *domain, string_view name="") |
![]() | |
static const Metaclass * | getStaticMetaclass () |
Returns the metaclass of Object class. More... | |
static PropertyTypeEditorInfoSharedPtr | makeEditorInfo () |
Default implementation that returns empty editor info. More... | |
Protected Member Functions | |
virtual void | deployOverride () KZ_OVERRIDE |
Make graphics API object(s) in the resource usable by preparing GPU objects and data in them. Called by deploy() More... | |
virtual void | undeployOverride () KZ_OVERRIDE |
Free the GPU objects. After this, the resource is not usable for graphics API until deploy() is called again. Called by undeploy() More... | |
virtual void | invalidateOverride () KZ_OVERRIDE |
Notify resource that graphics context was lost and all GPU resources are invalid. Called by invalidate() More... | |
virtual unsigned int | getGPUMemoryUsageOverride () const KZ_OVERRIDE |
![]() | |
GPUResource (Domain *domain, string_view name="") | |
![]() | |
KzuResourceLoadState | getLoadState () |
Access. More... | |
![]() | |
void | initialize () |
void | onCopy (const Object &other) |
Additional Inherited Members | |
![]() | |
typedef vector < AppliedStyleEntry * > | AppliedStyleContainer |
Applied style container. More... | |
![]() | |
AppliedStyleContainer | m_appliedStyles |
Listing of applied styles applied to this object. More... | |
Mesh stores the geometry data for rendering Model3d nodes.
Each mesh has one or more clusters. Each cluster has vertex data, index data, and a material.
You can load a mesh from a .kzb file or create it with the createEmpty() function.
|
explicit |
|
virtual |
|
static |
void kanzi::Mesh::createBoundingVolume | ( | ) |
Update bounding volume for the mesh.
void kanzi::Mesh::initializeFromMemory | ( | unsigned int | vertexAttributeCount, |
const kzString * | vertexAttributeNames, | ||
const VertexAttribute::Semantic * | vertexAttributeSemantics, | ||
const GraphicsDataType * | vertexAttributeDataTypes, | ||
const unsigned int * | vertexAttributeDimensions, | ||
unsigned int | vertexCount, | ||
const kzByte * | vertexData, | ||
unsigned int | clusterCount, | ||
const unsigned int * | clusterIndexCounts, | ||
const kzU16 *const * | clusterIndices, | ||
const GraphicsPrimitiveType * | clusterTypes, | ||
MaterialSharedPtr const * | clusterMaterials | ||
) |
Creates a mesh from the data provided in the parameters.
vertexAttributeCount | Number of vertex attributes |
vertexAttributeNames | Array of vertex attribute names |
vertexAttributeSemantics | Array of vertex attribute semantics |
vertexAttributeDataTypes | Array of vertex attribute data types |
vertexAttributeDimensions | Array of vertex attribute dimensions |
vertexCount | Number of vertices |
vertexData | Vertex data, vertexCount formatted by vertex attributes |
clusterCount | Number of clusters |
clusterIndexCounts | Array of cluster index counts |
clusterIndices | Array of pointers to cluster index data |
clusterTypes | Array of cluster primitive type |
void kanzi::Mesh::generateSphere | ( | float | radius, |
unsigned int | segmentCount, | ||
unsigned int | rowCount, | ||
MaterialSharedPtr | material = MaterialSharedPtr() , |
||
kzString | materialURL = "" |
||
) |
Populates a mesh with a sphere shape in a single cluster.
void kanzi::Mesh::generateBox | ( | float | width, |
float | height, | ||
float | depth, | ||
MaterialSharedPtr | material = MaterialSharedPtr() , |
||
kzString | materialURL = "" |
||
) |
Populates a mesh with a box shape in a single cluster.
width | Width of the box (size along the x axis) |
height | Height of the box (size along the y axis) |
depth | Depth of the box (size along z axis) |
material | Material pointer for the cluster. If set, leave the materialURL parameter empty. |
materialURL | Resource address for the cluster material. If set, leave the material parameter empty. |
void kanzi::Mesh::generatePlane | ( | float | width, |
float | height, | ||
bool | invertU, | ||
bool | invertV, | ||
MaterialSharedPtr | material = MaterialSharedPtr() , |
||
kzString | materialURL = "" |
||
) |
Generates a plane shape.
width | Width of the plane (size along the x axis) |
height | Height of the plane (size along the y axis) |
invertU | If true, the first texture coordinate is inverted |
invertV | If true, the second texture coordinate is inverted |
material | Material pointer for the cluster. If set, leave the materialURL parameter empty. |
materialURL | Resource address for the cluster material. If set, leave the material parameter empty. |
void kanzi::Mesh::bind | ( | unsigned int | clusterIndex, |
ShaderSharedPtr | shader | ||
) |
Prepares a cluster from the mesh for rendering with the specified shader.
After the cluster is rendered, call the unbind() function.
clusterIndex | Which cluster to render |
shader | Which shader to render with |
void kanzi::Mesh::unbind | ( | ShaderSharedPtr | shader | ) |
KzuBoundingVolumeSharedPtr kanzi::Mesh::getBoundingVolume | ( | ) |
Returns the bounding volume of the mesh.
unsigned int kanzi::Mesh::getVertexCount | ( | ) | const |
Returns the vertex count of the mesh.
size_t kanzi::Mesh::getVertexAttributeCount | ( | ) | const |
Gets the number of the vertex attributes in the mesh.
void kanzi::Mesh::getVertexAttributeInfo | ( | unsigned int | index, |
string & | out_name, | ||
VertexAttribute::Semantic * | out_semantic, | ||
GraphicsDataType * | out_dataType, | ||
unsigned int * | out_dimension, | ||
unsigned int * | out_offset, | ||
unsigned int * | out_size | ||
) |
Gets the information about the specific vertex attribute in the mesh.
index | Which vertex attribute to query |
out_name | Name of the vertex attribute |
out_semantic | Semantic of the vertex attribute |
out_dataType | Data type of the vertex attribute |
out_dimension | Dimension of the vertex attribute |
out_offset | Offset of the vertex data for the vertex attribute |
out_size | Size of the vertex attribute |
unsigned int kanzi::Mesh::getVertexSize | ( | ) | const |
Gets the vertex size.
const kzByte* kanzi::Mesh::getVertexData | ( | ) | const |
Gets the pointer to the vertex data.
unsigned int kanzi::Mesh::getClusterCount | ( | ) | const |
Gets the number of clusters in the mesh.
unsigned int kanzi::Mesh::getIndexCount | ( | unsigned int | clusterIndex | ) | const |
Gets the number of indices in a specified cluster.
clusterIndex | Which cluster to query |
const kzU16* kanzi::Mesh::getIndices | ( | unsigned int | clusterIndex | ) | const |
Gets the index data in the specified cluster.
clusterIndex | Which cluster to query |
GraphicsPrimitiveType kanzi::Mesh::getClusterType | ( | unsigned int | clusterIndex | ) | const |
Gets the primitive type for the cluster.
clusterIndex | Which cluster to query |
Material* kanzi::Mesh::getMaterial | ( | unsigned int | clusterIndex | ) | const |
Gets the cluster material.
clusterIndex | Which cluster to query |
void kanzi::Mesh::setMaterial | ( | unsigned int | clusterIndex, |
MaterialSharedPtr | material | ||
) |
Sets the cluster material.
clusterIndex | The cluster for which to set the material |
material | The material to apply to the cluster |
bool kanzi::Mesh::updateBoundingBox | ( | Node3D * | baseNode, |
const KzcDynamicArray * | transformedObjectList | ||
) |
size_t kanzi::Mesh::getBoneCount | ( | ) | const |
Node3D* kanzi::Mesh::getBoneNode | ( | size_t | boneIndex | ) | const |
Node3D* kanzi::Mesh::getBoneChildJoint | ( | size_t | boneIndex | ) | const |
void kanzi::Mesh::attach | ( | Node * | baseNode | ) |
void kanzi::Mesh::detach | ( | ) |
bool kanzi::Mesh::isRenderable | ( | ) | const |
void kanzi::Mesh::setPrimitiveVertexAttributes | ( | ) |
void kanzi::Mesh::loadVertices | ( | KzcInputStream * | inputStream, |
bool | halfFloatSupported | ||
) |
void kanzi::Mesh::loadDataFromKZB | ( | const KzuResourceLoaderThreadContext * | threadContext, |
KzcInputStream * | inputStream, | ||
const KzuBinaryFileInfo * | file | ||
) |
void kanzi::Mesh::loadPrimitiveFromKZB | ( | const KzuResourceLoaderThreadContext * | threadContext, |
KzcInputStream * | inputStream, | ||
const KzuBinaryFileInfo * | file | ||
) |
Loads mesh primitive from KZB.
int kanzi::Mesh::acquireAttributeIndex | ( | StringToAttributeIndexSharedPtr | attributeMap, |
const string & | shaderAttributeName | ||
) |
vector<int> const& kanzi::Mesh::acquireAttributeMap | ( | ShaderSharedPtr | shader | ) |
void kanzi::Mesh::interpolateMorphTargets | ( | ) |
void kanzi::Mesh::applySkeleton | ( | Node * | baseNode, |
const KzcDynamicArray * | transformedObjectList | ||
) |
VertexAttribute const& kanzi::Mesh::getVertexAttribute | ( | int | index | ) | const |
void kanzi::Mesh::bindAttribute | ( | Renderer * | renderer, |
unsigned int | shaderAttributeIndex, | ||
int | meshVertexAttributeIndex | ||
) |
Binds the vertex buffer and sets the vertex attribute pointer.
unsigned int kanzi::Mesh::bindAttributes | ( | ShaderSharedPtr | shader | ) |
void kanzi::Mesh::bindIndices | ( | unsigned int | clusterIndex | ) |
void kanzi::Mesh::bindMorphAttributes | ( | Morph * | morph | ) |
void kanzi::Mesh::removeAttributeMapping | ( | ShaderSharedPtr | shader, |
const string & | shaderAttribute | ||
) |
void kanzi::Mesh::prepareMorph | ( | ) |
|
virtual |
Function for loading the resource from .KZB.
This function is called when loading the data from .KZB file. Implementations should call super class loadFromKZB before reading anything else from inputStream. This function is called from arbitrary loading threads. The parameter threadContext contains thread safe memory manager and a thread specific Property manager which can be locked with the threadLock in the threadContext. This function may not access resource manager or the UIDomain due to race conditions.
Reimplemented from kanzi::GPUResource.
|
virtual |
Function for finishing the loading of the resource.
This function is called in the main thread after loading the data. Implementations should call super class finishLoading first. The parameter threadContext contains thread safe memory manager and the property manager that was used for loading the resource, which can be locked with the threadLock in the threadContext.
Reimplemented from kanzi::GPUResource.
|
virtual |
Unload function for resource.
Releases all memory taken by the resource except the resource loader.
Reimplemented from kanzi::GPUResource.
|
virtual |
Function for getting the memory usage of a resource.
Reimplemented from kanzi::GPUResource.
|
virtual |
Notify resource that graphics context was lost and all GPU resources are invalid.
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
Make graphics API object(s) in the resource usable by preparing GPU objects and data in them. Called by deploy()
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
Free the GPU objects. After this, the resource is not usable for graphics API until deploy() is called again. Called by undeploy()
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
Notify resource that graphics context was lost and all GPU resources are invalid. Called by invalidate()
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
Reimplemented from kanzi::GPUResource.