コード例 #1
0
ファイル: VectorTest.cs プロジェクト: LiruJ/LiruGameHelper
        public void ThreeValueValidVector3Test()
        {
            Vector3 vector = new Vector3(74, 102, -50);
            Vector3 output = ToVector3.Parse("74, 102, -50");

            Assert.AreEqual(vector, output, $"The expected vector ({vector}) did not match the returned vector ({output}).");
        }
コード例 #2
0
ファイル: VectorTest.cs プロジェクト: LiruJ/LiruGameHelper
        public void ThreeValueTryValidVector3Test()
        {
            Vector3 vector = new Vector3(15, 62, -30);

            Assert.IsTrue(ToVector3.TryParse("15, 62, -30", out Vector3 output), "TryParse returned false.");
            Assert.AreEqual(vector, output, $"TryParse returned true but the expected vector ({vector}) did not match the returned vector ({output}).");
        }
コード例 #3
0
    private static IEnumerable <Vector3> NewCatmullRom <T>(IList nodes, ToVector3 <T> toVector3, Int32 slices, Boolean loop)
    {
        if (nodes.Count >= 2)
        {
            yield return(toVector3((T)nodes[0]));

            Int32 last    = nodes.Count - 1;
            Int32 current = 0;
            while (loop || current < last)
            {
                if (loop && current > last)
                {
                    current = 0;
                }
                Int32 previous  = (current != 0) ? (current - 1) : ((!loop) ? current : last);
                Int32 start     = current;
                Int32 end       = (current != last) ? (current + 1) : ((!loop) ? current : 0);
                Int32 next      = (end != last) ? (end + 1) : ((!loop) ? end : 0);
                Int32 stepCount = slices + 1;
                for (Int32 step = 1; step <= stepCount; step++)
                {
                    yield return(CatmullRom(toVector3((T)nodes[previous]), toVector3((T)nodes[start]), toVector3((T)nodes[end]), toVector3((T)nodes[next]), step, stepCount));
                }
                current++;
            }
        }
        yield break;
    }
コード例 #4
0
ファイル: VectorTest.cs プロジェクト: LiruJ/LiruGameHelper
        public void ThreeValueDecimalTest()
        {
            // Save the current culture.
            CultureInfo currentCulture = CultureInfo.CurrentCulture;

            // Set the culture to German, as it uses the ',' character for decimal places which should break parsing if not accounted for.
            CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("de-DE");

            Vector3 vector = new Vector3(74.67f, 102.12f, -50.0582f);
            Vector3 output = ToVector3.Parse("74.67, 102.12, -50.0582");

            // Set the culture back so that the error message displays correctly.
            CultureInfo.CurrentCulture = currentCulture;

            Assert.AreEqual(vector, output);
        }
コード例 #5
0
 private static IEnumerable <Vector3> NewBezier <T>(Function ease, IList nodes, ToVector3 <T> toVector3, Single maxStep, IEnumerable <Single> steps)
 {
     if (nodes.Count >= 2)
     {
         Vector3[] points = new Vector3[nodes.Count];
         foreach (Single num in steps)
         {
             Single step = num;
             for (Int32 i = 0; i < nodes.Count; i++)
             {
                 points[i] = toVector3((T)nodes[i]);
             }
             yield return(Bezier(ease, points, step, maxStep));
         }
     }
     yield break;
 }
コード例 #6
0
 /**
  * Generic bezier spline sequence generator used to implement the time and
  * slice variants. Normally you would not use this function directly.
  */
 static IEnumerable <Vector3> NewBezier <T>(Function ease, IList nodes, ToVector3 <T> toVector3, float maxStep, IEnumerable <float> steps)
 {
     // need at least two nodes to spline between
     if (nodes.Count >= 2)
     {
         // copy nodes array since Bezier is destructive
         Vector3[] points = new Vector3[nodes.Count];
         foreach (float step in steps)
         {
             // re-initialize copy before each destructive call to Bezier
             for (int i = 0; i < nodes.Count; i++)
             {
                 points[i] = toVector3((T)nodes[i]);
             }
             yield return(Bezier(ease, points, step, maxStep));
             // make sure last value is always generated
         }
     }
 }
コード例 #7
0
ファイル: Interpolate.cs プロジェクト: desmond0412/LegacyWTOS
        /// <summary>
        /// Generic catmull-rom spline sequence generator used to implement the
        /// Vector3[] and Transform[] variants. Normally you would not use this
        /// function directly.
        /// </summary>
        /// <param name="nodes">
        /// A <see cref="IList"/>
        /// </param>
        /// <param name="toVector3">
        /// A <see cref="ToVector3<T>"/>
        /// </param>
        /// <param name="slices">
        /// A <see cref="System.Int32"/>
        /// </param>
        /// <param name="loop">
        /// A <see cref="System.Boolean"/>
        /// </param>
        /// <returns>
        /// A <see cref="IEnumerable<Vector3>"/>
        /// </returns>
        static IEnumerable <Vector3> NewCatmullRom <T>(IList nodes, ToVector3 <T> toVector3, int slices, bool loop)
        {
            // need at least two nodes to spline between
            if (nodes.Count >= 2)
            {
                // yield the first point explicitly, if looping the first point
                // will be generated again in the step for loop when interpolating
                // from last point back to the first point
                yield return(toVector3((T)nodes[0]));

                int last = nodes.Count - 1;
                for (int current = 0; loop || current < last; current++)
                {
                    // wrap around when looping
                    if (loop && current > last)
                    {
                        current = 0;
                    }
                    // handle edge cases for looping and non-looping scenarios
                    // when looping we wrap around, when not looping use start for
                    // previous and end for next when you at the ends of the nodes
                    // array
                    int previous = (current == 0) ? ((loop) ? last : current) : current - 1;
                    int start    = current;
                    int end      = (current == last) ? ((loop) ? 0 : current) : current + 1;
                    int next     = (end == last) ? ((loop) ? 0 : end) : end + 1;

                    // adding one guarantees yielding at least the end point
                    int stepCount = slices + 1;
                    for (int step = 1; step <= stepCount; step++)
                    {
                        yield return(CatmullRom(toVector3((T)nodes[previous]),
                                                toVector3((T)nodes[start]),
                                                toVector3((T)nodes[end]),
                                                toVector3((T)nodes[next]),
                                                step, stepCount));
                    }
                }
            }
        }
コード例 #8
0
ファイル: NgInterpolate.cs プロジェクト: isoundy000/wzry-1
 private static IEnumerable <Vector3> NewBezier <T>(Function ease, IList nodes, ToVector3 <T> toVector3, float maxStep, IEnumerable <float> steps)
 {
     return(new < NewBezier > c__IteratorB <T> {
         nodes = nodes, steps = steps, toVector3 = toVector3, ease = ease, maxStep = maxStep, <$> nodes = nodes, <$> steps = steps, <$> toVector3 = toVector3, <$> ease = ease, <$> maxStep = maxStep, $PC = -2
     });
コード例 #9
0
        private void btn_RayCast_Click(object sender, EventArgs e)
        {
            if (BotMain.IsRunning)
            {
                return;
            }

            ZetaDia.Memory.ClearCache();
            ZetaDia.Actors.Update();
            Navigator.SearchGridProvider.Update();


            flowLayout_OutPut.Controls.Clear();


            float   FromX, FromY, FromZ, ToX, ToY, ToZ;
            Vector3 FromVector3, ToVector3;

            try
            {
                if (!Raycast_UsingPlayerLocation)
                {
                    FromVector3 = ConvertTextToVector3(txtbox_Raycast_X.Text, txtbox_Raycast_Y.Text, txtbox_Raycast_Z.Text);
                    if (FromVector3 == Vector3.Zero)
                    {
                        return;
                    }
                }
                else
                {
                    FromVector3 = ZetaDia.Me.Position;
                }

                ToVector3 = ConvertTextToVector3(txtbox_RaycastTo_X.Text, txtbox_RaycastTo_Y.Text, txtbox_RaycastTo_Z.Text);
                if (ToVector3 == Vector3.Zero)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                var exceptionEntry = new UserControlDebugEntry(String.Format("{0}\r\n{1}", ex.Message, ex.StackTrace));
                flowLayout_OutPut.Controls.Add(exceptionEntry);
                return;
            }

            bool raycast = Navigator.Raycast(FromVector3, ToVector3);
            var  entry   = new UserControlDebugEntry(String.Format("Navigator Raycast={0} ({1} to {2}", raycast, FromVector3, ToVector3));

            flowLayout_OutPut.Controls.Add(entry);

            raycast = ZetaDia.Physics.Raycast(FromVector3, ToVector3, NavCellFlags.AllowWalk);
            entry   = new UserControlDebugEntry(String.Format("Physics Raycast={0} ({1} to {2}", raycast, FromVector3, ToVector3));
            flowLayout_OutPut.Controls.Add(entry);

            Vector2 outHitPoint;

            raycast = Navigator.SearchGridProvider.Raycast(FromVector3.ToVector2(), ToVector3.ToVector2(), out outHitPoint);
            entry   = new UserControlDebugEntry(String.Format("SearchGridProvider Raycast={0} HitPoint: ({1}) ({2} to {3}", raycast, outHitPoint, FromVector3, ToVector3));
            flowLayout_OutPut.Controls.Add(entry);
        }