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


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

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


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

示例1: updateDG

void geometryReplicatorGeometryOverride::updateDG()
{
	if (!fPath.isValid()) {
		MFnDependencyNode fnThisNode(fThisNode);

		MObject messageAttr = fnThisNode.attribute("message");
		MPlug messagePlug(fThisNode, messageAttr);

		MPlugArray connections;
		if (messagePlug.connectedTo(connections, false, true)) {
			for (unsigned int i = 0; i < connections.length(); ++i) {
				MObject node = connections[i].node();
				if (node.hasFn(MFn::kMesh) ||
					node.hasFn(MFn::kNurbsSurface) ||
					node.hasFn(MFn::kNurbsCurve) ||
					node.hasFn(MFn::kBezierCurve))
				{
					MDagPath path;
					MDagPath::getAPathTo(node, path);

					fPath = path;
					fType = path.apiType();

					break;
				}
			}
		}
	}
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:29,代码来源:geometryReplicator.cpp

示例2: 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

示例3: if

//---------------------------------------------
void	IV_makeSelection(void* data)
//---------------------------------------------
{

	
	BPT_InsertVtx* nodePtr = (BPT_InsertVtx*) data;
	MEventMessage::removeCallback(nodePtr->eID);

	MDagPath meshPath;
	nodePtr->getMeshPath(meshPath);

	if( !(meshPath.apiType() == MFn::kInvalid) && nodePtr->validIndices.length() != 0)	//zur Sicherheit, sollte aber eigentlich nicht mueueglich sein
	{
		MFnSingleIndexedComponent compFn;
		
		MFn::Type type = MFn::kInvalid;
		if(nodePtr->validIndices[0] == 1)
			type = MFn::kMeshEdgeComponent;
		else if(nodePtr->validIndices[0] == 2)
			type = MFn::kMeshPolygonComponent;
		else if(nodePtr->validIndices[0] == 3)
			type = MFn::kMeshVertComponent;
		
		assert(type != MFn::kInvalid);
		//flag wieder entfernen
		nodePtr->validIndices.remove(0);

		MSelectionList compList, current;
		
		MObject comps = compFn.create(type);
		compFn.addElements(nodePtr->validIndices);
		
		compList.add(meshPath,comps);
		compList.add(nodePtr->thisMObject());
	

		

	//	MGlobal::getActiveSelectionList(current);
		
		MGlobal::setActiveSelectionList(compList, MGlobal::kAddToList);
	//	MGlobal::setActiveSelectionList(current,MGlobal::kAddToList);

	
	}
}
开发者ID:Byron,项目名称:bsuite,代码行数:47,代码来源:BPT_insertVtxNode.cpp

示例4: GetSelectedMeshTransformPath

bool GDExporter::GetSelectedMeshTransformPath(MDagPath &transformPath)
{
	MSelectionList currSelection;
	MGlobal::getActiveSelectionList(currSelection);

	unsigned int selectionCount = currSelection.length();
	
	MFnMesh* exportingMesh = 0;

	for(unsigned int selectionIndex = 0; selectionIndex < selectionCount; ++selectionIndex )
	{
		MDagPath currPath;
		currSelection.getDagPath(selectionIndex, currPath);

		if( currPath.apiType() != MFn::kTransform )
			continue;

		MFnTransform currTransform(currPath);
		unsigned int childCount = currTransform.childCount();
		for(unsigned int childIndex = 0; childIndex < childCount; ++childIndex)
		{
			MObject childObject = currTransform.child(childIndex);
			if( childObject.apiType() == MFn::kMesh )
			{
				MFnMesh childMesh(childObject);
				if( childMesh.isIntermediateObject() )
					continue;

				currTransform.getPath(transformPath);
				return true;
			}
		}
	}

	return false;
}
开发者ID:Burnsidious,项目名称:FSGDEngine,代码行数:36,代码来源:GDExporter.cpp

示例5: initializeSetsAndLookupTables


//.........这里部分代码省略.........
		return false;
	}
	
	//////////////////////////////////////////////////////////////////
	//
	// Go through all of the set members (flattened lists) and mark
	// in the lookup-tables, the sets that each mesh component belongs
	// to.
	//
	//
	//////////////////////////////////////////////////////////////////
	bool flattenedList = true;
	MDagPath object;
	MObject component;
	MSelectionList memberList;
	
	
	for ( i=0; i<numSets; i++ )
	{
		MFnSet fnSet( (*sets)[i] );		
		memberList.clear();
		stat = fnSet.getMembers( memberList, flattenedList );

		if (MS::kSuccess != stat) {
			fprintf(stderr,"Error in fnSet.getMembers()!\n");
		}

		int m, numMembers;
		numMembers = memberList.length();
		for ( m=0; m<numMembers; m++ )
		{
			if ( memberList.getDagPath(m,object,component) ) {

				if ( (!component.isNull()) && (object.apiType() == MFn::kMesh) )
				{
					if (component.apiType() == MFn::kMeshVertComponent) {
						MItMeshVertex viter( object, component );	
						for ( ; !viter.isDone(); viter.next() )
						{
							int compIdx = viter.index();
							MString name = object.fullPathName();
							
							// Figure out which object vertexTable
							// to get.
							//

							int o, numObjectNames;
							numObjectNames = objectNames->length();
							for ( o=0; o<numObjectNames; o++ ) {
								if ( (*objectNames)[o] == name ) {
									// Mark set i as true in the table
									//		
									vertexTable = vertexTablePtr[o];
									*(vertexTable + numSets*compIdx + i) = true;
									break;
								}
							}
						}
					}
					else if (component.apiType() == MFn::kMeshPolygonComponent) 
					{
						MItMeshPolygon piter( object, component );
						for ( ; !piter.isDone(); piter.next() )
						{
							int compIdx = piter.index();
							MString name = object.fullPathName();
开发者ID:2asoft,项目名称:xray,代码行数:67,代码来源:maTranslator.cpp

示例6: fillSubSkeleton

void DMPDSExporter::fillSubSkeleton( DMPParameters* param, const MDagPath& subSkelDag )
{
	if (subSkelDag.apiType() != MFn::kJoint)
	{
		return; // early out.
	}
	MStatus status; 
	// try to retrieve the root path, otherwise ignore it.
	MDagPath rootJntDag, tmpJointPath;
	tmpJointPath = subSkelDag;
	rootJntDag = tmpJointPath;
	while (tmpJointPath.length() > 0)
	{
		tmpJointPath.pop();
		if (tmpJointPath.hasFn(MFn::kJoint) && (tmpJointPath.length() > 0))
		{
			rootJntDag = tmpJointPath;
		}
	}
	// check whether we have processed this joint.
	for (unsigned int i = 0; i < mSkelData.skeleton.subSkeletons.size(); ++i)
	{
		if (mSkelData.skeleton.subSkeletons[i].name == rootJntDag.partialPathName().asUTF8())
		{		
			return;
		}
	}
	DMPSkeletonData::SubSkeletonStruct newSkel;
	newSkel.name = rootJntDag.partialPathName().asUTF8();

	//set the skeleton to the desired neutral pose
	if (param->neutralPoseType == DMPParameters::NPT_SkinBindPose)
	{
		MGlobal::executeCommand("select " + rootJntDag.fullPathName(),true);
		//disable constraints, IK, etc...
		MGlobal::executeCommand("doEnableNodeItems false all",true);
		// Note: we reset to the bind pose
		MGlobal::executeCommand("dagPose -r -g -bp",true);
	}

 	// build animation clip info, for animation exporting.
 	if (param->bExportSkelAnimation)
 	{
 		for (unsigned int i = 0; i < param->clipList.size(); ++i)
 		{
 			// convert to realtime speed(seconds);
 			float sampleRate;
 			float clipStart;
 			float clipEnd;
 			if (param->animSampleType == DMPParameters::AST_Frame)
 			{
 				sampleRate = param->samplerRate / param->fps;
 				clipStart = (param->clipList[i].start - 1.0f) / param->fps;	// include the first clip;
 				clipEnd = param->clipList[i].end / param->fps;
 			}
 			else
 			{
 				sampleRate = param->samplerRate;
 				clipStart = param->clipList[i].start;
 				clipEnd = param->clipList[i].end;
 			}
 			DMPSkeletonData::TransformAnimation newAnim;
 			newAnim.name = param->clipList[i].clipName.asUTF8();
 			newAnim.startTime = clipStart;
			newAnim.endTime = clipEnd;
			newSkel.animations.push_back(newAnim);
 		}
 	}


	fillBones(&newSkel, "", param, rootJntDag);

	mSkelData.skeleton.subSkeletons.push_back(newSkel);
}
开发者ID:jiazhipeng03,项目名称:Duel-Engine,代码行数:74,代码来源:DuelMPDSExporter.cpp

示例7: fillBones

void DMPDSExporter::fillBones( DMPSkeletonData::SubSkeletonStruct* subSkel, string parent, DMPParameters* param, MDagPath& jointDag )
{
	MStatus status;
	if (jointDag.apiType() != MFn::kJoint)
	{
		return; // early out.
	}
	DMPSkeletonData::BoneStruct newBone;
	newBone.boneHandle = (unsigned int)subSkel->bones.size();
	newBone.name = jointDag.partialPathName().asUTF8();
	newBone.parentName = parent;

	MFnIkJoint fnJoint(jointDag, &status);
	//	matrix = [S] * [RO] * [R] * [JO] * [IS] * [T]
	/*
		These matrices are defined as follows:
		•[S] : scale
		•[RO] : rotateOrient (attribute name is rotateAxis)
		•[R] : rotate
		•[JO] : jointOrient
		•[IS] : parentScaleInverse
		•[T] : translate

		The methods to get the value of these matrices are:
		•[S] : getScale
		•[RO] : getScaleOrientation
		•[R] : getRotation
		•[JO] : getOrientation
		•[IS] : (the inverse of the getScale on the parent transformation matrix)
		•[T] : translation

	*/
	MVector trans = fnJoint.getTranslation(MSpace::kTransform);
	double scale[3];
	fnJoint.getScale(scale);
	MQuaternion R, RO, JO;
	fnJoint.getScaleOrientation(RO);
	fnJoint.getRotation(R);
	fnJoint.getOrientation(JO);
	MQuaternion rot = RO * R * JO; 
	
	newBone.translate[0] = trans.x * param->lum;
	newBone.translate[1] = trans.y * param->lum;
	newBone.translate[2] = trans.z * param->lum;

	newBone.orientation[0] = rot.w;
	newBone.orientation[1] = rot.x;
	newBone.orientation[2] = rot.y;
	newBone.orientation[3] = rot.z;

	newBone.scale[0] = scale[0];
	newBone.scale[1] = scale[1];
	newBone.scale[2] = scale[2];

	subSkel->bones.push_back(newBone);
	// Load child joints
	for (unsigned int i=0; i<jointDag.childCount();i++)
	{
		MObject child;
		child = jointDag.child(i);
		MDagPath childDag = jointDag;
		childDag.push(child);
		fillBones(subSkel, newBone.name, param, childDag);
	}
	// now go for animations
	if (param->bExportSkelAnimation)
	{
		for (unsigned int i = 0; i < subSkel->animations.size(); ++i)
		{
			DMPSkeletonData::TransformAnimation& anim = subSkel->animations[i];
			DMPSkeletonData::TransformTrack subTrack;
			subTrack.targetBone = newBone.name;

			MPlug		plugT;	// translate
 			MPlug		plugR;	// R
 			MPlug		plugRO;	// RO
 			MPlug		plugJO;	// JO
			MPlug		plugS;	// scale
			double		dataT[3];
			double		dataR[3];
			double		dataRO[3];
			double		dataJO[3];
			double		dataS[3];
			MFnDependencyNode	fnDependNode( jointDag.node(), &status );
			
			plugT = fnDependNode.findPlug("translate", false, &status);
 			plugR = fnDependNode.findPlug("rotate", false, &status);
 			plugRO = fnDependNode.findPlug("rotateAxis", false, &status);
 			plugJO = fnDependNode.findPlug("jointOrient", false, &status);
			plugS = fnDependNode.findPlug("scale", false, &status);

			float timeStep = param->samplerRate;
			if (param->animSampleType == DMPParameters::AST_Frame)
			{
				timeStep /= param->fps;
			}
			for (float curTime = anim.startTime; curTime <= anim.endTime; curTime += timeStep)
			{
				MTime		mayaTime;
				DMPSkeletonData::TransformKeyFrame keyframe;
//.........这里部分代码省略.........
开发者ID:jiazhipeng03,项目名称:Duel-Engine,代码行数:101,代码来源:DuelMPDSExporter.cpp

示例8: GetSelectedMesh

MFnMesh* GDExporter::GetSelectedMesh(void)
{
	MSelectionList currSelection;
	MGlobal::getActiveSelectionList(currSelection);

	unsigned int selectionCount = currSelection.length();
	
	MFnMesh* exportingMesh = 0;

	for(unsigned int selectionIndex = 0; selectionIndex < selectionCount; ++selectionIndex )
	{
		MDagPath currPath;
		currSelection.getDagPath(selectionIndex, currPath);

		if( currPath.apiType() != MFn::kTransform )
			continue;

		MFnTransform currTransform(currPath);
		unsigned int childCount = currTransform.childCount();
		for(unsigned int childIndex = 0; childIndex < childCount; ++childIndex)
		{
			MObject childObject = currTransform.child(childIndex);
			if( childObject.apiType() == MFn::kMesh )
			{
				MFnDagNode dagNode;
				dagNode.setObject(childObject);
				MDagPath childPath;
				dagNode.getPath(childPath);
				
				MFnMesh* pChildMesh = new MFnMesh(childPath);
				
				if( pChildMesh->isIntermediateObject() )
					continue;
				
				bool bExportMesh = true;
				if( pChildMesh->isInstanced(false) )
					if( childPath.instanceNumber() != 0 )
						bExportMesh = false;

				if( bExportMesh )
				{
					if( exportingMesh != 0 )
					{
						delete exportingMesh;
						delete pChildMesh;
						MGlobal::displayError(MString("GDExporter - More than one mesh object selected."));
						return 0;
					}

					exportingMesh = pChildMesh;
				}
			}
		}
	}

	if( exportingMesh == 0 )
	{
		MGlobal::displayError(MString("GDExporter - No mesh objects currently selected."));
		return 0;
	}

	return exportingMesh;
}
开发者ID:Burnsidious,项目名称:FSGDEngine,代码行数:63,代码来源:GDExporter.cpp

示例9: translateNode

	// Method for iterating over nodes in a dependency graph from top to bottom
	MStatus OgreExporter::translateNode(MDagPath& dagPath)
	{
		if (m_params.exportAnimCurves)
		{
			MObject dagPathNode = dagPath.node();
			MItDependencyGraph animIter( dagPathNode,
				MFn::kAnimCurve,
				MItDependencyGraph::kUpstream,
				MItDependencyGraph::kDepthFirst,
				MItDependencyGraph::kNodeLevel,
				&stat );

			if (stat)
			{
				for (; !animIter.isDone(); animIter.next())
				{
					MObject anim = animIter.thisNode(&stat);
					MFnAnimCurve animFn(anim,&stat);
					std::cout << "Found animation curve: " << animFn.name().asChar() << "\n";
					std::cout << "Translating animation curve: " << animFn.name().asChar() << "...\n";
					std::cout.flush();
					stat = writeAnim(animFn);
					if (MS::kSuccess == stat)
					{
						std::cout << "OK\n";
						std::cout.flush();
					}
					else
					{
						std::cout << "Error, Aborting operation\n";
						std::cout.flush();
						return MS::kFailure;
					}
				}
			}
		}
		if (dagPath.hasFn(MFn::kMesh)&&(m_params.exportMesh||m_params.exportMaterial||m_params.exportSkeleton)
			&& (dagPath.childCount() == 0))
		{	// we have found a mesh shape node, it can't have any children, and it contains
			// all the mesh geometry data
			MDagPath meshDag = dagPath;
			MFnMesh meshFn(meshDag);
			if (!meshFn.isIntermediateObject())
			{
				std::cout << "Found mesh node: " << meshDag.fullPathName().asChar() << "\n";
				std::cout << "Loading mesh node " << meshDag.fullPathName().asChar() << "...\n";
				std::cout.flush();
				stat = m_pMesh->load(meshDag,m_params);
				if (MS::kSuccess == stat)
				{
					std::cout << "OK\n";
					std::cout.flush();
				}
				else
				{
					std::cout << "Error, mesh skipped\n";
					std::cout.flush();
				}
			}
		}
		else if (dagPath.hasFn(MFn::kCamera)&&(m_params.exportCameras) && (!dagPath.hasFn(MFn::kShape)))
		{	// we have found a camera shape node, it can't have any children, and it contains
			// all information about the camera
			MFnCamera cameraFn(dagPath);
			if (!cameraFn.isIntermediateObject())
			{
				std::cout <<  "Found camera node: "<< dagPath.fullPathName().asChar() << "\n";
				std::cout <<  "Translating camera node: "<< dagPath.fullPathName().asChar() << "...\n";
				std::cout.flush();
				stat = writeCamera(cameraFn);
				if (MS::kSuccess == stat)
				{
					std::cout << "OK\n";
					std::cout.flush();
				}
				else
				{
					std::cout << "Error, Aborting operation\n";
					std::cout.flush();
					return MS::kFailure;
				}
			}
		}
		else if ( ( dagPath.apiType() == MFn::kParticle ) && m_params.exportParticles )
		{	// we have found a set of particles
			MFnDagNode fnNode(dagPath);
			if (!fnNode.isIntermediateObject())
			{
				std::cout <<  "Found particles node: "<< dagPath.fullPathName().asChar() << "\n";
				std::cout <<  "Translating particles node: "<< dagPath.fullPathName().asChar() << "...\n";
				std::cout.flush();
				Particles particles;
				particles.load(dagPath,m_params);
				stat = particles.writeToXML(m_params);
				if (MS::kSuccess == stat)
				{
					std::cout << "OK\n";
					std::cout.flush();
				}
//.........这里部分代码省略.........
开发者ID:Anti-Mage,项目名称:ogre,代码行数:101,代码来源:ogreExporter.cpp

示例10: writeObjectToRib

void liqWriteArchive::writeObjectToRib(const MDagPath &objDagPath, bool writeTransform)
{
  if (!isObjectVisible(objDagPath)) {
    return;
  }

  if (debug) { cout << "liquidWriteArchive: writing object: " << objDagPath.fullPathName().asChar() << endl; }
  if (objDagPath.node().hasFn(MFn::kShape) || MFnDagNode( objDagPath ).typeName() == "liquidCoorSys") {
    // we're looking at a shape node, so write out the geometry to the RIB
    outputObjectName(objDagPath);

    liqRibNode ribNode;
    ribNode.set(objDagPath, 0, MRT_Unknown);

    // don't write out clipping planes
    if ( ribNode.object(0)->type == MRT_ClipPlane ) return;

    if ( ribNode.rib.box != "" && ribNode.rib.box != "-" ) {
      RiArchiveRecord( RI_COMMENT, "Additional RIB:\n%s", ribNode.rib.box.asChar() );
    }
    if ( ribNode.rib.readArchive != "" && ribNode.rib.readArchive != "-" ) {
      // the following test prevents a really nasty infinite loop !!
      if ( ribNode.rib.readArchive != outputFilename )
        RiArchiveRecord( RI_COMMENT, "Read Archive Data: \nReadArchive \"%s\"", ribNode.rib.readArchive.asChar() );
    }
    if ( ribNode.rib.delayedReadArchive != "" && ribNode.rib.delayedReadArchive != "-" ) {
      // the following test prevents a really nasty infinite loop !!
      if ( ribNode.rib.delayedReadArchive != outputFilename )
        RiArchiveRecord( RI_COMMENT, "Delayed Read Archive Data: \nProcedural \"DelayedReadArchive\" [ \"%s\" ] [ %f %f %f %f %f %f ]", ribNode.rib.delayedReadArchive.asChar(), ribNode.bound[0], ribNode.bound[3], ribNode.bound[1], ribNode.bound[4], ribNode.bound[2], ribNode.bound[5]);
    }

    // If it's a curve we should write the basis function
    if ( ribNode.object(0)->type == MRT_NuCurve ) {
      RiBasis( RiBSplineBasis, 1, RiBSplineBasis, 1 );
    }

    if ( !ribNode.object(0)->ignore ) {
      ribNode.object(0)->writeObject();
    }
  } else {
    // we're looking at a transform node
    bool wroteTransform = false;
    if (writeTransform && (objDagPath.apiType() == MFn::kTransform)) {
      if (debug) { cout << "liquidWriteArchive: writing transform: " << objDagPath.fullPathName().asChar() << endl; }
      // push the transform onto the RIB stack
      outputObjectName(objDagPath);
      MFnDagNode mfnDag(objDagPath);
      MMatrix tm = mfnDag.transformationMatrix();
      if (true) { // (!tm.isEquivalent(MMatrix::identity)) {
        RtMatrix riTM;
        tm.get(riTM);
        wroteTransform = true;
        outputIndentation();
        RiAttributeBegin();
        indentLevel++;
        outputIndentation();
        RiConcatTransform(riTM);
      }
    }
    // go through all the children of this node and deal with each of them
    int nChildren = objDagPath.childCount();
    if (debug) { cout << "liquidWriteArchive: object " << objDagPath.fullPathName().asChar() << "has " << nChildren << " children" << endl; }
    for(int i=0; i<nChildren; ++i) {
      if (debug) { cout << "liquidWriteArchive: writing child number " << i << endl; }
      MDagPath childDagNode;
      MStatus stat = MDagPath::getAPathTo(objDagPath.child(i), childDagNode);
      if (stat) {
        writeObjectToRib(childDagNode, outputChildTransforms);
      } else {
        MGlobal::displayWarning("error getting a dag path to child node of object " + objDagPath.fullPathName());
      }
    }
    if (wroteTransform) {
      indentLevel--;
      outputIndentation();
      RiAttributeEnd();
    }
  }
  if (debug) { cout << "liquidWriteArchive: finished writing object: " << objDagPath.fullPathName().asChar() << endl; }
}
开发者ID:virtualritz,项目名称:liquidmaya,代码行数:80,代码来源:liqWriteArchive.cpp


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