// minimum plugin // used Brent's ppt slides to configure and maya help for content // also used Brent's includes and public function declarations // move .mll file to maya/pluging/ when built #include #include #include #include #include #include #include #include #include #include /* #include #include #include #include #include #include #include #include #include #include #include #include #include #include */ class accessVertices : public MPxCommand { public: //creator function static void *creator(); //command execution functions virtual MStatus doIt(const MArgList &args); }; MStatus accessVertices::doIt( const MArgList& args ) { MStatus stat; //get the list of user selected objects at the time the plugin was called MSelectionList selection; selection.clear(); MGlobal::getActiveSelectionList(selection); MItSelectionList iter(selection); //grab the poly meshes in the user selected objects MDagPath meshDagPath; MFnMesh mesh; iter.setFilter(MFn::kMesh); for (iter.reset();!iter.isDone();iter.next()) { //get the dag path to the current mesh iter.getDagPath(meshDagPath); //get a function wrapper for the mesh mesh.setObject(meshDagPath); MFnMesh fnMesh( meshDagPath ); // get the vertices that are part of the current mesh MPointArray vertexList; fnMesh.getPoints( vertexList, MSpace::kObject ); // iterate through all the vertices for ( unsigned i = 0; i < vertexList.length(); i++ ) { vertexList[i].cartesianize(); MPoint point = vertexList[i]; point.x = 20*point.x; vertexList[i] = point; } fnMesh.setPoints(vertexList); } return stat; } void* accessVertices::creator() { return new accessVertices; } MStatus initializePlugin( MObject obj ) { MFnPlugin plugin( obj, "Alias", "1.0", "Any" ); plugin.registerCommand( "accessVertices", accessVertices::creator ); return MS::kSuccess; } MStatus uninitializePlugin( MObject obj ) { MFnPlugin plugin( obj ); plugin.deregisterCommand( "accessVertices" ); return MS::kSuccess; }