Beispiel #1
0
        public SplineObject GetRealSpline()
        {
            global::System.IntPtr cPtr = C4dApiPINVOKE.BaseObject_GetRealSpline(swigCPtr);
            SplineObject          ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SplineObject(cPtr, false);

            return(ret);
        }
Beispiel #2
0
        public virtual SplineObject GetContour(BaseObject op, BaseDocument doc, double lod, BaseThread bt)
        {
            global::System.IntPtr cPtr = C4dApiPINVOKE.ObjectData_GetContour(swigCPtr, BaseObject.getCPtr(op), BaseDocument.getCPtr(doc), lod, BaseThread.getCPtr(bt));
            SplineObject          ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SplineObject(cPtr, false);

            return(ret);
        }
Beispiel #3
0
        public static SplineObject Alloc(int pcnt, SPLINETYPE type)
        {
            global::System.IntPtr cPtr = C4dApiPINVOKE.SplineObject_Alloc(pcnt, (int)type);
            SplineObject          ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SplineObject(cPtr, false);

            return(ret);
        }
Beispiel #4
0
    public void AddHeadAtClosestLocation(SplineObject newHead)
    {
        splineObjects.Add(newHead);

        newHead.t     = getClosestLocationT(newHead.transform.position);
        newHead.oldT  = newHead.t;
        newHead.lastT = newHead.t;
    }
Beispiel #5
0
    public void RemoveHead(SplineObject oldHead)
    {
        int index = splineObjects.IndexOf(oldHead);

        if (index >= 0)
        {
            splineObjects.RemoveAt(index);
        }
    }
Beispiel #6
0
 public void AddHeadAtPoint(SplineObject newHead, GameObject point)
 {
     if (controlPoints.Contains(point))
     {
         splineObjects.Add(newHead);
         newHead.t      = controlPoints.IndexOf(point) - 1;
         newHead.oldT   = newHead.t;
         newHead.lastT  = newHead.t;
         newHead.spline = this;
     }
 }
Beispiel #7
0
        public SplineObject GenerateCircle(double rad)
        {
            const double TANG = 0.415;

            double sn, cs;
            int    i, sub = 4;

            SplineObject op = SplineObject.Alloc(sub * 2, SPLINETYPE.SPLINETYPE_BEZIER);

            if (null == op || null == op.MakeVariableTag(C4dApi.Tsegment, 2))
            {
                C4dApi.blDelete_cs(op);
                return(null);
            }

            op.GetDataInstance().SetBool(C4dApi.SPLINEOBJECT_CLOSED, true);

            Segment seg = new Segment();

            seg.closed = true;
            seg.cnt    = sub;
            op.SetSegmentAt(0, seg);
            op.SetSegmentAt(1, seg);

            for (i = 0; i < sub; i++)
            {
                double angle = 2.0 * Math.PI * (double)i / (double)sub;
                sn = Math.Sin(angle);
                cs = Math.Cos(angle);

                double3 vOuter         = new double3(cs * rad, sn * rad, 0.0);
                double3 vOuterTangentL = new double3(sn * rad * TANG, -cs * rad * TANG, 0.0);
                double3 vOuterTangentR = -vOuterTangentL;
                double3 vInner         = vOuter * 0.5;
                double3 vInnerTangentL = vOuterTangentL * 0.5;
                double3 vInnerTangentR = -vInnerTangentL;

                op.SetPointAt(i, vOuter);
                Tangent outerTangent = new Tangent();
                outerTangent.vl = vOuterTangentL;
                outerTangent.vr = vOuterTangentR;
                op.SetTangentAt(i, outerTangent);

                op.SetPointAt(i + sub, vInner);
                Tangent innerTangent = new Tangent();
                innerTangent.vl = vInnerTangentL;
                innerTangent.vr = vInnerTangentR;
                op.SetTangentAt(i + sub, innerTangent);
            }
            op.Message(C4dApi.MSG_UPDATE);

            return(op);
        }
Beispiel #8
0
        private void ensureNodeComponents(SplineObject component)
        {
            var count = component.transform.childCount;

            for (int i = 0; i < count; i++)
            {
                var point = component.transform.GetChild(i).gameObject;
                if (point.GetComponent <SplineNode>() == null)
                {
                    point.AddComponent <SplineNode>();
                }
            }
        }
Beispiel #9
0
        public static ITestInput CreateTestInput(GameObject go, IInlet <SplineSys> inlet, SplineSys splineSys)
        {
            SplineObject splineObj = go.AddComponent <SplineObject>();

            splineObj.splineSys = splineSys;

            SplineInout splineIn = new SplineInout()
            {
                splineObj = splineObj
            };

            return(splineIn);
        }
Beispiel #10
0
    public void AddHeadAtT(SplineObject newHead, float t)
    {
        if (t > controlPoints.Count)
        {
            t -= controlPoints.Count;
        }

        splineObjects.Add(newHead);
        newHead.t      = t;
        newHead.oldT   = newHead.t;
        newHead.lastT  = newHead.t;
        newHead.spline = this;
    }
Beispiel #11
0
        public static ITestOutput CreateTestOutput(GameObject go, IOutlet <SplineSys> outlet)
        {
            SplineObject splineObj = go.AddComponent <SplineObject>();

            splineObj.splineSys = new SplineSys();

            SplineInout splineIn = new SplineInout()
            {
                splineObj = splineObj
            };

            return(splineIn);
        }
Beispiel #12
0
        public override SplineObject GetContour(BaseObject op, BaseDocument doc, double lod, BaseThread bt)
        {
            BaseContainer bc = op.GetDataInstance();
            SplineObject  bp = GenerateCircle(bc.GetFloat(CIRCLEOBJECT_RAD));

            if (bp == null)
            {
                return(null);
            }
            BaseContainer bb = bp.GetDataInstance();

            bb.SetInt32(C4dApi.SPLINEOBJECT_INTERPOLATION, bc.GetInt32(C4dApi.SPLINEOBJECT_INTERPOLATION));
            bb.SetInt32(C4dApi.SPLINEOBJECT_SUB, bc.GetInt32(C4dApi.SPLINEOBJECT_SUB));
            bb.SetFloat(C4dApi.SPLINEOBJECT_ANGLE, bc.GetFloat(C4dApi.SPLINEOBJECT_ANGLE));
            bb.SetFloat(C4dApi.SPLINEOBJECT_MAXIMUMLENGTH, bc.GetFloat(C4dApi.SPLINEOBJECT_MAXIMUMLENGTH));

            OrientObject(bp, bc.GetInt32(C4dApi.PRIM_PLANE), bc.GetBool(C4dApi.PRIM_REVERSE));

            return(bp);
        }
Beispiel #13
0
    public GameObject GetPrevPointForHead(SplineObject h)
    {
        if (splineObjects.Contains(h))
        {
            int nextPIndex = 0;

            if (gameMode == GameModes.Forward ||
                (gameMode == GameModes.PingPong && h.pingpongSign > 0.0f))
            {
                nextPIndex = ((int)h.t + 1) % controlPoints.Count;
            }
            else
            {
                nextPIndex = ((int)h.t + 2) % controlPoints.Count;
            }

            return(controlPoints[nextPIndex]);
        }

        return(null);
    }
Beispiel #14
0
 private global::System.IntPtr SwigDirectorGetContour(global::System.IntPtr op, global::System.IntPtr doc, double lod, global::System.IntPtr bt)
 {
     return(SplineObject.getCPtr(GetContour((op == global::System.IntPtr.Zero) ? null : new BaseObject(op, false), (doc == global::System.IntPtr.Zero) ? null : new BaseDocument(doc, false), lod, (bt == global::System.IntPtr.Zero) ? null : new BaseThread(bt, false))).Handle);
 }
Beispiel #15
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SplineObject obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Beispiel #16
0
 public void AddHead(SplineObject newHead)
 {
     splineObjects.Add(newHead);
     newHead.spline = this;
 }
Beispiel #17
0
        public override void OnInspectorGUI()
        {
            if (Application.isPlaying)
            {
                return;
            }

            if (serializedObject.isEditingMultipleObjects)
            {
                return;
            }

            this.node = target as SplineNode;
            if (node.transform.parent == null)
            {
                return;
            }

            this.spline = node.transform.parent.GetComponent <SplineObject>();
            if (spline == null)
            {
                return;
            }

            using (BeginGroup("Selection"))
            {
                EditorGUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("Spline"))
                    {
                        Selection.activeGameObject = spline.gameObject;
                    }

                    if (GUILayout.Button("Prev"))
                    {
                        var index = spline.ControlPoints.IndexOf(node.transform) - 1;
                        if (index < 0)
                        {
                            index = spline.ControlPoints.Count - 1;
                        }
                        Selection.activeGameObject = spline.ControlPoints[index].gameObject;
                    }

                    if (GUILayout.Button("Next"))
                    {
                        var index = spline.ControlPoints.IndexOf(node.transform) + 1;
                        if (index > spline.ControlPoints.Count - 1)
                        {
                            index = 0;
                        }
                        Selection.activeGameObject = spline.ControlPoints[index].gameObject;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            using (BeginGroup("Insert New Node"))
            {
                EditorGUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("Before"))
                    {
                        insertNodeBefore();
                    }

                    if (GUILayout.Button("After"))
                    {
                        insertNodeAfter();
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            using (BeginGroup("Other Actions"))
            {
                if (GUILayout.Button("Split Spline"))
                {
                }
            }
        }
Beispiel #18
0
        public bool Init(SplineObject op)
        {
            bool ret = C4dApiPINVOKE.SplineLengthData_Init__SWIG_2(swigCPtr, SplineObject.getCPtr(op));

            return(ret);
        }
Beispiel #19
0
        static void OrientObject(SplineObject op, int plane, bool reverse)
        {
            // double3 padr = op.GetPointW();
            // Tangent hadr = op.GetTangentW(), h;
            int nPoints = op.GetPointCount();
            int i;

            bool bTangents = op.GetTangentCount() != 0;

            if (plane >= 1)
            {
                switch (plane)
                {
                case 1:     // ZY
                    for (i = 0; i < nPoints; i++)
                    {
                        double3 v = op.GetPointAt(i);
                        op.SetPointAt(i, new double3(-v.z, v.y, v.x));
                        if (!bTangents)
                        {
                            continue;
                        }
                        Tangent t  = op.GetTangentAt(i);
                        Tangent t2 = new Tangent();
                        t2.vl = new double3(-t.vl.z, t.vl.y, t.vl.x);
                        t2.vr = new double3(-t.vr.z, t.vr.y, t.vr.x);
                        op.SetTangentAt(i, t2);
                    }
                    break;

                case 2:     // XZ
                    for (i = 0; i < nPoints; i++)
                    {
                        double3 v = op.GetPointAt(i);
                        op.SetPointAt(i, new double3(v.x, -v.z, v.y));
                        if (!bTangents)
                        {
                            continue;
                        }
                        Tangent t  = op.GetTangentAt(i);
                        Tangent t2 = new Tangent();
                        t2.vl = new double3(t.vl.x, -t.vl.z, t.vl.y);
                        t2.vr = new double3(t.vr.x, -t.vr.z, t.vr.y);
                        op.SetTangentAt(i, t2);
                    }
                    break;
                }
            }

            if (reverse)
            {
                double3 p;
                int     to = nPoints / 2;
                if ((nPoints % 2) != 0)
                {
                    to++;
                }
                for (i = 0; i < to; i++)
                {
                    p = op.GetPointAt(i);
                    op.SetPointAt(i, op.GetPointAt(nPoints - 1 - i));
                    op.SetPointAt(nPoints - 1 - i, p);
                    if (!bTangents)
                    {
                        continue;
                    }
                    Tangent h1    = op.GetTangentAt(i);
                    Tangent h2    = op.GetTangentAt(nPoints - 1 - i);
                    Tangent hTmp1 = new Tangent();
                    Tangent hTmp2 = new Tangent();
                    hTmp1.vl = new double3(h2.vr);
                    hTmp1.vr = new double3(h2.vl);
                    hTmp2.vl = new double3(h1.vr);
                    hTmp2.vr = new double3(h1.vl);
                    op.SetTangentAt(i, hTmp1);
                    op.SetTangentAt(nPoints - 1 - i, hTmp2);
                }
            }

            op.Message(C4dApi.MSG_UPDATE);
        }
Beispiel #20
0
        public bool Init(SplineObject op, int segment, ref Fusee.Math.Core.double3 /* Vector*&_cstype */ padr)
        {
            bool ret = C4dApiPINVOKE.SplineLengthData_Init__SWIG_0(swigCPtr, SplineObject.getCPtr(op), segment, ref padr /* Vector*&_csin */);

            return(ret);
        }