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


C# MObject.hasFn方法代码示例

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


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

示例1: updateManipulators

        public static void updateManipulators(RotateManipContext ctx)
        {
            if (ctx == null)
                return;

            ctx.deleteManipulators();

            // Add the rotate manipulator to each selected object.  This produces 
            // behavior different from the default rotate manipulator behavior.  Here,
            // a distinct rotate manipulator is attached to every object.
            // 
            try
            {
                MSelectionList list = MGlobal.activeSelectionList;

                MItSelectionList iter = new MItSelectionList(list, MFn.Type.kInvalid);
                for (; !iter.isDone; iter.next())
                {

                    // Make sure the selection list item is a depend node and has the
                    // required plugs before manipulating it.
                    //
                    MObject dependNode = new MObject();
                    iter.getDependNode(dependNode);
                    if (dependNode.isNull || !dependNode.hasFn(MFn.Type.kDependencyNode))
                    {
                        MGlobal.displayWarning("Object in selection list is not a depend node.");
                        continue;
                    }

                    MFnDependencyNode dependNodeFn = new MFnDependencyNode(dependNode);
                    try
                    {
                        /* MPlug rPlug = */
                        dependNodeFn.findPlug("rotate");
                    }
                    catch (System.Exception)
                    {
                        MGlobal.displayWarning("Object cannot be manipulated: " + dependNodeFn.name);
                        continue;
                    }

                    // Add manipulator to the selected object
                    //
                    MObject manipObject = new MObject();

                    exampleRotateManip manipulator;
                    try
                    {
                        manipulator = exampleRotateManip.newManipulator("exampleRotateManipCSharp", manipObject) as exampleRotateManip;

                        // Add the manipulator
                        //
                        ctx.addManipulator(manipObject);

                        // Connect the manipulator to the object in the selection list.
                        //
                        try
                        {
                            manipulator.connectToDependNode(dependNode);
                        }
                        catch (System.Exception)
                        {
                            MGlobal.displayWarning("Error connecting manipulator to object: " + dependNodeFn.name);
                        }
                    }
                    catch (System.Exception)
                    {

                    }
                }
            }
            catch (System.Exception)
            {

            }

        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:78,代码来源:rotateManip.cs

示例2: componentToPlugs

        //
        // Description
        //
        //    Converts the given component values into a selection list of plugs.
        //    This method is used to map components to attributes.
        //
        // Arguments
        //
        //    component - the component to be translated to a plug/attribute
        //    list      - a list of plugs representing the passed in component
        //
        public override void componentToPlugs(MObject component, MSelectionList list)
        {
            if ( component.hasFn(MFn.Type.kSingleIndexedComponent) ) {

                MFnSingleIndexedComponent fnVtxComp = new MFnSingleIndexedComponent( component );
                MObject thisNode = thisMObject();
                MPlug plug = new MPlug( thisNode, mControlPoints );
                // If this node is connected to a tweak node, reset the
                // plug to point at the tweak node.
                //
                convertToTweakNodePlug(plug);

                int len = fnVtxComp.elementCount;

                for ( int i = 0; i < len; i++ )
                {
                    plug.selectAncestorLogicalIndex((uint)fnVtxComp.element(i), plug.attribute);
                    list.add(plug);
                }
            }
        }
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:32,代码来源:apiMeshShape.cs

示例3: validGeometrySelected

		//! Ensure that valid geometry is selected
		bool validGeometrySelected()
		{
			MSelectionList list = new MSelectionList();
			MGlobal.getActiveSelectionList(list);
			MItSelectionList iter = new MItSelectionList(list, MFn.Type.kInvalid);

			for (; !iter.isDone; iter.next())
			{
				MObject dependNode = new MObject();
				iter.getDependNode(dependNode);
				if (dependNode.isNull || !dependNode.hasFn(MFn.Type.kTransform))
				{
					MGlobal.displayWarning("Object in selection list is not right type of node");
					return false;
				}

				MFnDependencyNode dependNodeFn = new MFnDependencyNode(dependNode);
				MStringArray attributeNames = new MStringArray();
				attributeNames.append("scaleX");
				attributeNames.append("translateX");

				int i;
				for ( i = 0; i < attributeNames.length; i++ )
				{
					MPlug plug = dependNodeFn.findPlug(attributeNames[i]);
					if ( plug.isNull )
					{
						MGlobal.displayWarning("Object cannot be manipulated: " +
							dependNodeFn.name);
						return false;
					}
				}
			}
			return true;
		}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:36,代码来源:lineManipContainer.cs

示例4: componentToPlugs

		public override void componentToPlugs(MObject component, MSelectionList list)
		//
		// Description
		//
		//    Converts the given component values into a selection list of plugs.
		//    This method is used to map components to attributes.
		//
		// Arguments
		//
		//    component - the component to be translated to a plug/attribute
		//    list      - a list of plugs representing the passed in component
		//
		{
			if ( component.hasFn(MFn.Type.kSingleIndexedComponent) ) {

				MFnSingleIndexedComponent fnVtxComp = new MFnSingleIndexedComponent( component );
				MObject thisNode = thisMObject();
				MPlug plug = new MPlug( thisNode, mControlPoints );
				// If this node is connected to a tweak node, reset the
				// plug to point at the tweak node.
				//
				convertToTweakNodePlug(plug);

				int len = fnVtxComp.elementCount;

				for ( int i = 0; i < len; i++ )
				{
					plug.selectAncestorLogicalIndex((uint)fnVtxComp.element(i), plug.attribute);
					list.add(plug);
				}
			}
		}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:32,代码来源:apiMeshShape.cs

示例5: connectNodeToNode

        //
        //    Description:
        //        Overloaded function from MPxDragAndDropBehavior
        //    this method will handle the connection between the slopeShaderNodeCSharp and the shader it is
        //    assigned to as well as any meshes that it is assigned to.
        //
        public override void connectNodeToNode(MObject sourceNode, MObject destinationNode, bool force)
        {
            MFnDependencyNode src = new MFnDependencyNode(sourceNode);

            //if we are dragging from a lambert
            //we want to check what we are dragging
            //onto.
            if(sourceNode.hasFn(MFn.Type.kLambert))
            {
                //MObject shaderNode;
                MPlugArray connections = new MPlugArray();
                MObjectArray shaderNodes = new MObjectArray();
                shaderNodes.clear();

                //if the source node was a lambert
                //than we will check the downstream connections to see
                //if a slope shader is assigned to it.
                //
                src.getConnections(connections);
                int i;
                for(i = 0; i < connections.length; i++)
                {
                    //check the incoming connections to this plug
                    //
                    MPlugArray connectedPlugs = new MPlugArray();
                    connections[i].connectedTo(connectedPlugs, true, false);
                    for(uint j = 0; j < connectedPlugs.length; j++)
                    {
                        //if the incoming node is a slope shader than
                        //append the node to the shaderNodes array
                        //
                        MObject currentnode = connectedPlugs[i].node;
                        if (new MFnDependencyNode(currentnode).typeName == "slopeShaderNodeCSharp")
                        {
                            shaderNodes.append(currentnode);
                        }
                    }
                }

                //if we found a shading node
                //than check the destination node
                //type to see if it is a mesh
                //
                if(shaderNodes.length > 0)
                {
                    MFnDependencyNode dest = new MFnDependencyNode(destinationNode);
                    if(destinationNode.hasFn(MFn.Type.kMesh))
                    {
                        //if the node is a mesh than for each slopeShaderNodeCSharp
                        //connect the worldMesh attribute to the dirtyShaderPlug
                        //attribute to force an evaluation of the node when the mesh
                        //changes
                        //
                        for(i = 0; i < shaderNodes.length; i++)
                        {
                            MPlug srcPlug = dest.findPlug("worldMesh");
                            MPlug destPlug = new MFnDependencyNode(shaderNodes[i]).findPlug("dirtyShaderPlug");

                            if(!srcPlug.isNull && !destPlug.isNull)
                            {
                                string cmd = "connectAttr -na ";
                                cmd += srcPlug.name + " ";
                                cmd += destPlug.name;

                                try
                                {
                                    // in slopeShaderBehavior.cpp, this may excute failed but continue on the following code, so we catch it.
                                    MGlobal.executeCommand(cmd);
                                }
                                catch (System.Exception)
                                {
                                    MGlobal.displayError("ExcuteCommand (" + cmd + ") failed.");
                                }
                            }
                        }

                        //get the shading engine so we can assign the shader
                        //to the mesh after doing the connection
                        //
                        MObject shadingEngine = findShadingEngine(sourceNode);

                        //if there is a valid shading engine than make
                        //the connection
                        //
                        if(!shadingEngine.isNull)
                        {
                            string cmd = "sets -edit -forceElement ";
                            cmd += new MFnDependencyNode(shadingEngine).name + " ";
                            cmd += new MFnDagNode(destinationNode).partialPathName;
                            MGlobal.executeCommand(cmd);
                        }
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:101,代码来源:slopeShader.cs

示例6: shouldBeUsedFor

        public override bool shouldBeUsedFor(MObject sourceNode, MObject destinationNode, MPlug sourcePlug, MPlug destinationPlug)
        {
            bool result = false;

            if(sourceNode.hasFn(MFn.Type.kLambert))
            {
                //if the source node was a lambert
                //than we will check the downstream connections to see
                //if a slope shader is assigned to it.
                //
                MObject shaderNode = new MObject();
                MFnDependencyNode src = new MFnDependencyNode(sourceNode);
                MPlugArray connections = new MPlugArray();

                src.getConnections(connections);
                for(int i = 0; i < connections.length; i++)
                {
                    //check the incoming connections to this plug
                    //
                    MPlugArray connectedPlugs = new MPlugArray();
                    connections[i].connectedTo(connectedPlugs, true, false);
                    for(int j = 0; j < connectedPlugs.length; j++)
                    {
                        //if the incoming node is a slope shader than
                        //set shaderNode equal to it and break out of the inner
                        //loop
                        //
                        if(new MFnDependencyNode(connectedPlugs[j].node).typeName == "slopeShaderNodeCSharp")
                        {
                            shaderNode = connectedPlugs[j].node;
                            break;
                        }
                    }

                    //if the shaderNode is not null
                    //than we have found a slopeShaderNodeCSharp
                    //
                    if(!shaderNode.isNull)
                    {
                        //if the destination node is a mesh than we will take
                        //care of this connection so set the result to true
                        //and break out of the outer loop
                        //
                        if(destinationNode.hasFn(MFn.Type.kMesh))
                            result = true;

                        break;
                    }
                }
            }
            if (new MFnDependencyNode(sourceNode).typeName == "slopeShaderNodeCSharp")
            //if the sourceNode is a slope shader than check what we
            //are dropping on to
            //
            {
                if(destinationNode.hasFn(MFn.Type.kLambert))
                    result = true;
                else if (destinationNode.hasFn(MFn.Type.kMesh))
                    result = true;
            }

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

示例7: shouldPruneLight

 private bool shouldPruneLight( MObject obj )
 {
     return !(obj.hasFn(MFn.Type.kAmbientLight) || obj.hasFn(MFn.Type.kDirectionalLight) ||
                      obj.hasFn(MFn.Type.kPointLight) || obj.hasFn(MFn.Type.kSpotLight));
 }
开发者ID:KasumiL5x,项目名称:ciri,代码行数:5,代码来源:MayaParser.cs


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