Kanzi 4.1.0
Mesh Class Reference

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

Inheritance diagram for Mesh:
[legend]

Classes

class  CreateInfo
 Use Mesh.CreateInfo to describe and create meshes. More...
 

Static Public Member Functions

static ObjectRef< Meshcreate (Domain domain, Mesh.CreateInfo createInfo, String name)
 Creates a mesh with specified mesh creation parameters.
 
static ObjectRef< MeshcreateBox (Domain domain, Vector3 size, long subdivisions, String name, Material material)
 Creates a mesh with a box shape in a single cluster.
 
static ObjectRef< MeshcreateIcosphere (Domain domain, float radius, long subdivisions, String name, Material material)
 Creates a mesh with a sphere shape in a single cluster.
 
static ObjectRef< MeshcreatePlane (Domain domain, float width, float height, long subdivisions, boolean invertU, boolean invertV, String name, Material material)
 Creates a plane shape.
 
static ObjectRef< MeshcreateQuadsphere (Domain domain, float radius, long subdivisions, String name, Material material)
 Creates a mesh with a sphere shape in a single cluster.
 
static ObjectRef< MeshcreateSphere (Domain domain, float radius, long segmentCount, long rowCount, String name, Material material)
 Creates a mesh with a sphere shape in a single cluster.
 

Static Public Attributes

static final Metaclass metaclass = com.rightware.kanzi.metadata.MeshMetadata.metaclass
 The Metaclass for the class.
 
- Static Public Attributes inherited from GPUResource
static final Metaclass metaclass
 The Metaclass for the class.
 
- Static Public Attributes inherited from Resource
static final Metaclass metaclass
 The Metaclass for the class.
 
- Static Public Attributes inherited from ResourceProxy
static final Metaclass metaclass
 The Metaclass for the class.
 
- Static Public Attributes inherited from KanziObject
static final Metaclass metaclass = new AbstractMetaclass("Kanzi.Object")
 The Metaclass for the class.
 

Additional Inherited Members

- Public Member Functions inherited from GPUResource
int getGPUMemoryUsage ()
 Gets the amount of GPU memory used by the resource.
 
boolean isDeployed ()
 
- Public Member Functions inherited from ResourceProxy
String getName ()
 Gets the resource name.
 
String getUrl ()
 Gets the resource URL.
 
void setKeepAlive (boolean keepAlive)
 Sets the keep alive flag.
 
- Public Member Functions inherited from KanziObject
boolean equals (Object object)
 
Domain getDomain ()
 Returns the domain the object belongs to.
 
Metaclass getDynamicMetaclass ()
 Returns the metaclass of the dynamic type of the object.
 
long getNative ()
 Gets a pointer to the backing C++ instance.
 
TDataType getOptionalProperty (PropertyType< TDataType > propertyType)
 Returns the current value of a property type, but does not use the default value if there are no inputs to the property value.
 
TDataType getProperty (PropertyType< TDataType > propertyType)
 Returns the current value of a property type.
 
int hashCode ()
 
boolean hasValue (PropertyType< TDataType > propertyType)
 Evaluates whether there are any inputs into the property value.
 
boolean isStale ()
 Test if the object is stale i.e.
 
void removeLocalValue (PropertyType< TDataType > propertyType)
 Removes the local value associated with the property.
 
void setFlagKeepDuringPatching (PropertyType< TDataType > propertyType)
 Sets the flag to indicate that the property was loaded from KZB.
 
void setProperty (PropertyType< TDataType > propertyType, TDataType value)
 Sets the local value of a property type.
 
ObjectRef< TTypetryCreateObjectRef (Class< TType > clazz)
 Tries to create an owning ObjectRef instance to this KanziObject.
 
- Public Attributes inherited from ResourceMetadata
AbstractMetaclass metaclass = new AbstractMetaclass("Kanzi.Resource")
 Metaclass for Resource.
 
- Public Attributes inherited from GPUResourceMetadata
AbstractMetaclass metaclass = new AbstractMetaclass("Kanzi.GPUResource")
 Metaclass for GPUResource.
 
- Public Attributes inherited from MeshMetadata
AbstractMetaclass metaclass = new AbstractMetaclass("Kanzi.Mesh")
 Metaclass for Mesh.
 

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.

Member Function Documentation

◆ create()

static ObjectRef< Mesh > create ( Domain domain,
Mesh.CreateInfo createInfo,
String name )
static

Creates a mesh with specified mesh creation parameters.

To create a mesh, you need a Mesh.CreateInfo structure. When you create a Mesh, Kanzi deploys the primitive vertex and index data to GPU memory.

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

◆ createBox()

static ObjectRef< Mesh > createBox ( Domain domain,
Vector3 size,
long subdivisions,
String name,
Material material )
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 handle for the cluster. If set, leave the materialURL parameter empty.
Returns
Mesh handle.

◆ createIcosphere()

static ObjectRef< Mesh > createIcosphere ( Domain domain,
float radius,
long subdivisions,
String name,
Material material )
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 handle for the cluster.
Returns
Mesh handle.

◆ createPlane()

static ObjectRef< Mesh > createPlane ( Domain domain,
float width,
float height,
long subdivisions,
boolean invertU,
boolean invertV,
String name,
Material material )
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 handle for the cluster. If set, leave the materialURL parameter empty.
Returns
Mesh handle.

◆ createQuadsphere()

static ObjectRef< Mesh > createQuadsphere ( Domain domain,
float radius,
long subdivisions,
String name,
Material material )
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 handle for the cluster.
Returns
Mesh handle.

◆ createSphere()

static ObjectRef< Mesh > createSphere ( Domain domain,
float radius,
long segmentCount,
long rowCount,
String name,
Material material )
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 handle for the cluster.
Returns
Mesh handle.