Kanzi 4.1.0
kanzi::MeshVertexAttribute Class Reference

MeshVertexAttribute describes how Kanzi stores mesh vertex and instance data in memory, and (in CreateInfo context) carries the source data for the attribute. More...

#include <kanzi/core.ui/graphics3d/graphics_enums.hpp>

Inheritance diagram for kanzi::MeshVertexAttribute:
[legend]

Public Member Functions

 MeshVertexAttribute ()
 Constructor.
 
 MeshVertexAttribute (string_view name, Semantic semantic, unsigned int semanticIndex, gfx::Format format, unsigned int offset)
 Constructor.
 
- Public Member Functions inherited from kanzi::VertexAttribute
 VertexAttribute ()=default
 Constructor.
 
 VertexAttribute (string_view name, Semantic semantic, unsigned int semanticIndex)
 Constructor.
 

Public Attributes

gfx::BufferHandleGuard bufferHandle
 Optional pre-created buffer handle to reuse instead of allocating a new buffer.
 
unsigned int divisor
 Attribute divisor.
 
gfx::Format format
 Attribute format.
 
vector< byte > initialData
 Source data for this attribute.
 
unsigned int offset
 Attribute offset within its binding.
 
- Public Attributes inherited from kanzi::VertexAttribute
string name
 Name of the attribute. Not currently used.
 
SemanticKey semanticKey
 

Friends

bool operator!= (const MeshVertexAttribute &attribute1, const MeshVertexAttribute &attribute2)
 
bool operator== (const MeshVertexAttribute &attribute1, const MeshVertexAttribute &attribute2)
 Compares the attribute specification.
 
void swap (MeshVertexAttribute &attribute1, MeshVertexAttribute &attribute2)
 

Additional Inherited Members

- Public Types inherited from kanzi::VertexAttribute
enum  Semantic {
  SemanticPosition , SemanticNormal , SemanticTangent , SemanticTextureCoordinate ,
  SemanticColor , SemanticWeight , SemanticMatrixPalette , SemanticBitangent ,
  SemanticCount , SemanticCustom , SemanticInvalid
}
 Specifies the available vertex attributes. More...
 

Detailed Description

MeshVertexAttribute describes how Kanzi stores mesh vertex and instance data in memory, and (in CreateInfo context) carries the source data for the attribute.

Since MeshVertexAttribute is derived from VertexAttribute, it has a name, a semantic, and a semantic index. Each mesh attribute also has:

  • Format
  • Offset (within its binding)
  • Divisor (0 for vertex attributes, >0 for instance attributes)
  • Initial data (optional source bytes, consumed during Mesh::create())
  • Buffer handle (optional pre-created buffer to reuse)

The per-attribute stride is derived from the format at use-site via gfx::getPixelStride(format).

Instance attributes are similar to vertex attributes, but have a divisor set to a non-zero value, and are shared by all vertices of an instance. The divisor value indicates how many instances share the same attribute values. Value 1 means that every instance gets a new value. Value 2 means that two instances share the values and every other instance gets new values, and so on.

Constructor & Destructor Documentation

◆ MeshVertexAttribute() [1/2]

kanzi::MeshVertexAttribute::MeshVertexAttribute ( )
inlineexplicit

Constructor.

◆ MeshVertexAttribute() [2/2]

kanzi::MeshVertexAttribute::MeshVertexAttribute ( string_view name,
Semantic semantic,
unsigned int semanticIndex,
gfx::Format format,
unsigned int offset )
inlineexplicit

Constructor.

Parameters
nameName of vertex attribute.
semanticSemantic of vertex attribute.
semanticIndexSemantic index of vertex attribute.
formatFormat of vertex attribute.
offsetOffset of vertex attribute.
Since
Kanzi 4.1.0 changed from (dataType, dimension) to gfx::Format.

Friends And Related Symbol Documentation

◆ swap

void swap ( MeshVertexAttribute & attribute1,
MeshVertexAttribute & attribute2 )
friend

◆ operator==

bool operator== ( const MeshVertexAttribute & attribute1,
const MeshVertexAttribute & attribute2 )
friend

Compares the attribute specification.

Does not compare initialData or bufferHandle — those are transient source fields and are not part of attribute identity.

◆ operator!=

bool operator!= ( const MeshVertexAttribute & attribute1,
const MeshVertexAttribute & attribute2 )
friend

Member Data Documentation

◆ format

gfx::Format kanzi::MeshVertexAttribute::format

Attribute format.

Since
Kanzi 4.1.0

◆ offset

unsigned int kanzi::MeshVertexAttribute::offset

Attribute offset within its binding.

Always 0u for vertex attributes (each attribute owns its own de-interleaved buffer); meaningful only for interleaved instance attributes.

◆ divisor

unsigned int kanzi::MeshVertexAttribute::divisor

Attribute divisor.

Value 0 for vertex attributes, 1+ for instance attributes.

Since
Kanzi 3.9.6

◆ initialData

vector<byte> kanzi::MeshVertexAttribute::initialData

Source data for this attribute.

Size must not exceed vertexCount * gfx::getPixelStride(format). A smaller size is a partial upload — the remaining bytes can be written later via Mesh::setVertexSubData. An empty vector creates the buffer with no initial upload. Consumed by Mesh::create(); when memoryType != GpuOnly, retained on the Mesh and returned by Mesh::getVertexData(SemanticKey).

Since
Kanzi 4.1.0

◆ bufferHandle

gfx::BufferHandleGuard kanzi::MeshVertexAttribute::bufferHandle

Optional pre-created buffer handle to reuse instead of allocating a new buffer.

Since
Kanzi 4.1.0

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