class MAGES::MeshDeformations::CuttableMesh

Overview

Cut framework for skinned and static meshes. More…

class CuttableMesh: public MonoBehaviour
{
public:
    // structs

    struct CutOptions;

    // fields

    bool handleMeshReconstruction = true;
    bool useWithSoftbodies = false;
    CutOptions cutOptions = new CutOptions { partPrefabPath = "LessonPrefabs/LessonX/StageX/ActionX/", autoGenerateColliders = true, seperationDistance = 0.001f, destroyOriginalAfterCut = true };
    UnityEvent onCut = new UnityEvent();
    GameObject negativeGameObjectAfterCut = null;
    GameObject positiveGameObjectAfterCut = null;

    // methods

    bool Cut(
        Plane cutPlane,
        out Mesh positiveSide,
        out Mesh negativeSide,
        out GameObject final
    );

    bool UndoCut();
};

Detailed Documentation

Cut framework for skinned and static meshes.

Fields

bool handleMeshReconstruction = true

If true the new GameObject generation process is handled locally. If false, nothing will be created, the user should handle the output Meshes of the Cut function.

bool useWithSoftbodies = false

Specifies ,when used with a Softbody object, if the connecting spring links of it will be cut.

CutOptions cutOptions = new CutOptions { partPrefabPath = "LessonPrefabs/LessonX/StageX/ActionX/", autoGenerateColliders = true, seperationDistance = 0.001f, destroyOriginalAfterCut = true }

Cut options. These will be overriden when Cut is used with softbody objects.

UnityEvent onCut = new UnityEvent()

Invoked after performing a cut on a mesh.

GameObject negativeGameObjectAfterCut = null

The newly created GameObject, after a cut, on the negative side of the cut plane. Only used if handleMeshReconstruction is enabled.

GameObject positiveGameObjectAfterCut = null

The newly created GameObject, after a cut, on the positive side of the cut plane. Only used if handleMeshReconstruction is enabled.

Methods

bool Cut(
    Plane cutPlane,
    out Mesh positiveSide,
    out Mesh negativeSide,
    out GameObject final
)

Cuts a mesh based on a plane.

Parameters:

cutPlane

The plane to cut across. The plane must be in world space coords.

negativeSide

The generated mesh below the cutPlane

positiveSide

The generated mesh below the cutPlane

bool UndoCut()

Undoes a cut. Only applicable when a cut was performed with the handleMeshReconstruction option enabled.

Returns:

True on successful undo