示例#1
0
        public override void doIt(MArgList args)
        {
            // Command line argument specifies type of primitive to create
            //
            shapeFlag = 1;
            if (args.length > 0)
            {
                shapeFlag = args.asInt(0);
            }

            // Create the mesh and its transform.
            try
            {
                createNodes();
            }
            catch (System.Exception)
            {
                // If the creation failed, clean up any partial changes made.
                dagMod.undoIt();
                throw;                //Rethrow the same exception
            }

            return;
        }
示例#2
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();
        }
示例#3
0
 public override void undoIt()
 {
     modifier.undoIt();
     return;
 }
示例#4
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();
		}