Beispiel #1
0
        public static void TestAutoRotationEquivalence()
        {
            var p1 = new AutoWindingPath(TestPath1, Vector3.up);
            var p2 = new AutoWindingPath(TestNormalizedPath1, Vector3.up);

            for (int i = 0; i <= 200; ++i)
            {
                double  t         = i / 200.0;
                double  adjustedT = p2.GetUnmappedTime(t);
                Vector3 norm1     = p1.GetNormal(t);
                Vector3 norm2     = p2.GetNormal(adjustedT);
                AreEqual(norm1, norm2, 0.01f);
            }
        }
Beispiel #2
0
        private IPath CalculatePath()
        {
            if (_knots.Count == 0)
            {
                return(null);
            }

            RecalculateControlPoints();

            List <IPath> paths = new List <IPath>();

            Vector3 startUp = StartUp;
            Vector3 up      = startUp;

            for (int i = 0; i < NumberOfSegments; ++i)
            {
                IPath path = GetSegmentPath(i);
                if (RotationMode == RotationMode.AutoWind)
                {
                    AutoWindingPath rotationPath = null;

                    if (i == NumberOfSegments - 1)
                    {
                        rotationPath = new AutoWindingPath(path, up, startUp);
                    }
                    else
                    {
                        rotationPath = new AutoWindingPath(path, up);
                        if (i == 0)
                        {
                            startUp = rotationPath.StartUpVector;
                        }
                    }
                    path = rotationPath;
                    up   = rotationPath.EndUpVector;
                }
                else if (RotationMode == RotationMode.PerKnotUp)
                {
                    int index     = i % _knots.Count;
                    int nextIndex = (i + 1) % _knots.Count;
                    path = new AutoWindingPath(path, _knots[index].Up, _knots[nextIndex].Up);
                }
                paths.Add(path);
            }

            return(new ChainedPath(OvershootMode, paths));
        }