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


C++ MItDag类代码示例

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


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

示例1: while

    // ------------------------------------------------------------
    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

示例2: l

SceneInterfacePtr LiveScene::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( "IECoreMaya::LiveScene::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( "IECoreMaya::LiveScene::retrieveScene: Couldn't find transform at specified path " + pathName );
		}
		return 0;
	}
	
}
开发者ID:cnpinto,项目名称:cortex,代码行数:60,代码来源:LiveScene.cpp

示例3: m_isRoot

LiveScene::LiveScene() : m_isRoot( true )
{
	tbb::mutex::scoped_lock l( s_mutex );
	
	// initialize to the root path:
	MItDag it;
	it.getPath( m_dagPath );
}
开发者ID:cnpinto,项目名称:cortex,代码行数:8,代码来源:LiveScene.cpp

示例4: retVal

//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MStatus CVsSkinnerCmd::FindSkinnerNodesInHierarchy(
	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 ( !IsSkinnerNode( sDagPath ) )
				continue;

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

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

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

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

示例5: GetCurves

bool HesperisIO::GetCurves(const MDagPath &root, MDagPathArray & dst)
{
    MStatus stat;
	MItDag iter;
	iter.reset(root, MItDag::kDepthFirst, MFn::kNurbsCurve);
	for(; !iter.isDone(); iter.next()) {								
		MDagPath apath;		
		iter.getPath( apath );
		if(IsCurveValid(apath)) {
            MFnDagNode fdag(apath);
            if(!fdag.isIntermediateObject())
                dst.append(apath);
        }
	}
    return dst.length() > 0;
}
开发者ID:ahmidou,项目名称:aphid,代码行数:16,代码来源:HesperisIO.cpp

示例6: doIt

MStatus unShowAvailableSystems::doIt( const MArgList& args )
{
	MItDag dagIter;
	MFnDagNode worldDag (dagIter.root());
	MDagPath worldPath;
	worldDag.getPath(worldPath);

	std::string str;
	findAvailableSystems(str,worldPath);
	if(!str.empty())
	{
		MessageBox(0,str.c_str(),"Particle or Ribbon Systems",0);
	}
	else
	{
		MessageBox(0,"no particle or ribbon system yet","Particle or Ribbon Systems",0);
	}

	return MS::kSuccess;
}
开发者ID:cpzhang,项目名称:zen,代码行数:20,代码来源:mayammexport.cpp

示例7: fillSkeleton

void DMPDSExporter::fillSkeleton( DMPParameters* param )
{
	MStatus stat;
	mSkelData.clear();
	if (!param->bExportSkeleton)
	{
		return;
	}
	mSkelData.skeleton.name = param->skeletonFileName.asUTF8();


	// Get the selection list
	MSelectionList activeList;
	stat = MGlobal::getActiveSelectionList(activeList);
	if(param->bExportAll)
	{
		// We are exporting the whole scene
		MItDag dagIter;
		MFnDagNode worldDag (dagIter.root());
		MDagPath worldPath;
		worldDag.getPath(worldPath);
		traverseSubSkeleton(param, worldPath);
	}
	else
	{
		if (MStatus::kSuccess != stat)
		{
			return;
		}
		MItSelectionList iter(activeList);

		for ( ; !iter.isDone(); iter.next())
		{								
			MDagPath dagPath;
			iter.getDagPath(dagPath);
			traverseSubSkeleton(param, dagPath); 
		}	
	}
	// may lose selection while exporting, so reset it.
	MGlobal::setActiveSelectionList(activeList);
}
开发者ID:jiazhipeng03,项目名称:Duel-Engine,代码行数:41,代码来源:DuelMPDSExporter.cpp

示例8: DoSelect

//-----------------------------------------------------------------------------
// Selects all vstAttachment nodes in the scene
//-----------------------------------------------------------------------------
MStatus CVstAttachmentCmd::DoSelect()
{
	MSelectionList mSelectionList;
	MDagPath mDagPath;

	for ( MItDag dagIt; !dagIt.isDone(); dagIt.next() )
	{
		if ( MFnDependencyNode( dagIt.item() ).typeName() == "vstAttachment" )
		{
			dagIt.getPath( mDagPath );
			mSelectionList.add( mDagPath, MObject::kNullObj, true );
		}
	}

	if ( mSelectionList.length() )
	{
		// Save the current selection just in case we want to undo stuff
		MGlobal::getActiveSelectionList( m_mSelectionList );
		MGlobal::setActiveSelectionList( mSelectionList, MGlobal::kReplaceList );
		m_undoable = true;
	}

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

示例9: Mesh

	// Execute the command
	MStatus OgreExporter::doIt(const MArgList& args)
	{
		// clean up
		delete m_pMesh;
		delete m_pMaterialSet;

		// Parse the arguments.
		m_params.parseArgs(args);
		// Create output files
		m_params.openFiles();
		// Create a new empty mesh
		m_pMesh = new Mesh();
		// Create a new empty material set
		m_pMaterialSet = new MaterialSet();
		// Save current time for later restore
		m_curTime = MAnimControl::currentTime();
		// Save active selection list for later restore
		MGlobal::getActiveSelectionList(m_selList);
		/**************************** LOAD DATA **********************************/
		if (m_params.exportAll)
		{	// We are exporting the whole scene
			std::cout << "Export the whole scene\n";
			std::cout.flush();
			MItDag dagIter;
			MFnDagNode worldDag (dagIter.root());
			MDagPath worldPath;
			worldDag.getPath(worldPath);
			stat = translateNode(worldPath);
		}
		else
		{	// We are translating a selection
			std::cout << "Export selected objects\n";
			std::cout.flush();
			// Get the selection list
			MSelectionList activeList;
			stat = MGlobal::getActiveSelectionList(activeList);
			if (MS::kSuccess != stat)
			{
				std::cout << "Error retrieving selection list\n";
				std::cout.flush();
				exit();
				return MS::kFailure;
			}
			MItSelectionList iter(activeList);

			for ( ; !iter.isDone(); iter.next())
			{								
				MDagPath dagPath;
				stat = iter.getDagPath(dagPath);
				stat = translateNode(dagPath); 
			}							
		}

		// Load vertex animations
		if (m_params.exportVertAnims)
			m_pMesh->loadAnims(m_params);

		// Load blend shapes
		if (m_params.exportBlendShapes)
			m_pMesh->loadBlendShapes(m_params);

		// Restore skeleton to correct pose
		if (m_pMesh->getSkeleton())
			m_pMesh->getSkeleton()->restorePose();

		// Load skeleton animation (do it now, so we have loaded all needed joints)
		if (m_pMesh->getSkeleton() && m_params.exportSkelAnims)
		{
			// Load skeleton animations
			m_pMesh->getSkeleton()->loadAnims(m_params);
		}

		/**************************** WRITE DATA **********************************/
		stat = writeOgreData();

		std::cout << "Export completed succesfully\n";
		std::cout.flush();
		exit();

		return MS::kSuccess;
	}
开发者ID:Anti-Mage,项目名称:ogre,代码行数:82,代码来源:ogreExporter.cpp

示例10: retrieveExportNodes

    // ------------------------------------------------------------
    bool SceneGraph::retrieveExportNodes()
    {
        // Create a selection list containing only the root nodes (implies export all!)
        MSelectionList allTargets;
        for (   MItDag it ( MItDag::kBreadthFirst ); 
                it.depth()<=1 && it.item()!=MObject::kNullObj; 
                it.next() )
        {
            MDagPath path;
            MStatus status = it.getPath ( path );
            String pathName = path.fullPathName().asChar();

            // Attach a function set
            MFnDependencyNode fn ( path.node() );
            String theNodeName = fn.name().asChar();

            // Check if it's the world node
            if ( it.depth() == 0 ) continue;

            if ( status == MStatus::kSuccess )
            {
                if ( mExportSelectedOnly )
                    allTargets.add ( path );
                else
                    mTargets.add ( path );
            }
        }

        // now fill in the targets, either the same as allTargets, or it is export selection only
        if ( mExportSelectedOnly )
        {
            // Export the selection:
            // Grab the selected DAG components
            if ( MStatus::kFailure == MGlobal::getActiveSelectionList ( mTargets ) )
            {
                std::cerr << "MGlobal::getActiveSelectionList" << std::endl;
                return false;
            }

            // For all the non-transforms selected, make sure to extend to the transforms underneath.
            MDagPathArray additions;
            MIntArray removals;

            for ( uint32 i = 0; i < mTargets.length(); ++i )
            {
                MDagPath itemPath;
                mTargets.getDagPath ( i, itemPath );
                if ( !itemPath.node().hasFn ( MFn::kTransform ) )
                {
                    MDagPath transformPath = itemPath;
                    while ( transformPath.length() > 0 )
                    {
                        transformPath.pop();

                        if ( !mTargets.hasItem ( transformPath ) )
                        {
                            additions.append ( transformPath );
                            break;
                        }
                    }
                    removals.append ( i );
                }
            }

            for ( uint32 i = 0; i < removals.length(); ++i ) mTargets.remove ( removals[i] - i );
            for ( uint32 i = 0; i < additions.length(); ++i ) mTargets.add ( additions[i] );

            // Add all the forced nodes to the list.
            uint32 forceNodeCount = mForcedNodes.length();
            for ( uint32 i = 0; i < forceNodeCount; ++i )
            {
                MDagPath p = mForcedNodes[i];
                if ( mTargets.hasItem ( p ) ) continue;

                mTargets.add ( p );
            }

            // Add additional selection paths for any objects in our
            // selection which have been instanced (either directly, or
            // via instancing of an ancestor) - as otherwise, the selection
            // will only include ONE of the DAG paths
            //
            addInstancedDagPaths ( mTargets );

            // remove any selected nodes CONTAINED within other selected
            // hierarchies (to ensure we don't export subtrees multiple times)
            //
            removeMultiplyIncludedDagPaths ( mTargets );
        }

        return true;
    }
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:93,代码来源:COLLADAMayaSceneGraph.cpp

示例11: writeBrokenRefConnections

//
// Write out all of the connections in the scene.
//
void maTranslator::writeConnections(fstream& f)
{
	//
	// If the scene has broken any connections which were made in referenced
	// files, handle those first so that the attributes are free for any new
	// connections which may come along.
	//
	writeBrokenRefConnections(f);

	//
	// We're about to write out the scene's connections in three parts: DAG
	// nodes, non-DAG non-default nodes, then default nodes.
	//
	// It's really not necessary that we group them like this and would in
	// fact be more efficient to do them all in one MItDependencyNodes
	// traversal.  However, this is the order in which the normal MayaAscii
	// translator does them, so this makes it easier to compare the output
	// of this translator to Maya's output.
	//

	//
	// Write out connections for the DAG nodes first.
	//
	MItDag	dagIter;
	dagIter.traverseUnderWorld(true);

	for (dagIter.next(); !dagIter.isDone(); dagIter.next())
	{
		MObject		node = dagIter.item();
		MFnDagNode	dagNodeFn(node);

		if (!dagNodeFn.isFlagSet(fConnectionFlag)
		&&	dagNodeFn.canBeWritten()
		&&	!dagNodeFn.isDefaultNode())
		{
			writeNodeConnections(f, dagIter.item());
			dagNodeFn.setFlag(fConnectionFlag, true);
		}
	}

	//
	// Now do the non-DAG, non-default nodes.
	//
	MItDependencyNodes	nodeIter;

	for (; !nodeIter.isDone(); nodeIter.next())
	{
		MFnDependencyNode	nodeFn(nodeIter.item());

		if (!nodeFn.isFlagSet(fConnectionFlag)
		&&	nodeFn.canBeWritten()
		&&	!nodeFn.isDefaultNode())
		{
			writeNodeConnections(f, nodeIter.item());
			nodeFn.setFlag(fConnectionFlag, true);
		}
	}

	//
	// And finish up with the default nodes.
	//
	unsigned int	numNodes = fDefaultNodes.length();
	unsigned int	i;

	for (i = 0; i < numNodes; i++)
	{
		MFnDependencyNode	nodeFn(fDefaultNodes[i]);

		if (!nodeFn.isFlagSet(fConnectionFlag)
		&&	nodeFn.canBeWritten()
		&&	nodeFn.isDefaultNode())
		{
			writeNodeConnections(f, fDefaultNodes[i]);
			nodeFn.setFlag(fConnectionFlag, true);
		}
	}
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:80,代码来源:maTranslator.cpp

示例12: getBoundingBox

MBoundingBox AbcWriteJob::getBoundingBox(double iFrame, const MMatrix & eMInvMat)
{
    MStatus status;
    MBoundingBox curBBox;

    if (iFrame == mFirstFrame)
    {
        // Set up bbox shape map in the first frame.
        // If we have a lot of transforms and shapes, we don't need to
        // iterate them for each frame.
        MItDag dagIter;
        for (dagIter.reset(mCurDag); !dagIter.isDone(); dagIter.next())
        {
            MObject object = dagIter.currentItem();
            MDagPath path;
            dagIter.getPath(path);

            // short-circuit if the selection flag is on but this node is not in the
            // active selection

            // MGlobal::isSelected(ob) doesn't work, because DG node and DAG node is
            // not the same even if they refer to the same MObject
            if (mArgs.useSelectionList && !mSList.hasItem(path))
            {
                dagIter.prune();
                continue;
            }

            MFnDagNode dagNode(path, &status);
            if (status == MS::kSuccess)
            {
                // check for riCurves flag for flattening all curve object to
                // one curve group
                MPlug riCurvesPlug = dagNode.findPlug("riCurves", &status);
                if ( status == MS::kSuccess && riCurvesPlug.asBool() == true)
                {
                    MBoundingBox box = dagNode.boundingBox();
                    box.transformUsing(path.exclusiveMatrix()*eMInvMat);
                    curBBox.expand(box);

                    // Prune this curve group
                    dagIter.prune();

                    // Save children paths
                    std::map< MDagPath, util::ShapeSet, util::cmpDag >::iterator iter =
                        mBBoxShapeMap.insert(std::make_pair(mCurDag, util::ShapeSet())).first;
                    if (iter != mBBoxShapeMap.end())
                        (*iter).second.insert(path);
                }
                else if (object.hasFn(MFn::kParticle)
                    || object.hasFn(MFn::kMesh)
                    || object.hasFn(MFn::kNurbsCurve)
                    || object.hasFn(MFn::kNurbsSurface) )
                {
                    if (util::isIntermediate(object))
                        continue;

                    MBoundingBox box = dagNode.boundingBox();
                    box.transformUsing(path.exclusiveMatrix()*eMInvMat);
                    curBBox.expand(box);

                    // Save children paths
                    std::map< MDagPath, util::ShapeSet, util::cmpDag >::iterator iter =
                        mBBoxShapeMap.insert(std::make_pair(mCurDag, util::ShapeSet())).first;
                    if (iter != mBBoxShapeMap.end())
                        (*iter).second.insert(path);
                }
            }
        }
    }
    else
    {
        // We have already find out all the shapes for the dag path.
        std::map< MDagPath, util::ShapeSet, util::cmpDag >::iterator iter =
            mBBoxShapeMap.find(mCurDag);
        if (iter != mBBoxShapeMap.end())
        {
            // Iterate through the saved paths to calculate the box.
            util::ShapeSet& paths = (*iter).second;
            for (util::ShapeSet::iterator pathIter = paths.begin();
                pathIter != paths.end(); pathIter++)
            {
                MFnDagNode dagNode(*pathIter, &status);
                if (status == MS::kSuccess)
                {
                    MBoundingBox box = dagNode.boundingBox();
                    box.transformUsing((*pathIter).exclusiveMatrix()*eMInvMat);
                    curBBox.expand(box);
                }
            }
        }
    }

    return curBBox;
}
开发者ID:boberfly,项目名称:gafferDependencies,代码行数:95,代码来源:AbcWriteJob.cpp

示例13: ExportMayaNodes

void MayaMeshExporter::ExportMayaNodes(MItDag& dag_iterator)
{
	int start_frame = static_cast<int>(MAnimControl::minTime().as(MTime::kNTSCField));
	int end_frame = static_cast<int>(MAnimControl::maxTime().as(MTime::kNTSCField));
	int num_frames = end_frame - start_frame + 1;
	meshml_obj_.NumFrames(num_frames);

	MAnimControl::setCurrentTime(MTime(start_frame, MTime::kNTSCField));

	for (MItDependencyNodes dn(MFn::kSkinClusterFilter); !dn.isDone(); dn.next())
	{
		MStatus status = MS::kSuccess;
		MObject object = dn.item();
		shared_ptr<MFnSkinCluster> skin_cluster = MakeSharedPtr<MFnSkinCluster>(object, &status);

		std::vector<MObject> objs;
		unsigned int num_geometries = skin_cluster->numOutputConnections();
		for (unsigned int i = 0; i < num_geometries; ++ i) 
		{
			unsigned int index = skin_cluster->indexForOutputConnection(i);
			objs.push_back(skin_cluster->outputShapeAtIndex(index));
		}

		if (num_geometries > 0)
		{
			skin_clusters_.push_back(std::make_pair(skin_cluster, objs));
		}

		MDagPathArray influence_paths;
		int num_influence_objs = skin_cluster->influenceObjects(influence_paths, &status);

		MDagPath joint_path, root_path;
		for (int i = 0; i < num_influence_objs; ++ i)
		{
			joint_path = influence_paths[i];
			if (joint_path.hasFn(MFn::kJoint))
			{
				// Try to retrieve the root path
				root_path = joint_path;
				while (joint_path.length() > 0)
				{
					joint_path.pop();
					if (joint_path.hasFn(MFn::kJoint) && (joint_path.length() > 0))
					{
						root_path = joint_path;
					}
				}

				if (root_path.hasFn(MFn::kJoint))
				{
					MFnIkJoint fn_joint(root_path);

					// Don't work on existing joints
					KLAYGE_AUTO(iter, joint_to_id_.find(fn_joint.fullPathName().asChar()));
					if (iter == joint_to_id_.end())
					{
						this->ExportJoint(NULL, fn_joint, root_path);
					}
				}
			}
		}
	}
	
	MDagPath dag_path;
	for (; !dag_iterator.isDone(); dag_iterator.next())
	{
		MStatus status = dag_iterator.getPath(dag_path);
		if (!status)
		{
			std::cout << "Fail to get DAG path." << std::endl;
			continue;
		}

		MString obj_name = dag_iterator.partialPathName();
		switch (dag_path.apiType())
		{
		case MFn::kTransform:
			{
				/*MFnTransform fnTransform(dagPath, &status);
				if (status == MS::kSuccess)
				{
					MFloatMatrix matrix = fnTransform.transformation().asMatrix();
					// TODO: how to handle transformations?
				}
				else
				std::cout << "Fail to initialize transform node." << std::endl;*/
			}
			break;

		case MFn::kMesh:
			{
				MFnMesh fn_mesh(dag_path, &status);
				if (MS::kSuccess == status)
				{
					if (!fn_mesh.isIntermediateObject())
					{
						this->ExportMesh(obj_name, fn_mesh, dag_path);
					}
					else
					{
//.........这里部分代码省略.........
开发者ID:qioixiy,项目名称:KlayGE,代码行数:101,代码来源:exporter.cpp

示例14: MPoint

MStatus HairToolContext::doPress( MEvent& event )
 {
	// if we have a left mouse click
	if(event.mouseButton() == MEvent::kLeftMouse)
	{
		//Our Viewer
		m_View = M3dView::active3dView();

		//Get Screen click position
		event.getPosition( m_storage[0], m_storage[1] );
		screenPoints = vector<vec2>();
		screenPoints.push_back(vec2(m_storage[0], m_storage[1]));
		//char buffer[200];
		//sprintf(buffer, "print \"%i, %i\\n\"", m_storage[0], m_storage[1]);
		//MGlobal::executeCommand(buffer);

		//Camera stuff
		MPoint origin = MPoint();
		MVector direction = MVector();
		m_View.viewToWorld(m_storage[0], m_storage[1], origin, direction);

		//Iterate through meshes in scene
		bool intersection = false;
		MPointArray points =  MPointArray();
		MIntArray polygonIds =  MIntArray();
		MItDag dagIter = MItDag(MItDag::kBreadthFirst, MFn::kInvalid);
		for( ; !dagIter.isDone(); dagIter.next() ){
			MDagPath dagPath;
			dagIter.getPath(dagPath);
			MFnDagNode dagNode( dagPath);

			//Object cannot be intermediate, it must be a mesh
			if( dagNode.isIntermediateObject() ) continue;
			if( !dagPath.hasFn(MFn::kMesh) ) continue;
			if( dagPath.hasFn(MFn::kTransform) ) continue;

			MGlobal::executeCommand(MString("print \"node is a mesh \\n\""));

			//MFnMesh mesh = MFnMesh(dagPath);
			MFnMesh mesh(dagPath);
			points =  MPointArray();
			polygonIds =  MIntArray();
			intersection = mesh.intersect(origin, direction, points, 1e-010, MSpace::kWorld, &polygonIds);
			
			if(intersection){
				break;
			}
		}
		
		if(intersection){
			intersectionFound = true;

			MDagPath dagPath;
			dagIter.getPath(dagPath);
			// MFnMesh mesh = MFnMesh(dagPath);
			MFnMesh mesh(dagPath);

			//Polygon Normal
			MVector polygonNormal;
			mesh.getPolygonNormal(polygonIds[0], polygonNormal, MSpace::kWorld);
			if(polygonNormal.normal().angle(direction.normal()) < 20.0f){
				//polygonNormal = mesh.get
			}

			//Camera Right
			m_View.getCamera(dagPath);
			MFnCamera camera(dagPath);
			MVector cameraRight = camera.rightDirection(MSpace::kWorld);
			
			//Resulting Plane
			//Point
			point = points[0];
			//Normal
			normal = cameraRight^polygonNormal;

			//pushback point
			splinePoints = vector<MPoint>();
			splinePoints.push_back(MPoint(points[0].x, points[0].y, points[0].z, points[0].w));

			/*//Calculate Tvalue
			tValue = (points[0].x - origin.x)/direction.x;*/
			
		}
		else{
			intersectionFound = false;
			MGlobal::executeCommand("print \" No Intersection \\n\"");
		}

		// yay!
		return MS::kSuccess;
	}

	// just let the base class handle the event*/
	return MPxContext::doPress(event);
 }
开发者ID:naojitaniguchi,项目名称:OverCoar-for-Maya-2016,代码行数:95,代码来源:HairToolContext.cpp

示例15: optSelected

//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MSelectionList CVsSkinnerCmd::DoNewVolumes(
	const MDagPath &skinnerPath,
	const MSelectionList &skeletonList )
{
	MSelectionList retList;

	const bool optSelected( m_undo.ArgDatabase().isFlagSet( kOptSelected ) );

	MSelectionList optSelection;
	m_undo.ArgDatabase().getObjects( optSelection );

	// TODO: Maybe some fancier logic to only create volumes on joints that make sense?
	//		 Perhaps the ol' has children but no shapes gag?  Watch out for vstHelperBones!

	MDagPath mDagPath;
	for ( MItSelectionList sIt( optSelection ); !sIt.isDone(); sIt.next() )
	{
		if ( sIt.itemType() == MItSelectionList::kDagSelectionItem && sIt.getDagPath( mDagPath ) && mDagPath.hasFn( MFn::kTransform ) )
		{
			if ( optSelected )
			{
				MObject cObj( DoNewVolume( skinnerPath, mDagPath ) );
				if ( cObj.isNull() )
				{
					mwarn << "Couldn't create new volume on " << skinnerPath.partialPathName()
						<< " using " << mDagPath.partialPathName() << " as a parent" << std::endl;
				}
				else
				{
					retList.add( skinnerPath, cObj, true );
				}
			}
			else
			{
				MItDag dIt;
				for ( dIt.reset( mDagPath ); !dIt.isDone(); dIt.next() )
				{
					dIt.getPath( mDagPath );

					if ( mDagPath.childCount() )
					{
						uint nShapes( 0 );
						mDagPath.numberOfShapesDirectlyBelow( nShapes );

						if ( nShapes == 0U || mDagPath.hasFn( MFn::kJoint ) )
						{
							MObject cObj( DoNewVolume( skinnerPath, mDagPath ) );
							if ( cObj.isNull() )
							{
								mwarn << "Couldn't create new volume on " << skinnerPath.partialPathName()
									<< " using " << mDagPath.partialPathName() << " as a parent" << std::endl;
							}
							else
							{
								retList.add( skinnerPath, cObj, true );
							}
						}
					}
				}
			}
		}
	}

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


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