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


C++ MDagPathArray::length方法代码示例

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


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

示例1: obj

/** Create a RIB representation of the given node in the DAG as a ribgen.
 */
liqRibObj::liqRibObj( const MDagPath &path, ObjectType objType )
:
  written( 0 ),
  instanceMatrices(),
  objectHandle( NULL ),
  referenceCount( 0 ),
  data()
{
  LIQDEBUGPRINTF( "-> creating dag node handle rep\n");

  MStatus status;
  MObject obj( path.node() );
  MObject skip;

  //lightSources = NULL;
  MFnDagNode nodeFn( obj );

  // Store the matrices for all instances of this node at this time
  // so that they can be used to determine if this node's transformation
  // is animated.  This information is used for doing motion blur.
  MDagPathArray instanceArray;
  nodeFn.getAllPaths( instanceArray );
  unsigned last( instanceArray.length() );
  instanceMatrices.resize( last );
  for ( unsigned i( 0 ); i < last; i++ ) instanceMatrices[ i ] = instanceArray[ i ].inclusiveMatrix();

  LIQDEBUGPRINTF( "-> checking handles display status\n");

  ignore = !areObjectAndParentsVisible( path );
  if ( !ignore ) ignore = !areObjectAndParentsTemplated( path );
  if ( !ignore ) ignore = !isObjectPrimaryVisible( path );

  // check that the shape's transform does not a have a liqIgnoreShapes attribute.
  ignoreShapes = false;
  MDagPath searchPath( path );
  while ( searchPath.apiType() != ( MFn::kTransform ) && searchPath.length() > 1 ) searchPath.pop();
  
  MFnDagNode transformDN( searchPath );
  status.clear();
  MPlug ignorePlug = transformDN.findPlug( "liqIgnoreShapes", &status );
  if ( status == MS::kSuccess ) ignorePlug.getValue( ignoreShapes );

  ignoreShadow = !isObjectCastsShadows( path );
  if ( !ignoreShadow ) ignoreShadow = !areObjectAndParentsVisible( path );
  if ( !ignoreShadow ) ignoreShadow = !areObjectAndParentsTemplated( path );
  
  receiveShadow = isObjectReceivesShadows( path );

  // don't bother storing it if it's not going to be visible!
  LIQDEBUGPRINTF( "-> about to create rep\n");

  if ( !ignore || !ignoreShadow ) 
  {
    if ( objType == MRT_RibGen ) 
    {
      type = MRT_RibGen;
      data = liqRibDataPtr( new liqRibGenData( obj, path ) );
    } 
    else 
    {
      // check to see if object's class is derived from liqCustomNode
      liqCustomNode *customNode( NULL );
      MFnDependencyNode mfnDepNode( obj, &status );
      if ( status ) 
      {
        MPxNode *mpxNode( mfnDepNode.userNode() );
        if ( mpxNode ) 
          customNode = dynamic_cast< liqCustomNode* >( mpxNode ); // will be NULL if cast is not invalid
      }
      // Store the geometry/light/shader data for this object in RIB format
      if ( customNode ) 
      {
        type = MRT_Custom;
        data = liqRibDataPtr( new liqRibCustomNode( (( !ignoreShapes )? obj : skip ), customNode ) );
      } 
      else if ( obj.hasFn(MFn::kNurbsSurface) ) 
      {
        type = MRT_Nurbs;
        data = liqRibDataPtr( new liqRibSurfaceData( ( !ignoreShapes )? obj : skip ) );
      } 
      else if ( obj.hasFn(MFn::kSubdiv) ) 
      {
        type = MRT_Subdivision;
        data = liqRibDataPtr( new liqRibMayaSubdivisionData( ( !ignoreShapes )? obj : skip ) );
      } 
      else if ( obj.hasFn(MFn::kNurbsCurve) ) 
      {
        type = MRT_NuCurve;
        data = liqRibDataPtr( new liqRibNuCurveData( ( !ignoreShapes )? obj : skip ) );
      } 
      else if ( obj.hasFn(MFn::kPfxGeometry) ) 
      {
	      type = objType;
        data = liqRibDataPtr( new liqRibPfxData( (( !ignoreShapes )? obj : skip), objType ) );
      } 
      else if ( obj.hasFn( MFn::kPfxToon ) ) 
      {
        type = MRT_PfxToon;
//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:liquidmaya,代码行数:101,代码来源:liqRibObj.cpp

示例2: doConversion

IECore::ObjectPtr FromMayaSkinClusterConverter::doConversion( const MObject &object, IECore::ConstCompoundObjectPtr operands ) const
{
	MStatus stat;

	// our data storage objects
	IECore::StringVectorDataPtr influenceNamesData = new IECore::StringVectorData();
	IECore::M44fVectorDataPtr influencePoseData  = new IECore::M44fVectorData();
	IECore::IntVectorDataPtr pointIndexOffsetsData  = new IECore::IntVectorData();
	IECore::IntVectorDataPtr pointInfluenceCountsData = new IECore::IntVectorData();
	IECore::IntVectorDataPtr pointInfluenceIndicesData = new IECore::IntVectorData();
	IECore::FloatVectorDataPtr pointInfluenceWeightsData = new IECore::FloatVectorData();

	// get a skin cluster fn
	MFnSkinCluster skinClusterFn(object);

	MDagPathArray influencePaths;
	skinClusterFn.influenceObjects(influencePaths);

	// get the influence names
	int influencesCount = influencePaths.length();
	influenceNamesData->writable().reserve( influencesCount );

	InfluenceName in = (InfluenceName)m_influenceNameParameter->getNumericValue();
	switch( in )
	{
		case Partial :
		{
			for (int i=0; i < influencesCount; i++)
			{
				influenceNamesData->writable().push_back( influencePaths[i].partialPathName(&stat).asChar() );
			}
			break;
		}
		case Full :
		{
			for (int i=0; i < influencesCount; i++)
			{
				influenceNamesData->writable().push_back( influencePaths[i].fullPathName(&stat).asChar() );
			}
			break;
		}
	}

	// extract bind pose
	MFnDependencyNode skinClusterNodeFn( object );

	MPlug bindPreMatrixArrayPlug = skinClusterNodeFn.findPlug( "bindPreMatrix", true, &stat );

	for (int i=0; i < influencesCount; i++)
	{
		MPlug bindPreMatrixElementPlug = bindPreMatrixArrayPlug.elementByLogicalIndex(
				skinClusterFn.indexForInfluenceObject( influencePaths[i], NULL ), &stat);
		MObject matObj;
		bindPreMatrixElementPlug.getValue( matObj );
		MFnMatrixData matFn( matObj, &stat );
		MMatrix mat = matFn.matrix();
		Imath::M44f cmat = IECore::convert<Imath::M44f>( mat );

		influencePoseData->writable().push_back( cmat );
	}

	// extract the skinning information

	// get the first input geometry to the skin cluster
	// TODO: if needed, extend this to retrieve more than one output geometry
	MObjectArray outputGeoObjs;
	stat = skinClusterFn.getOutputGeometry( outputGeoObjs );

	if (! stat)
	{
		throw IECore::Exception( "FromMayaSkinClusterConverter: skinCluster node does not have any output geometry!" );
	}

	// get the dag path to the first object
	MFnDagNode dagFn( outputGeoObjs[0] );
	MDagPath geoPath;
	dagFn.getPath( geoPath );

	// generate a geo iterator for the components
	MItGeometry geoIt( outputGeoObjs[0] );
	int currentOffset = 0;

	// loop through all the points of the geometry to extract their bind information
	for ( ; !geoIt.isDone(); geoIt.next() )
	{
		MObject pointObj = geoIt.currentItem( &stat );
		MDoubleArray weights;
		unsigned int weightsCount;

		skinClusterFn.getWeights( geoPath, pointObj, weights, weightsCount );
		int pointInfluencesCount = 0;

		for ( int influenceId = 0; influenceId < int( weightsCount ); influenceId++ )
		{
			// ignore zero weights, we are generating a compressed (non-sparse) representation of the weights
			/// \todo: use a parameter to specify a threshold value rather than 0.0
			if ( weights[influenceId] != 0.0 )
			{
				pointInfluencesCount++;
				pointInfluenceWeightsData->writable().push_back( float( weights[influenceId] ) );
//.........这里部分代码省略.........
开发者ID:AtomicFiction,项目名称:cortex,代码行数:101,代码来源:FromMayaSkinClusterConverter.cpp

示例3: pathName

/** Create a RIB representation of the given node in the DAG as a ribgen.
 */
liqRibObj::liqRibObj( const MDagPath &path, ObjectType objType )
    :
    written( 0 ),
    instanceMatrices(),
    objectHandle( NULL ),
    referenceCount( 0 ),
    data()
{
    CM_TRACE_FUNC("liqRibObj::liqRibObj("<<path.fullPathName()<<","<<objType<<")");

    LIQDEBUGPRINTF( "-> creating dag node handle rep\n");
    MString pathName(path.fullPathName()); //debug
    MStatus status;
    MObject obj( path.node() );
    MObject skip;

    //lightSources = NULL;
    MFnDagNode nodeFn( obj );

    // Store the matrices for all instances of this node at this time
    // so that they can be used to determine if this node's transformation
    // is animated.  This information is used for doing motion blur.
    MDagPathArray instanceArray;
    nodeFn.getAllPaths( instanceArray );
    unsigned last( instanceArray.length() );
    instanceMatrices.resize( last );
    for( unsigned i( 0 ); i < last; i++ )
        instanceMatrices[ i ] = instanceArray[ i ].inclusiveMatrix();

    LIQDEBUGPRINTF( "-> checking handles display status\n");

    ignore = !areObjectAndParentsVisible( path );
    if( !ignore )
        ignore = !areObjectAndParentsTemplated( path );

    if( !ignore )
        ignore = !isObjectPrimaryVisible( path );

    // check that the shape's transform does not a have a liqIgnoreShapes attribute.
    ignoreShapes = false;
    MDagPath searchPath( path );
    while ( searchPath.apiType() != ( MFn::kTransform ) && searchPath.length() > 1 )
        searchPath.pop();

    MFnDagNode transformDN( searchPath );
    status.clear();
    MPlug ignorePlug = transformDN.findPlug( "liqIgnoreShapes", &status );
    if( status == MS::kSuccess )
        ignorePlug.getValue( ignoreShapes );

    ignoreShadow = !isObjectCastsShadows( path );
    if( !ignoreShadow )
        ignoreShadow = !areObjectAndParentsVisible( path );

    if( !ignoreShadow )
        ignoreShadow = !areObjectAndParentsTemplated( path );


    // don't bother storing it if it's not going to be visible!
    LIQDEBUGPRINTF( "-> about to create rep\n");

    if( !ignore || !ignoreShadow )
    {
        if( objType == MRT_RibGen )
        {
            type = MRT_RibGen;
            data = liqRibDataPtr( new liqRibGenData( obj, path ) );
        }
        else
        {

            // check to see if object's class is derived from liqCustomNode
            liqCustomNode *customNode( NULL );
            MFnDependencyNode mfnDepNode( obj, &status );
            if( status )
            {
                MPxNode *mpxNode( mfnDepNode.userNode() );
                if(mpxNode)
                    customNode = dynamic_cast< liqCustomNode* >( mpxNode ); // will be NULL if cast is not invalid
            }

            // Store the geometry/light/shader data for this object in RIB format
            if(customNode)
            {
                type = MRT_Custom;
                if( !ignoreShapes )
                    data = liqRibDataPtr( new liqRibCustomNode( obj, customNode ) );
                else
                    data = liqRibDataPtr( new liqRibCustomNode( skip, customNode ) );
            }
            else if( obj.hasFn(MFn::kNurbsSurface) )
            {
                type = MRT_Nurbs;
                if( !ignoreShapes )
                    data = liqRibDataPtr( new liqRibSurfaceData( obj ) );
                else
                    data = liqRibDataPtr( new liqRibSurfaceData( skip ) );
            }
//.........这里部分代码省略.........
开发者ID:yaoyansi,项目名称:maya2renderer,代码行数:101,代码来源:liqRibObj.cpp

示例4: writeRefNodeParenting

//
// Deal with nodes whose parenting is between referenced and non-referenced
// nodes.
//
void maTranslator::writeRefNodeParenting(fstream& f)
{
	unsigned int numNodes = fParentingRequired.length();
	unsigned int i;

	for (i = 0; i < numNodes; i++)
	{
		MFnDagNode	nodeFn(fParentingRequired[i]);

		//
		// Find out if this node has any parents from referenced or
		// non-referenced files.
		//
		bool			hasRefParents = false;
		bool			hasNonRefParents = false;
		unsigned int	numParents = nodeFn.parentCount();
		unsigned int	p;

		for (p = 0; p < numParents; p++)
		{
			MObject		parent = nodeFn.parent(p);
			MFnDagNode	parentFn(parent);

			if (parentFn.isFromReferencedFile())
				hasRefParents = true;
			else
				hasNonRefParents = true;

			if (hasRefParents && hasNonRefParents) break;
		}

		//
		// If this node is from a referenced file and it has parents which
		// are also from a referenced file, then it already has its first
		// parent and all others are added instances.
		//
		// Similarly if the node is not from a referenced file and has
		// parents which are also not from referenced files.
		//
		bool	alreadyHasFirstParent =
			(nodeFn.isFromReferencedFile() ? hasRefParents : hasNonRefParents);

		//
		// Now run through the parents again and output any parenting
		// which involves a non-referenced node, either as parent or child.
		//
		for (p = 0; p < numParents; p++)
		{
			MObject		parent = nodeFn.parent(p);
			MFnDagNode	parentFn(parent);

			if (parentFn.isFromReferencedFile() != nodeFn.isFromReferencedFile())
			{
				//
				// Get the first path to the parent.
				//
				MDagPath	parentPath;
				MDagPath::getAPathTo(parentFn.object(), parentPath);

				writeParent(
					f, parentPath, fParentingRequired[i], alreadyHasFirstParent
				);

				//
				// If it didn't have its first parent before, it does now.
				//
				alreadyHasFirstParent = true;
			}
		}
	}
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:75,代码来源:maTranslator.cpp

示例5: CreateMeshGroup

bool HesperisIO::CreateMeshGroup(const MDagPathArray & paths, ATriangleMeshGroup * dst)
{
    MStatus stat;
	unsigned i, j;
	int numPnts = 0;
	unsigned numNodes = 0;
	unsigned numTris = 0;
	
	// MGlobal::displayInfo(" hesperis check meshes");
	
	MIntArray triangleCounts, triangleVertices;
	MPointArray ps;
    MPoint wp;
	MMatrix worldTm;
    
    const unsigned n = paths.length();
    for(i=0; i<n; i++) {
		MFnMesh fmesh(paths[i].node(), &stat);
		if(!stat) continue;
		numNodes++;
        
        numPnts += fmesh.numVertices();
		fmesh.getTriangles(triangleCounts, triangleVertices);
		numTris += triangleVertices.length() / 3;
	}
    
    if(numNodes < 1 || numTris < 1) {
        MGlobal::displayInfo(" insufficient mesh data");
        return false;   
    }
    
    //MGlobal::displayInfo(MString(" mesh count: ") + numNodes +
    //                     MString(" vertex count: ") + numPnts +
	//                    MString(" triangle count: ") + numTris);
	
    dst->create(numPnts, numTris, numNodes);
	Vector3F * pnts = dst->points();
	unsigned * inds = dst->indices();
    unsigned * pntDrift = dst->pointDrifts();
    unsigned * indDrift = dst->indexDrifts();
    
    unsigned pDrift = 0;
    unsigned iDrift = 0;
    unsigned iNode = 0;
    for(i=0; i<n; i++) {
		MFnMesh fmesh(paths[i].node(), &stat);
		if(!stat) continue;
        //MGlobal::displayInfo(fmesh.name());
        //MGlobal::displayInfo(MString("p drift ")+pDrift+
        //                     MString("i drift ")+iDrift);
		
        worldTm = AHelper::GetWorldTransformMatrix(paths[i]);
		
		fmesh.getPoints(ps, MSpace::kObject);
		fmesh.getTriangles(triangleCounts, triangleVertices);
			
		for(j=0; j<fmesh.numVertices(); j++) {
            wp = ps[j] * worldTm - GlobalReferencePoint;
			pnts[pDrift + j].set((float)wp.x, (float)wp.y, (float)wp.z);
        }
		
		for(j=0; j<triangleVertices.length(); j++)
			inds[iDrift + j] = pDrift + triangleVertices[j];
        
        pntDrift[iNode] = pDrift;
        indDrift[iNode] = iDrift;
        
        pDrift += fmesh.numVertices();
        iDrift += triangleVertices.length();
        iNode++;
	}
    
    return true;
}
开发者ID:spinos,项目名称:aphid,代码行数:74,代码来源:HesperisIO.cpp


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