当前位置: 首页>>代码示例>>C#>>正文


C# MObject类代码示例

本文整理汇总了C#中MObject的典型用法代码示例。如果您正苦于以下问题:C# MObject类的具体用法?C# MObject怎么用?C# MObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MObject类属于命名空间,在下文中一共展示了MObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: doIt

        //
        // Takes the  nodes that are on the active selection list and adds an
        // attribute changed callback to each one.
        //
        public override void doIt(MArgList args)
        {
            MObject 		node = new MObject();
            MSelectionList 	list = new MSelectionList();

            // Register node callbacks for all nodes on the active list.
            //
            MGlobal.getActiveSelectionList( list );

            for ( uint i=0; i<list.length; i++ )
            {
                list.getDependNode( i, node );

                try
                {
                    node.AttributeChanged += userCB;
                }
                catch (Exception)
                {
                    MGlobal.displayInfo("MNodeMessage.addCallback failed\n");
                    continue;
                }

                // C# SDK will cleanup events, when this plugin is unloaded
                // callbacks.append(node);
            }

            return;
        }
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:33,代码来源:nodeMessageCmd.cs

示例2: connectNodeToAttr

        //
        //    Description:
        //        Overloaded function from MPxDragAndDropBehavior
        //    this method will assign the correct output from the slope shader
        //    onto the given attribute.
        //
        public override void connectNodeToAttr(MObject sourceNode, MPlug destinationPlug, bool force)
        {
            MFnDependencyNode src = new MFnDependencyNode(sourceNode);

            //if we are dragging from a slopeShaderNodeCSharp
            //to a shader than connect the outColor
            //plug to the plug being passed in
            //
            if(destinationPlug.node.hasFn(MFn.Type.kLambert)) {
                if (src.typeName == "slopeShaderNodeCSharp")
                {
                    MPlug srcPlug = src.findPlug("outColor");
                    if(!srcPlug.isNull && !destinationPlug.isNull)
                    {
                        string cmd = "connectAttr ";
                        cmd += srcPlug.name + " ";
                        cmd += destinationPlug.name;
                        MGlobal.executeCommand(cmd);
                    }
                }
            } else {
                //in all of the other cases we do not need the plug just the node
                //that it is on
                //
                MObject destinationNode = destinationPlug.node;
                connectNodeToNode(sourceNode, destinationNode, force);
            }
        }
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:34,代码来源:slopeShader.cs

示例3: checkArgs

		//======================================================================
		//
		// Check the parsed arguments and do/undo/redo the command as appropriate
		//
		void checkArgs(ref MArgDatabase argsDb)
		{
			MSelectionList objects = new MSelectionList();

            argsDb.getObjects(objects);

			for (uint i = 0; i < objects.length; ++i)
			{
                MDagPath dagPath = new MDagPath();
                objects.getDagPath((uint)i, dagPath);
                MFnDagNode dagNode = new MFnDagNode(dagPath.node);
                MObject obj = dagNode.child(0);
                if (obj.apiTypeStr == "kMesh")
                {
                    fMesh = new MFnMesh(obj);
                    fObj = obj;
                    fObjTransform = dagPath.node;
                }
			}

			if( fMesh == null || fObj == null || fObjTransform == null )
			{
				string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kObjectNotFoundError);
				throw new ArgumentException(errMsg, "argsDb");
			}
		}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:30,代码来源:CreateMetadataFromTypeCmd.cs

示例4: receiveCurveFromMaya

        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;
        }
开发者ID:MrWalsh,项目名称:DynaMaya-WIP,代码行数:35,代码来源:DynamoMayaService.cs

示例5: apiMeshGeomIterator

        public apiMeshGeomIterator(object userGeometry, MObject component)
            : base(userGeometry, component)
        {
            meshGeometry = (apiMeshGeom)userGeometry;

            reset();
        }
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:7,代码来源:apiMeshIterator.cs

示例6: addComplexFloatGenericAttribute

        // Adds a generic attribute that accepts a float, float2, float3
        public static void addComplexFloatGenericAttribute(ref MObject attrObject, string longName, string shortName)
        {
            // Create the generic attribute and set the 3 accepts types
            MFnGenericAttribute gAttr = new MFnGenericAttribute();
            attrObject = gAttr.create( longName, shortName );
            try
            {
                gAttr.addAccept(MFnNumericData.Type.kFloat);

                gAttr.addAccept(MFnNumericData.Type.k2Float);

                gAttr.addAccept(MFnNumericData.Type.k3Float);
            }
            catch (System.Exception)
            {
                MGlobal.displayError("error happens in addAccept");
            }

            gAttr.isWritable = false;
            gAttr.isStorable = false;

            // Add the attribute to the node
            try
            {
                addAttribute(attrObject);
            }
            catch (System.Exception)
            {
                MGlobal.displayError("error happens in addAttribute");
            }
        }
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:32,代码来源:genericAttributeNode.cs

示例7: Awake

    protected override void Awake()
    {
        base.Awake();

        if (_rTrans == null) _rTrans = GetComponent<RectTransform>();
        if (_mObj == null) _mObj = transform.GetComponentInParentRecursively<MObject>();
    }
开发者ID:SoulfulSolutions,项目名称:The_Last_Ranger,代码行数:7,代码来源:MObjTranslate.cs

示例8: connectToDependNode

        public override void connectToDependNode(MObject node)
        {

            // Find the rotate and rotatePivot plugs on the node.  These plugs will 
            // be attached either directly or indirectly to the manip values on the
            // rotate manip.
            //
            MFnDependencyNode nodeFn = new MFnDependencyNode(node);
            MPlug rPlug = nodeFn.findPlug("rotate");
            MPlug rcPlug = nodeFn.findPlug("rotatePivot");

            // If the translate pivot exists, it will be used to move the state manip
            // to a convenient location.
            //
            MPlug tPlug = nodeFn.findPlug("translate");

            // To avoid having the object jump back to the default rotation when the
            // manipulator is first used, extract the existing rotation from the node
            // and set it as the initial rotation on the manipulator.
            //
            MEulerRotation existingRotation = new MEulerRotation(vectorPlugValue(rPlug));
            MVector existingTranslation = new MVector(vectorPlugValue(tPlug));

            // 
            // The following code configures default settings for the rotate 
            // manipulator.
            //

            MFnRotateManip rotateManip = new MFnRotateManip(fRotateManip);
            rotateManip.setInitialRotation(existingRotation);
            rotateManip.setRotateMode(MFnRotateManip.RotateMode.kObjectSpace);
            rotateManip.displayWithNode(node);

            // Add a callback function to be called when the rotation value changes
            //

            //rotatePlugIndex = addManipToPlugConversionCallback( rPlug, (manipToPlugConversionCallback)&exampleRotateManip::rotationChangedCallback );
            ManipToPlugConverion[rPlug] = rotationChangedCallback;
            // get the index of plug
            rotatePlugIndex = this[rPlug];

            // Create a direct (1-1) connection to the rotation center plug
            //
            rotateManip.connectToRotationCenterPlug(rcPlug);

            // Place the state manip at a distance of 2.0 units away from the object
            // along the X-axis.
            //
            MFnStateManip stateManip = new MFnStateManip(fStateManip);
            MVector delta = new MVector(2, 0, 0);
            stateManip.setTranslation(existingTranslation + delta,
                MSpace.Space.kTransform);

            finishAddingManips();
            base.connectToDependNode(node);
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:56,代码来源:rotateManip.cs

示例9: createMesh

        protected MObject createMesh(MTime time, ref MObject outData)
        {
            int numVertices, frame;
            float cubeSize;
            MFloatPointArray points = new MFloatPointArray();
            MFnMesh meshFS = new MFnMesh();

            // Scale the cube on the frame number, wrap every 10 frames.
            frame = (int)time.asUnits(MTime.Unit.kFilm);
            if (frame == 0)
                frame = 1;
            cubeSize = 0.5f * (float)(frame % 10);

            const int numFaces = 6;
            numVertices = 8;

            MFloatPoint vtx_1 = new MFloatPoint(-cubeSize, -cubeSize, -cubeSize);
            MFloatPoint vtx_2 = new MFloatPoint(cubeSize, -cubeSize, -cubeSize);
            MFloatPoint vtx_3 = new MFloatPoint(cubeSize, -cubeSize, cubeSize);
            MFloatPoint vtx_4 = new MFloatPoint(-cubeSize, -cubeSize, cubeSize);
            MFloatPoint vtx_5 = new MFloatPoint(-cubeSize, cubeSize, -cubeSize);
            MFloatPoint vtx_6 = new MFloatPoint(-cubeSize, cubeSize, cubeSize);
            MFloatPoint vtx_7 = new MFloatPoint(cubeSize, cubeSize, cubeSize);
            MFloatPoint vtx_8 = new MFloatPoint(cubeSize, cubeSize, -cubeSize);
            points.append(vtx_1);
            points.append(vtx_2);
            points.append(vtx_3);
            points.append(vtx_4);
            points.append(vtx_5);
            points.append(vtx_6);
            points.append(vtx_7);
            points.append(vtx_8);


            // Set up an array containing the number of vertices
            // for each of the 6 cube faces (4 verticies per face)
            //
            int[] face_counts = { 4, 4, 4, 4, 4, 4 };
            MIntArray faceCounts = new MIntArray(face_counts);

            // Set up and array to assign vertices from points to each face 
            //
            int[] face_connects = {	0, 1, 2, 3,
									4, 5, 6, 7,
									3, 2, 6, 5,
									0, 3, 5, 4,
									0, 4, 7, 1,
									1, 7, 6, 2	};
            MIntArray faceConnects = new MIntArray(face_connects);

            MObject newMesh = meshFS.create(numVertices, numFaces, points, faceCounts, faceConnects, outData);

            return newMesh;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:54,代码来源:animCubeNode.cs

示例10: TrackingObject

		public TrackingObject(MObject source)
		{
			this.Position = new Vector2D((double)source.X(), (double)source.Y());
			this.Area = source.Area();
			this.Width = source.Width();
			this.Height = source.Height();
			this.Left = source.Left();
			this.Right = source.Right();
			this.Top = source.Top();
			this.Bottom = source.Bottom();
		}
开发者ID:keith06,项目名称:VVVV.Nodes.Image,代码行数:11,代码来源:TrackingObject.cs

示例11: iterator

 //////////////////////////////////////////////////////////////////
 //
 // Overrides from MPxGeometryData
 //
 //////////////////////////////////////////////////////////////////
 public override MPxGeometryIterator iterator( MObjectArray componentList,
     MObject component,
     bool useComponents)
 {
     apiMeshGeomIterator result = null;
     if ( useComponents ) {
         result = new apiMeshGeomIterator( fGeometry, componentList );
     }
     else {
         result = new apiMeshGeomIterator( fGeometry, component );
     }
     return result;
 }
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:18,代码来源:apiMeshData.cs

示例12: geometryIteratorSetup

 public override MPxGeometryIterator geometryIteratorSetup(MObjectArray componentList, MObject components, bool forReadOnly)
 {
     apiSimpleShapeIterator result;
     if (components.isNull)
     {
         result = new apiSimpleShapeIterator(controlPoints, componentList);
     }
     else
     {
         result = new apiSimpleShapeIterator(controlPoints, components);
     }
     return result;
 }
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:13,代码来源:apiSimpleShape.cs

示例13: createVertexStream

        public override void createVertexStream(MObject objPath,
            MVertexBuffer vertexBuffer,
            MComponentDataIndexing targetIndexing,
            MComponentDataIndexing sharedIndexing,
            MVertexBufferArray sourceStreams)
        {
            // get the descriptor from the vertex buffer.
            // It describes the format and layout of the stream.
            MVertexBufferDescriptor descriptor = vertexBuffer.descriptor;

            // we are expecting a float stream.
            if (descriptor.dataType != Autodesk.Maya.OpenMayaRender.MHWRender.MGeometry.DataType.kFloat) return;

            // we are expecting a float2
            if (descriptor.dimension != 2) return;

            // we are expecting a texture channel
            if (descriptor.semantic != Autodesk.Maya.OpenMayaRender.MHWRender.MGeometry.Semantic.kTexture) return;

            // get the mesh from the current path, if it is not a mesh we do nothing.
            MFnMesh mesh = null;
            try {
                mesh = new MFnMesh(objPath);
            } catch(System.Exception) {
                return; // failed
            }

            MUintArray indices = targetIndexing.indicesProperty;
            uint vertexCount = indices.length;
            if (vertexCount <= 0) return;

            unsafe {
                // acquire the buffer to fill with data.
                float * buffer = (float *)vertexBuffer.acquire(vertexCount);

                for (int i = 0; i < vertexCount; i++)
                {
                    // Here we are embedding some custom data into the stream.
                    // The included effects (vertexBufferGeneratorGL.cgfx and
                    // vertexBufferGeneratorDX11.fx) will alternate
                    // red, green, and blue vertex colored triangles based on this input.
                    *(buffer++) = 1.0f;
                    *(buffer++) = (float)indices[i]; // color index
                }

                // commit the buffer to signal completion.
                vertexBuffer.commit( (byte *)buffer);
            }
        }
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:49,代码来源:vertexBufferGenerator.cs

示例14: receiveVertexPositionsFromMaya

 public Point3DCollection receiveVertexPositionsFromMaya(string node_name)
 {
     MPlug plLocal = getPlug(node_name, "outMesh");
     MObject oOutMesh = new MObject();
     plLocal.getValue(oOutMesh);
     MFnMesh m = new MFnMesh(oOutMesh);
     MPointArray p_aVertices = new MPointArray();
     m.getPoints(p_aVertices, MSpace.Space.kWorld);
     Point3DCollection vertices = new Point3DCollection();
     foreach (MPoint p in p_aVertices)
     {
         vertices.Add(new Point3D(p.x, p.y, p.z));
     }
     return vertices;
 }
开发者ID:MrWalsh,项目名称:DynaMaya-WIP,代码行数:15,代码来源:DynamoMayaService.cs

示例15: getSourceIndexing

        public override bool getSourceIndexing(MObject obj, MComponentDataIndexing sourceIndexing)
		{
            // get the mesh from the current path, if it is not a mesh we do nothing.
			MFnMesh mesh = null;
			try {
				mesh = new MFnMesh(obj);
			} catch(System.Exception) {
				return false;
			}

			// if it is an empty mesh we do nothing.
			int numPolys = mesh.numPolygons;
			if (numPolys <= 0) return false;

			// for each face
            MUintArray vertToFaceVertIDs = sourceIndexing.indicesProperty;
			uint faceNum = 0;
			for (int i = 0; i < numPolys; i++)
			{
				// assign a color ID to all vertices in this face.
				uint faceColorID = faceNum % 3;

				int vertexCount = mesh.polygonVertexCount(i);
				for (int j = 0; j < vertexCount; j++)
				{
					// set each face vertex to the face color
					vertToFaceVertIDs.append(faceColorID);
				}

				faceNum++;
			}

			// assign the source indexing
			sourceIndexing.setComponentType(MComponentDataIndexing.MComponentType.kFaceVertex);

			return true;
		}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:37,代码来源:vertexBufferGenerator.cs


注:本文中的MObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。