Exemplo n.º 1
0
        public void receiveCurveFromMaya(string node_name, out Point3DCollection controlVertices, out List<double> weights, out List<double> knots, out int degree, out bool closed, out bool rational)
        {
            MPlug plLocal = getPlug(node_name, "local");
            MObject oLocal = new MObject();
            plLocal.getValue(oLocal);

            MFnNurbsCurve nc = new MFnNurbsCurve(oLocal);

            MPointArray p_aCVs = new MPointArray();
            nc.getCVs(p_aCVs, MSpace.Space.kWorld);
            controlVertices = new Point3DCollection();
            weights = new List<double>();
            foreach (MPoint p in p_aCVs)
            {
                controlVertices.Add(new Point3D(p.x, p.y, p.z));
                weights.Add(1.0);
            }

            double min = 0, max = 0;
            nc.getKnotDomain(ref min, ref max);
            MDoubleArray d_aKnots = new MDoubleArray();
            nc.getKnots(d_aKnots);

            knots = new List<double>();
            knots.Add(min);
            foreach (double d in d_aKnots)
            {
                knots.Add(d);
            }
            knots.Add(max);

            degree = nc.degree;
            closed = nc.form == MFnNurbsCurve.Form.kClosed ? true : false;
            rational = true;
        }
Exemplo n.º 2
0
        public void receiveCurveFromMaya(string node_name, out Point3DCollection controlVertices, out List <double> weights, out List <double> knots, out int degree, out bool closed, out bool rational)
        {
            MPlug   plLocal = getPlug(node_name, "local");
            MObject oLocal  = new MObject();

            plLocal.getValue(oLocal);

            MFnNurbsCurve nc = new MFnNurbsCurve(oLocal);

            MPointArray p_aCVs = new MPointArray();

            nc.getCVs(p_aCVs, MSpace.Space.kWorld);
            controlVertices = new Point3DCollection();
            weights         = new List <double>();
            foreach (MPoint p in p_aCVs)
            {
                controlVertices.Add(new Point3D(p.x, p.y, p.z));
                weights.Add(1.0);
            }

            double min = 0, max = 0;

            nc.getKnotDomain(ref min, ref max);
            MDoubleArray d_aKnots = new MDoubleArray();

            nc.getKnots(d_aKnots);

            knots = new List <double>();
            knots.Add(min);
            foreach (double d in d_aKnots)
            {
                knots.Add(d);
            }
            knots.Add(max);

            degree   = nc.degree;
            closed   = nc.form == MFnNurbsCurve.Form.kClosed ? true : false;
            rational = true;
        }
Exemplo n.º 3
0
        public void receiveCurveFromMaya(string nodeName, int space, out Point3DCollection controlVertices,
                                         out List <double> weights, out List <double> knots, out int degree, out bool closed, out bool rational)
        {
            var dagnode = getDagNode(nodeName);
            var nc      = new MFnNurbsCurve(dagnode);

            var p_aCVs = new MPointArray();

            switch (space)
            {
            case 0:     //object
                nc.getCVs(p_aCVs, MSpace.Space.kObject);
                break;

            case 1:     //world
                nc.getCVs(p_aCVs, MSpace.Space.kWorld);
                break;

            default:
                nc.getCVs(p_aCVs, MSpace.Space.kWorld);
                break;
            }


            controlVertices = new Point3DCollection();
            weights         = new List <double>();
            if (MGlobal.isZAxisUp)
            {
                foreach (var p in p_aCVs)
                {
                    controlVertices.Add(new Point3D(p.x, p.y, p.z));
                    weights.Add(1.0);
                }
            }
            else
            {
                foreach (var p in p_aCVs)
                {
                    controlVertices.Add(new Point3D(p.x, -p.z, p.y));
                    weights.Add(1.0);
                }
            }

            double min = 0, max = 0;

            nc.getKnotDomain(ref min, ref max);
            var d_aKnots = new MDoubleArray();

            nc.getKnots(d_aKnots);

            knots = new List <double>();
            knots.Add(min);
            foreach (var d in d_aKnots)
            {
                knots.Add(d);
            }
            knots.Add(max);

            degree   = nc.degree;
            closed   = nc.form == MFnNurbsCurve.Form.kClosed ? true : false;
            rational = true;
        }
Exemplo n.º 4
0
        internal static void decomposeMayaCurve(MDagPath dagnode, MSpace.Space space,
                                                out Point3DCollection controlVertices, out List <double> weights, out List <double> knots, out int degree,
                                                out bool closed, out bool rational)
        {
            var nc     = new MFnNurbsCurve(dagnode);
            var cvct   = nc.numSpans;
            var p_aCVs = new MPointArray();

            degree   = nc.degree;
            closed   = nc.form == MFnNurbsCurve.Form.kPeriodic ? true : false;
            rational = true;
            nc.getCVs(p_aCVs, space);


            controlVertices = new Point3DCollection();
            weights         = new List <double>();
            if (MGlobal.isYAxisUp)
            {
                if (closed)
                {
                    for (var i = 0; i < cvct; i++)
                    {
                        controlVertices.Add(new Point3D(p_aCVs[i].x, p_aCVs[i].y, p_aCVs[i].z));
                        weights.Add(1.0);
                    }
                }
                else
                {
                    foreach (var p in p_aCVs)
                    {
                        controlVertices.Add(new Point3D(p.x, p.y, p.z));
                        weights.Add(1.0);
                    }
                }
            }
            else
            {
                if (closed)
                {
                    for (var i = 0; i < cvct; i++)
                    {
                        controlVertices.Add(new Point3D(p_aCVs[i].x, -p_aCVs[i].z, p_aCVs[i].y));
                        weights.Add(1.0);
                    }
                }
                else
                {
                    foreach (var p in p_aCVs)
                    {
                        controlVertices.Add(new Point3D(p.x, -p.z, p.y));
                        weights.Add(1.0);
                    }
                }
            }

            double min = 0, max = 0;

            nc.getKnotDomain(ref min, ref max);
            var d_aKnots = new MDoubleArray();

            nc.getKnots(d_aKnots);

            knots = new List <double>();
            knots.Add(min);
            knots.AddRange(d_aKnots);
            knots.Add(max);

            nc.Dispose();
            d_aKnots.Dispose();
        }