Skip to content

EntropyCanvas::MeshData

Mesh geometry data suitable for rendering. More…

#include <MeshData.h>

Name
structVec4
4D vector for tangents (xyz = tangent, w = handedness)
structVec3
3D vector
structVec2
2D vector for UVs
Name
size_tvertexCount() const
Get vertex count.
size_ttriangleCount() const
Get triangle count.
MeshDatasphere(float radius =0.5f, uint32_t segments =32, uint32_t rings =16)
Create a UV sphere.
VertexTierrequiredTier() const
Determine the minimum vertex tier required for this mesh.
MeshDataplane(float width =1.0f, float depth =1.0f, uint32_t subdivisionsX =1, uint32_t subdivisionsZ =1)
Create a plane on the XZ plane.
boolisValid() const
Check if mesh has valid geometry.
boolhasUVs() const
Check if mesh has UVs.
boolhasTangents() const
Check if mesh has tangents.
boolhasNormals() const
Check if mesh has normals.
boolhasExtendedUVs() const
Check if mesh has extended UV channels (uv2 or uv3).
boolhasExtendedData() const
Check if mesh requires Extended tier data.
boolhasColors() const
Check if mesh has vertex colors.
MeshDatacylinder(float radius =0.5f, float height =1.0f, uint32_t segments =32)
Create a cylinder along the Y axis.
MeshDatacone(float radius =0.5f, float height =1.0f, uint32_t segments =32)
Create a cone along the Y axis.
AssetIdcomputeAssetId() const
Compute content-addressed AssetId for this mesh.
MeshDatabox(float size =1.0f)
Create a unit box centered at origin.
MeshDatabox(float width, float height, float depth)
Create a box with custom dimensions.
Name
std::vector< Vec2 >uv3
Quaternary UV coordinates (Extended tier, packed with uv2).
std::vector< Vec2 >uv2
Tertiary UV coordinates (Extended tier, packed with uv3).
std::vector< Vec2 >uv1
Secondary UV coordinates (Basic tier, packed with uv0).
std::vector< Vec2 >uv0
Primary UV coordinates.
std::vector< Vec4 >tangents
Tangent vectors (Tangent tier, xyz = tangent, w = handedness).
std::stringprimPath
Prim path in USD scene hierarchy (if from USD).
std::vector< Vec3 >positions
Vertex positions.
std::vector< Vec3 >normals
Vertex normals (may be per-vertex or per-face-vertex, indexed same as positions).
std::stringname
Display name.
std::vector< uint32_t >indices
Triangle indices (always 32-bit).
std::vector< Vec4 >colors
Vertex colors (RGBA, Extended tier).
Vec3boundsMin
Axis-aligned bounding box minimum.
Vec3boundsMax
Axis-aligned bounding box maximum.
struct EntropyCanvas::MeshData;

Mesh geometry data suitable for rendering.

This structure holds mesh geometry data in a format ready for GPU upload. The data is pre-triangulated and includes positions, normals, UVs, and indices.

Vertex data is organized into tiers for efficient GPU buffer allocation:

  • Basic tier: positions, normals, uv0, uv1 (40 bytes/vertex)
  • Tangent tier: adds tangents (16 bytes/vertex)
  • Extended tier: adds uv2, uv3, colors (32 bytes/vertex)

Coordinate system follows USD conventions (Y-up, right-handed). Clients may need to transform for their rendering API.

Usage: auto result = UsdMeshExtractor::extract(stagePtr); for (const auto& mesh : result.meshes) { VertexTier tier = mesh.requiredTier(); // Create GPU mesh with appropriate vertex buffers }

inline size_t vertexCount() const

Get vertex count.

inline size_t triangleCount() const

Get triangle count.

static MeshData sphere(
float radius =0.5f,
uint32_t segments =32,
uint32_t rings =16
)

Create a UV sphere.

Parameters:

  • radius Sphere radius (default 0.5)
  • segments Horizontal segments (default 32)
  • rings Vertical rings (default 16)

Return: MeshData for the sphere

inline VertexTier requiredTier() const

Determine the minimum vertex tier required for this mesh.

Examines which vertex attributes are populated and returns the minimum tier needed to represent all data:

  • Extended if uv2, uv3, or colors are present
  • Tangent if tangents are present
  • Basic otherwise
static MeshData plane(
float width =1.0f,
float depth =1.0f,
uint32_t subdivisionsX =1,
uint32_t subdivisionsZ =1
)

Create a plane on the XZ plane.

Parameters:

  • width X dimension (default 1)
  • depth Z dimension (default 1)
  • subdivisionsX X subdivisions (default 1)
  • subdivisionsZ Z subdivisions (default 1)

Return: MeshData for the plane

inline bool isValid() const

Check if mesh has valid geometry.

inline bool hasUVs() const

Check if mesh has UVs.

inline bool hasTangents() const

Check if mesh has tangents.

inline bool hasNormals() const

Check if mesh has normals.

inline bool hasExtendedUVs() const

Check if mesh has extended UV channels (uv2 or uv3).

inline bool hasExtendedData() const

Check if mesh requires Extended tier data.

inline bool hasColors() const

Check if mesh has vertex colors.

static MeshData cylinder(
float radius =0.5f,
float height =1.0f,
uint32_t segments =32
)

Create a cylinder along the Y axis.

Parameters:

  • radius Cylinder radius (default 0.5)
  • height Cylinder height (default 1)
  • segments Radial segments (default 32)

Return: MeshData for the cylinder

static MeshData cone(
float radius =0.5f,
float height =1.0f,
uint32_t segments =32
)

Create a cone along the Y axis.

Parameters:

  • radius Base radius (default 0.5)
  • height Cone height (default 1)
  • segments Radial segments (default 32)

Return: MeshData for the cone

AssetId computeAssetId() const

Compute content-addressed AssetId for this mesh.

Return: Content-addressed AssetId for this mesh

Computes a SHA-256 hash of the mesh geometry data to produce a deterministic, content-addressed identifier. Same geometry always produces the same AssetId.

The hash includes:

  • name
  • positions, normals, uv0-uv3, tangents, colors
  • indices
  • bounds
static MeshData box(
float size =1.0f
)

Create a unit box centered at origin.

Parameters:

  • size Box dimensions (default 1x1x1)

Return: MeshData for the box

static MeshData box(
float width,
float height,
float depth
)

Create a box with custom dimensions.

Parameters:

  • width X dimension
  • height Y dimension
  • depth Z dimension

Return: MeshData for the box

std::vector< Vec2 > uv3;

Quaternary UV coordinates (Extended tier, packed with uv2).

std::vector< Vec2 > uv2;

Tertiary UV coordinates (Extended tier, packed with uv3).

std::vector< Vec2 > uv1;

Secondary UV coordinates (Basic tier, packed with uv0).

std::vector< Vec2 > uv0;

Primary UV coordinates.

std::vector< Vec4 > tangents;

Tangent vectors (Tangent tier, xyz = tangent, w = handedness).

std::string primPath;

Prim path in USD scene hierarchy (if from USD).

std::vector< Vec3 > positions;

Vertex positions.

std::vector< Vec3 > normals;

Vertex normals (may be per-vertex or per-face-vertex, indexed same as positions).

std::string name;

Display name.

std::vector< uint32_t > indices;

Triangle indices (always 32-bit).

std::vector< Vec4 > colors;

Vertex colors (RGBA, Extended tier).

Vec3 boundsMin {1e38f, 1e38f, 1e38f};

Axis-aligned bounding box minimum.

Vec3 boundsMax {-1e38f, -1e38f, -1e38f};

Axis-aligned bounding box maximum.


Updated on 2026-01-26 at 16:50:32 -0500