Docs/Classes/Mc3Object

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.

ValueXML elementActive 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

FieldTypeDescription
typeObjectTypeDetermines the object's behavior and which optional fields are active.
namestringHuman-readable name. Used by animation channels as target.
idstringXML ID (unique per document, may be empty if not set).
transformMc3TransformLocal transform: position, rotation (XYZ Euler °), scale, pivot.
deformoptional<Mc3Deform>Geometry-level deform scale, applied before the object transform.
materialstringID reference into Mc3Document.materials.
visibleboolDefault: true.
collisionstringCollision shape hint: "none", "box", "mesh", etc.
tagsvector<string>Space-separated tag list.
primitiveoptional<Mc3Primitive>Shape parameters for primitive types.
extrudeoptional<Mc3Extrude>Extrude path + cross-section parameters.
csgOperationoptional<Mc3CsgOperation>CSG operation type (Union / Difference / Intersection).
definitionstringFor Instance: ID of the definition in Mc3Document.definitions.
meshSourcestringFor Mesh: relative path to the OBJ file.
materialOverridestringFor Instance: material to use instead of the definition's materials.
isCutterboolDefault: false. Set to true for role="cutter" children in <difference>.
childrenvector<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.