Beispiel #1
0
        internal static Curve CurveFromMfnNurbsCurveFromDag(MDagPath dagPath, MSpace.Space space)
        {
            Point3DCollection controlVertices;
            List <double>     weights, knots;
            int  degree;
            bool closed, rational;

            decomposeMayaCurve(dagPath, space, out controlVertices, out weights, out knots, out degree, out closed,
                               out rational);

            // var controlPoints = new List<Point>(controlVertices.Count);
            var curvePoints = new PointList(controlVertices.Count);

            if (MGlobal.isYAxisUp)
            {
                curvePoints.AddRange(controlVertices.Select(cv => Point.ByCoordinates(cv.X, -cv.Z, cv.Y)));
            }
            else
            {
                curvePoints.AddRange(controlVertices.Select(cv => Point.ByCoordinates(cv.X, cv.Y, cv.Z)));
            }

            Curve theCurve;

            if (closed)
            {
                theCurve = NurbsCurve.ByControlPoints(curvePoints, degree, true);
            }
            else
            {
                theCurve = NurbsCurve.ByControlPointsWeightsKnots(curvePoints, weights.ToArray(), knots.ToArray(),
                                                                  degree);
            }


            curvePoints.Dispose();

            return(theCurve);
        }