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


C++ MDagPath::hasFn方法代码示例

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


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

示例1: getShapeNode

MStatus sgCurveEditBrush_context::getShapeNode( MDagPath& path )
{
    MStatus status;

    if ( path.apiType() == MFn::kNurbsCurve )
    {
        return MS::kSuccess;
    }

    unsigned int numShapes;
    status = path.numberOfShapesDirectlyBelow( numShapes );
    CHECK_MSTATUS_AND_RETURN_IT( status );

    for ( unsigned int i = 0; i < numShapes; ++i )
    {
        status = path.extendToShapeDirectlyBelow( i );
        CHECK_MSTATUS_AND_RETURN_IT( status );

        if ( !path.hasFn( MFn::kNurbsCurve ) )
        {
            path.pop();
            continue;
        }

        MFnDagNode fnNode( path, &status );
        CHECK_MSTATUS_AND_RETURN_IT( status );
        if ( !fnNode.isIntermediateObject() )
        {
            return MS::kSuccess;
        }
        path.pop();
    }

    return MS::kFailure;
}
开发者ID:jonntd,项目名称:mayadev-1,代码行数:35,代码来源:sgCurveEditBrush_context_def.cpp

示例2: retrieveChild

IECore::SceneInterfacePtr MayaScene::retrieveChild( const Name &name, MissingBehaviour missingBehaviour ) const
{
	tbb::mutex::scoped_lock l( s_mutex );
	
	if( m_dagPath.length() == 0 && !m_isRoot )
	{
		throw Exception( "MayaScene::retrieveChild: Dag path no longer exists!" );
	}
	
	MSelectionList sel;
	sel.add( m_dagPath.fullPathName() + "|" + std::string( name ).c_str() );
	
	MDagPath path;
	MStatus st = sel.getDagPath( 0, path );
	
	if( !path.hasFn( MFn::kTransform ) )
	{
		if( missingBehaviour == SceneInterface::ThrowIfMissing )
		{
			throw Exception( "MayaScene::retrieveChild: Couldn't find transform at specified path " + std::string( path.fullPathName().asChar() ) );
		}
		return 0;
	}
	
	return duplicate( path );
}
开发者ID:Shockspot,项目名称:cortex,代码行数:26,代码来源:MayaScene.cpp

示例3: doIt

MStatus recoverVisibleCmd::doIt(const MArgList&)
{
	MStatus status;
	MItDag dagItr(MItDag::kDepthFirst, MFn::kInvalid,&status);
	if(status!=MS::kSuccess){MGlobal::displayError(" Failure in DAG iterator");return status;}
	for(;!dagItr.isDone();dagItr.next())
	{
		MDagPath dagPath;
		status = dagItr.getPath(dagPath);
		if(status!=MS::kSuccess){MGlobal::displayError(" Failure in getting path");return status;}
		MFnDagNode dagNode(dagPath,&status);
		if(dagNode.isIntermediateObject())continue;
		if(!dagPath.hasFn(MFn::kDependencyNode))continue;

		MObject mObj=dagNode.object(&status);
		if(status!=MS::kSuccess){MGlobal::displayError(" Failure in getting object");return status;}

		//getParticle
		MFnDependencyNode fnNode(mObj, &status);
		if(status!=MS::kSuccess){MGlobal::displayError(" Failure in getting dependency node");return status;}
		if(fnNode.typeId() == OParticleNode::typeId) MPlug(mObj, OParticleNode::isVisible).setValue(true);
		if(fnNode.typeId() == edgeNode::typeId) MPlug(mObj, edgeNode::isVisible).setValue(true);
			
		
	}


	return status;
}
开发者ID:duxing,项目名称:HandOfMidas,代码行数:29,代码来源:nodeCmd.cpp

示例4: GetShapeNode

MStatus GetShapeNode(MDagPath& path, bool intermediate) {
  MStatus status;

  if (IsShapeNode(path)) {
    // Start at the transform so we can honor the intermediate flag.
    path.pop();
  }

  if (path.hasFn(MFn::kTransform)) {
    unsigned int shapeCount = path.childCount();

    for (unsigned int i = 0; i < shapeCount; ++i) {
      status = path.push(path.child(i));
      CHECK_MSTATUS_AND_RETURN_IT(status);
      if (!IsShapeNode(path)) {
        path.pop();
        continue;
      }

      MFnDagNode fnNode(path, &status);
      CHECK_MSTATUS_AND_RETURN_IT(status);
      if ((!fnNode.isIntermediateObject() && !intermediate) ||
          (fnNode.isIntermediateObject() && intermediate)) {
        return MS::kSuccess;
      }
      // Go to the next shape
      path.pop();
    }
  }

  // No valid shape node found.
  return MS::kFailure;
}
开发者ID:AtomicFiction,项目名称:cvwrap,代码行数:33,代码来源:common.cpp

示例5: retrieveScene

SceneInterfacePtr MayaScene::retrieveScene( const Path &path, MissingBehaviour missingBehaviour ) const
{
	tbb::mutex::scoped_lock l( s_mutex );
	
	if( path.size() == 0 )
	{
		MItDag it;
		MDagPath rootPath;
		it.getPath( rootPath );
		return duplicate( rootPath, true );
	}
	
	MString pathName;
	
	for( Path::const_iterator it=path.begin(); it != path.end(); ++it )
	{
		pathName += "|";
		pathName += std::string( *it ).c_str();
	}
	
	MSelectionList sel;
	MStatus st = sel.add( pathName );
	if( !st )
	{
		if( missingBehaviour == SceneInterface::ThrowIfMissing )
		{
			std::string pathName;
			for( size_t i = 0; i < path.size(); ++i )
			{
				pathName += std::string( path[i] ) + "/";
			}
			
			throw Exception( "MayaScene::retrieveScene: Couldn't find transform at specified path " + pathName );
		}
		return 0;
	}
	
	MDagPath dagPath;
	sel.getDagPath( 0, dagPath );
	
	if( dagPath.hasFn( MFn::kTransform ) )
	{
		return duplicate( dagPath );
	}
	else
	{
		if( missingBehaviour == SceneInterface::ThrowIfMissing )
		{
			std::string pathName;
			for( size_t i = 0; i < path.size(); ++i )
			{
				pathName += std::string( path[i] ) + "/";
			}
			
			throw Exception( "MayaScene::retrieveScene: Couldn't find transform at specified path " + pathName );
		}
		return 0;
	}
	
}
开发者ID:Shockspot,项目名称:cortex,代码行数:60,代码来源:MayaScene.cpp

示例6: IsSkinnerNode

//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MStatus CVsSkinnerCmd::IsSkinnerNode(
	const MDagPath &iDagPath )
{
	if ( iDagPath.hasFn( MFn::kPluginShape ) && MFnDagNode( iDagPath ).typeName() == "vsSkinner" )
		return MS::kSuccess;

	return MS::kFailure;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:11,代码来源:vsSkinnerCmd.cpp

示例7: twistSurf

MStatus twistSurf()
{
	MStatus status;

	cout << ">>>> Start twist routine <<<<" << endl;

	MString	surface1("surface1");
	MGlobal::selectByName(surface1, MGlobal::kReplaceList);

	// Create an iterator for the active selection list
	//
	MSelectionList slist;
	MGlobal::getActiveSelectionList( slist );
	MItSelectionList iter( slist );

	if (iter.isDone()) {
		cerr << "Nothing selected\n";
		return MS::kFailure;
	}

	MDagPath objectPath;
	MObject component;

	for ( ; !iter.isDone(); iter.next() ) {
		status = iter.getDagPath( objectPath, component );

		if (objectPath.hasFn(MFn::kNurbsSurface))
			status = twistNurbsSurface(objectPath, component);
		else if (objectPath.hasFn(MFn::kMesh))
			status = twistPolygon(objectPath, component);
		else {
			cerr << "Selected object is not a NURBS surface or a polygon\n";
			return MS::kFailure;
		}
	}

	if ( status ) {
		cout << ">>>> Twist Successfull <<<<\n";
	} else {
		cout << ">>>> Twist Failed <<<<\n";
	}

	return status;
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:44,代码来源:surfaceTwist.cpp

示例8: AddColorSetToMesh

//-----------------------------------------------------------------------------
// Adds a color set to the input history of the passed mesh
//-----------------------------------------------------------------------------
MObject ValveMaya::AddColorSetToMesh(
	const MString &colorSetName,
	const MDagPath &mDagPath,
	MDagModifier &mDagModifier )
{
	if ( !mDagPath.hasFn( MFn::kMesh ) )
		return MObject::kNullObj;

	MFnMesh meshFn( mDagPath );
	MString uniqueColorSetName;

	{
		MStringArray colorSetNames;
		meshFn.getColorSetNames( colorSetNames );
		const uint nColorSets( colorSetNames.length() );
		for ( int i( 0 ); uniqueColorSetName.length() == 0; ++i )
		{
			uniqueColorSetName = colorSetName;
			if ( i > 0 )
			{
				uniqueColorSetName += i;
			}
			for ( uint j( 0U ); j != nColorSets; ++j )
			{
				if ( uniqueColorSetName == colorSetNames[ j ] )
				{
					uniqueColorSetName.clear();
					break;
				}
			}
		}
	}

	// Create a 'createColorSet' node
	MObject ccsObj( mDagModifier.MDGModifier::createNode( "createColorSet" ) );
	mDagModifier.doIt();
	const MFnDependencyNode ccsFn( ccsObj );
	MPlug csnP( ccsFn.findPlug( "colorSetName" ) );
	csnP.setValue( uniqueColorSetName );

	// Insert it in the history of the mesh
	MPlug inMeshP( meshFn.findPlug( "inMesh" ) );
	MPlugArray mPlugArray;
	if ( inMeshP.connectedTo( mPlugArray, true, false ) && mPlugArray.length() )
	{
		mDagModifier.disconnect( mPlugArray[ 0 ], inMeshP );
		mDagModifier.connect( mPlugArray[ 0 ], ccsFn.findPlug( "inputGeometry" ) );
	}

	mDagModifier.connect( ccsFn.findPlug( "outputGeometry" ), inMeshP );
	mDagModifier.doIt();

	return ccsObj;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:57,代码来源:valveMaya.cpp

示例9: execute

MStatus PluginTestUserOperation::execute(const MHWRender::MDrawContext & drawContext)
{
	//return MStatus::kSuccess;
	M3dView view;
	if(M3dView::getM3dViewFromModelPanel(panelName, view) == MStatus::kSuccess)
	{
		// Get the current viewport and scale it relative to that
		//
		int targetW, targetH;
		drawContext.getRenderTargetSize(targetW, targetH);

		// Some user drawing of scene bounding boxes
		//
		MDagPath cameraPath;
		MFnCamera fnCamera;
		view.getCamera(cameraPath);
		MMatrix m3dViewProjection, m3dViewModelView;
		view.projectionMatrix(m3dViewProjection);
		view.modelViewMatrix(m3dViewModelView);
		MFloatMatrix m3dFloatViewProjection(m3dViewProjection.matrix);
		MFloatMatrix m3dFloatViewModelView(m3dViewModelView.matrix);
		MFloatMatrix viewProjection = m3dFloatViewModelView * m3dFloatViewProjection;
		SurfaceDrawTraversal traversal;
		traversal.enableFiltering(true);
		traversal.setFrustum(cameraPath, targetW, targetH);
		traversal.traverse();
		unsigned int numItems = traversal.numberOfItems();
		MFnMesh fnMesh;
		for (int i = 0; i < numItems; i++)
		{
			MDagPath path;
			traversal.itemPath(i, path);
			if (path.hasFn(MFn::kMesh))
			{
				fnMesh.setObject(path);
				MFloatMatrix modelWorld(path.inclusiveMatrix().matrix);
				MTransformationMatrix transformMatrix;
				MFloatMatrix modelViewProjection = modelWorld * viewProjection;
				modelViewProjection = modelViewProjection.transpose();
				MIntArray triangleCounts;
				MIntArray triangleVertices; // This is the index list for all the triangles in the mesh in one big list. Ie. first 3 are for tri 1 etc. Index into getPoints()
				fnMesh.getTriangles(triangleCounts, triangleVertices);
				//int indices[100];
				//triangleVertices.get(indices);
				MFloatPointArray vertexArray;
				//float points[1000][4];
				fnMesh.getPoints(vertexArray);
				//vertexArray.get(points);
				UserSceneRenderer::get()->render(triangleVertices, vertexArray, modelViewProjection);
			}
		}
	}
	return MStatus::kSuccess;
}
开发者ID:fawnha,项目名称:morftech,代码行数:54,代码来源:PluginTestUserOperation.cpp

示例10: getObjectShadingGroups

bool getObjectShadingGroups(const MDagPath& shapeObjectDP, MObject& shadingGroup)
{
    // if obj is a light, simply return the mobject
    if (shapeObjectDP.hasFn(MFn::kLight))
        shadingGroup = shapeObjectDP.node();

    if (shapeObjectDP.hasFn(MFn::kMesh))
    {
        // Find the Shading Engines Connected to the SourceNode
        MFnMesh fnMesh(shapeObjectDP.node());

        // A ShadingGroup will have a MFnSet
        MObjectArray sets, comps;
        fnMesh.getConnectedSetsAndMembers(shapeObjectDP.instanceNumber(), sets, comps, true);

        // Each set is a Shading Group. Loop through them
        for (unsigned int i = 0; i < sets.length(); ++i)
        {
            shadingGroup = sets[i];
            return true;
        }
    }

    if (shapeObjectDP.hasFn(MFn::kNurbsSurface)||shapeObjectDP.hasFn(MFn::kParticle)||shapeObjectDP.hasFn(MFn::kNParticle))
    {

        MObject instObjGroupsAttr;
        if (shapeObjectDP.hasFn(MFn::kNurbsSurface))
        {
            MFnNurbsSurface fnNurbs(shapeObjectDP.node());
            instObjGroupsAttr = fnNurbs.attribute("instObjGroups");
        }
        if (shapeObjectDP.hasFn(MFn::kParticle)||shapeObjectDP.hasFn(MFn::kNParticle))
        {
            MFnParticleSystem fnPart(shapeObjectDP.node());
            instObjGroupsAttr = fnPart.attribute("instObjGroups");
        }
        MPlug instPlug(shapeObjectDP.node(), instObjGroupsAttr);

        // Get the instance that our node is referring to;
        // In other words get the Plug for instObjGroups[intanceNumber];
        MPlug instPlugElem = instPlug.elementByLogicalIndex(shapeObjectDP.instanceNumber());

        // Find the ShadingGroup plugs that we are connected to as Source
        MPlugArray SGPlugArray;
        instPlugElem.connectedTo(SGPlugArray, false, true);

        // Loop through each ShadingGroup Plug
        for (unsigned int i=0; i < SGPlugArray.length(); ++i)
        {
            shadingGroup = SGPlugArray[i].node();
            return true;
        }
    }
    return false;
}
开发者ID:dictoon,项目名称:appleseed-maya,代码行数:56,代码来源:shadingutils.cpp

示例11: joint

MayaTransformWriter::MayaTransformWriter(double iFrame,
    MayaTransformWriter & iParent, MDagPath & iDag,
    uint32_t iTimeIndex,
    bool iWriteVisibility)
{
    if (iDag.hasFn(MFn::kJoint))
    {
        MFnIkJoint joint(iDag);

        Alembic::AbcGeom::OXform obj(iParent.getObject(), joint.name().asChar(),
            iTimeIndex);
        mSchema = obj.getSchema();

        Alembic::Abc::OCompoundProperty cp = obj.getProperties();
        mAttrs = AttributesWriterPtr(new AttributesWriter(iFrame, cp, joint,
            iTimeIndex, iWriteVisibility));

        pushTransformStack(iFrame, joint);
    }
    else
    {
        MFnTransform trans(iDag);
        Alembic::AbcGeom::OXform obj(iParent.getObject(), trans.name().asChar(),
            iTimeIndex);
        mSchema = obj.getSchema();

        Alembic::Abc::OCompoundProperty cp = obj.getProperties();
        mAttrs = AttributesWriterPtr(new AttributesWriter(iFrame, cp, trans,
            iTimeIndex, iWriteVisibility));

        pushTransformStack(iFrame, trans);
    }


    // need to look at inheritsTransform
    MFnDagNode dagNode(iDag);
    MPlug inheritPlug = dagNode.findPlug("inheritsTransform");
    if (!inheritPlug.isNull())
    {
        if (util::getSampledType(inheritPlug) != 0)
            mInheritsPlug = inheritPlug;

        mSample.setInheritsXforms(inheritPlug.asBool());
    }

    // everything is default, don't write anything
    if (mSample.getNumOps() == 0 && mSample.getInheritsXforms())
        return;

    mSchema.set(mSample);
}
开发者ID:oyaGG,项目名称:helgemathee-alembic-softimage,代码行数:51,代码来源:MayaTransformWriter.cpp

示例12: doIt

MStatus surfaceTwist::doIt( const MArgList& )
//
//	Description:
//		Plugin command to test Selection List Iterator.
//
//
{
	MStatus status;

	// Create an iterator for the active selection list
	//
	MSelectionList slist;
	MGlobal::getActiveSelectionList( slist );
	MItSelectionList iter( slist );

	if (iter.isDone()) {
		cerr << "Nothing selected\n";
		return MS::kFailure;
	}

	MDagPath objectPath;
	MObject component;

	for ( ; !iter.isDone(); iter.next() ) {
		status = iter.getDagPath( objectPath, component );

		if (objectPath.hasFn(MFn::kNurbsSurface))
			status = twistNurbsSurface(objectPath, component);
		else if (objectPath.hasFn(MFn::kMesh))
			status = twistPolygon(objectPath, component);
		else {
			cerr << "Selected object is not a NURBS surface or a polygon\n";
			return MS::kFailure;
		}
	}
	return status;
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:37,代码来源:surfaceTwistCmd.cpp

示例13: FindMeshesInHierarchy

//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MStatus CVsSkinnerCmd::FindMeshesInHierarchy(
	const MDagPath &iDagPath,
	MSelectionList &oList )
{
	MStatus retVal( MS::kFailure );

	MDagPath rDagPath( iDagPath );	// Root dag path
	while ( rDagPath.length() > 1U )
	{
		rDagPath.pop();
	}

	MDagPath mDagPath;
	MDagPath sDagPath;

	uint nShapes;

	MItDag dIt;
	if ( rDagPath.length() )
	{
		dIt.reset( rDagPath );
	}

	for ( ; !dIt.isDone(); dIt.next() )
	{
		if ( !dIt.getPath( mDagPath ) )
			continue;

		mDagPath.numberOfShapesDirectlyBelow( nShapes );
		for ( uint i( 0U ); i != nShapes; ++i )
		{
			sDagPath = mDagPath;
			sDagPath.extendToShapeDirectlyBelow( i );
			if ( sDagPath.hasFn( MFn::kMesh ) )
				continue;

			oList.add( sDagPath, MObject::kNullObj, true );
			retVal = MS::kSuccess;
		}

		if ( !ConnectedToMesh( mDagPath, sDagPath ) )
			continue;

		oList.add( sDagPath, MObject::kNullObj, true );
		retVal = MS::kSuccess;
	}

	return retVal;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:52,代码来源:vsSkinnerCmd.cpp

示例14: findAvailableSystems

MStatus unShowAvailableSystems::findAvailableSystems(std::string& str,MDagPath& dagPath)
{
	MStatus stat = MS::kSuccess;

	if(dagPath.hasFn(MFn::kJoint))
	{
		MFnIkJoint jointFn(dagPath);
		std::string name = dagPath.partialPathName().asChar();
		MPlug plug = jointFn.findPlug("unRibbonEnabled");
		if(!plug.isNull())
		{
			bool enabled;
			plug.getValue(enabled);
			char s[256];
			sprintf(s,"%s RibbonSystem %s\n",name.c_str(),enabled ? "True" : "False");
			str += s;
		}
		plug = jointFn.findPlug("unParticleEnabled");
		if(!plug.isNull())
		{
			bool enabled;
			plug.getValue(enabled);
			char s[256];
			sprintf(s,"%s ParticleSystem %s\n",name.c_str(),enabled ? "True" : "False");
			str += s;
		}
	}

	for (unsigned int i = 0; i < dagPath.childCount(); i++)
	{
		MObject child = dagPath.child(i);
		MDagPath childPath;
		stat = MDagPath::getAPathTo(child,childPath);
		if (MS::kSuccess != stat)
		{
			return MS::kFailure;
		}
		stat = findAvailableSystems(str,childPath);
		if (MS::kSuccess != stat)
			return MS::kFailure;
	}
	return MS::kSuccess;
}
开发者ID:cpzhang,项目名称:zen,代码行数:43,代码来源:mayammexport.cpp

示例15: updateLightList

//
// Method to add in a light "prune" list. Only selected
// lights will be have their shadows requested, and
// be used for the scene render shader override.
//
MStatus viewRenderOverrideShadows::updateLightList()
{
	mLightList.clear();

	shadowPrepass* shadowOp = (shadowPrepass*)mRenderOperations[kShadowPrePass];
	sceneRender* sceneOp = (sceneRender*)mRenderOperations[kMaya3dSceneRender];
	if (!shadowOp || !sceneOp)
		return MStatus::kFailure;

	// Scan selection list for active lights
	//
	MSelectionList selectList;
	MDagPath dagPath;
	MObject component;
	MGlobal::getActiveSelectionList( selectList );
	for (unsigned int i=0; i<selectList.length(); i++)
	{
		selectList.getDagPath( i, dagPath, component );
		dagPath.extendToShape();
		if ( dagPath.hasFn( MFn::kLight ) )
		{
			mLightList.add( dagPath );
		}
	}
	
	// Set light list to prune which lights to request shadows for
	//
	if (mLightList.length())
		shadowOp->setLightList( &mLightList );
	else
		shadowOp->setLightList( NULL );

	// Set light list to prune which lights to bind for scene shader
	//
	if (mLightList.length())
		sceneOp->setLightList( &mLightList );
	else
		sceneOp->setLightList( NULL );

	return MStatus::kSuccess;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:46,代码来源:viewRenderOverrideShadows.cpp


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