コード例 #1
0
 public TweenData_RectTransform_AnchorPosSpline(RectTransform inRectTransform, ISpline inSpline, Axis inAxis, SplineTweenSettings inSettings)
 {
     m_RectTransform  = inRectTransform;
     m_Spline         = inSpline;
     m_Axis           = inAxis;
     m_SplineSettings = inSettings;
 }
コード例 #2
0
 private RageSvgPathElement()
 {
     Spline   = null;
     gO       = null;
     IsClosed = false;
     IsLinear = false;
 }
コード例 #3
0
 public TweenData_SplineControl_Position(ISpline inSpline, int inIndex, Vector3 inTarget, Axis inAxis)
 {
     m_Spline = inSpline;
     m_Index  = inIndex;
     m_Target = inTarget;
     m_Axis   = inAxis;
 }
コード例 #4
0
 /// <summary> Updates the Outline Width of every element of a RageGroup.  </summary>
 /// <param name="list">Group List</param>
 /// <param name="outlineWidth">Absolute outline Width or multiplying factor, per path</param>
 /// <param name="proportional">If proportional, outlineWidth is a multiplying factor to the current value</param>
 /// <param name="refresh">If false, only updates the AA data, doesn't refresh</param>
 public static void UpdateOutlineWidth(this List <RageGroupElement> list, float outlineWidth, bool proportional, bool refresh)
 {
     if (list == null)
     {
         return;
     }
     foreach (RageGroupElement rageGroupItem in list)
     {
         ISpline path = rageGroupItem.Spline;
         if (path == null)
         {
             continue;
         }
         if (proportional)
         {
             path.Outline.Width = path.Outline.Width * outlineWidth;
         }
         else
         {
             path.Outline.Width = outlineWidth;
         }
         if (refresh)
         {
             path.Rs.RefreshMesh(true, true, true);
         }
     }
 }
コード例 #5
0
    private static bool IsInsideSpline(ISpline mainSpline, ISpline subSpline)
    {
        if (mainSpline.PointsCount < 3)
        {
            return(false);
        }
        if (subSpline.PointsCount < 3)
        {
            return(false);
        }
        bool pointsInSpline = true;

        for (int i = 0; i < subSpline.PointsCount; i++)
        {
            var point = subSpline.GetPointAt(i).Position;
            pointsInSpline = SplineContainsPoint(mainSpline, point);
            if (!pointsInSpline)
            {
                break;
            }
        }
        if (!pointsInSpline)
        {
            return(false);
        }
        return(true);
    }
コード例 #6
0
    private static void GetCutPointData(ISpline mainSpline, ISpline subSpline, ref float cutPointSplinePosition, ref float holeCutPointSplinePosition, ref Vector3 cutPointPosition, ref Vector3 holeCutPointPosition, ref float cutPointDistance)
    {
        int mainSplineSubdiv = mainSpline.PointsCount > 10 ? mainSpline.PointsCount : 10;
        int holeSplineSubdiv = subSpline.PointsCount > 10 ? subSpline.PointsCount : 10;

        float pointStep     = 1 / (float)mainSplineSubdiv;
        float holePointStep = 1 / (float)holeSplineSubdiv;

        for (float i = 0; i < 1; i += pointStep)
        {
            Vector3 splinePointPosition = mainSpline.Rs.spline.GetPoint(i);
            for (float j = 0; j < 1; j += holePointStep)
            {
                Vector3 holePointPosition = subSpline.Rs.spline.GetPoint(j);
                var     currentDist       = Vector2.Distance(splinePointPosition, holePointPosition);
                if ((Mathf.Approximately(i, 0)) && (Mathf.Approximately(j, 0)))
                {
                    cutPointDistance = currentDist;
                }
                if (cutPointDistance <= currentDist)
                {
                    continue;
                }
                cutPointDistance           = currentDist;
                cutPointSplinePosition     = i;
                holeCutPointSplinePosition = j;
                cutPointPosition           = splinePointPosition;
                holeCutPointPosition       = holePointPosition;
            }
        }
    }
コード例 #7
0
    private static List <int> ProcessHoles(ISpline mainSpline, Dictionary <int, ISpline> subSplines)
    {
        List <ISpline> holes    = new List <ISpline>();
        List <int>     toRemove = new List <int>();

        foreach (KeyValuePair <int, ISpline> path in subSplines)
        {
            if (!IsInsideSpline(mainSpline, path.Value))
            {
                continue;
            }
            if (IsInsideSplines(subSplines, path.Value))
            {
                continue;
            }
            holes.Add(path.Value);
            toRemove.Add(path.Key);
        }
        while (holes.Count > 0)
        {
            int holeIndex = FindHoleClosestToEdge(mainSpline, holes);
            MakeHole(mainSpline, holes[holeIndex]);
            holes.RemoveAt(holeIndex);
        }
        return(toRemove);
    }
コード例 #8
0
ファイル: SplineExtensions.cs プロジェクト: xenosl/ShuHai
        /// <summary>
        ///     Interpolates over the whole spline by the specified parametric value.
        /// </summary>
        /// <param name="self">The spline instance applied.</param>
        /// <param name="t">
        ///     Parametric value ranges from 0 to 1 representing the position along the whole length of the spline.
        /// </param>
        public static Vector3 Interpolate(this ISpline self, float t)
        {
            float pos   = t * (self.PointCount - 1);
            var   index = (int)pos;

            return(self.Interpolate(index, pos - index));
        }
コード例 #9
0
ファイル: Spline.cs プロジェクト: leventeren/BeauRoutine
        /// <summary>
        /// Returns info about a segment on the spline.
        /// </summary>
        static public SplineSegment GetSegment(this ISpline inSpline, float inPercent)
        {
            SplineSegment seg;

            inSpline.GetSegment(inPercent, out seg);
            return(seg);
        }
コード例 #10
0
    private static int FindHoleClosestToEdge(ISpline mainSpline, List <ISpline> holes)
    {
        int   holeIndex    = 0;
        float holeDistance = 0;

        for (int i = 0; i < holes.Count; i++)
        {
            float   cutPointSplinePosition     = 0;
            float   holeCutPointSplinePosition = 0;
            Vector3 cutPointPosition           = mainSpline.GetPointAt(0).Position;
            Vector3 holeCutPointPosition       = holes[i].GetPointAt(0).Position;
            float   cutPointDistance           = 0;

            GetCutPointData(mainSpline, holes[i], ref cutPointSplinePosition, ref holeCutPointSplinePosition, ref cutPointPosition, ref holeCutPointPosition, ref cutPointDistance);

            if (i == 0)
            {
                holeDistance = cutPointDistance;
                continue;
            }

            if (cutPointDistance >= holeDistance)
            {
                continue;
            }

            holeIndex    = i;
            holeDistance = cutPointDistance;
        }
        return(holeIndex);
    }
コード例 #11
0
        public static Quaternion Twist(ISpline core, float t_core, ISpline guide, float t_guide)
        {
            Vector3 corePoint     = core.Evaluate(t_core);
            Vector3 rotationPoint = guide.Evaluate(t_guide);

            Vector3 tangentBasis = core.Tangent(t_core);

            tangentBasis = tangentBasis.normalized;

            Vector3 normalBasis = Vector3.Cross(tangentBasis, rotationPoint - corePoint);

            normalBasis = normalBasis.normalized;

            #region Uncomment this region to debug all Twist invocations

            /*
             * //Vector3 binormalBasis = Vector3.Cross(normalBasis, tangentBasis);
             * //binormalBasis = binormalBasis.normalized;
             *
             * //Debug.DrawLine(corePoint, corePoint + tangentBasis, Color.blue);
             * //Debug.DrawLine(corePoint, corePoint + normalBasis, Color.green);
             * //Debug.DrawLine(corePoint, corePoint + binormalBasis, Color.red);
             */

            #endregion Uncomment this region to debug all Twist invocations

            return(Quaternion.LookRotation(tangentBasis, normalBasis));
        }
コード例 #12
0
ファイル: Spline.cs プロジェクト: leventeren/BeauRoutine
 /// <summary>
 /// Generates info about an interpolation along the given spline.
 /// </summary>
 static public void GetUpdateInfo(this ISpline inSpline, float inPercent, SplineLerp inLerpMethod, Curve inSegmentEase, out SplineUpdateInfo outInfo)
 {
     outInfo.Spline    = inSpline;
     outInfo.Percent   = inSpline.TransformPercent(inPercent, inLerpMethod);
     outInfo.Point     = inSpline.GetPoint(outInfo.Percent, inSegmentEase);
     outInfo.Direction = inSpline.GetDirection(outInfo.Percent, inSegmentEase);
 }
コード例 #13
0
        public Bounds CalculateTransformedBounds(int maxIter = DEF_ITER_BOUND)
        {
            ISpline spline = Spline;

            if (spline == null)
            {
                Dbg.LogErr("BaseSplineBehaviour.CalculateTransformedBounds: not set spline yet");
                return(new Bounds());
            }

            Bounds bd = new Bounds();

            if (maxIter < 0)
            {
                maxIter = Mathf.Max((spline.PointCount - 1) * 10, 100);
            }

            for (int i = 0; i < maxIter; ++i)
            {
                float   t = (float)i / (float)maxIter;
                Vector3 p = GetTransformedPosition(t);
                bd.Encapsulate(p);
            }

            return(bd);
        }
コード例 #14
0
 /// <summary> Updates the Anti-Aliasing on every element of a RageGroup.  </summary>
 /// <param name="list">Group List</param>
 /// <param name="antiAlias">Absolute AA or multiplying factor, per path</param>
 /// <param name="proportional">If proportional, antiAlias is a multiplying factor to the default value</param>
 /// <param name="refresh">If false, only updates the AA data, doesn't refresh</param>
 public static void UpdateAa(this List <RageGroupElement> list, float antiAlias, bool proportional, bool refresh)
 {
     if (list == null)
     {
         return;
     }
     foreach (RageGroupElement rageGroupItem in list)
     {
         if (rageGroupItem == null || rageGroupItem.Spline == null)
         {
             continue;
         }
         ISpline path = rageGroupItem.Spline;
         if (path == null)
         {
             continue;
         }
         if (proportional)
         {
             path.Outline.AntialiasingWidth = rageGroupItem.DefaultAa * antiAlias;
         }
         else
         {
             path.Outline.AntialiasingWidth = antiAlias;
         }
         if (refresh)
         {
             path.Rs.RefreshMesh(true, true, true);
         }
     }
 }
コード例 #15
0
    private void CalculateContainedPoints()
    {
        TouchingSplines = null;
        RageMagnetPoint.RemoveMagnetsFromPoint(this, Points);

        List <ISpline>         splines = new List <ISpline>();
        List <RageMagnetPoint> points  = new List <RageMagnetPoint>();

        foreach (RageGroupElement item in Group.List)
        {
            ISpline spline = item.Spline;
            if (spline == null)
            {
                continue;
            }
            for (int i = 0; i < (spline).PointsCount; i++)
            {
                FeedColliderData(points, spline, i);
                if (!splines.Contains(spline))
                {
                    splines.Add(spline);
                }
            }
        }

        TouchingSplines = splines.ToArray();
        Points          = points.ToArray();
    }
コード例 #16
0
 protected void Reset()
 {
     Spline = CreateSpline();
     foreach (var point in transform.Cast <Transform>().Select(t => t.localPosition))
     {
         Spline.AddPoint(point);
     }
 }
コード例 #17
0
ファイル: LineBuilder.cs プロジェクト: SonGit/RainDay
 public LineBuilder(IBezierBuilder b, IJointBuilder j, IJointBuilder js, ICapBuilder c, ISpline line)
 {
     _bezierDrawer         = b;
     _jointDrawer          = j;
     _capDrawer            = c;
     _line                 = line;
     _jointIntersectDrawer = js;
 }
コード例 #18
0
 public EvaluationCache(ISpline spline, int cacheSize)
     : base(cacheSize)
 {
     for (int i = 0; i < this.Values.Length; i++)
     {
         this.Values[i] = spline.Evaluate((float)i / (Values.Length - 1));
     }
 }
コード例 #19
0
    /// <summary> Finds the geometric center of a spline </summary>
    private static Vector3 GetSplineCenter(ISpline spline)
    {
        var meshFilter = spline.GameObject.GetComponent <MeshFilter>();

        return(new Vector3(meshFilter.sharedMesh.bounds.center.x * spline.GameObject.transform.lossyScale.x,
                           meshFilter.sharedMesh.bounds.center.y * spline.GameObject.transform.lossyScale.y,
                           meshFilter.sharedMesh.bounds.center.z * spline.GameObject.transform.lossyScale.z));
    }
コード例 #20
0
 public TweenData_Transform_PositionSpline(Transform inTransform, ISpline inSpline, Space inSpace, Axis inAxis, SplineTweenSettings inSettings)
 {
     m_Transform      = inTransform;
     m_Spline         = inSpline;
     m_Space          = inSpace;
     m_Axis           = inAxis;
     m_SplineSettings = inSettings;
 }
コード例 #21
0
 ISpline GetSpline()
 {
     if (_Spline == null)
     {
         _Spline = GetComponent <ISpline>();
     }
     return(_Spline);
 }
コード例 #22
0
        protected override IEnumerable <float3> PointData(ISpline spline)
        {
            ISpline2D spline3D = (spline as ISpline2D);

            foreach (float2 point in spline3D.SplineEntityData2D.Value.Points)
            {
                yield return(new float3(point, 0f));
            }
        }
コード例 #23
0
        protected override int SplineSegmentPointCount(ISpline spline)
        {
            ISpline2D spline3D = (spline as ISpline2D);

            Assert.NotNull(spline3D, "Unable to convert spline");
            Assert.NotNull(spline3D.SplineEntityData2D, "spline failed to generate data");

            return(spline3D.SplineEntityData2D.Value.Points.Length);
        }
コード例 #24
0
ファイル: TestHelpers.cs プロジェクト: crener/Dots-Spline
        public static void ClearSpline(ISpline spline)
        {
            while (spline.ControlPointCount > 0)
            {
                spline.RemoveControlPoint(0);
            }

            Assert.AreEqual(0f, spline.Length());
            Assert.AreEqual(0, spline.ControlPointCount);
        }
コード例 #25
0
ファイル: Spline.cs プロジェクト: leventeren/BeauRoutine
        /// <summary>
        /// Samples the spline for the given range and outputs to a list.
        /// </summary>
        static public void Sample(this ISpline inSpline, List <Vector2> outPoints, float inStart, float inEnd, int inNumSamples, SplineLerp inLerp = SplineLerp.Vertex)
        {
            float delta = inEnd - inStart;

            for (int i = 0; i < inNumSamples; ++i)
            {
                float t = (float)i / (inNumSamples - 1);
                outPoints.Add(inSpline.GetPoint(inSpline.TransformPercent(inStart + t * delta, inLerp)));
            }
        }
コード例 #26
0
ファイル: Loft.cs プロジェクト: Mortoc/UnityProcedural
        public Loft(ISpline path, ISpline shape)
        {
            if (path == null)
                throw new ArgumentNullException("path");
            if (shape == null)
                throw new ArgumentNullException("shape");

            Path = path;
            Shape = shape;
        }
コード例 #27
0
 private static void RedrawDraftCheck(ISpline spline, bool draft)
 {
     if (draft)
     {
         spline.Redraw(false, true, false, true);
     }
     else
     {
         spline.Redraw();
     }
 }
コード例 #28
0
 /// <summary> Caches the original world position of the spline points. Very useful for Pivotools. </summary>
 private static void CachePointsDefaultData(ISpline path, RageGroupElement item, int pathPointCount)
 {
     for (int i = 0; i < pathPointCount; i++)
     {
         item.GroupPointCache[i] = new RageGroupPointCache();
         ISplinePoint point = path.GetPointAt(i);
         item.GroupPointCache[i].PointPos   = point.Position;
         item.GroupPointCache[i].InCtrlPos  = point.InTangent;
         item.GroupPointCache[i].OutCtrlPos = point.OutTangent;
     }
 }
コード例 #29
0
        public static void DrawTestInterpolate(ISpline worldSpline, float t)
        {
            Vector3 targetPoint = worldSpline.Evaluate(t);
            float   sphereSize  = PathEditorUtility.Nice3DHandleSize(targetPoint);

            Handles.color = GetTColor(t);
            Handles.SphereCap(0, targetPoint, Quaternion.identity, sphereSize);

            Handles.color = Color.cyan;
            Handles.DrawAAPolyLine(targetPoint, targetPoint + worldSpline.Tangent(t).normalized);
        }
コード例 #30
0
ファイル: Spline.cs プロジェクト: leventeren/BeauRoutine
        /// <summary>
        /// Aligns a RectTransform to a point along the spline, using anchoredPosition.
        /// </summary>
        static public void AlignAnchorPos(ISpline inSpline, RectTransform inTransform, float inPercent, Axis inAxis, SplineLerp inLerpMethod, Curve inSegmentEase, SplineOrientationSettings inOrientation)
        {
            SplineUpdateInfo info;

            GetUpdateInfo(inSpline, inPercent, inLerpMethod, inSegmentEase, out info);
            inTransform.SetAnchorPos(info.Point, inAxis);
            if (inOrientation != null)
            {
                inOrientation.Apply(ref info, inTransform, Space.Self);
            }
        }
コード例 #31
0
    public static ISpline[] GetSplinesInChildren(GameObject go)
    {
        RageSpline[] tmp    = go.GetComponentsInChildren <RageSpline>();
        ISpline[]    result = new ISpline[tmp.Length];
        for (int i = 0; i < tmp.Length; i++)
        {
            result[i] = Adapt(tmp[i]);
        }

        return(result);
    }
コード例 #32
0
        /// <summary>
        /// Builds a cache from the results of evenly evaluating a spline.
        /// </summary>
        public static EvaluationCache EvenEvaluationCache(int cacheSize, ISpline spline, LengthCache splineLengthCache)
        {
            var points = new Vector3[cacheSize];

            for (int i = 0; i < points.Length; i++)
            {
                points[i] = EvenlyEvaluate(
                    spline,
                    (float)i / (points.Length - 1),
                    splineLengthCache);
            }

            return new EvaluationCache(points);
        }
コード例 #33
0
 /// <summary>
 /// Evaluates a spline based on the integrated length of the spline.
 /// </summary>
 public static Vector3 EvenlyEvaluate(ISpline spline, float percentLength, LengthCache splineLengthCache)
 {
     return spline.Evaluate(t_PercentLength(percentLength, splineLengthCache));
 }
コード例 #34
0
ファイル: Loft.cs プロジェクト: Mortoc/UnityProcedural
 public static Mesh GenerateMesh(ISpline path, ISpline shape, uint pathSegments, uint shapeSegments)
 {
     return new Loft(path, shape).GenerateMesh(pathSegments, shapeSegments);
 }