struct property

StructType<MeshD> struct
final

Describes the raw memory layout, construction, and pointer representation of this struct type.

Implementation

static final StructType<MeshD> struct = .new(
  factory: MeshD.new,
  layout: .aligned<MeshField>({
    .vertexCount:   RInt(), // Number of vertices stored in arrays
    .triangleCount: RInt(), // Number of triangles stored (indexed or not)

    // Vertex attributes data
    .vertices:      RPointer(RFloat()), // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
    .texcoords:     RPointer(RFloat()), // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
    .texcoords2:    RPointer(RFloat()), // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5)
    .normals:       RPointer(RFloat()), // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
    .tangents:      RPointer(RFloat()), // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
    .colors:        RPointer(RUnsignedChar()), // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
    .indices:       RPointer(RUnsignedShort()), // Vertex indices (in case vertex data comes indexed)

    // Skin data for animation
    .boneCount:     RInt(), // Number of bones (MAX: 256 bones)
    .boneIndices:   RPointer(RUnsignedChar()), // Vertex bone indices, up to 4 bones influence by vertex (skinning) (shader-location = 6)
    .boneWeights:   RPointer(RFloat()), // Vertex bone weight, up to 4 bones influence by vertex (skinning) (shader-location = 7)

    // Runtime animation vertex data (CPU skinning)
    // NOTE: In case of GPU skinning, not used, pointers are NULL
    .animVertices:  RPointer(RFloat()), // Animated vertex positions (after bones transformations)
    .animNormals:   RPointer(RFloat()), // Animated normals (after bones transformations)

    // OpenGL identifiers
    .vaoId:         RUnsignedInt(), // OpenGL Vertex Array Object id
    .vboId:         RPointer(RUnsignedInt()), // OpenGL Vertex Buffer Objects id (default vertex data)
  }),
);