Beispiel #1
0
        public static Mesh MorphToSplineCopy(
            Mesh mesh,
            Vector3 axis,
            Gem.Math.Spline spline)
        {
            var result = Copy(mesh);

            MorphToSpline(result, axis, spline);
            return(result);
        }
Beispiel #2
0
        public static Mesh AlignToSplineCopy(
            Mesh mesh,
            Vector3 axis,
            Vector3 splineRotationAxis,
            Gem.Math.Spline spline,
            float distance)
        {
            var result = Copy(mesh);

            AlignToSpline(result, axis, splineRotationAxis, spline, distance);
            return(result);
        }
Beispiel #3
0
 /// <summary>
 /// Align the object with the spline. Transforms object so that its origin is on the spline.
 /// </summary>
 /// <returns></returns>
 public static void AlignToSpline(
     Mesh mesh,
     Vector3 axis,
     Vector3 splineRotationAxis,
     Gem.Math.Spline spline,
     float distance)
 {
     Morph(mesh, (v) =>
     {
         var splinePoint   = spline.Point(distance);
         var splineTangent = spline.Tangent(distance);
         var m             = Matrix.CreateFromAxisAngle(Vector3.Normalize(splineRotationAxis),
                                                        Gem.Math.Vector.AngleBetweenVectors(axis, splineTangent));
         return(splinePoint + Vector3.Transform(v, m));
     });
 }
Beispiel #4
0
        /// <summary>
        /// Morph the object onto a spline. Expects the object's origin to already be aligned with the spline.
        /// </summary>
        /// <returns></returns>
        public static void MorphToSpline(
            Mesh mesh,
            Vector3 axis,
            Gem.Math.Spline spline)
        {
            Morph(mesh, (v) =>
            {
                var distance      = Gem.Math.Vector.ProjectAOntoB(v, axis).Length() / axis.Length();
                var splinePoint   = spline.Point(distance);
                var splineTangent = spline.Tangent(distance);
                var rel           = (axis * distance) - v;
                var m             = Matrix.CreateFromAxisAngle(Vector3.Normalize(spline.RotationAxis),//splineRotationAxis),
                                                               Gem.Math.Vector.AngleBetweenVectors(axis, splineTangent));


                return(splinePoint + Vector3.Transform(rel, m));
            });
        }