예제 #1
0
 public polyPrimitive()
 {
     iarr         = new MFloatPointArray();
     pa           = new MFloatPointArray();
     faceCounts   = new MIntArray();
     faceConnects = new MIntArray();
     dagMod       = new MDagModifier();
     MGlobal.displayInfo("test polyPrimitive.");
 }
예제 #2
0
        public static void RenameDagList(MDagPath[] dagList, string formatStr)
        {
            MDagModifier dagModifier = new MDagModifier();

            for (int i = 0; i < dagList.Length; i++)
            {
                dagModifier.renameNode(dagList[i].node, string.Format(formatStr, i));
            }
            dagModifier.doIt();
        }
        public override void doIt(MArgList argl)
        {
            MGlobal.displayInfo("Hello World\n");

            _dagModifier = new MDagModifier();

            _transform = _dagModifier.createNode("camera");
            _dagModifier.renameNode(_transform, "motionCamera");

            redoIt();
        }
예제 #4
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));
        }
예제 #5
0
        private void setMeshData(MObject transform, MObject dataWrapper)
        {
            // Get the mesh node.
            MFnDagNode dagFn = new MFnDagNode(transform);
            MObject    mesh  = dagFn.child(0);

            // The mesh node has two geometry inputs: 'inMesh' and 'cachedInMesh'.
            // 'inMesh' is only used when it has an incoming connection, otherwise
            // 'cachedInMesh' is used. Unfortunately, the docs say that 'cachedInMesh'
            // is for internal use only and that changing it may render Maya
            // unstable.
            //
            // To get around that, we do the little dance below...

            // Use a temporary MDagModifier to create a temporary mesh attribute on
            // the node.
            MFnTypedAttribute tAttr    = new MFnTypedAttribute();
            MObject           tempAttr = tAttr.create("tempMesh", "tmpm", MFnData.Type.kMesh);
            MDagModifier      tempMod  = new MDagModifier();

            tempMod.addAttribute(mesh, tempAttr);

            tempMod.doIt();

            // Set the geometry data onto the temp attribute.
            dagFn.setObject(mesh);

            MPlug tempPlug = dagFn.findPlug(tempAttr);

            tempPlug.setValue(dataWrapper);

            // Use the temporary MDagModifier to connect the temp attribute to the
            // node's 'inMesh'.
            MPlug inMeshPlug = dagFn.findPlug("inMesh");

            tempMod.connect(tempPlug, inMeshPlug);

            tempMod.doIt();

            // Force the mesh to update by grabbing its output geometry.
            dagFn.findPlug("outMesh").asMObject();

            // Undo the temporary modifier.
            tempMod.undoIt();
        }
예제 #6
0
 public lineManipCmd()
 {
     modifier = new MDagModifier();
 }
예제 #7
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));
        }
예제 #8
0
 public lineManipCmd()
 {
     modifier = new MDagModifier();
 }
예제 #9
0
		private void setMeshData(MObject transform, MObject dataWrapper)
		{
			// Get the mesh node.
			MFnDagNode  dagFn = new MFnDagNode(transform);
			MObject     mesh = dagFn.child(0);

			// The mesh node has two geometry inputs: 'inMesh' and 'cachedInMesh'.
			// 'inMesh' is only used when it has an incoming connection, otherwise
			// 'cachedInMesh' is used. Unfortunately, the docs say that 'cachedInMesh'
			// is for internal use only and that changing it may render Maya
			// unstable.
			//
			// To get around that, we do the little dance below...

			// Use a temporary MDagModifier to create a temporary mesh attribute on
			// the node.
			MFnTypedAttribute  tAttr = new MFnTypedAttribute();
			MObject tempAttr = tAttr.create("tempMesh", "tmpm", MFnData.Type.kMesh);
			MDagModifier tempMod = new MDagModifier();

			tempMod.addAttribute(mesh, tempAttr);

			tempMod.doIt();

			// Set the geometry data onto the temp attribute.
			dagFn.setObject(mesh);

			MPlug  tempPlug = dagFn.findPlug(tempAttr);

			tempPlug.setValue(dataWrapper);

			// Use the temporary MDagModifier to connect the temp attribute to the
			// node's 'inMesh'.
			MPlug  inMeshPlug = dagFn.findPlug("inMesh");
	
			tempMod.connect(tempPlug, inMeshPlug);

			tempMod.doIt();

			// Force the mesh to update by grabbing its output geometry.
			dagFn.findPlug("outMesh").asMObject();

			// Undo the temporary modifier.
			tempMod.undoIt();
		}
예제 #10
0
		public polyPrimitive()
		{
			iarr = new MFloatPointArray();
			pa = new MFloatPointArray();
			faceCounts = new MIntArray();
			faceConnects = new MIntArray();
			dagMod = new MDagModifier();
			MGlobal.displayInfo("test polyPrimitive.");
		}
예제 #11
0
        private void dynMeshToMayaMesh(string name, Mesh dynMesh = null, TSplineSurface tsMesh = null)
        {
            bool     nodeExists = false;
            MDagPath node       = null;
            Task     unpackTask = null;
            Task     mobjTask   = null;

            try
            {
                node       = DMInterop.getDagNode(name);
                nodeExists = true;
            }
            catch (Exception)
            {
                nodeExists = false;
            }

            MIntArray        faceCnx   = new MIntArray();
            MFloatPointArray verticies = new MFloatPointArray();
            MIntArray        faceVtxCt = new MIntArray();
            int numVert = 0;
            int numPoly = 0;

            if (dynMesh != null)
            {
                numVert    = dynMesh.VertexPositions.Length;
                numPoly    = dynMesh.FaceIndices.Length;
                unpackTask = Task.Factory.StartNew(() => unpackDynMesh(dynMesh, out faceCnx, out verticies, out faceVtxCt));
                unpackTask.Wait(4000);
            }

            if (tsMesh != null)
            {
                numVert    = tsMesh.VerticesCount;
                numPoly    = tsMesh.FacesCount;
                unpackTask = Task.Factory.StartNew(() => unpackTsMesh(tsMesh, out faceCnx, out verticies, out faceVtxCt));
                unpackTask.Wait(4000);
            }



            if (nodeExists)
            {
                try
                {
                    meshFn = new MFnMesh(node);
                    meshFn.createInPlace(numVert, numPoly, verticies, faceVtxCt, faceCnx);
                }
                catch (Exception e)
                {
                    MGlobal.displayWarning(e.Message);
                }
            }
            else
            {
                try
                {
                    dagMod = new MDagModifier();
                    // Create a mesh data wrapper to hold the new geometry.
                    MFnMeshData dataFn      = new MFnMeshData();
                    MObject     dataWrapper = dataFn.create();

                    // Create the mesh geometry and put it into the wrapper.
                    meshFn = new MFnMesh();
                    MObject dataObj   = meshFn.create(numVert, numPoly, verticies, faceVtxCt, faceCnx, dataWrapper);
                    MObject transform = dagMod.createNode("mesh", MObject.kNullObj);

                    dagMod.doIt();

                    renameNodes(transform, name);
                    dagMod.doIt();
                    assignShadingGroup(transform, "initialShadingGroup");
                    dagMod.doIt();
                    setMeshData(transform, dataWrapper);
                }
                catch (Exception e)
                {
                    MGlobal.displayWarning(e.Message);
                }
            }

            //GC.Collect();
            //GC.WaitForPendingFinalizers();
        }