-
Notifications
You must be signed in to change notification settings - Fork 0
/
MayaCamera_to_Unity.mel
200 lines (122 loc) · 5.54 KB
/
MayaCamera_to_Unity.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
// for cinematic video 20/Sep/2016
//// Shadowart path ////
proc string Shot_in_SceneDevelopment(string $NameOfShot)
{
return "D:/Git/shadow/Assets/ScenesDevelopment/Cinematic/" + $NameOfShot + "/" ;
}
proc fbxexptcamera() {
FBXExportSplitAnimationIntoTakes -clear;
int $strf =`intField -q -v craStartFrameIF`;
int $endf =`intField -q -v craEndFrameIF`;
string $ShotName =`textField -q -text as_savedirTF`;
string $fileNAM = `textField -q -text as_AnmNameTF`;
string $IsPathOfShot = Shot_in_SceneDevelopment($ShotName);
string $CamDirPath = ( $IsPathOfShot + "cam/" );
string $mainCamName = "locator_Camera";
string $targetCamName = "locator_Camera_Target";
playbackOptions -min $strf -max $endf;
select -r "locator_Camera";
select -add "locator_Camera_Target";
$bakeFrame = $strf + ":" + $endf;
bakeSimulation -t $bakeFrame;
delete -constraints;
FBXProperty Export|IncludeGrp|Animation -v true;
FBXProperty Export|IncludeGrp|Animation -q;
select $mainCamName;
FBXExport -f ($CamDirPath + $fileNAM + $mainCamName + ".fbx") -s;
print ($CamDirPath + $fileNAM + $mainCamName + ".fbx");
select $targetCamName;
FBXExport -f ($CamDirPath + $fileNAM + $targetCamName + ".fbx") -s;
print ($CamDirPath + $fileNAM + $targetCamName + ".fbx");
}
// UI
global proc sin_AnmCopyWindowProc()
{
if (`window -exists my_AnmCopyWindow`) {
deleteUI my_AnmCopyWindow;
windowPref -remove my_AnmCopyWindow;
}
if(`window -q -exists rename_UI`) {
deleteUI rename_UI;
}
window -w 230 -h 170 -s true -maximizeButton 0 -t "Rapid Rig Exporter 2.12" -le 900 my_AnmCopyWindow;
columnLayout -adj false;
separator -w 270 -h 3 -style "in";
separator -w 270 -h 3 -style "none";
rowColumnLayout
-numberOfColumns 3
-columnAttach 1 "left" 5
-columnWidth 1 85
-columnWidth 2 185;
//save dire
text -label "Shot Number";
// button -bgc 0.8 0.8 0.8 -l ".." -c as_pickDirProc;
textField -enterCommand textFieldEnterCommand as_savedirTF;
setParent..;
rowColumnLayout
-numberOfColumns 3
-columnAttach 1 "left" 5
-columnWidth 1 85
-columnWidth 2 185;
text -label "File Name :";
textField as_AnmNameTF;
setParent..;
frameLayout -lv 0 -mw 2 -mh 2;
rowLayout -nc 6 -adj 6;
button -h 20 -l "Start" -ann "set current frame as start frame" -c "intField -e -v `currentTime -q` craStartFrameIF";
setParent -m ..;
intField -h 20 -w 35 -v `playbackOptions -q -min` craStartFrameIF;
button -h 20 -l " End " -ann "set current frame as end frame" -c "intField -e -v `currentTime -q` craEndFrameIF";
setParent -m ..;
intField -h 20 -w 35 -v `playbackOptions -q -max` craEndFrameIF;
setParent ..;
setParent ..;
frameLayout -lv 0 -mw 1 -mh 2;
rowLayout -nc 6 -adj 6;
button -w 135 -h 20 -l "Create Locator" -ann "for tank" -bgc 0.5 1.0 0.3 -c "GenerateCamLocator()";
button -w 135 -h 20 -l" Export Camera " -bgc 0.5 1.0 0.7 -ann "export fbx function" -c "fbxexptcamera()";
setParent ..;
setParent ..;
separator -w 270 -h 1 -style "in";
separator -w 270 -h 1 -style "none";
rowColumnLayout
-numberOfColumns 3
-columnAttach 1 "left" 5
-columnWidth 1 185
-columnWidth 2 85;
setParent..;
showWindow my_AnmCopyWindow;
}
proc GenerateCamLocator(){
if (size(`ls locator_Camera`) != 0){
delete locator_Camera;
}
else {
}
if (size(`ls locator_Camera_Target`) != 0){
delete locator_Camera_Target;
}
else{
}
string $SelectedCameraName[] = `ls -sl`;
float $mainCam_pos[] = `xform -q -ws -t $SelectedCameraName[0]`;
float $mainCam_rot[] = `xform -q -ws -ro $SelectedCameraName[0]`;
spaceLocator -n locator_Camera;
pointConstraint -offset 0 0 0 -weight 1 $SelectedCameraName[0] locator_Camera;
orientConstraint -offset 0 0 0 -weight 1 $SelectedCameraName[0] locator_Camera;
spaceLocator -n locator_Camera_Target;
select -r locator_Camera_Target;
move $mainCam_pos[0] $mainCam_pos[1] $mainCam_pos[2];
rotate $mainCam_rot[0] $mainCam_rot[1] $mainCam_rot[2];
move -r -os -wd 0 0 -3000 ;
parentConstraint -mo -weight 1 $SelectedCameraName[0] locator_Camera_Target;
expression -s "float $ncp;\n$ncp = `getAttr Main_CameraShape.nearClipPlane`;\nsetAttr locator_Camera.scaleX $ncp;";
expression -s "float $fcp;\n$fcp = `getAttr Main_CameraShape.farClipPlane`;\nsetAttr locator_Camera.scaleY $fcp;";
expression -s "float $fl;\nfloat $vfa;\nfloat $FoV;\n$fl = `getAttr Main_CameraShape.focalLength`;\n$vfa = `getAttr Main_CameraShape.verticalFilmAperture`;\n$Fov = 2.0 * atan((0.5*$vfa)/($fl*0.03937)) * 57.29578;\nsetAttr locator_Camera.scaleZ $Fov;";
}
proc readMayaSceneName()
{
string $RFName = `textField -q -text MayaSceneName`;
file -f -options "v=0;" -ignoreVersion -typ "mayaAscii" -o $RFName;
}
sin_AnmCopyWindowProc;