Initial Commit
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using ImstkUnity;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ImstkEditor
|
||||
{
|
||||
[CustomEditor(typeof(ConnectiveTissue))]
|
||||
public class ConnectiveTissueEditor : Editor
|
||||
{
|
||||
// Local variables for caching editor results
|
||||
Deformable sideA;
|
||||
Deformable sideB;
|
||||
|
||||
double maxDistance;
|
||||
double strandsPerFace;
|
||||
int segmentsPerStrand;
|
||||
double distanceStiffness;
|
||||
double uniformMassValue;
|
||||
double viscousDampingCoeff;
|
||||
|
||||
GUIContent sideAContent = new GUIContent("Side A", "One side of the objects that should be connected.");
|
||||
GUIContent sideBContent = new GUIContent("Side B", "One side of the objects that should be connected.");
|
||||
GUIContent maxDistContent = new GUIContent("Maximum Distance", "If side a and b are closer than this value" +
|
||||
" connective tissue strands will be generated. If 0 the distance between the centers will be used");
|
||||
GUIContent strandsPerFaceContent = new GUIContent("Strands per Face", "Indicates the density of strands " +
|
||||
"that are being generated, fractions can be used e.g. 0.5 will generate a strand for half the faces");
|
||||
GUIContent segmentsPerStrandContent = new GUIContent("Segments per Strand", "Determines the number of " +
|
||||
"segments for each strand");
|
||||
GUIContent distanceStiffnessContent = new GUIContent("Distance Stiffness", "Determines how much the " +
|
||||
"connective tissue will resist extension.");
|
||||
GUIContent massValueContent = new GUIContent("Uniform Mass Value", "Mass per vertex of the object");
|
||||
GUIContent viscousDampingContent = new GUIContent("Viscous Damping", "Dampens the system");
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var script = target as ConnectiveTissue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
sideA = EditorGUILayout.ObjectField(sideAContent, script.objectA, typeof(ImstkUnity.Deformable), true) as ImstkUnity.Deformable;
|
||||
sideB = EditorGUILayout.ObjectField(sideBContent,script.objectB, typeof(ImstkUnity.Deformable), true) as ImstkUnity.Deformable;
|
||||
|
||||
maxDistance = EditorGUILayout.DoubleField(maxDistContent, script.maxDistance);
|
||||
strandsPerFace = EditorGUILayout.DoubleField(strandsPerFaceContent, script.strandsPerFace);
|
||||
segmentsPerStrand = EditorGUILayout.IntField(segmentsPerStrandContent, script.segmentsPerStrand);
|
||||
distanceStiffness = EditorGUILayout.DoubleField(distanceStiffnessContent, script.distanceStiffness);
|
||||
uniformMassValue = EditorGUILayout.DoubleField(massValueContent, script.uniformMassValue);
|
||||
viscousDampingCoeff = EditorGUILayout.DoubleField(viscousDampingContent, script.viscousDampingCoeff);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if ((sideA == null && sideB == null) || sideA != sideB)
|
||||
{
|
||||
script.objectA = sideA;
|
||||
script.objectB = sideB;
|
||||
}
|
||||
|
||||
script.maxDistance = maxDistance;
|
||||
script.strandsPerFace = strandsPerFace;
|
||||
script.segmentsPerStrand = segmentsPerStrand;
|
||||
script.distanceStiffness = distanceStiffness;
|
||||
script.uniformMassValue = uniformMassValue;
|
||||
script.viscousDampingCoeff = viscousDampingCoeff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user