class MAGES::MeshDeformations::SpringMassSoftbody

Overview

class SpringMassSoftbody: public MonoBehaviour
{
public:
    // fields

    Dictionary> TearActionDisconnectedParticles = new Dictionary>();
    string eventTrigger = "";
    bool particleFoldoutState = true;
    bool springFoldoutState = true;
    bool skinningFoldoutState = true;
    bool springConnectionGizmos = false;

    // properties

    float ParticleScale;
    float ParticleDistance;
    float ParticleConnectionDistance;
    float ParticleMass;
    bool UseParticleGravity;
    bool ParticleSelfCollisions;
    bool AdjustParticlesOnMesh;
    float Stiffness;
    float Damper;
    float Plasticity;
    float MaxDeformationDistance;
    float MaxWeightAffectionDistance;
    AnimationCurve WeightCurve;
    int MaxBonesPerVertex;
    List Particles;
    Transform ParticleParentTransform;
    Rigidbody CenterRigidbody;
    int VertexCount;
    Mesh SoftbodyMesh;
    SkinnedMeshRenderer SoftbodySkinnedMeshRenderer;
    bool IsInitialized;
    bool IsStatic;

    // methods

    bool Initialize();
    bool Destroy();
    void EnableSimulation(bool enabled = true);
    bool CreateParticle(in Vector3 worldPosition);
    void UndoTearActionDestroyedConnections(string eventTrigger);

    bool TearSoftbody(
        TriangularMesh deformableMesh,
        int newVerticesCount,
        in UtilitiesHelper.Hexahedron tearBox,
        in IEnumerable newParticlesAtVertices
    );

    bool CutSoftbody(in Plane cutPlane);
    void Start();
    void Update();
    void LateUpdate();
};

Detailed Documentation

Properties

Mesh SoftbodyMesh

The new created Mesh from the softbody script.

SkinnedMeshRenderer SoftbodySkinnedMeshRenderer

The new created skinned mesh renderer from the softbody script.

Methods

bool Initialize()

Initializes the softbody.

Returns:

True on successful initialization

bool Destroy()

Destroys Softbody and Restores oject to the original.

Returns:

True on success

void EnableSimulation(bool enabled = true)

Enables/Disables softbody simulation.

Parameters:

enabled

bool CreateParticle(in Vector3 worldPosition)

Creates a particle at the specified position (fast for runtime)

Parameters:

worldPosition

The world position to spawn the particle at

Returns:

bool TearSoftbody(
    TriangularMesh deformableMesh,
    int newVerticesCount,
    in UtilitiesHelper.Hexahedron tearBox,
    in IEnumerable newParticlesAtVertices
)

Tears a softbody.

Parameters:

deformableMesh

The deformable mesh associated with the tear

tearBox

The world space tearbox

newParticlesAtVertices

The vertex indices at which to create new particles

Returns:

True on success

bool CutSoftbody(in Plane cutPlane)

Cuts a softbody.

Returns: