Namespace: MDPackage.Modifiers
A lite version of a complete sculpting solution for mesh renderers in Unity editor / at runtime.
Visit
link for pro version.
The input is not handled by default, as the Unity Engine has many options for handling input and controls in general.
MD-Package components that contain some input features consist of 'Input Hookup' properties that handle the input in a generic way.
You can set these properties from your own input system. The component will display more information about the input setup, so please follow up on this information.
You can find all the input-hookup properties below.
Read more here (Online documentation slide)
Public Methods
public void Sculpting_DoSculpting(Vector3 worldPosition, Vector3 directionLocal, float radius, float intensity, BrushStatus brushState)
public void Sculpting_SetupEssentials(float radius, float intensity, bool showBrush, Vector3 brushPosition, Vector3 brushRotationDirection, BrushStatus status, SculptingMode mode)
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_RefreshMeshCollider()
public void Sculpting_ChangeBrushSize(float size)
public void Sculpting_ChangeBrushIntensity(float strength)
public void Sculpting_ChangeStylizeIntensity(float intens)
public void Sculpting_ChangeSmoothIntensity(int intens)
public void Sculpting_ChangeBrushStatus(int StateIndex)
Public Fields and Properties
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 bool sculptingMobileSupport = false;
public bool sculptingRecalculateNormalsOnRelease = true;
public bool sculptingUpdateColliderAfterRelease = true;
public bool sculptingUseBrushProjection = true;
public GameObject sculptingBrushProjection;
public bool sculptingBrushProjectionAutomaticallyCreated = false;
public float sculptingBrushSize = 0.5f;
public float sculptingBrushIntensity = 0.05f;
public BrushStatus sculptingBrushStatus = BrushStatus.None;
public SculptingMode sculptingMode = SculptingMode.BrushDirection;
public Vector3 sculptingCustomDirection;
public bool sculptingEnableHeightLimitations = false;
public Vector2 sculptingHeightLimitations;
public bool sculptingEnableDistanceLimitations = false;
public float sculptingDistanceLimitation = 1.0f;
public CustomDirObjDirection sculptingCustomDirObjDirection;
public GameObject sculptingCustomDirectionObject;
public InterpolationType sculptingInterpolationType = InterpolationType.Exponential;
public bool sculptingUseInput = true;
public bool sculptingVRInput = false;
public bool sculptingUseRaiseFunct = true;
public bool sculptingUseLowerFunct = true;
public bool sculptingUseRevertFunct = false;
public bool sculptingUseNoiseFunct = false;
public bool sculptingUseSmoothFunct = false;
public bool sculptingUseStylizeFunct = false;
public NoiseTypes sculptingNoiseTypes = NoiseTypes.XYZ;
[Range(0.01f,0.99f)]
public float sculptingStylizeIntensity = 0.65f;
[Range(0.01f, 1f)]
public float sculptingSmoothIntensity = 0.5f;
public SmoothingType sculptingSmoothingType = SmoothingType.HcFilter;
public Camera sculptingCameraCache;
public bool sculptingFromCursor = true;
public Transform sculptingOriginTransform;
public LayerMask sculptingLayerMask = ~0;
public bool sculptingRecordHistory = false;
public List<HistoryRecords> SculptingHistoryRecords { get; }
public int SculptingMaxHistoryRecords { get; set; }
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.useNormalSmoothingAngle = true;
sculpting.Sculpting_RefreshMeshCollider();
sculpting.sculptingUseInput = true;
sculpting.sculptingUseRaiseFunct = true;
sculpting.sculptingUseLowerFunct = true;
sculpting.sculptingUseRevertFunct = true;
sculpting.sculptingBrushIntensity = 0.5f;
sculpting.sculptingBrushSize = 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;
public Camera mainCam;
[Space]
public float brushSize = 0.35f;
public float brushIntensity = 0.1f;
private void Start()
{
sculpting = gameObject.AddComponent<MDM_SculptingLite>();
sculpting.sculptingUseInput = 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();
}
}