MD Package Technical & APi Documentation
MD_Utilities
Namespace: MDPackage.Utilities
MD(MeshDeformation) utilities - extended library related to meshes, transformations and 3D math.
Public Static Methods
// Specific utilities that extends the MD Package
public static class Specific
{
// Restrict gameObject from other types. This will prevent the gameObject from adding specific types
public static bool RestrictFromOtherTypes(GameObject sender, Type focusedType, Type[] restrictedTypes, bool includeSelfType = true, bool checkForBaseClass = true)
// Prepare specific modifier for further use in the MD Package
public static bool PrepareMeshDeformationModifier(MD_ModifierBase sender, MeshFilter senderFilter, Type[] restrictedTypes, bool checkVertexCountLimit = true, MD_ModifierBase.MeshReferenceType meshReferenceType = MD_ModifierBase.MeshReferenceType.GetFromPreferences)
// Check vertex count limit. If the limitation is over the required level, the window/ debug will popout
public static bool CheckVertexCountLimit(int inputVertexCount, GameObject sender = null)
// Create a brand new mesh reference - instantiates an entry mesh
public static Mesh CreateNewMeshReference(Mesh entryMesh)
// Create a brand new mesh reference, does some additional work (if shared mesh exists) - Safer way
public static void CreateNewMeshReference(MeshFilter entryMeshFilter)
// Returns a proper pipeline default shader (URP/HDRP/BuiltIn)
public static Shader GetProperPipelineDefaultShader()
}

// Mesh smoothing - Laplacian filter method
public static class VertexSmoothingLaplacianFilter
{
// Returns smooth calculation of Laplacian method (Calculates entire mesh)
public static Mesh LaplacianFilter(Mesh mesh, float intensity, bool recalculateNormals = true)
// Returns smooth calculation of Laplacian method (Calculates the given vertices)
public static Vector3[] LaplacianFilter(Vector3[] vertices, int[] triangles, float intensity)
// Returns smooth calculation of Laplacian method (Calculates the given vertices) specifically for sculpting
public static Vector3[] LaplacianFilter(Vector3[] vertices, int[] triangles, float intensity, MDM_SculptingLite.SculptingBrushData sculptingAttributes)
}

// Mesh smoothing - Humphrey's filter method
public static class VertexSmoothingHCFilter
{
// Returns smooth calculation of HC Filter method (Calculates the given vertices) specifically for sculpting
public static Vector3[] HCFilter(Vector3[] inVerts, int[] inTris, MDM_SculptingLite.SculptingBrushData sculptingAttributes, float alpha = 0.8f, float beta = 0.94f)
// Returns smooth calculation of HC Filter method
public static Vector3[] HCFilter(Vector3[] inVerts, int[] inTris, float alpha = 0.8f, float beta = 0.94f)
}

// Mesh subdivision - mesh vertex population
public static class MeshSubdivision
{
// Subdivide specific mesh by specific level; Subdivision levels = 2, 3, 4, 6, 8, 9, 12, 16, 18, 24.
public static void Subdivide(Mesh mesh, int level)
}

// Mesh normals recalculation with smoothing angle feature
public static class RecalculateNormalsSmoothingAngle
{
// Recalculate normals with a specific smoothing angle. 90 degrees is a default value. Use 0 degrees for flat smoothing
public static void RecalculateNormals(Mesh mesh, float angle = 90)
// Recalculate normals with a specific smoothing angle. 90 degrees is a default value. Use 0 degrees for flat smoothing
public static Vector3[] RecalculateNormals(NormalData nd, float angle = 90)
}

// Arbitrary transformation helpers
public static class Transformations
{
// Convert point from local space to world space
public static Vector3 TransformPoint(Vector3 worldSpacePosition, Quaternion worldSpaceRotation, Vector3 worldSpaceScale, Vector3 localSpacePoint)
// Convert point from world space to local space
public static Vector3 TransformPointInverse(Vector3 worldSpacePosition, Quaternion worldSpaceRotation, Vector3 worldSpaceScale, Vector3 worldSpacePoint)
// Convert direction from local space to world space
public static Vector3 TransformDirection(Vector3 worldSpacePosition, Quaternion worldSpaceRotation, Vector3 worldSpaceScale, Vector3 localSpaceDirection)
}

// Custom 3D math library - linear algebra and interpolations
public static class Math3D
{
// Custom Vector linear interpolation between A to B
public static Vector3 CustomLerp(Vector3 a, Vector3 b, float t)
// Procedural instance-based perlin noise
public sealed class Perlin
}