blob: 512df5a1759d4124ee405df1b18b93723afdaf22 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
#include <stdio.h>
#include <maya/MArgDatabase.h>
#include <maya/MArgList.h>
#include <maya/MDagPath.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MString.h>
#include <maya/MSyntax.h>
#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;
}
|