Namespace: MDPackage.Modifiers
Deform mesh by the specific weight values & sphere-based effector attributes.
Read more here (Online documentation slide)
Public Methods
public void Effector_UpdateMesh()
Public Fields and Properties
public EffectorType effectorType = EffectorType.OnePointed;
public Transform weightNode0;
public Transform weightNode1;
public Transform weightNode2;
public Transform weightNode3;
[Range(0.0f, 1.0f)] public float weight = 0.5f;
public float weightMultiplier = 1.0f;
public float weightDensity = 3.0f;
[Range(0.0f, 1.0f)] public float weightEffectorA = 0.5f;
[Range(0.0f, 1.0f)] public float weightEffectorB = 0.5f;
[Range(0.0f, 1.0f)] public float weightEffectorC = 0.5f;
public bool clampEffector = false;
public float clampVectorValue = 1.0f;
public float minClamp = -5.0f;
public float maxClamp = 5.0f;
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
{
public Transform myNode;
private MDM_MeshEffector effector;
private void Start()
{
if (!myNode)
Debug.LogError("myNode is not assigned!");
effector = MD_ModifierBase.CreateModifier<MDM_MeshEffector>(gameObject, MD_ModifierBase.MeshReferenceType.CreateNewReference);
effector.effectorType = MDM_MeshEffector.EffectorType.OnePointed;
effector.weightNode0 = myNode;
effector.weightMultiplier = -1;
effector.clampEffector = true;
}
private void Update()
{
if (!myNode)
{
Debug.LogError("myNode is not assigned!");
return;
}
if (Input.GetKeyDown(KeyCode.Space))
effector.MDModifier_SubdivideMesh();
if (Input.GetKeyDown(KeyCode.R))
effector.MDModifier_RestoreMesh();
myNode.position = transform.position + new Vector3(Mathf.Sin(Time.time * 0.5f) * 1.5f, 0, Mathf.Cos(Time.time * 0.5f) * 1.5f);
}
}