예제 #1
0
 void OnPostRender()
 {
     if (Splines.Length == 0)
     {
         return;
     }
     for (int s = 0; s < Splines.Length; s++)
     {
         CurvySplineBase   spline    = Splines[s];
         UnityEngine.Color lineColor = (s < Colors.Length) ? Colors[s] : UnityEngine.Color.green;
         if (spline && spline.IsInitialized)
         {
             Points = spline.GetApproximation();
             CreateLineMaterial();
             lineMaterial.SetPass(0);
             GL.Begin(GL.LINES);
             GL.Color(lineColor);
             for (int i = 1; i < Points.Length; i++)
             {
                 GL.Vertex(Points[i - 1]);
                 GL.Vertex(Points[i]);
             }
             GL.End();
         }
     }
 }
예제 #2
0
 void Awake()
 {
     mRenderer = GetComponent<LineRenderer>();
     m_Spline = GetComponent<CurvySpline>();
     if (!m_Spline)
         m_Spline = GetComponent<CurvySplineGroup>();
 }
 void OnSplineRefresh(CurvySplineBase spline)
 {
     Planar = CurvyUtility.isPlanar(Spline, out IgnoreAxis);
     if (Planar)
         Triangulate();
     Repaint();
 }
예제 #4
0
        /*! \cond PRIVATE */

        void getInterpolatedSourcePosition(CurvySplineBase spline, float tf, out Vector3 position, out Vector3 tangent, out Vector3 up)
        {
            if (spline.Length == 0)
            {
                position = spline.transform.localPosition;
                tangent  = Vector3.forward;
                up       = Vector3.up;
            }
            else
            {
                if (UseCache)
                {
                    position = spline.InterpolateFast(tf);
                    tangent  = spline.GetTangentFast(tf);
                }
                else
                {
                    position = spline.Interpolate(tf);
                    tangent  = spline.GetTangent(tf, position);
                }
                up = spline.GetOrientationUpFast(tf);
            }
            if (Space == Space.World)
            {
                position = spline.transform.TransformPoint(position);
                tangent  = spline.transform.TransformDirection(tangent);
                up       = spline.transform.TransformDirection(up);
            }
        }
예제 #5
0
 protected void OnRefreshEvent(CurvySplineBase sender)
 {
     if (OnRefresh != null)
     {
         OnRefresh(sender);
     }
 }
 void hookSplineEvents(CurvySplineBase spline)
 {
     if (SplineOnRefresh.IsSetup)
     {
         spline.OnRefresh.AddListener(onSplineRefresh);
         setupEventTarget(SplineOnRefresh, ref splineOnRefreshEventTarget);
     }
 }
예제 #7
0
 void UnhookSpline(CurvySplineBase spline)
 {
     if (!spline)
     {
         return;
     }
     spline.OnRefresh -= OnSourceRefresh;
 }
예제 #8
0
 SplinePolyLine(CurvySplineBase spline, VertexCalculation vertexMode, float angle, float distance, Space space = Space.World)
 {
     Spline     = spline;
     VertexMode = vertexMode;
     Angle      = angle;
     Distance   = distance;
     Space      = space;
 }
예제 #9
0
 void OnSplineRefresh(CurvySplineBase sender)
 {
     if (Time.realtimeSinceStartup - mLastRefresh > AutoRefreshSpeed)
     {
         mLastRefresh = Time.realtimeSinceStartup;
         Refresh();
     }
 }
예제 #10
0
 void OnSplineRefresh(CurvySplineBase spline)
 {
     Planar = CurvyUtility.isPlanar(Spline, out IgnoreAxis);
     if (Planar)
     {
         Triangulate();
     }
     Repaint();
 }
예제 #11
0
 void Awake()
 {
     mRenderer = GetComponent <LineRenderer>();
     m_Spline  = GetComponent <CurvySpline>();
     if (!m_Spline)
     {
         m_Spline = GetComponent <CurvySplineGroup>();
     }
 }
        public override void OnEnter()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(GameObject);

            if (go)
            {
                _spl = go.GetComponent <CurvySplineBase>();
            }
        }
 void OnSplineRefresh(CurvySplineBase spl)
 {
     if (!Splines.Contains((CurvySpline)spl))
     {
         spl.OnRefresh -= OnSplineRefresh;
         return;
     }
     doRefreshLength();
 }
 void UnhookSpline(CurvySplineBase spline)
 {
     if (!spline)
     {
         return;
     }
     spline.OnRefresh.RemoveListener(OnSourceRefresh);
     splineTransforms.Remove(spline);
 }
예제 #15
0
 public void Add(CurvySplineBase spline)
 {
     if (spline != null)
     {
         Splines.Add(new GLSlotData()
         {
             Spline = spline
         });
     }
 }
예제 #16
0
 public void Remove(CurvySplineBase spline)
 {
     for (int i = Splines.Count - 1; i >= 0; i--)
     {
         if (Splines[i].Spline == spline)
         {
             Splines.RemoveAt(i);
         }
     }
 }
 void HookSpline(CurvySplineBase spline)
 {
     if (!spline)
     {
         return;
     }
     spline.OnRefresh.AddListenerOnce(OnSourceRefresh);
     if (!splineTransforms.ContainsKey(spline))
     {
         splineTransforms.Add(spline, new TTransform(spline.transform));
     }
 }
    // Look for another lane to the left or right
    bool TrySwitchLane(Vector3 dir)
    {
        CurvySplineBase followUpSpline;
        float           newTF;

        if (RaycastForFollowUpSpline(dir, out followUpSpline, out newTF))
        {
            Spline = followUpSpline;
            TF     = newTF;
            return(true);
        }
        return(false);
    }
예제 #19
0
        public CurvyMeshSegmentInfo(SplinePathMeshBuilder mb, float tf, float distance, Vector3 scale)
        {
            Target = mb.Spline;
            TF = tf;
            mDistance = distance;

            Vector3 p = (mb.FastInterpolation) ? Target.InterpolateFast(TF) : Target.Interpolate(TF);

            if (mb.UseWorldPosition)
                Matrix = Matrix4x4.TRS(mb.Transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale);
            else
                Matrix = Matrix4x4.TRS(Target.Transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale);
        }
        void CurveGUI(SplinePolyLine curve)
        {
            GUILayout.BeginHorizontal();
            CurvySplineBase o = curve.Spline;

            curve.Spline = (CurvySplineBase)EditorGUILayout.ObjectField(curve.Spline, typeof(CurvySplineBase), true, GUILayout.Width(140));

            if (o != curve.Spline)
            {
                UnhookSpline(o);
            }
            HookSpline(curve.Spline);

            curve.VertexMode = (SplinePolyLine.VertexCalculation)EditorGUILayout.EnumPopup(curve.VertexMode, GUILayout.Width(140));
            GUILayout.Space(20);
            curve.Orientation = (ContourOrientation)EditorGUILayout.EnumPopup(curve.Orientation);
            if (GUILayout.Button(new GUIContent(CurvyStyles.DeleteSmallTexture, "Remove"), GUILayout.ExpandWidth(false)))
            {
                if (curve.Spline)
                {
                    UnhookSpline(curve.Spline);
                }
                Curves.Remove(curve);
                refreshNow = true;
                GUIUtility.ExitGUI();
            }
            switch (curve.VertexMode)
            {
            case SplinePolyLine.VertexCalculation.ByAngle:
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(150);
                float lw = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 40;
                curve.Angle = Mathf.Max(0, EditorGUILayout.FloatField("Angle", curve.Angle, GUILayout.Width(140)));
                EditorGUIUtility.labelWidth = 60;
                GUILayout.Space(20);
                curve.Distance = EditorGUILayout.FloatField("Min. Dist.", curve.Distance, GUILayout.Width(150));
                EditorGUIUtility.labelWidth = lw;
                if (curve.Angle == 0)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(140);
                    EditorGUILayout.HelpBox("Angle must be >0", MessageType.Error);
                }
                break;
            }
            GUILayout.EndHorizontal();
        }
예제 #21
0
 GLSlotData getSlot(CurvySplineBase spline)
 {
     if (spline)
     {
         foreach (var slot in Splines)
         {
             if (slot.Spline == spline)
             {
                 return(slot);
             }
         }
     }
     return(null);
 }
예제 #22
0
    static public void CreateCloneBuilder()
    {
        var path = SplinePathCloneBuilder.Create();

        if (Selection.activeGameObject)
        {
            CurvySplineBase spl = Selection.activeGameObject.GetComponent <CurvySplineBase>();

            if (spl)
            {
                path.Spline = spl;
            }
        }
        Selection.activeGameObject = path.gameObject;
    }
예제 #23
0
        // Code that runs on entering the state.
        public override void OnEnter()
        {
            if (!Spline.IsNone)
            {
                mSpline = Spline.Value.GetComponent <CurvySplineBase>();
            }

            if (mSpline && !everyFrame)
            {
                DoInterpolate();
            }
            if (!everyFrame)
            {
                Finish();
            }
        }
예제 #24
0
    public CurvyMeshSegmentInfo(SplinePathMeshBuilder mb, float tf, float distance, Vector3 scale)
    {
        Target    = mb.Spline;
        TF        = tf;
        mDistance = distance;

        Vector3 p = (mb.FastInterpolation) ? Target.InterpolateFast(TF) : Target.Interpolate(TF);

        if (mb.UseWorldPosition)
        {
            Matrix = Matrix4x4.TRS(mb.Transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale);
        }
        else
        {
            Matrix = Matrix4x4.TRS(Target.transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale);
        }
    }
예제 #25
0
 // Raycast a direction for another spline and get the nearest position on it
 bool RaycastForFollowUpSpline(Vector3 dir, out CurvySplineBase newSpline, out float newTF)
 {
     newSpline = null;
     newTF = 0;
     Ray R = new Ray(mTransform.position, dir);
     RaycastHit hitInfo;
     if (Physics.Raycast(R, out hitInfo, LAYER_LANE))
     {
         newSpline = hitInfo.collider.transform.parent.GetComponent<CurvySplineBase>();
         if (newSpline)
         {
             newTF = newSpline.GetNearestPointTF(hitInfo.point);
             return true;
         }
     }
     return false;
 }
예제 #26
0
 void RenderSpline(CurvySplineBase spl, Color lineColor)
 {
     if (spl && spl.IsInitialized)
     {
         Points = spl.GetApproximation();
         CreateLineMaterial();
         lineMaterial.SetPass(0);
         GL.Begin(GL.LINES);
         GL.Color(lineColor);
         for (int i = 1; i < Points.Length; i++)
         {
             GL.Vertex(Points[i - 1]);
             GL.Vertex(Points[i]);
         }
         GL.End();
     }
 }
예제 #27
0
        // Code that runs on entering the state.
        public override void OnEnter()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(GameObject);

            if (go)
            {
                mSpline = go.GetComponent <CurvySplineBase>();
                if (mSpline && !everyFrame && !lateUpdate)
                {
                    DoInterpolate();
                }
            }
            if (!everyFrame)
            {
                Finish();
            }
        }
예제 #28
0
 void RenderSpline(CurvySplineBase spl, Color lineColor)
 {
     if (spl && spl.IsInitialized)
     {
         Points = spl.GetApproximation();
         CreateLineMaterial();
         lineMaterial.SetPass(0);
         GL.Begin(GL.LINES);
         GL.Color(lineColor);
         for (int i = 1; i < Points.Length; i++)
         {
             GL.Vertex(Points[i - 1]);
             GL.Vertex(Points[i]);
         }
         GL.End();
     }
 }
    // Raycast a direction for another spline and get the nearest position on it
    bool RaycastForFollowUpSpline(Vector3 dir, out CurvySplineBase newSpline, out float newTF)
    {
        newSpline = null;
        newTF     = 0;
        Ray        R = new Ray(mTransform.position, dir);
        RaycastHit hitInfo;

        if (Physics.Raycast(R, out hitInfo, LAYER_LANE))
        {
            newSpline = hitInfo.collider.transform.parent.GetComponent <CurvySplineBase>();
            if (newSpline)
            {
                newTF = newSpline.GetNearestPointTF(hitInfo.point);
                return(true);
            }
        }
        return(false);
    }
예제 #30
0
        void CurveGUI(SplinePolyLine curve, bool canRemove)
        {
            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.BeginHorizontal();
            CurvySplineBase o = curve.Spline;

            curve.Spline = (CurvySplineBase)EditorGUILayout.ObjectField(new GUIContent("Spline", "Note: Curves from a SplineGroup needs to be connected!"), curve.Spline, typeof(CurvySplineBase), true);
            if (o != curve.Spline)
            {
                UnhookSpline(o);
            }
            HookSpline(curve.Spline);
            if (canRemove)
            {
                if (GUILayout.Button(new GUIContent(mTexDelete, "Remove"), GUILayout.ExpandWidth(false)))
                {
                    if (curve.Spline)
                    {
                        UnhookSpline(curve.Spline);
                    }
                    Curves.Remove(curve);
                    refreshNow = true;
                    GUIUtility.ExitGUI();
                }
            }
            GUILayout.EndHorizontal();

            curve.VertexMode = (SplinePolyLine.VertexCalculation)EditorGUILayout.EnumPopup(new GUIContent("Vertex Generation"), curve.VertexMode);

            switch (curve.VertexMode)
            {
            case SplinePolyLine.VertexCalculation.ByAngle:
                curve.Angle = Mathf.Max(0, EditorGUILayout.FloatField(new GUIContent("Angle"), curve.Angle));
                if (curve.Angle == 0)
                {
                    EditorGUILayout.HelpBox("Angle must be >0", MessageType.Error);
                }
                curve.Distance = EditorGUILayout.FloatField(new GUIContent("Minimum Distance"), curve.Distance);
                break;
            }
            GUILayout.EndVertical();
        }
예제 #31
0
 /// <summary>
 /// Grows/Shrinks a spline or a spline group
 /// </summary>
 /// <param name="spline">the spline or group</param>
 /// <param name="center">the center of the effect</param>
 /// <param name="growByPercent">the percentage to grow/shrink</param>
 internal static void Grow(CurvySplineBase spline, UnityEngine.Vector3 center, float growByPercent)
 {
     if (spline is CurvySplineGroup)
     {
         CurvySplineGroup grp = (CurvySplineGroup)spline;
         foreach (CurvySpline spl in grp.Splines)
         {
             Grow(spl, center, growByPercent);
         }
     }
     else
     {
         CurvySpline spl = (CurvySpline)spline;
         foreach (CurvySplineSegment cp in spl.ControlPoints)
         {
             UnityEngine.Vector3 dir = center - cp.Position;
             float dist = dir.magnitude;
             cp.Position = center + dir.normalized * dist * growByPercent;
         }
     }
 }
        public static void CreateMeshBuilder()
        {
            var path = SplinePathMeshBuilder.Create();
            var prim = GameObject.CreatePrimitive(PrimitiveType.Plane);

#if UNITY_3_5_7
            prim.active = false;
#else
            prim.SetActive(false);
#endif
            path.GetComponent <MeshRenderer>().sharedMaterial = prim.GetComponent <MeshRenderer>().sharedMaterial;
            DestroyImmediate(prim);
            if (Selection.activeGameObject)
            {
                CurvySplineBase spl = Selection.activeGameObject.GetComponent <CurvySplineBase>();
                if (spl)
                {
                    path.Spline = spl;
                }
            }
            Selection.activeGameObject = path.gameObject;
        }
예제 #33
0
 void OnSplineRefresh(CurvySplineBase spl)
 {
     if (!Splines.Contains((CurvySpline)spl))
     {
         spl.OnRefresh -= OnSplineRefresh;
         return;
     }
     if (!mIsInitialized)
     {
         return;
     }
     doRefreshLength();
     mIsContinuous = true;
     for (int i = 0; i < Count - 1; i++)
     {
         if (!NextSplineConnected(i))
         {
             mIsContinuous = false;
             break;
         }
     }
     mIsClosed = (Count > 1 && NextSplineConnected(Count - 1));
 }
 void Init(CurvySplineBase spline)
 {
     Curves.Add(new SplinePolyLine(spline));
     HookSpline(spline);
 }
예제 #35
0
 /// <summary>
 /// Creates a Spline2MeshCurve class using Spline2MeshCurve.VertexMode.ByApproximation
 /// </summary>
 public SplinePolyLine(CurvySplineBase spline)
     : this(spline, VertexCalculation.ByApproximation, 0,0)
 {
 }
예제 #36
0
 /// <summary>
 /// Creates a Spline2MeshCurve class using Spline2MeshCurve.VertexMode.ByAngle
 /// </summary>
 public SplinePolyLine(CurvySplineBase spline, float angle, float distance)
     : this(spline,VertexCalculation.ByAngle,angle,distance)
 {
 }
예제 #37
0
 void UnhookSpline(CurvySplineBase spline)
 {
     if (!spline) return;
     spline.OnRefresh -= OnSourceRefresh;
 }
 protected void OnRefreshEvent(CurvySplineBase sender)
 {
     if (OnRefresh != null) {
         OnRefresh(sender);
     }
 }
예제 #39
0
 GLSlotData getSlot(CurvySplineBase spline)
 {
     if (spline)
     {
         foreach (var slot in Splines)
             if (slot.Spline == spline)
                 return slot;
     }
     return null;
 }
    void Update()
    {
        if (!Spline || !Spline.IsInitialized)
        {
            return;
        }

        // *** Place Player in editor ***
        if (!Application.isPlaying)
        {
            if (Spline.Interpolate(TF) != mTransform.position)
            {
                mTransform.position = Spline.Interpolate(TF);
            }
            return;
        }

        int dir = 1;

        // advance on lane. We use PingPong clamping to detect when we reach the end of a spline (in that case dir changes!)
        Vector3 newPosOnSpline = Spline.MoveBy(ref TF, ref dir, Speed * Time.deltaTime, CurvyClamping.PingPong);
        Vector3 newTangent     = Spline.GetTangent(TF);

        // Advance by spline curvation delta. We don't use newPosOnSpline directly because we don't want a snap-effect when in air or switching lanes
        mTransform.position += newPosOnSpline - mLastPosOnSpline;

        // *** Switch lanes? ***
        if (Input.GetButtonDown("Horizontal"))
        {
            if (TrySwitchLane(Input.GetAxis("Horizontal") < 0 ? Vector3.left : Vector3.right))
            {
                newPosOnSpline = Spline.Interpolate(TF);
            }
        }
        // *** Jump? ***
        if (!mInAir && !Jumping && Input.GetKey(KeyCode.Space))
        {
            StartCoroutine(Jump());
        }

        // Set orientation
        mTransform.forward = newTangent;

        // Oops! We've reached end of spline. Check if we can fall down onto another spline...
        if (dir != 1)
        {
            CurvySplineBase newSpline;
            float           newTF;
            if (RaycastForFollowUpSpline(Vector3.down, out newSpline, out newTF))
            {
                // we found a new spline underneath us. Let's use it from now on
                Spline         = newSpline;
                TF             = newTF;
                newPosOnSpline = Spline.Interpolate(TF);
                mInAir         = (newPosOnSpline - mTransform.position).sqrMagnitude > 0.001f;
            }
            else
            {
                StartCoroutine(Die()); // No Spline found. Time to die...
            }
        }


        // When in air or switching lanes, our position isn't where it should be. So we drag the player toward the lane position
        if (!Jumping)
        {
            Vector3 offset = mTransform.position - newPosOnSpline;
            if (offset.sqrMagnitude > 0.001f)
            {
                if (mInAir)
                {
                    mTransform.position -= offset.normalized * Gravity * Time.deltaTime;
                }
                else
                {
                    mTransform.position -= offset.normalized * SwitchSpeed * Time.deltaTime;
                }
            }
            else
            {
                mInAir = false;
            }
        }
        else   // Perform a jump
        {
            mTransform.Translate(0, mJumpDelta * Time.deltaTime, 0, Space.Self);
        }



        mLastPosOnSpline = newPosOnSpline;
    }
 // Look for another lane to the left or right
 bool TrySwitchLane(Vector3 dir)
 {
     CurvySplineBase followUpSpline;
     float newTF;
     if (RaycastForFollowUpSpline(dir, out followUpSpline, out newTF)) {
         Spline=followUpSpline;
         TF = newTF;
         return true;
     }
     return false;
 }
예제 #42
0
 SplinePolyLine(CurvySplineBase spline, VertexCalculation vertexMode, float angle, float distance)
 {
     Spline = spline;
     VertexMode = vertexMode;
     Angle = angle;
     Distance = distance;
 }
예제 #43
0
 /// <summary>
 /// Grows/Shrinks a spline or a spline group
 /// </summary>
 /// <param name="spline">the spline or group</param>
 /// <param name="center">the center of the effect</param>
 /// <param name="growByPercent">the percentage to grow/shrink</param>
 internal static void Grow(CurvySplineBase spline, Vector3 center, float growByPercent)
 {
     if (spline is CurvySplineGroup) {
         CurvySplineGroup grp = (CurvySplineGroup)spline;
         foreach (CurvySpline spl in grp.Splines)
             Grow(spl, center, growByPercent);
     }
     else {
         CurvySpline spl = (CurvySpline)spline;
         foreach (CurvySplineSegment cp in spl.ControlPoints) {
             Vector3 dir = center - cp.Position;
             float dist = dir.magnitude;
             cp.Position = center + dir.normalized * dist * growByPercent;
         }
     }
 }
 void OnSplineRefresh(CurvySplineBase sender)
 {
     if (Time.realtimeSinceStartup - mLastRefresh > AutoRefreshSpeed) {
         mLastRefresh = Time.realtimeSinceStartup;
         Refresh(false);
     }
 }
 void OnSplineRefresh(CurvySplineBase spl)
 {
     if (!Splines.Contains((CurvySpline)spl)) {
         spl.OnRefresh -= OnSplineRefresh;
         return;
     }
     doRefreshLength();
 }
 void HookSpline(CurvySplineBase spline)
 {
     if (!spline) return;
     spline.OnRefresh.AddListenerOnce(OnSourceRefresh);
     if (!splineTransforms.ContainsKey(spline))
         splineTransforms.Add(spline,new TTransform(spline.transform));
 }
	void Update () 
    {
        if (!Spline || !Spline.IsInitialized)
            return;
        
        // *** Place Player in editor ***
        if (!Application.isPlaying) {
            if (Spline.Interpolate(TF)!=mTransform.position)
                mTransform.position = Spline.Interpolate(TF);
            return;
        }

        int dir=1;
        
        // advance on lane. We use PingPong clamping to detect when we reach the end of a spline (in that case dir changes!)
        Vector3 newPosOnSpline=Spline.MoveBy(ref TF, ref dir, Speed*Time.deltaTime, CurvyClamping.PingPong);
        Vector3 newTangent = Spline.GetTangent(TF);

        // Advance by spline curvation delta. We don't use newPosOnSpline directly because we don't want a snap-effect when in air or switching lanes
        mTransform.position += newPosOnSpline - mLastPosOnSpline;

        // *** Switch lanes? ***
        if (Input.GetButtonDown("Horizontal")) {
            if (TrySwitchLane(Input.GetAxis("Horizontal") < 0 ? Vector3.left : Vector3.right)) {
                newPosOnSpline = Spline.Interpolate(TF);
            }
        }        
        // *** Jump? ***
        if (!mInAir && !Jumping && Input.GetKey(KeyCode.Space)) {
            StartCoroutine(Jump());
        }
       
        // Set orientation
        mTransform.forward = newTangent;

        // Oops! We've reached end of spline. Check if we can fall down onto another spline...
        if (dir != 1) {
            CurvySplineBase newSpline;
            float newTF;
            if (RaycastForFollowUpSpline(Vector3.down, out newSpline, out newTF)) {
                // we found a new spline underneath us. Let's use it from now on
                Spline = newSpline;
                TF = newTF;
                newPosOnSpline = Spline.Interpolate(TF);
                mInAir = (newPosOnSpline - mTransform.position).sqrMagnitude > 0.001f;
            }
            else {
                StartCoroutine(Die()); // No Spline found. Time to die...
            }
        }


        // When in air or switching lanes, our position isn't where it should be. So we drag the player toward the lane position
        if (!Jumping) {
            Vector3 offset = mTransform.position - newPosOnSpline;
            if (offset.sqrMagnitude > 0.001f) {
                if (mInAir)
                    mTransform.position -= offset.normalized * Gravity * Time.deltaTime;
                else
                    mTransform.position -= offset.normalized * SwitchSpeed * Time.deltaTime;
            }
            else
                mInAir = false;
        }
        else { // Perform a jump
            mTransform.Translate(0, mJumpDelta * Time.deltaTime,0, Space.Self);
        }
        
        

        mLastPosOnSpline = newPosOnSpline;
	}
 void UnhookSpline(CurvySplineBase spline)
 {
     if (!spline) return;
     spline.OnRefresh.RemoveListener(OnSourceRefresh);
     splineTransforms.Remove(spline);
 }
 void Init(CurvySplineBase spline)
 {
     Curves.Add(new SplinePolyLine(spline));
     HookSpline(spline);
 }
예제 #50
0
 public void Remove(CurvySplineBase spline)
 {
     for (int i = Splines.Count - 1; i >= 0; i--)
         if (Splines[i].Spline == spline)
             Splines.RemoveAt(i);
 }
예제 #51
0
 void OnSourceRefresh(CurvySplineBase spline)
 {
     refreshNow = true;
 }
예제 #52
0
        /*! \cond PRIVATE */

        void getInterpolatedSourcePosition(CurvySplineBase spline,float tf, out Vector3 position, out Vector3 tangent, out Vector3 up)
        {
            if (UseCache)
            {
                position = spline.InterpolateFast(tf);
                tangent = spline.GetTangentFast(tf);
            }
            else
            {
                position = spline.Interpolate(tf);
                tangent = spline.GetTangent(tf, position);
            }
            up = spline.GetOrientationUpFast(tf);
            if (Space == Space.World)
            {
                position = spline.transform.TransformPoint(position);
                tangent = spline.transform.TransformDirection(tangent);
                up = spline.transform.TransformDirection(up);
            }
        }
예제 #53
0
 public void Add(CurvySplineBase spline)
 {
     if (spline!=null)
         Splines.Add(new GLSlotData() { Spline = spline });
 }
예제 #54
0
 void OnSplineRefresh(CurvySplineBase spl)
 {
     if (!Splines.Contains((CurvySpline)spl)) {
         spl.OnRefresh -= OnSplineRefresh;
         return;
     }
     if (!mIsInitialized)
         return;
     doRefreshLength();
     mIsContinuous=true;
     for (int i=0;i<Count-1;i++)
         if (!NextSplineConnected(i)){
             mIsContinuous=false;
             break;
         }
     mIsClosed = (Count>1 && NextSplineConnected(Count - 1));
 }
예제 #55
0
 void OnSplineRefresh(CurvySplineBase sender)
 {
     mNeedRefresh=true;
 }