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


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

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


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

示例1: isCompound

static bool isCompound(const MPlug& plgInShape)
{
	MPlugArray plgaConnectedTo;
	plgInShape.connectedTo(plgaConnectedTo, true, true);
	int numSelectedShapes = plgaConnectedTo.length();

	if(numSelectedShapes > 0) {

		MObject node = plgaConnectedTo[0].node();

		MDagPath dagPath;
		MDagPath::getAPathTo(node, dagPath);
		int numChildren = dagPath.childCount();

		if (node.hasFn(MFn::kTransform))
		{
			MFnTransform trNode(dagPath);
			const char* name = trNode.name().asChar();
			printf("name = %s\n", name);

			for (int i=0;i<numChildren;i++)
			{
				MObject child = dagPath.child(i);
				if(child.hasFn(MFn::kMesh))
				{
					return false;
				}

				if(child.hasFn(MFn::kTransform))
				{
					MDagPath dagPath;
					MDagPath::getAPathTo(child, dagPath);
					MFnTransform trNode(dagPath);
					const char* name = trNode.name().asChar();
					printf("name = %s\n", name);

					int numGrandChildren = dagPath.childCount();
					{
						for (int i=0;i<numGrandChildren;i++)
						{
							MObject grandchild = dagPath.child(i);
							if(grandchild.hasFn(MFn::kMesh))
							{
								return true;
							}
						}
					}
				}
			}
		}
	}
	return false;
}
开发者ID:benelot,项目名称:dynamica,代码行数:53,代码来源:collisionShapeNode.cpp

示例2: getDagPathByChildName

bool getDagPathByChildName(MDagPath & ioDagPath, const std::string & iChildName)
{
    unsigned int numChildren = ioDagPath.childCount();
    std::string strippedName = stripPathAndNamespace(iChildName);
    MObject closeMatch;

    for (unsigned int i = 0; i < numChildren; ++i)
    {
        MObject child = ioDagPath.child(i);
        MFnDagNode dagChild(child);
        std::string name = dagChild.partialPathName().asChar();
        if (name == iChildName)
        {
            ioDagPath.push(child);
            return true;
        }

        if (closeMatch.isNull())
        {
            if (strippedName == stripPathAndNamespace(name))
            {
                closeMatch = child;
            }
        }
    }

    if (!closeMatch.isNull())
    {
        ioDagPath.push(closeMatch);
        return true;
    }

    return false;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:34,代码来源:util.cpp

示例3: getChildDags

void LiveScene::getChildDags( const MDagPath& dagPath, MDagPathArray& paths ) const
{
	for( unsigned i=0; i < dagPath.childCount(); ++i )
	{
		MDagPath childPath = dagPath;
		childPath.push( dagPath.child( i ) );
		
		if( dagPath.length() == 0 )
		{
			// bizarrely, this iterates through things like the translate manipulator and
			// the view cube too, so lets skip them so they don't show up:
			if( childPath.node().hasFn( MFn::kManipulator3D ) )
			{
				continue;
			}

			// looks like it also gives us the ground plane, so again, lets skip that:
			if( childPath.fullPathName() == "|groundPlane_transform" )
			{
				continue;
			}
		}
		
		paths.append( childPath );
	}
}
开发者ID:cnpinto,项目名称:cortex,代码行数:26,代码来源:LiveScene.cpp

示例4: findForcedNodes

    // ------------------------------------------------------------
    void SceneGraph::findForcedNodes()
    {
        MStatus status;

        if ( mExportSelectedOnly )
        {
            MSelectionList selectedItems;
            MGlobal::getActiveSelectionList ( selectedItems );
            uint selectedCount = selectedItems.length();
            MDagPathArray queue;

            for ( uint i = 0; i < selectedCount; ++i )
            {
                MDagPath selectedPath;
                status = selectedItems.getDagPath ( i, selectedPath );
                if ( status == MStatus::kSuccess ) queue.append ( selectedPath );
            }

            while ( queue.length() > 0 )
            {
                MDagPath selectedPath = queue[queue.length() - 1];
                queue.remove ( queue.length() - 1 );

                // Queue up the children.
                uint childCount = selectedPath.childCount();
                for ( uint i = 0; i < childCount; ++i )
                {
                    MObject node = selectedPath.child ( i );
                    MDagPath childPath = selectedPath;
                    childPath.push ( node );
                    queue.append ( childPath );
                }

                // Look for a mesh
                if ( selectedPath.node().hasFn ( MFn::kMesh ) )
                {
                    // export forced nodes in path
                    addForcedNodes ( selectedPath );
                }
            }
        }
        else
        {
            for ( MItDag dagIt ( MItDag::kBreadthFirst ); !dagIt.isDone(); dagIt.next() )
            {
                MDagPath currentPath;
                status = dagIt.getPath ( currentPath );
                if ( status == MStatus::kSuccess )
                {
                    MFnDagNode node ( currentPath );
                    String nodeName = node.name().asChar();
                    if ( currentPath.node().hasFn ( MFn::kMesh ) )
                    {
                        // export forced nodes in path
                        addForcedNodes ( currentPath );
                    }
                }
            }
        }
    }
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:61,代码来源:COLLADAMayaSceneGraph.cpp

示例5: 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:chadmv,项目名称:cvwrap,代码行数:33,代码来源:common.cpp

示例6: if

osg::ref_ptr<osg::Node> Group::exporta(MDagPath &dp)
{
	osg::ref_ptr<osg::Group> osggroup;

	// Get the node of this path
	MObject node = dp.node();

	// 1. Create the adequate type of node
	if( node.hasFn(MFn::kEmitter) ) {
		// Emitters are subclasses of Transform
		// We build the transform and then add the emitter as a child
		osggroup = Transform::exporta(node);
		osggroup->addChild( PointEmitter::exporta(node).get() );
	}
	else if( node.hasFn(MFn::kTransform) ){
		osggroup = Transform::exporta(node);
	}
	else {
		// Generic group (kWorld)
		osggroup = new osg::Group();
	}

	// 2. Process and add children
	for(int i=0; i<dp.childCount(); i++){
		// Add child to the path and recursively call the exportation function
		MDagPath dpc(dp);
		dpc.push(dp.child(i));
		osg::ref_ptr<osg::Node> child = DAGNode::exporta(dpc);
		if(child.valid()){
			// ** Check ** If any children is a LightSource, deactivate culling 
			// for this group in order to apply the light even though it is not
			// directly visible
			if( dynamic_cast<osg::LightSource *>(child.get()) != NULL )
				osggroup->setCullingActive(false);
			osggroup->addChild(child.get());
		}
	}

	// 3. If there are no children, the node is ignored
	if( osggroup->getNumChildren() == 0 ){
		// Buuuuuuut, if there is an animation, it is saved to disk
		// because it can be a useful camera animation
		osg::AnimationPathCallback *cb = dynamic_cast< osg::AnimationPathCallback * >(osggroup->getUpdateCallback());
		if(cb){
			MFnDependencyNode dn(node);
			std::cout << "EXPORTING CAMERA ANIMATION: " << dn.name().asChar() << std::endl;
            CameraAnimation::save(cb->getAnimationPath(), Config::instance()->getSceneFilePath().getDirectory() + "/" + Config::instance()->getSceneFilePath().getFileBaseName() + "_" + std::string(dn.name().asChar()) + ".path" );
		}
		return NULL;
	}

    // Name the node (mesh)
	MFnDependencyNode dnodefn(node);
	osggroup->setName( dnodefn.name().asChar() );

	return (osg::Node *)osggroup.get();
}
开发者ID:rpavlik,项目名称:maya2osg,代码行数:57,代码来源:group.cpp

示例7:

bool ik2Bsolver::findFirstJointChild(const MDagPath & root, MDagPath & result)
{
    const unsigned count = root.childCount();
    unsigned i;
    for(i=0; i<count; i++) {
        MObject c = root.child(i);
        if(c.hasFn(MFn::kJoint)) {
            MDagPath::getAPathTo(c, result);
            return 1;
        }
    }
    return 0;
}
开发者ID:ahmidou,项目名称:aphid,代码行数:13,代码来源:zsoftIkSolver.cpp

示例8: filterNode

/*
	Draw traversal utility to prune out everything but shapes.
*/
bool MSurfaceDrawTraversal::filterNode( const MDagPath &traversalItem )
{
	bool prune = false;
	if ( traversalItem.childCount() == 0)
	{
		if ( !traversalItem.hasFn( MFn::kMesh) &&
			!traversalItem.hasFn( MFn::kNurbsSurface) &&
			!traversalItem.hasFn( MFn::kSubdiv)
			)
		{
			prune = true;
		}
	}
	return prune;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:18,代码来源:viewRenderOverrideUserOperation.cpp

示例9: isLightTransform

// todo: extend with own light extensions.
bool isLightTransform(MDagPath& dagPath)
{
    uint numChilds = dagPath.childCount();
    for (uint chId = 0; chId < numChilds; chId++)
    {
        MDagPath childPath = dagPath;
        MStatus stat = childPath.push(dagPath.child(chId));
        if (!stat)
        {
            continue;
        }
        if (childPath.node().hasFn(MFn::kLight))
            return true;
    }
    return false;
}
开发者ID:dictoon,项目名称:appleseed-maya,代码行数:17,代码来源:tools.cpp

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

示例11: findCamera

bool findCamera(MDagPath& dagPath)
{
    if (dagPath.node().hasFn(MFn::kCamera))
        return true;
    uint numChilds = dagPath.childCount();
    for (uint chId = 0; chId < numChilds; chId++)
    {
        MDagPath childPath = dagPath;
        MStatus stat = childPath.push(dagPath.child(chId));
        if (!stat)
        {
            continue;
        }
        MString childName = childPath.fullPathName();
        return findCamera(childPath);
    }

    return false;
}
开发者ID:dictoon,项目名称:appleseed-maya,代码行数:19,代码来源:tools.cpp

示例12: traverseSubSkeleton

void DMPDSExporter::traverseSubSkeleton( DMPParameters* param, const MDagPath& dagPath )
{
	MStatus stat; 
	fillSubSkeleton(param, dagPath); 
	// look for meshes and cameras within the node's children
	for (unsigned int i=0; i<dagPath.childCount(); i++)
	{
		MObject child = dagPath.child(i);
		MDagPath childPath = dagPath;
		stat = childPath.push(child);
		if (MStatus::kSuccess != stat)
		{
			std::cout << "Error retrieving path to child " << i << " of: " << dagPath.fullPathName().asChar();
			std::cout.flush();
			return;
		}
		fillSubSkeleton(param, childPath);
		if (MStatus::kSuccess != stat)
		{
			return;
		}
	}
}
开发者ID:jiazhipeng03,项目名称:Duel-Engine,代码行数:23,代码来源:DuelMPDSExporter.cpp

示例13: doIt


//.........这里部分代码省略.........
        else if (lowerValue == "userattrprefixes") {
          splitListArg(valuePair[1], userPrefixFilters);
        }
        else if (lowerValue == "userattrs") {
          splitListArg(valuePair[1], userAttributes);
        }
        else {
          MGlobal::displayWarning(
              "[ExocortexAlembic] Skipping invalid token: " + tokens[j]);
          continue;
        }
      }

      // now check the object strings
      for (unsigned int k = 0; k < objectStrings.length(); k++) {
        MSelectionList sl;
        MString objectString = objectStrings[k];
        sl.add(objectString);
        MDagPath dag;
        for (unsigned int l = 0; l < sl.length(); l++) {
          sl.getDagPath(l, dag);
          MObject objRef = dag.node();
          if (objRef.isNull()) {
            MGlobal::displayWarning("[ExocortexAlembic] Skipping object '" +
                                    objectStrings[k] + "', not found.");
            break;
          }

          // get all parents
          MObjectArray parents;

          // check if this is a camera
          bool isCamera = false;
          for (unsigned int m = 0; m < dag.childCount(); ++m) {
            MFnDagNode child(dag.child(m));
            MFn::Type ctype = child.object().apiType();
            if (ctype == MFn::kCamera) {
              isCamera = true;
              break;
            }
          }

          if (dag.node().apiType() == MFn::kTransform && !isCamera &&
              !globalspace && !withouthierarchy) {
            MDagPath ppath = dag;
            while (!ppath.node().isNull() && ppath.length() > 0 &&
                   ppath.isValid()) {
              parents.append(ppath.node());
              if (ppath.pop() != MStatus::kSuccess) {
                break;
              }
            }
          }
          else {
            parents.append(dag.node());
          }

          // push all parents in
          while (parents.length() > 0) {
            bool found = false;
            for (unsigned int m = 0; m < objects.length(); m++) {
              if (objects[m] == parents[parents.length() - 1]) {
                found = true;
                break;
              }
            }
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:67,代码来源:AlembicWriteJob.cpp

示例14: OutputMaterials

void OutputMaterials(MSelectionList selected){
	
	//::output << "BRUS";//header Brush
	//StartChunck();
MString temp;
MString affich;
	

	
int MatExists=0;

	for(int i=0;i<selected.length();i++){
Affich("element selectioné");

	MDagPath path;
	MObject obj;
	
	int index;
	selected.getDagPath(i,path);
	index = path.childCount();
	affich ="childs ";affich+=index;
	Affich(affich);

	selected.getDependNode(index,obj);


	
	
	//obj=path.child(0);//.child(0);

	

	//MFnMesh fn(path);
	//obj=fn.parent(0);
	//path.getPath(path);
	MFnMesh fna(path.child(1));
	
	
	unsigned int instancenumbers;
	MObjectArray shaders;
	MIntArray indices;
	
	fna.getConnectedShaders(instancenumbers,shaders,indices);

	affich = "shaders lenght "; 
	affich += shaders.length();
Affich(affich);

switch(shaders.length()) {

		// if no shader applied to the mesh instance
		case 0:
			{
				//***************Affich("pas de matériaux");
			}
			break;

		// if all faces use the same material
	
		// if more than one material is used, write out the face indices the materials
		// are applied to.
		default:
			{
				//************************Affich("trouvé plusieurs matériaux");

				
				//write_int(shaders.length());

				// now write each material and the face indices that use them
				
				for(int j=0;j < shaders.length();++j)
				{						
					for(int matest=0;matest<Matid.length();matest++){
						//**************************Affich(Matid[matest].asChar());
						//*****************************Affich(GetShaderName( shaders[j] ).asChar());
						if(Matid[matest]== GetShaderName( shaders[j] )){
						MatExists = 1;
						
						}//fin if matid
						
						}// fin for matest
					if(MatExists != 1){
					//*****************************Affich("matériau absent de la liste, enregistrement");
					Matid.append(GetShaderName( shaders[j] ).asChar());
					::output << "BRUS";//header Brush
						StartChunck();
							//write_int(Matid.length());//id Brush
						//écrire le nb de textures
						int a=nb_Tex_by_Brush[Matid.length()-1];
						if (a==0) a=1;
						info="nb de textures pour ce brush ";
						info+=nb_Tex_by_Brush[Matid.length()-1];
						Affich(info);

							write_int(a);//nb textures in brush
	
						::output << GetShaderName( shaders[j] ).asChar();
						::output << char(0x00);
						
						
//.........这里部分代码省略.........
开发者ID:LordShion,项目名称:B3DMayaExporterPlugin,代码行数:101,代码来源:last_good_2_12_10_08.cpp

示例15: loadJoint


//.........这里部分代码省略.........
				plug.getValue(tail);
				plug = jointFn.findPlug("unParticleUnShaded");
				bool unshaded;
				plug.getValue(unshaded);
				plug = jointFn.findPlug("unParticleUnFogged");
				bool unfogged;
				plug.getValue(unfogged);
				plug = jointFn.findPlug("unParticleBlockByY0");
				bool blockByY0 = false;
				if(!plug.isNull())
					plug.getValue(blockByY0);

				newJoint.particle.visible = visible;
				newJoint.particle.speed = speed;
				newJoint.particle.variation = variation / 100.0f;
				newJoint.particle.coneAngle = coneAngle;
				newJoint.particle.gravity = gravity;
				newJoint.particle.explosiveForce = explosiveForce;
				newJoint.particle.life = life;
				newJoint.particle.lifeVar = lifeVar;
				newJoint.particle.emissionRate = emissionRate;
				newJoint.particle.initialNum = initialNum;
				newJoint.particle.limitNum = limitNum;
				newJoint.particle.attachToEmitter = attachToEmitter;
				newJoint.particle.moveWithEmitter = moveWithEmitter;
				newJoint.particle.forTheSword = forTheSword;
				newJoint.particle.forTheSwordInitialAngle = forTheSwordInitialAngle;
				newJoint.particle.wander = wander;
				newJoint.particle.wanderRadius = wanderRadius;
				newJoint.particle.wanderSpeed = wanderSpeed;
				newJoint.particle.aspectRatio = aspectRatio;
				newJoint.particle.initialAngleBegin = angleBegin;
				newJoint.particle.initialAngleEnd = angleEnd;
				newJoint.particle.rotationSpeed = rotationSpeed;
				newJoint.particle.rotationSpeedVar = rotationSpeedVar;
				newJoint.particle.width = width;
				newJoint.particle.length = length;
				newJoint.particle.height = height;
				newJoint.particle.blendMode = blendMode;
				newJoint.particle.textureFilename = textureName.asChar();
				newJoint.particle.textureRows = rows;
				newJoint.particle.textureCols = cols;
				newJoint.particle.changeStyle = changeStyle;
				newJoint.particle.changeInterval = changeInterval;
				newJoint.particle.tailLength = tailLength;
				newJoint.particle.timeMiddle = timeMiddle;
				newJoint.particle.colorStart[0] = colorStart[0];
				newJoint.particle.colorStart[1] = colorStart[1];
				newJoint.particle.colorStart[2] = colorStart[2];
				newJoint.particle.colorMiddle[0] = colorMiddle[0];
				newJoint.particle.colorMiddle[1] = colorMiddle[1];
				newJoint.particle.colorMiddle[2] = colorMiddle[2];
				newJoint.particle.colorEnd[0] = colorEnd[0];
				newJoint.particle.colorEnd[1] = colorEnd[1];
				newJoint.particle.colorEnd[2] = colorEnd[2];
				newJoint.particle.alpha[0] = alpha[0];
				newJoint.particle.alpha[1] = alpha[1];
				newJoint.particle.alpha[2] = alpha[2];
				newJoint.particle.scale[0] = scale[0];
				newJoint.particle.scale[1] = scale[1];
				newJoint.particle.scale[2] = scale[2];
				newJoint.particle.scaleVar[0] = scaleVar[0];
				newJoint.particle.scaleVar[1] = scaleVar[1];
				newJoint.particle.scaleVar[2] = scaleVar[2];
				newJoint.particle.fixedSize = fixedSize;
				newJoint.particle.headLifeSpan[0] = headLifeSpan[0];
				newJoint.particle.headLifeSpan[1] = headLifeSpan[1];
				newJoint.particle.headLifeSpan[2] = headLifeSpan[2];
				newJoint.particle.headDecay[0] = headDecay[0];
				newJoint.particle.headDecay[1] = headDecay[1];
				newJoint.particle.headDecay[2] = headDecay[2];
				newJoint.particle.tailLifeSpan[0] = tailLifeSpan[0];
				newJoint.particle.tailLifeSpan[1] = tailLifeSpan[1];
				newJoint.particle.tailLifeSpan[2] = tailLifeSpan[2];
				newJoint.particle.tailDecay[0] = tailDecay[0];
				newJoint.particle.tailDecay[1] = tailDecay[1];
				newJoint.particle.tailDecay[2] = tailDecay[2];
				newJoint.particle.head = head;
				newJoint.particle.tail = tail;
				newJoint.particle.unshaded = unshaded;
				newJoint.particle.unfogged = unfogged;
				newJoint.particle.blockByY0 = blockByY0;
			}
		}

		m_joints.push_back(newJoint);
		// Get pointer to newly created joint
		parentJoint = &newJoint;
	}
	// Load children joints
	for (i=0; i<jointDag.childCount();i++)
	{
		MObject child;
		child = jointDag.child(i);
		MDagPath childDag = jointDag;
		childDag.push(child);
		loadJoint(childDag,parentJoint);
	}

}
开发者ID:cpzhang,项目名称:zen,代码行数:101,代码来源:skeleton.cpp


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