Exemplo n.º 1
0
 /// <summary>
 /// Initializes the surface instance
 /// </summary>
 public void Initialize()
 {
     meshFilter = GetComponent <MeshFilter>();
     if (transforms == Transforms.FromParent)
     {
         GetControlPointsFromTranssform();
     }
     else
     {
     }
     knotsU           = NurbsUtils.Knots(countU, degreeU);
     knotsV           = NurbsUtils.Knots(countV, degreeV);
     mesh             = new Mesh();
     mesh.name        = gameObject.name + "_surface";
     mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
     UpdateSurface();
 }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.LabelField("Curve Settings:", EditorStyles.boldLabel);
            myTarget.type = (CurveType)EditorGUILayout.EnumPopup("Curve Type:", myTarget.type);
            switch (myTarget.type)
            {
            case CurveType.NURBS:
                myTarget.degree = EditorGUILayout.IntField("Degree:", myTarget.degree);
                break;

            default:
                break;
            }
            myTarget.resolution = EditorGUILayout.FloatField("Resolution:", myTarget.resolution);
            myTarget.transforms = (Transforms)EditorGUILayout.EnumPopup("Control Points Provider:", myTarget.transforms);
            switch (myTarget.transforms)
            {
            case Transforms.AsList:
                EditorGUILayout.PropertyField(controlPointTransforms, new GUIContent("Control Point Transform"), true);
                break;

            case Transforms.FromParent:
                EditorGUILayout.PropertyField(controlPointsParent, new GUIContent("Control Points Parent"));
                break;
            }
            myTarget.initializeOnStart = EditorGUILayout.Toggle("Initialize On Start:", myTarget.initializeOnStart);
            myTarget.autoUpdate        = EditorGUILayout.Toggle("Auto-Update:", myTarget.autoUpdate);
            if (myTarget.type == CurveType.NURBS)
            {
                EditorGUILayout.PropertyField(knots, new GUIContent("Knots"), true);
                if (GUILayout.Button("Get Knot Vector:"))
                {
                    switch (myTarget.transforms)
                    {
                    case Transforms.AsList:
                        myTarget.knots = NurbsUtils.Knots(myTarget.controlPointTransforms.Length, myTarget.degree);
                        break;

                    case Transforms.FromParent:
                        myTarget.knots = NurbsUtils.Knots(myTarget.controlPointsParent.childCount, myTarget.degree);
                        break;
                    }
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes the Curve
 /// </summary>
 public void Initialize()
 {
     lineRenderer = GetComponent <LineRenderer>();
     lineRenderer.useWorldSpace = false;
     if (transforms == Transforms.FromParent)
     {
         GetControlPointsFromTransform();
     }
     else
     {
         if (controlPointTransforms != null && controlPointTransforms.Length != 0 && (controlPoints == null || controlPoints.Length == 0))
         {
             GetControlPointsFromTransforms();
         }
     }
     knots = NurbsUtils.Knots(controlPoints.Length, degree);
     UpdateCurve();
 }