EntropyCanvas::MeshData
EntropyCanvas::MeshData
Section titled “EntropyCanvas::MeshData”Mesh geometry data suitable for rendering. More…
#include <MeshData.h>
Public Classes
Section titled “Public Classes”| Name | |
|---|---|
| struct | Vec4 4D vector for tangents (xyz = tangent, w = handedness) |
| struct | Vec3 3D vector |
| struct | Vec2 2D vector for UVs |
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| size_t | vertexCount() const Get vertex count. |
| size_t | triangleCount() const Get triangle count. |
| MeshData | sphere(float radius =0.5f, uint32_t segments =32, uint32_t rings =16) Create a UV sphere. |
| VertexTier | requiredTier() const Determine the minimum vertex tier required for this mesh. |
| 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. |
| bool | isValid() const Check if mesh has valid geometry. |
| bool | hasUVs() const Check if mesh has UVs. |
| bool | hasTangents() const Check if mesh has tangents. |
| bool | hasNormals() const Check if mesh has normals. |
| bool | hasExtendedUVs() const Check if mesh has extended UV channels (uv2 or uv3). |
| bool | hasExtendedData() const Check if mesh requires Extended tier data. |
| bool | hasColors() const Check if mesh has vertex colors. |
| MeshData | cylinder(float radius =0.5f, float height =1.0f, uint32_t segments =32) Create a cylinder along the Y axis. |
| MeshData | cone(float radius =0.5f, float height =1.0f, uint32_t segments =32) Create a cone along the Y axis. |
| AssetId | computeAssetId() const Compute content-addressed AssetId for this mesh. |
| MeshData | box(float size =1.0f) Create a unit box centered at origin. |
| MeshData | box(float width, float height, float depth) Create a box with custom dimensions. |
Public Attributes
Section titled “Public Attributes”| 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::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 Axis-aligned bounding box minimum. |
| Vec3 | boundsMax Axis-aligned bounding box maximum. |
Detailed Description
Section titled “Detailed Description”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 }
Public Functions Documentation
Section titled “Public Functions Documentation”function vertexCount
Section titled “function vertexCount”inline size_t vertexCount() constGet vertex count.
function triangleCount
Section titled “function triangleCount”inline size_t triangleCount() constGet triangle count.
function sphere
Section titled “function sphere”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
function requiredTier
Section titled “function requiredTier”inline VertexTier requiredTier() constDetermine 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
function plane
Section titled “function plane”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
function isValid
Section titled “function isValid”inline bool isValid() constCheck if mesh has valid geometry.
function hasUVs
Section titled “function hasUVs”inline bool hasUVs() constCheck if mesh has UVs.
function hasTangents
Section titled “function hasTangents”inline bool hasTangents() constCheck if mesh has tangents.
function hasNormals
Section titled “function hasNormals”inline bool hasNormals() constCheck if mesh has normals.
function hasExtendedUVs
Section titled “function hasExtendedUVs”inline bool hasExtendedUVs() constCheck if mesh has extended UV channels (uv2 or uv3).
function hasExtendedData
Section titled “function hasExtendedData”inline bool hasExtendedData() constCheck if mesh requires Extended tier data.
function hasColors
Section titled “function hasColors”inline bool hasColors() constCheck if mesh has vertex colors.
function cylinder
Section titled “function cylinder”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
function cone
Section titled “function cone”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
function computeAssetId
Section titled “function computeAssetId”AssetId computeAssetId() constCompute 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
function box
Section titled “function box”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
function box
Section titled “function 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
Public Attributes Documentation
Section titled “Public Attributes Documentation”variable uv3
Section titled “variable uv3”std::vector< Vec2 > uv3;Quaternary UV coordinates (Extended tier, packed with uv2).
variable uv2
Section titled “variable uv2”std::vector< Vec2 > uv2;Tertiary UV coordinates (Extended tier, packed with uv3).
variable uv1
Section titled “variable uv1”std::vector< Vec2 > uv1;Secondary UV coordinates (Basic tier, packed with uv0).
variable uv0
Section titled “variable uv0”std::vector< Vec2 > uv0;Primary UV coordinates.
variable tangents
Section titled “variable tangents”std::vector< Vec4 > tangents;Tangent vectors (Tangent tier, xyz = tangent, w = handedness).
variable primPath
Section titled “variable primPath”std::string primPath;Prim path in USD scene hierarchy (if from USD).
variable positions
Section titled “variable positions”std::vector< Vec3 > positions;Vertex positions.
variable normals
Section titled “variable normals”std::vector< Vec3 > normals;Vertex normals (may be per-vertex or per-face-vertex, indexed same as positions).
variable name
Section titled “variable name”std::string name;Display name.
variable indices
Section titled “variable indices”std::vector< uint32_t > indices;Triangle indices (always 32-bit).
variable colors
Section titled “variable colors”std::vector< Vec4 > colors;Vertex colors (RGBA, Extended tier).
variable boundsMin
Section titled “variable boundsMin”Vec3 boundsMin {1e38f, 1e38f, 1e38f};Axis-aligned bounding box minimum.
variable boundsMax
Section titled “variable boundsMax”Vec3 boundsMax {-1e38f, -1e38f, -1e38f};Axis-aligned bounding box maximum.
Updated on 2026-01-26 at 16:50:32 -0500