Cut Action

Warning

It’s highly recommended to read the CTD_Deformable and Realtime Cut sections.

Cut action is referring to a specific type of Action that a user has to cut a mesh in a specific position in order to complete it.

For instance, a Cut action can be scripted as follows:

public class CutSkin : CutAction
{
    public override void Initialize()
    {
        SetCutPrefabs("Lesson7/Stage2/Action0/CutSkinConstructorPrefab", "Skin");

        base.Initialize();
    }
}

Note

Notice how the developer defined action inherits from the CutAction base prototype.

Action Script Explanation

  1. SetCutPrefabs(string arg1, string arg2)

This method sets the Action’s cut prefabs that will be spawned on Initialize. To set a Cut Action you need to spawn a Cut Prefab and set its parent. The first argument is the path to the cut prefab while the second argument is the name of the parent object in the scene, which is the object that will be cut.

2. Prefab Constructor To create the correct prefabs you need to set the constructor as follows.

First, there is a ‘Edit Cut Plane Bounds’ button in the Constructor, which allows you to edit the plane (change its position, rotation and scale) on which you want the object to be cut. In the Cut Tools option, you need to add the prefabs of the gameobjects that will be used to cut the selected object. Then in the Cut Victim Name option, you need to add the name of the object in the scene that will be cut. Lastly, you will need to set the Angle Error threshold, which refers to the threshold of the angle that the cutting tool can have in comparison with the plane.

Cut Prefab Constructor”
  1. Finally, the base.Initialize() method needs to be called to set the prefabs on the BasePrototype.

Adding More to it

A more complex example that involves spawning two Cuttable objects, a cutting tool and an extra Cut Constructor is the following:

public override void Initialize()
{
    SpawnCutObject("Lesson7/Stage2/Action0/Skin");
    SpawnCutObject("Lesson7/Stage2/Action0/Fat");
    SetCutPrefabs("Lesson7/Stage2/Action0/CutSkinConstructorPrefab", "Skin(Clone)");
    SetCutPrefabs("Lesson7/Stage2/Action0/CutFatConstructorPrefab", "Fat(Clone)");
    SpawnCuttingTools("Lesson7/Stage2/Action0/CustomCuttingTool");
    base.Initialize();
}