예제 #1
0
        public void sendCurveToMaya(string node_name, Point3DCollection controlVertices, List <double> knots, int degree,
                                    MFnNurbsCurveForm form)
        {
            var dn             = new MFnDagNode(getDagNode(node_name));
            var plCreate       = dn.findPlug("create");
            var plDynamoCreate = new MPlug();

            try
            {
                plDynamoCreate = dn.findPlug("dynamoCreate");
            }
            catch
            {
                var tAttr           = new MFnTypedAttribute();
                var ldaDynamoCreate = tAttr.create("dynamoCreate", "dc", MFnData.Type.kNurbsCurve, MObject.kNullObj);
                try
                {
                    dn.addAttribute(ldaDynamoCreate, MFnDependencyNode.MAttrClass.kLocalDynamicAttr);
                    plDynamoCreate = dn.findPlug(ldaDynamoCreate);
                    var dagm = new MDagModifier();
                    dagm.connect(plDynamoCreate, plCreate);
                    dagm.doIt();
                }
                catch
                {
                    return;
                }
            }

            var ncd    = new MFnNurbsCurveData();
            var oOwner = ncd.create();
            var nc     = new MFnNurbsCurve();

            var p_aControlVertices = new MPointArray();

            foreach (var p in controlVertices)
            {
                p_aControlVertices.Add(new MPoint(p.X, p.Y, p.Z));
            }

            var d_aKnots = new MDoubleArray();

            for (var i = 1; i < knots.Count - 1; ++i)
            {
                d_aKnots.Add(knots[i]);
            }

            nc.create(p_aControlVertices, d_aKnots, (uint)degree, (MFnNurbsCurve.Form)form, false, true, oOwner);

            plDynamoCreate.setMObject(oOwner);

            MGlobal.executeCommandOnIdle(string.Format("dgdirty {0}.create;", node_name));
        }
예제 #2
0
        public void sendCurveToMaya(string node_name, Point3DCollection controlVertices, List<double> knots, int degree, MFnNurbsCurveForm form)
        {
            MFnDagNode dn = new MFnDagNode(getDagNode(node_name));
            MPlug plCreate = dn.findPlug("create");
            MPlug plDynamoCreate = new MPlug();

            try
            {
                plDynamoCreate = dn.findPlug("dynamoCreate");
            }
            catch
            {
                MFnTypedAttribute tAttr = new MFnTypedAttribute();
                MObject ldaDynamoCreate = tAttr.create("dynamoCreate", "dc", MFnData.Type.kNurbsCurve, MObject.kNullObj);
                try
                {
                    dn.addAttribute(ldaDynamoCreate, MFnDependencyNode.MAttrClass.kLocalDynamicAttr);
                    plDynamoCreate = dn.findPlug(ldaDynamoCreate);
                    MDagModifier dagm = new MDagModifier();
                    dagm.connect(plDynamoCreate, plCreate);
                    dagm.doIt();
                }
                catch
                {
                    return;
                }
            }

            MFnNurbsCurveData ncd = new MFnNurbsCurveData();
            MObject oOwner = ncd.create();
            MFnNurbsCurve nc = new MFnNurbsCurve();

            MPointArray p_aControlVertices = new MPointArray();
            foreach (Point3D p in controlVertices)
            {
                p_aControlVertices.Add(new MPoint(p.X, p.Y, p.Z));
            }

            MDoubleArray d_aKnots = new MDoubleArray();
            for (int i = 1; i < knots.Count - 1; ++i )
            {
                d_aKnots.Add(knots[i]);
            }

            nc.create(p_aControlVertices, d_aKnots, (uint)degree, (MFnNurbsCurve.Form)form, false, true, oOwner);

            plDynamoCreate.setMObject(oOwner);

            MGlobal.executeCommandOnIdle(String.Format("dgdirty {0}.create;", node_name));
        }