MD Package Technical & APi Documentation
MDM_MeshEffector :: MD_ModifierBase
Namespace: MDPackage.Modifiers
Deform mesh by the specific weight values & spherical effectors.
Read more here (Online documentation slide)
Properties
// IMDThreading implementation

// Use multithreading feature for this modifier?
public bool ThreadUseMultithreading { get; set; }
// Is multithreading in Unity-editor supported?
public bool ThreadEditorThreadSupported { get; }
// Is a task finished for this thread?
public bool ThreadIsDone { get; }
// Sleep time for a thread in ms
public int ThreadSleep { get; set; }

// Use/ manipulate with effector nodes as gameObjects in the scene?
public bool UseGameObjectsAsWeights { get; set; }
// OnePointed, TwoPointed, ThreePointed, FourPointed
public EffectorType CurrentEffectorType { get; set; }

// Effector node A - raw
public Vector3 WeightNodeA { get; set; }
// Effector node B - raw
public Vector3 WeightNodeB { get; set; }
// Effector node C - raw
public Vector3 WeightNodeC { get; set; }
// Effector node D - raw
public Vector3 WeightNodeD { get; set; }

// Effector node A - as gameObject
public Transform WeightNodeATransform { get; set; }
// Effector node B - as gameObject
public Transform WeightNodeBTransform { get; set; }
// Effector node C - as gameObject
public Transform WeightNodeCTransform { get; set; }
// Effector node D - as gameObject
public Transform WeightNodeDTransform { get; set; }

// Total weight of the modifier
public float Weight { get; set; }
public float WeightMultiplier { get; set; }
public float WeightDensity { get; set; }

// Weight value between nodes A and B
public float WeightEffectorAB { get; set; }
// Weight value between nodes B and C
public float WeightEffectorBC { get; set; }
// Weight value between nodes C and D
public float WeightEffectorCD { get; set; }

// Conditions

public bool ClampEffector { get; set; }
public float ClampVectorValue { get; set; }
public float ClampMin { get; set; }
public float ClampMax { get; set; }
Public Methods
// Update the current mesh state with modified vertices
public void Effector_UpdateMesh()
Examples
The following paragraphs contain Mesh Effector modifier component used in a practical example - deform specific mesh with custom node transform.
using UnityEngine;
using MDPackage.Modifiers;

[RequireComponent(typeof(MeshFilter))]
public class SampleScript : MonoBehaviour
{
// Assign custom node for mesh effector
 [SerializeField] private Transform myNode;

private MDM_MeshEffector effector;

private void Start()
 {
  if (!myNode)
   Debug.LogError("myNode is not assigned!");

  // Add/Create a Mesh Effector modifier to this object right after start
  effector = MD_ModifierBase.CreateModifier<MDM_MeshEffector>(gameObject, MD_ModifierBase.MeshReferenceType.CreateNewReference);
  effector.MbUpdateEveryFrame = true;
  // Set the effector type, assign node and enable clamping (to avoid mesh clippings)
  effector.CurrentEffectorType = MDM_MeshEffector.EffectorType.OnePointed;
  effector.UseGameObjectsAsWeights = true;
  effector.WeightNodeATransform = myNode;
  effector.WeightMultiplier = -1;
  effector.ClampEffector = true;
 }

private void Update()
 {
  // myNode must be assigned
  if (!myNode)
  {
   Debug.LogError("myNode is not assigned!");
   return;
  }

  // Sample extension - if space is pressed, increase the vertex count if possible
  if (Input.GetKeyDown(KeyCode.Space))
   effector.MDModifier_SubdivideMesh();
  // Sample extension - if R is pressed, restore mesh to its original state
  if (Input.GetKeyDown(KeyCode.R))
   effector.MDModifier_RestoreMesh();

  // Sample node position update
  myNode.position = transform.position + new Vector3(Mathf.Sin(Time.time * 0.5f) * 1.5f, 0, Mathf.Cos(Time.time * 0.5f) * 1.5f);
 }
}