Namespace: MDPackage.Modifiers
A lite version of a complete sculpting solution for mesh renderers in Unity editor / at runtime.
Visit
link for pro version.
Read more here (Online documentation slide)
Properties
public bool ThreadUseMultithreading { get; set; }
public bool ThreadEditorThreadSupported { get; }
public bool ThreadIsDone { get; }
public int ThreadSleep { get; set; }
public bool IsMobilePlatform { get; set; }
public bool IsVRPlatform { get; set; }
public bool RecalculateNormalsOnRelease { get; set; }
public bool RecalculateMeshColliderOnRelease { get; set; }
public bool RecordHistory { get; set; }
public int MaxHistoryRecords { get; set; }
public List<HistoryRecords> SculptingHistoryRecords { get; }
public bool UseBrushProjection { get; set; }
public GameObject BrushProjection { get; set; }
public float BrushSize { get; set; }
public float BrushIntensity { get; set; }
public BrushStatus BrushStatusOverride { get; set; }
public SculptingMode CurrentSculptingMode { get; set; }
public CustomDirObjDirection DirectionTowardsObjectType { get; set; }
public GameObject CustomDirectionObjectRef { get; set; }
public Vector3 CustomSculptingDirection { get; set; }
public bool UseHeightLimitations { get; set; }
public Vector2 HeightLimitations { get; set; }
public bool UseDistanceLimitations { get; set; }
public float DistanceLimitations { get; set; }
public InterpolationType CurrentInterpolationType { get; set; }
public bool UseInputHookups { get; set; }
public bool UseInputFeature_Raise { get; set; }
public bool UseInputFeature_Lower { get; set; }
public bool UseInputFeature_Revert { get; set; }
public bool UseInputFeature_Noise { get; set; }
public NoiseTypes CurrentNoiseType { get; set; }
public bool UseInputFeature_Smooth { get; set; }
public SmoothingType CurrentSmoothingType { get; set; }
public float SmoothingFilterLaplacianIntensity { get; set; }
public bool UseInputFeature_Stylize { get; set; }
public float StylizeIntensity { get; set; }
public Vector3 InputHook_CursorScreenPosition { get; set; }
public bool InputHook_Lower { get; set; }
public bool InputHook_Raise { get; set; }
public bool InputHook_Revert { get; set; }
public bool InputHook_Noise { get; set; }
public bool InputHook_Smooth { get; set; }
public bool InputHook_Stylize { get; set; }
public bool InputHook_GenericNonPCButton { get; set; }
public LayerMask CurrentSculptingLayerMask { get; set; }
public bool SculptingOriginIsCursor { get; set; }
public Transform SculptingOriginObject { get; set; }
public Camera MainCameraCache { get; set; }
Public Methods
public void Sculpting_DoSculpting(Vector3 worldPosition, Vector3 directionLocal, float radius, float intensity, BrushStatus brushState)
public void Sculpting_RefreshMeshCollider()
public void Sculpting_RecordControlUp()
public void Sculpting_RecordControlDown()
public void Sculpting_RecordHistory()
public void Sculpting_Undo(int jumpToRecordIndex)
public void Sculpting_Undo()
public void Sculpting_ChangeBrushStatus(int stateIndex)
public void Sculpting_ChangeSculptingMode(int modeIndex)
Examples
The following paragraphs contain SculptingLite modifier used in a practical example - create a sculpting editor at runtime.
Hence the custom input handling. You can adapt your own input system.
using UnityEngine;
using MDPackage.Modifiers;
[RequireComponent(typeof(MeshFilter))]
public class SampleScript : MonoBehaviour
{
private MDM_SculptingLite sculpting;
private void Start()
{
sculpting = gameObject.AddComponent<MDM_SculptingLite>();
sculpting.MbUseNormalSmoothingAngle = true;
sculpting.Sculpting_RefreshMeshCollider();
sculpting.UseInputHookups = true;
sculpting.UseInputFeature_Raise = true;
sculpting.UseInputFeature_Lower = true;
sculpting.UseInputFeature_Revert = true;
sculpting.BrushIntensity = 0.5f;
sculpting.BrushSize = 1f;
}
private void Update()
{
if (sculpting == null)
return;
sculpting.InputHook_CursorScreenPosition = Input.mousePosition;
sculpting.InputHook_Raise = Input.GetKey(KeyCode.Mouse0);
sculpting.InputHook_Lower = Input.GetKey(KeyCode.Mouse1);
sculpting.InputHook_Revert = Input.GetKey(KeyCode.Mouse2);
}
}
The following paragraphs contain SculptingLite modifier used in a practical example - create a custom sculpting raycast at runtime.
using UnityEngine;
using MDPackage.Modifiers;
[RequireComponent(typeof(MeshFilter))]
public class SampleScript : MonoBehaviour
{
private MDM_SculptingLite sculpting;
[SerializeField] private Camera mainCam;
[Space]
[SerializeField, Min(0)] private float brushSize = 0.35f;
[SerializeField] private float brushIntensity = 0.1f;
private void Start()
{
sculpting = gameObject.AddComponent<MDM_SculptingLite>();
sculpting.UseInputHookups = false;
sculpting.Sculpting_RefreshMeshCollider();
}
private void Update()
{
if (sculpting == null || mainCam == null)
return;
Ray r = mainCam.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(r, out RaycastHit h, 1000))
{
if (h.collider && h.collider.gameObject == sculpting.gameObject)
{
MDM_SculptingLite.BrushStatus status = MDM_SculptingLite.BrushStatus.None;
if (Input.GetMouseButton(0))
status = MDM_SculptingLite.BrushStatus.Raise;
else if (Input.GetMouseButton(1))
status = MDM_SculptingLite.BrushStatus.Lower;
if (status == MDM_SculptingLite.BrushStatus.None)
sculpting.Sculpting_RecordControlUp();
else
sculpting.Sculpting_RecordControlDown();
sculpting.Sculpting_DoSculpting(h.point, h.normal, brushSize, -brushIntensity, status);
}
else
sculpting.Sculpting_RecordControlUp();
}
else
sculpting.Sculpting_RecordControlUp();
}
}