Mc3Object
A node in the MC3 scene graph. Represents any geometric object, container, or CSG operation.
Header
mc3/include/MeshCraft/Mc3/Mc3Object.hpp
Namespace
MeshCraft::Mc3
ObjectType Enum
The type field determines which optional data fields are populated and how the object is rendered.
| Value | XML element | Active optional field(s) |
|---|---|---|
Box, Cube | <box>, <cube> | primitive |
Sphere | <sphere> | primitive |
Cylinder | <cylinder> | primitive |
Cone | <cone> | primitive |
Plane | <plane> | primitive |
Mesh | <mesh> | meshSource |
Extrude | <extrude> | extrude |
Group | <group> | children |
Instance | <instance> | definition, materialOverride |
Union | <union> | csgOperation, children |
Difference | <difference> | csgOperation, children |
Intersection | <intersection> | csgOperation, children |
Area | <area> | primitive (box extent) |
Public Fields
| Field | Type | Description |
|---|---|---|
type | ObjectType | Determines the object's behavior and which optional fields are active. |
name | string | Human-readable name. Used by animation channels as target. |
id | string | XML ID (unique per document, may be empty if not set). |
transform | Mc3Transform | Local transform: position, rotation (XYZ Euler °), scale, pivot. |
deform | optional<Mc3Deform> | Geometry-level deform scale, applied before the object transform. |
material | string | ID reference into Mc3Document.materials. |
visible | bool | Default: true. |
collision | string | Collision shape hint: "none", "box", "mesh", etc. |
tags | vector<string> | Space-separated tag list. |
primitive | optional<Mc3Primitive> | Shape parameters for primitive types. |
extrude | optional<Mc3Extrude> | Extrude path + cross-section parameters. |
csgOperation | optional<Mc3CsgOperation> | CSG operation type (Union / Difference / Intersection). |
definition | string | For Instance: ID of the definition in Mc3Document.definitions. |
meshSource | string | For Mesh: relative path to the OBJ file. |
materialOverride | string | For Instance: material to use instead of the definition's materials. |
isCutter | bool | Default: false. Set to true for role="cutter" children in <difference>. |
children | vector<shared_ptr<Mc3Object>> | Child nodes (Group, CSG types, etc.). |
Transform Formula
The world matrix for an object, given its local transform and the parent world matrix, is:
localMatrix = T(position + pivot) × R(rotation) × S(scale) × T(-pivot)
worldMatrix = parentWorld × localMatrix
This ensures the pivot is the rotation/scale center. The pivot is specified in local space.
Ownership
Objects are owned by shared_ptr. The scene graph's roots are stored in Mc3Document.objects. Children are stored in Mc3Object.children. Definitions are stored in Mc3Document.definitions.
The SelectionManager holds non-owning copies of shared_ptrs. This means deleting an object from the document while it is selected will leave a dangling shared_ptr in the selection — the application must clear the selection when modifying the object list.