// Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 #include #include #include #include #include #include #include #include "shaveHairShape.h" #include "shaveSDK.h" #include "shaveUtil.h" #include "shaveWriteHairCmd.h" const MString shaveWriteHairCmd::commandName = "shaveWriteHair"; MSyntax shaveWriteHairCmd::createSyntax() { MSyntax syntax; syntax.enableEdit(false); syntax.enableQuery(false); syntax.addArg(MSyntax::kString); return syntax; } MStatus shaveWriteHairCmd::doIt(const MArgList& args) { MStatus st; MArgDatabase argdb(syntax(), args, &st); if (!st) return st; MDagPath hairShape = shaveUtil::getCurrentHairShape(); if (!hairShape.isValid()) { MGlobal::displayError( commandName + ": no currently selected shave node." ); return MS::kFailure; } MString fileName; argdb.getCommandArgument(0, fileName); FILE* f = fopen(fileName.asChar(), "w"); if (!f) { MGlobal::displayError( commandName + ": cannot write to file '" + fileName + "'." ); return MS::kInvalidParameter; } fclose(f); MFnDependencyNode nodeFn(hairShape.node()); shaveHairShape* shs = (shaveHairShape*)nodeFn.userNode(); SHAVEwrite_hairDISK((char*)fileName.asChar(), shs->getHairNode()); return st; }