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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
#ifndef _WRITERIB
#define _WRITERIB
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
#include "shaveIO.h"
#ifndef NO_PRMAN
# ifdef _WIN32
// ri.h contains a lot of float/double mismatches. Let's stop VC++ from warning us about them.
# pragma warning(push)
# pragma warning(disable : 4244 )
# endif
# include <ri.h>
# ifdef _WIN32
# pragma warning(pop)
# endif
#endif
#include <vector>
#include <maya/MPxCommand.h>
#include <maya/MString.h>
#include "shaveGlobals.h"
#include "shaveSDK.h"
#if MAYA_API_VERSION < 20180000
class MArgDatabase;
#endif
class RfMFuncs;
class shaveWriteRib : public MPxCommand
{
public:
shaveWriteRib();
virtual ~shaveWriteRib();
MStatus doIt(const MArgList& args);
static void* createCmd();
static MSyntax createSyntax();
static const MString commandName;
protected:
#ifndef NO_PRMAN
typedef struct NodeInfo
{
typedef struct
{
RtBound fBBox;
MString fFilename;
} VoxelInfo;
std::vector<VoxelInfo> fVoxels;
} NodeInfo;
void addCurve(
int firstVertIdxIdx,
int lastVertIdxIdx,
const int* vertIndices,
const VERT* verts,
const VERT* vertColours,
const VERT* rootColour,
const VERT* tipColour,
float hairU,
float hairV,
float rootRadius,
float tipRadius,
const VERT* hairNormal,
bool tipFade,
int index
);
void beginFile(
RfMFuncs &rfm,
MString filename,
MString verbatim
) const;
void cleanup(
const MObjectArray& hairNodes,
const shaveGlobals::Globals& g
) const;
void clearCurves();
void endFile(RfMFuncs &rfm) const;
void freeBuffers(bool isInstanced);
MString getBaseFilename() const;
void getFrameTimes(
const MArgDatabase& argdb,
const shaveGlobals::Globals& g,
double curFrame
);
MStatus getHairShapes(
const MArgDatabase& argdb,
MObjectArray& hairShapes
) const;
void getMayaShutterTimes();
int getNumParams(bool isInstanced) const;
void getRendermanShutterTimes();
MString getVoxelFilename(
const MString& baseFilename,
const MString& nodeName,
int voxel
) const;
void initBuffers(
RfMFuncs &rfm,
MFnDependencyNode &nodeFn,
int numHairs,
int numVerts,
int numVertIndices,
float baseOpacity,
bool isInstanced
);
void outputCurves(
RfMFuncs &rfm,
int numCurves,
bool isShutterOpen
);
void outputInstanceGeom(
RfMFuncs &rfm,
MFnDependencyNode& nodeFn,
bool isShutterOpen,
MObject instanceMesh,
int numHairs,
int numVerts,
int numFaceVerts,
const int* faceList,
const int* faceStarts,
const int* faceEnds,
const VERT* verts,
const VERT* vertColors,
const VERT* vertNormals,
const VERT* growthSurfNormal,
int index
);
void outputGlobalDecls(RfMFuncs &rfm) const;
void outputMotionBegin(RfMFuncs &rfm) const;
void outputObjSpecificDecls(
RfMFuncs &rfm, bool isInstanced
) const;
void showHelp() const;
MStatus writeMultipleRibs(
RfMFuncs& rfm,
MObjectArray shaveNodes,
const shaveGlobals::Globals& g
);
MStatus writeRib(
RfMFuncs& rfm,
const MObjectArray& shaveNodes,
const shaveGlobals::Globals& g
);
MStatus writeSingleRib(
RfMFuncs& rfm,
MObjectArray shaveNodes,
const shaveGlobals::Globals& g
);
#endif
//
// Command flags.
//
bool fDoBinary;
bool fDoFullPaths;
bool fDoGzip;
bool fDoMotionBlur;
bool fDoNormals;
bool fDoOpacities;
bool fRestoreFrame;
bool fDoRootPositions;
bool fDoRootTipColors;
bool fDoSurfaceNormals;
bool fDoUVs;
bool fDoVertexColors;
bool fDoVoxels;
bool fDoWCoords;
#ifndef NO_PRMAN
//
// Buffers.
//
RtFloat fAmbDiff;
RtFloat fBaseOpacity;
RtFloat fGloss;
RtNormal* fNormal;
RtColor* fOpacity;
RtPointer* fParams;
RtColor* fRootColor;
RtPoint* fRootPosition;
RtFloat* fSCoord;
RtFloat fSelfShadow;
RtFloat fSpecular;
RtInt fSquirrel;
RtColor fSpecularColor;
RtColor fSpecularColor2;
RtNormal* fSurfaceNormal;
RtFloat* fTCoord;
RtColor* fTipColor;
RtToken* fTokens;
RtPoint* fVert;
RtColor* fVertexColor;
RtInt* fVertIndices;
RtInt* fVertsPerHair;
RtFloat* fWCoord;
RtFloat* fWidth;
RtInt* fIndex;
//
// Other
//
int fCurveIdx;
MString fFilename;
double fFrameCenter;
bool fFrameRelativeTime;
double fShutterOpen;
double fShutterClose;
float openoffset,closeoffset;
double fTimeFactor;
shaveGlobals::RibTimeUnits fTimeUnits;
bool fUseCubicCurves;
MString fUVSet;
int fVertIdx;
int fWidthIdx;
#endif
};
#endif
|