Exemple #1
0
MStatus GetAdjacency(MDagPath& pathMesh, std::vector<std::set<int> >& adjacency) {
  MStatus status;
  // Get mesh adjacency.  The adjacency will be all vertex ids on the connected faces.
  MItMeshVertex itVert(pathMesh, MObject::kNullObj, &status);
  CHECK_MSTATUS_AND_RETURN_IT(status);
  MFnMesh fnMesh(pathMesh, &status);
  CHECK_MSTATUS_AND_RETURN_IT(status);
  adjacency.resize(itVert.count());
  for (; !itVert.isDone(); itVert.next()) {
    MIntArray faces;
    status = itVert.getConnectedFaces(faces);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    adjacency[itVert.index()].clear();
    // Put the vertex ids in a set to avoid duplicates
    for (unsigned int j = 0; j < faces.length(); ++j) {
      MIntArray vertices;
      fnMesh.getPolygonVertices(faces[j], vertices);
      for (unsigned int k = 0; k < vertices.length(); ++k) {
        if (vertices[k] != itVert.index()) {
          adjacency[itVert.index()].insert(vertices[k]);
        }
      }
    }
  }
  return MS::kSuccess;
}
Exemple #2
0
MStatus HelloWorld::doIt(const MArgList& argList) {
	MGlobal::displayInfo("Hello World!");
	//Get list of selected items
	MSelectionList selectedItem;
	//Get list of selected items for realsies
	MGlobal::getActiveSelectionList(selectedItem);
	MStatus stat;
	//Iterate through them.
	MItSelectionList it(selectedItem);

	while (!it.isDone() ) {
		MDagPath dagPath;	//Will hold a path to the indexed object
		MObject component;	//List of selected components

		it.getDagPath(dagPath, component);

		MFnDependencyNode fn(dagPath.node());
		MString status = "OBJECT: ";
		status += fn.name().asChar();
		MGlobal::displayInfo(status);

		if (!component.isNull()) {
			MGlobal::displayInfo("Is not null!");
			MItMeshVertex itVert(dagPath, component, &stat);

			if (stat == MS::kSuccess)
			{
				while (!itVert.isDone())
				{
					
					MPoint point = itVert.position(MSpace::kWorld);
					MString pointStr;
					pointStr += itVert.index();
					pointStr += "\t";
					pointStr += point.x;
					point.x += 10;
					pointStr += "\t";
					pointStr += point.y;
					pointStr += "\t";
					pointStr += point.z;
					MGlobal::displayInfo(pointStr);
					itVert.setPosition(point, MSpace::kWorld);

					itVert.next();
				}
			}
		}
		else{
			MGlobal::displayInfo("Is null.. :(");
		}
		it.next();

	}



	return MS::kSuccess;
}