-
Notifications
You must be signed in to change notification settings - Fork 14
/
spReticleLoc.mel
289 lines (229 loc) · 15.2 KB
/
spReticleLoc.mel
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
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2014, Sony Pictures Imageworks
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the organization Sony Pictures Imageworks nor the
// names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER
// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///////////////////////////////////////////////////////////////////////////////
if(! `pluginInfo -q -loaded "spReticleLoc.so"`)
{
loadPlugin "spReticleLoc.so";
}
spInclude "<scripts/tools/spSettings/spSettings.mel>";
global proc spReticleLocCreate()
{
//Deleting deprecated spReticuleLoc nodes from scene
/*
string $reticuleLoc[] = `ls -type spReticuleLoc`;
if(size($reticuleLoc))
{
print ("Deleting deprecated spReticuleLoc nodes from scene.");
delete $reticuleLoc;
}
*/
string $reticleLoc[] = `ls -type spReticleLoc`;
if (size($reticleLoc) == 0)
{
string $reticleTransform = `createNode -n reticle transform`;
string $reticleShape = `createNode -n reticleShape -p $reticleTransform spReticleLoc`;
print ("Created " + $reticleShape + "\n");
print ("Setting showSettings defaults for " + $reticleShape + "\n");
spReticleLocSetDefault($reticleShape,"");
if (objExists("temp_master"))
{
parent $reticleTransform temp_master;
}
// Prevent strange clipping of light cone, and possible
// reflections of reticle text in shadows in Viewport 2.0
if (objExists($reticleLoc[0]+".castsShadows"))
{
setAttr ($reticleLoc[0]+".castsShadows") 0;
}
}
else
{
setAttr ($reticleLoc[0]+".drawingEnabled") 1;
}
}
proc addText(string $node, string $setting, int $index)
{
// Add the specified text setting to the spReticle node
int $text_textType = spSettingGetValueInt($setting + ".TextType", "");
setAttr ($node+".text[" + $index + "].textType") $text_textType;
int $text_textAlign = spSettingGetValueInt($setting + ".TextAlign", "");
setAttr ($node+".text[" + $index + "].textAlign") $text_textAlign;
int $text_textPosRel = spSettingGetValueInt($setting + ".TextPosRel", "");
setAttr ($node+".text[" + $index + "].textPosRel") $text_textPosRel;
int $text_textLevel = spSettingGetValueInt($setting + ".TextLevel", "");
setAttr ($node+".text[" + $index + "].textLevel") $text_textLevel;
float $text_textPosX = spSettingGetValueFloat($setting + ".TextPosX", "");
setAttr ($node+".text[" + $index + "].textPosX") $text_textPosX;
float $text_textPosY = spSettingGetValueFloat($setting + ".TextPosY", "");
setAttr ($node+".text[" + $index + "].textPosY") $text_textPosY;
float $text_textTrans = spSettingGetValueFloat($setting + ".TextTrans", "");
setAttr ($node+".text[" + $index + "].textTrans") $text_textTrans;
float $text_textScale = spSettingGetValueFloat($setting + ".TextScale", "");
setAttr ($node+".text[" + $index + "].textScale") $text_textScale;
float $text_textSize = spSettingGetValueFloat($setting + ".TextSize", "");
setAttr ($node+".text[" + $index + "].textSize") $text_textSize;
}
global proc spReticleLocSetDefault(string $node, string $tag)
{
if (`objExists $node`)
{
//Filmback Attributes
int $displayFilmGate = spSettingGetValueInt("showSettings.Tools.spReticle.DisplayFilmGate", "");
setAttr ($node+".displayFilmGate") $displayFilmGate;
float $filmGateMaskColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.FilmGateMaskColor", "");
setAttr ($node+".filmGateMaskColor") -type double3 $filmGateMaskColor[0] $filmGateMaskColor[1] $filmGateMaskColor[2];
float $filmGateMaskTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.FilmGateMaskTrans", "");
setAttr ($node+".filmGateMaskTrans") $filmGateMaskTrans;
float $filmGateLineColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.FilmGateLineColor", "");
setAttr ($node+".filmGateColor") -type double3 $filmGateLineColor[0] $filmGateLineColor[1] $filmGateLineColor[2];
float $filmGateLineTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.FilmGateLineTrans", "");
setAttr ($node+".filmGateTrans") $filmGateLineTrans;
float $horizFilmAperture = spSettingGetValueFloat("showSettings.Tools.spReticle.HorizFilmAperture", "");
float $vertFilmAperture = spSettingGetValueFloat("showSettings.Tools.spReticle.VertFilmAperture", "");
setAttr ($node+".filmbackAperture") $horizFilmAperture $vertFilmAperture;
//Projection Gate Settings
int $displayProjGate = spSettingGetValueInt("showSettings.Tools.spReticle.DisplayProjGate", "");
setAttr ($node+".displayProjGate") $displayProjGate;
float $horizontalProjGate = spSettingGetValueFloat("showSettings.Tools.spReticle.HorizProjGate", "");
setAttr ($node+".horizontalProjectionGate") $horizontalProjGate;
float $verticalProjGate = spSettingGetValueFloat("showSettings.Tools.spReticle.VertProjGate", "");
setAttr ($node+".verticalProjectionGate") $verticalProjGate;
float $projGateMaskColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.ProjGateMaskColor", "");
setAttr ($node+".projGateMaskColor") -type double3 $projGateMaskColor[0] $projGateMaskColor[1] $projGateMaskColor[2];
float $projGateMaskTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.ProjGateMaskTrans", "");
setAttr ($node+".projGateMaskTrans") $projGateMaskTrans;
float $projGateLineColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.ProjGateLineColor", "");
setAttr ($node+".projGateLineColor") -type double3 $projGateLineColor[0] $projGateLineColor[1] $projGateLineColor[2];
float $projGateLineTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.ProjGateLineTrans", "");
setAttr ($node+".projGateLineTrans") $projGateLineTrans;
//Aspect Ratio Settings
//Set Aspect ratio [0]
float $aspectRatio = spSettingGetValueFloat("showSettings.Tools.spReticle.AspectRatio", "");
setAttr ($node+".aspectRatios[0].aspectRatio") $aspectRatio;
int $aspectDisplayMode = spSettingGetValueInt("showSettings.Tools.spReticle.AspectDisplayMode", "");
setAttr ($node+".aspectRatios[0].displayMode") $aspectDisplayMode;
float $aspectMaskColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.AspectMaskColor", "");
setAttr ($node+".aspectRatios[0].aspectMaskColor") -type double3 $aspectMaskColor[0] $aspectMaskColor[1] $aspectMaskColor[2];
float $aspectMaskTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.AspectMaskTrans", "");
setAttr ($node+".aspectRatios[0].aspectMaskTrans") $aspectMaskTrans;
float $aspectLineColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.AspectLineColor", "");
setAttr ($node+".aspectRatios[0].aspectLineColor") -type double3 $aspectLineColor[0] $aspectLineColor[1] $aspectLineColor[2];
float $aspectLineTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.AspectLineTrans", "");
setAttr ($node+".aspectRatios[0].aspectLineTrans") $aspectLineTrans;
int $aspectDisplaySafeAction = spSettingGetValueInt("showSettings.Tools.spReticle.AspectDisplaySafeAction", "");
setAttr ($node+".aspectRatios[0].aspectDisplaySafeAction") $aspectDisplaySafeAction;
//Aspect Ratio Settings
//Set Aspect ratio [1]
int $aspectDisplayMode2 = spSettingGetValueInt("showSettings.Tools.spReticle.AspectDisplayMode2", "");
if ( $aspectDisplayMode2 != 0 )
{
float $aspectRatio2 = spSettingGetValueFloat("showSettings.Tools.spReticle.AspectRatio2", "");
setAttr ($node+".aspectRatios[1].aspectRatio") $aspectRatio2;
setAttr ($node+".aspectRatios[1].displayMode") $aspectDisplayMode2;
float $aspectMaskColor2[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.AspectMaskColor2", "");
setAttr ($node+".aspectRatios[1].aspectMaskColor") -type double3 $aspectMaskColor2[0] $aspectMaskColor2[1] $aspectMaskColor2[2];
float $aspectMaskTrans2 = spSettingGetValueFloat("showSettings.Tools.spReticle.AspectMaskTrans2", "");
setAttr ($node+".aspectRatios[1].aspectMaskTrans") $aspectMaskTrans2;
float $aspectLineColor2[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.AspectLineColor2", "");
setAttr ($node+".aspectRatios[1].aspectLineColor") -type double3 $aspectLineColor2[0] $aspectLineColor2[1] $aspectLineColor2[2];
float $aspectLineTrans2 = spSettingGetValueFloat("showSettings.Tools.spReticle.AspectLineTrans2", "");
setAttr ($node+".aspectRatios[1].aspectLineTrans") $aspectLineTrans2;
int $aspectDisplaySafeAction2 = spSettingGetValueInt("showSettings.Tools.spReticle.AspectDisplaySafeAction2", "");
setAttr ($node+".aspectRatios[1].aspectDisplaySafeAction") $aspectDisplaySafeAction2;
}
//Pan and Scan Settings
int $panScanDisplayMode = spSettingGetValueInt("showSettings.Tools.spReticle.PanScanDisplayMode", "");
setAttr ($node+".panScanDisplayMode") $panScanDisplayMode;
float $panScanAspectRatio = spSettingGetValueFloat("showSettings.Tools.spReticle.PanScanAspectRatio", "");
setAttr ($node+".panScanAspectRatio") $panScanAspectRatio;
float $panScanRatio = spSettingGetValueFloat("showSettings.Tools.spReticle.PanScanRatio", "");
setAttr ($node+".panScanRatio") $panScanRatio;
float $panScanOffset = spSettingGetValueFloat("showSettings.Tools.spReticle.PanScanOffset", "");
setAttr ($node+".panScanOffset") $panScanOffset;
float $panScanMaskColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.PanScanMaskColor", "");
setAttr ($node+".panScanMaskColor") -type double3 $panScanMaskColor[0] $panScanMaskColor[1] $panScanMaskColor[2];
float $panScanMaskTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.PanScanMaskTrans", "");
setAttr ($node+".panScanMaskTrans") $panScanMaskTrans;
float $panScanLineColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.PanScanLineColor", "");
setAttr ($node+".panScanLineColor") -type double3 $panScanLineColor[0] $panScanLineColor[1] $panScanLineColor[2];
float $panScanLineTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.PanScanLineTrans", "");
setAttr ($node+".panScanLineTrans") $panScanLineTrans;
//Pad Settings
int $usePadMask = spSettingGetValueBoolean("showSettings.Tools.spReticle.UsePadMask", "");
setAttr ($node+".usePad") $usePadMask;
int $padDisplayMode = spSettingGetValueInt("showSettings.Tools.spReticle.PadDisplayMode", "");
setAttr ($node+".padDisplayMode") $padDisplayMode;
float $padAmountX = spSettingGetValueFloat("showSettings.Tools.spReticle.PadAmountX", "");
setAttr ($node+".padAmountX") $padAmountX;
float $padAmountY = spSettingGetValueFloat("showSettings.Tools.spReticle.PadAmountY", "");
setAttr ($node+".padAmountY") $padAmountY;
float $padMaskColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.PadMaskColor", "");
setAttr ($node+".padMaskColor") -type double3 $padMaskColor[0] $padMaskColor[1] $padMaskColor[2];
float $padMaskTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.PadMaskTrans", "");
setAttr ($node+".padMaskTrans") $padMaskTrans;
float $padLineColor[] = spSettingGetValueFloat3("showSettings.Tools.spReticle.PadLineColor", "");
setAttr ($node+".padLineColor") -type double3 $padLineColor[0] $padLineColor[1] $padLineColor[2];
float $padLineTrans = spSettingGetValueFloat("showSettings.Tools.spReticle.PadLineTrans", "");
setAttr ($node+".padLineTrans") $padLineTrans;
addText($node, "showSettings.Tools.spReticle.Text", 0);
addText($node, "showSettings.Tools.spReticle.Text1", 1);
// add text2 which displays active shot name from sequencer for layoutScenes
if (spSettingGetValueString("showSettings.isLayoutScene", "") == "True")
{
addText($node, "showSettings.Tools.spReticle.Text2", 2);
$setShotName = "if(objExists(\""+$node+"\")){$shot = `sequenceManager -q -currentShot`; if(size($shot)) setAttr -type \"string\" "+$node+".text[2].textStr `getAttr ($shot + \".shotName\")`; else setAttr -type \"string\" "+$node+".text[2].textStr \" \";}";
// update shot name in reticle
eval($setShotName);
// set expression to update shot name on time change
if (!objExists("reticleExpression"))
{
expression -s $setShotName -o $node -ae 1 -uc all -n "reticleExpression";
}
}
//Ensure that drawing is enabled
setAttr ($node+".drawingEnabled") 1;
//Make reticle a template
setAttr ($node+".template") 1;
//use useSpReticle
int $useSpReticle = spSettingGetValueBoolean("showSettings.Tools.spReticle.UseSpReticle", "");
setAttr ($node+".useSpReticle") $useSpReticle;
//Set maxdistance based on circle of goodness settings
float $CircleOfGoodnessCubeHeight = spSettingGetValueFloat("showSettings.Maya.CircleOfGoodnessCubeHeight", "");
float $CircleOfGoodnessCubeWidth = spSettingGetValueFloat("showSettings.Maya.CircleOfGoodnessCubeWidth", "");
float $CircleOfGoodnessCubeDepth = spSettingGetValueFloat("showSettings.Maya.CircleOfGoodnessCubeDepth", "");
float $maxDistance = 0;
$maxDistance = max($CircleOfGoodnessCubeHeight/2, $maxDistance);
$maxDistance = max($CircleOfGoodnessCubeWidth/2, $maxDistance);
$maxDistance = max($CircleOfGoodnessCubeDepth/2, $maxDistance);
if ($maxDistance > 0)
setAttr ($node+".maximumDistance") $maxDistance;
}
}