Beispiel #1
0
        public override void doIt(MArgList args)
        {
            MArgDatabase argData = new MArgDatabase(syntax, args);

            bool creating = true;

            if (argData.isFlagSet(kCreateFlag))
            {
                creating = true;
            }
            else if (argData.isFlagSet(kDeleteFlag))
            {
                creating = false;
            }
            else
            {
                throw new ArgumentException("Command Syntax is incorrect", "args");
            }

            if (creating)
            {
                lineManipObj = modifier.createNode("simpleLineManipCSharp", MObject.kNullObj);
            }
            else
            {
                if (lineManipObj != null)
                {
                    modifier.deleteNode(lineManipObj);
                }
                lineManipObj = null;
            }

            redoIt();
        }
        public override void doIt(MArgList argl)
        {
            MGlobal.displayInfo("Hello World\n");

            _dagModifier = new MDagModifier();

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

            redoIt();
        }
Beispiel #3
0
        private void createNodes()
        {
            // Generate the raw data for the requested primitive.
            generatePrimitiveData();

            // 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.
            MFnMesh meshFn  = new MFnMesh();
            MObject dataObj = meshFn.create(
                num_verts,
                num_faces,
                pa,
                faceCounts,
                faceConnects,
                dataWrapper
                );

            // Use the DAG modifier to create an empty mesh node and its parent
            // transform.
            MObject transform = dagMod.createNode("mesh", MObject.kNullObj);

            // Commit the creation so that the transform and its child will be
            // valid below.
            dagMod.doIt();

            // At the moment we have a transform named something like 'transform1'
            // and a mesh named something like 'polySurfaceShape1'. Let's tidy that
            // up by renaming them as 'pPrimitive#' and 'pPrimitiveShape#', where
            // '#' is a number to ensure uniqueness.
            renameNodes(transform, "pPrimitive");
            // Commit the rename so that assignShadingGroup() can get the new name.
            dagMod.doIt();

            // Assign the mesh to a shading group.
            assignShadingGroup(transform, "initialShadingGroup");

            // Commit the changes.
            dagMod.doIt();

            // Set the mesh node to use the geometry we created for it.
            setMeshData(transform, dataWrapper);
        }
Beispiel #4
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();
        }