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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
#include <maya/MAnimControl.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MGlobal.h>
#include <maya/MObject.h>
#include <maya/MPlug.h>
#include <maya/MPlugArray.h>
#include <maya/MSelectionList.h>
#include <maya/MStatus.h>
#include <maya/MTime.h>
#include "shaveMaya.h"
#include "shaveRender.h"
#define USE_GLOBALS 0
MString shaveMaya::outFormat;
MString shaveMaya::outFormatString;
MString shaveMaya::outExt;
bool shaveMaya::animation;
MString shaveMaya::animExt;
MString shaveMaya::baseFileName;
float shaveMaya::deviceAspectRatio;
bool shaveMaya::deviceAspectRatioLocked;
int shaveMaya::doCameraMotion;
int shaveMaya::doDef;
short shaveMaya::doExtensionPadding;
bool shaveMaya::doMotionBlur;
int shaveMaya::doSingleFile;
MString shaveMaya::extension;
double shaveMaya::fov_ratio;
int shaveMaya::frameFirst;
int shaveMaya::frameLast;
unsigned int shaveMaya::frameBy;
bool shaveMaya::ignoreFilmGate;
unsigned int shaveMaya::imageDepth;
unsigned int shaveMaya::imageHeight;
unsigned int shaveMaya::imageWidth;
MString shaveMaya::imageName;
short shaveMaya::outPadding;
short shaveMaya::outFormatControl;
int shaveMaya::pixelSamples;
double shaveMaya::motionBlurByFrame;
bool shaveMaya::renderAllCameras;
int shaveMaya::mb2smoothValue;
double shaveMaya::mb2blurSharpness;
double shaveMaya::mb2blurLength;
bool shaveMaya::motionBlurType;
bool shaveMaya::useFrameExt;
//
// Get MAYA's render globals information
//
MStatus shaveMaya::getRenderGlobals()
{
MStatus status = MS::kSuccess;
doMotionBlur = false;
imageWidth = 0;
imageHeight = 0;
//
// Get the render globals node
//
MSelectionList renderGlobalsList;
renderGlobalsList.add("defaultRenderGlobals");
if (renderGlobalsList.length() < 1) return MS::kFailure;
MObject renderGlobalsNode;
renderGlobalsList.getDependNode(0, renderGlobalsNode);
MFnDependencyNode fnRenderGlobals(renderGlobalsNode);
//
// Get its resolution node.
//
MPlugArray connectedPlugs;
MPlug resPlug = fnRenderGlobals.findPlug("resolution");
resPlug.connectedTo(
connectedPlugs,
true, // asDestination
false, // asSource
&status
);
if (!status || (connectedPlugs.length() != 1)) return MS::kFailure;
MObject resNode = connectedPlugs[0].node(&status);
if (!status) return status;
MFnDependencyNode fnRes(resNode);
//
// If we're doing an interactive render, then the width and height
// of the output image are determined by the test resolution,
// otherwise they're determined by the resolution node.
//
if (MGlobal::mayaState() == MGlobal::kInteractive)
{
MIntArray res;
MGlobal::executeCommand("shave_getTestResolution", res);
if (res.length() == 2)
{
imageWidth = res[0];
imageHeight = res[1];
}
else
status = MS::kFailure;
}
else
{
short res_width;
short res_height;
fnRes.findPlug("width").getValue(res_width);
fnRes.findPlug("height").getValue(res_height);
imageWidth = (unsigned int)res_width;
imageHeight = (unsigned int)res_height;
}
//
// Determine the output image format
//
enum
{
kGIF = 0,
kSoftimage = 1,
kRLA = 2,
kTiff = 3,
kTiff16 = 4,
kSGI = 5,
kAlias = 6,
kMaya = 7,
kJPEG = 8,
kEPS = 9,
kMaya16 = 10,
kCineon = 11
};
short outputId;
fnRenderGlobals.findPlug("imageFormat").getValue(outputId);
switch (outputId)
{
case kSGI:
outFormat = "sgif";
outExt = "sgi";
break;
case kAlias:
outFormat = "alias";
outExt = "als";
break;
case kEPS:
outFormat = "cpostscript";
outExt = "ps";
break;
case kCineon:
outFormat = "cineon";
outExt = "cin";
break;
default:
outFormat = "tiff";
outExt = "tif";
break;
}
// Whether "outExt" is to be included in file name
fnRenderGlobals.findPlug("outFormatControl").getValue(outFormatControl);
if (outFormatControl == 2)
{
fnRenderGlobals.findPlug("outFormatExt").getValue(outFormatString);
}
//
// Get MOBLURS STUFF
//
fnRenderGlobals.findPlug("motionBlur").getValue(doMotionBlur);
fnRenderGlobals.findPlug("motionBlurByFrame").getValue(motionBlurByFrame);
fnRenderGlobals.findPlug("blurLength").getValue(mb2blurLength);
fnRenderGlobals.findPlug("blurSharpness").getValue(mb2blurSharpness);
fnRenderGlobals.findPlug("smoothValue").getValue(mb2smoothValue);
fnRenderGlobals.findPlug("motionBlurType").getValue(motionBlurType);
//
// Get own blur setting for Vray -- vlad|15Apr2010
//
if (shaveRender::rendererIsVray())
{
renderGlobalsList.clear();
renderGlobalsList.add("vraySettings");
if (renderGlobalsList.length() > 0)
{
MObject vraySettingsNode;
renderGlobalsList.getDependNode(0, vraySettingsNode);
MFnDependencyNode depFn(vraySettingsNode);
int mbOn = 0;
MPlug mbOnPlug = depFn.findPlug("cam_mbOn");
if(!mbOnPlug.isNull())
mbOnPlug.getValue(mbOn);
else
MGlobal::displayError("shave: can not find vraySettings.cam_mbOn plug.");
doMotionBlur = (mbOn != 0);
}
else
MGlobal::displayError("shave: can not get V-Ray settings.");
}
//
// Check if there is animation
//
fnRenderGlobals.findPlug("animation").getValue(animation);
MTime startFrame;
MTime endFrame;
float byFrame;
if (animation)
{
// Check if the time-slider or renderGlobals is used for
// the frame range
//
short animRange;
fnRenderGlobals.findPlug("animationRange").getValue(animRange);
if (USE_GLOBALS == animRange)
{
fnRenderGlobals.findPlug("startFrame").getValue(startFrame);
fnRenderGlobals.findPlug("endFrame").getValue(endFrame);
fnRenderGlobals.findPlug("byFrameStep").getValue(byFrame);
frameFirst = (int)startFrame.as(MTime::uiUnit());
frameLast = (int)endFrame.as(MTime::uiUnit());
frameBy = (unsigned int)byFrame;
}
else // USE_TIMESLIDER
{
startFrame = MAnimControl::minTime();
endFrame = MAnimControl::maxTime();
frameFirst = (int)startFrame.as(MTime::uiUnit());
frameLast = (int)endFrame.as(MTime::uiUnit());
}
// Check if motionBlur is turned on.
// (This is matrix motion blur)
// BIJAN
}
else // No animation
{
frameFirst = (int)MAnimControl::currentTime().as(MTime::uiUnit());
frameLast = (int)MAnimControl::currentTime().as(MTime::uiUnit());
frameBy = 1;
//doMotionBlur = false; // BIJAN
// Whether the frame number is to be incded in the file name
fnRenderGlobals.findPlug("useFrameExt").getValue(useFrameExt);
}
fnRenderGlobals.findPlug("extensionPadding").getValue(outPadding);
if (outPadding > 99) outPadding = 99;
//
// If a film gate is used this tells us whether the image is
// blacked out in regions outside the film-fit region.
// In our case we crop the image to the size of the region.
//
fnRenderGlobals.findPlug("ignoreFilmGate").getValue(ignoreFilmGate);
//
// Check if we should render all cameras, or only the active one
//
fnRenderGlobals.findPlug("renderAll").getValue(renderAllCameras);
//
// Get the device aspect ratio from the resolution node.
//
fnRes.findPlug("deviceAspectRatio").getValue(deviceAspectRatio);
fnRes.findPlug("lockDeviceAspectRatio").getValue(deviceAspectRatioLocked);
//
// Two of Maya's preset device aspect ratios (1.333 and 1.777)
// don't have enough precision for high-definition rendering, so
// let's adjust those appropriately.
//
if (((deviceAspectRatio - 1.33f) <= 0.003f)
&& ((deviceAspectRatio - 1.333f) >= -0.0f))
{
deviceAspectRatio = 1.333333f;
}
else if (((deviceAspectRatio - 1.77f) <= 0.007f)
&& ((deviceAspectRatio - 1.777f) >= -0.0f))
{
deviceAspectRatio = 1.777777f;
}
return MS::kSuccess;
}
|