-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnPoseSymmetricMaster_2021.txt
261 lines (226 loc) · 10.2 KB
/
UnPoseSymmetricMaster_2021.txt
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
////
// dll path, language
////
[VarDef, zfutilPath, "dummy"]
[VarDef, dllPath, "dummy"]
[VarDef, enLangFilePath, "dummy"]
[VarDef, language]
////
// debug
[VarDef, dataDirPath, [fileNameResolvePath, "UnPoseSymmetricMaster_2021\"]]
// install
//[VarDef, dataDirPath, [fileNameResolvePath, "ZBRUSH_ZSTARTUP\ZPlugs64\UnPoseSymmetricMaster_2021\"]]
////
// value for calculation
[MVarDef, memInOut, [Val, 1024*1024], 0]
[VarDef, rotX, 0]
[VarDef, posX]
[VarDef, posY]
[VarDef, posZ]
[VarDef, sizeX]
[VarDef, sizeY]
[VarDef, sizeZ]
//////
// search dlls
// from http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/#dllPath
//////
[RoutineDef, CheckSystem,
//check ZBrush version
[VarSet,Zvers,[ZBrushInfo,0]]
[If,[Val,Zvers] >= 4.8,,
[Note,"\Cff9923This zscript\Cffffff is not designed for this version of \Cff9923ZBrush\Cffffff.",,3,4737096,,300]
[Exit]
]
// Make sure we have the dll and set its path
[If, [ZBrushInfo, 6]==0,//windows
//use the path below for testing only
//[VarSet, dllPath, "UnPoseSymmetricMaster_2021\unPoseSymmetricMaster.dll"]
//[VarSet, zfutilPath, "UnPoseSymmetricMaster_2021\ZFileUtils64.dll"]
//[VarSet, enLangFilePath, "UnPoseSymmetricMaster_2021\lang\UnPoseSymmetricMaster_2021_en.xml"]
//use the path below for installed plugins
[VarSet, dllPath, "ZBRUSH_ZSTARTUP\ZPlugs64\UnPoseSymmetricMaster_2021\unPoseSymmetricMaster.dll"]
[VarSet, zfutilPath, "ZBRUSH_ZSTARTUP\ZPlugs64\UnPoseSymmetricMaster_2021\ZFileUtils64.dll"]
[VarSet, enLangFilePath, "ZBRUSH_ZSTARTUP\ZPlugs64\UnPoseSymmetricMaster_2021\lang\UnPoseSymmetricMaster_2021_en.xml"]
,
//use the path below for testing only
//[VarSet, dllPath, "UnPoseSymmetricMaster_2021\unPoseSymmetricMaster.lib"]
//[VarSet, zfutilPath, "UnPoseSymmetricMaster_2021\ZFileUtils.lib"]
//[VarSet, enLangFilePath, "UnPoseSymmetricMaster_2021\lang\UnPoseSymmetricMaster_2021_en.xml"]
//use the path below for installed plugins
[VarSet, dllPath, "ZBRUSH_ZSTARTUP\ZPlugs64\UnPoseSymmetricMaster_2021\unPoseSymmetricMaster.lib"]
[VarSet, zfutilPath, "ZBRUSH_ZSTARTUP\ZPlugs64\UnPoseSymmetricMaster_2021\ZFileUtils.lib"]
[VarSet, enLangFilePath, "ZBRUSH_ZSTARTUP\ZPlugs64\UnPoseSymmetricMaster_2021\lang\UnPoseSymmetricMaster_2021_en.xml"]
]
// check if there are dll/lib exists
[If, [FileExists, [Var,dllPath]],
, // else no DLL.
[Note,"\Cff9923Note :\Cc0c0c0 The \Cff9923 UnPoseSymmetricMaster plugin \Cffffffdll/lib\Cc0c0c0 could not be found at the correct location. Please re-install the plugin."]
[Exit]
]
]
//////
//////
// translation routine
// from http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/localization/
//////
[RoutineDef, ZFU_RegisterLocalizationFile,
[FileExecute, [Var, zfutilPath], RegisterLocalizationFile, enFilePath]
, enFilePath]
//////
//////
// startup
//////
// + search dll
[RoutineCall, CheckSystem]
//[RoutineCall, ZFU_GetCurrentLanguage, language]
[RoutineCall, ZFU_RegisterLocalizationFile, [FileNameResolvePath, [Var, enLangFilePath]]]
[FileExecute, [Var, dllPath], "initialize", "", 0, memInOut, ]
//////
// UI
//////
[ISubPalette, "ZPlugin:UnPoseSymmetric Master"]
[IButton, "ZPlugin:UnPoseSymmetric Master:Toggle Posed <=> Symmetry", "Toggle Posed posture and Symmetry posture.",
[If, [IExists, Tool:Export],
[IFreeze,
[RoutineCall, CheckSystem]
// get the name of current active sub tool
[VarSet, subTName, ""]
[VarSet, activeSubT, [SubToolGetActiveIndex]]
[VarSet, activeSubTName, ""]
// select active subtool
[SubToolSelect, [Var, activeSubT]]
[VarSet, subTName, [IGetTitle,Tool:ItemInfo]] // gets the tool name
[VarSet, activeSubTName, [StrExtract, #subTName, 0, [StrLength, #subTName]-2]] // this takes of the end period
// text for dll
[VarSet, textForDll, [StrMerge, [Var, dataDirPath], [Var, activeSubTName], ".GoZ"]]
// store current position
[VarSet, posX, [IGet,Tool:Geometry:X Position]]
[VarSet, posY, [IGet,Tool:Geometry:Y Position]]
[VarSet, posZ, [IGet,Tool:Geometry:Z Position]]
[If, [FileExecute, [Var, dllPath], "isCached", #textForDll, 0, memInOut, ],
// if the rotation is cached, do noting!
,
// export current subtool to GoZ file (temporary file)
[FileNameSetNext, [StrMerge, [Var, dataDirPath], #activeSubTName, ".GoZ"]]
// store current export settings
[VarSet, origScale, [IGet,Tool:Export:Scale]]
[VarSet, origOffsetX, [IGet,Tool:Export:X Offset]]
[VarSet, origOffsetY, [IGet,Tool:Export:Y Offset]]
[VarSet, origOffsetZ, [IGet,Tool:Export:Z Offset]]
[ISet,Tool:Export:Scale,0.0]
[ISet,Tool:Export:X Offset,0.0]
[ISet,Tool:Export:Y Offset,0.0]
[ISet,Tool:Export:Z Offset,0.0]
// store current size
[VarSet, sizeX, [IGet,Tool:Geometry:X Size]]
[VarSet, sizeY, [IGet,Tool:Geometry:Y Size]]
[VarSet, sizeZ, [IGet,Tool:Geometry:Z Size]]
[IPress,Tool:Export]
// restore scale/Offset
[ISet,Tool:Export:Scale,[Var, origScale]]
[ISet,Tool:Export:X Offset,[Var, origOffsetX]]
[ISet,Tool:Export:Y Offset,[Var, origOffsetY]]
[ISet,Tool:Export:Z Offset,[Var, origOffsetZ]]
]
// write parameters to memblock
[MVarSet, memInOut, 0, [Var, rotX]]
[VarSet, rotX, 0]
[VarSet, result, [FileExecute, [Var, dllPath], "getCachedRotation", #textForDll, 0, memInOut, ]]
]
[If, result,
[IFreeze,
[IClick, "Tool:Masking:Clear"]
// read parameters from memblock
[VarSet, currentRotMod, [IModGet, "Tool:Deformation:Rotate"]]
// pose <=> symmetry
[IModSet, "Tool:Deformation:Rotate", 4]
[ISet, "Tool:Deformation:Rotate", [MVarGet, memInOut, 0]]
[IModSet, "Tool:Deformation:Rotate", 2]
[ISet, "Tool:Deformation:Rotate", [MVarGet, memInOut, 1]]
[IModSet, "Tool:Deformation:Rotate", 1]
[ISet, "Tool:Deformation:Rotate", [MVarGet, memInOut, 2] + [MVarGet, memInOut, 7]]
// translation
[VarSet, updatedXYZ, [Val, [MVarGet, memInOut, 8] + [IGet, "Tool:Geometry:Position:X Position"]]]
[ISet, "Tool:Geometry:Position:X Position", [Var, updatedXYZ]]
[VarSet, updatedXYZ, [Val, [MVarGet, memInOut, 9] + [IGet, "Tool:Geometry:Position:Y Position"]]]
[ISet, "Tool:Geometry:Position:Y Position", [Var, updatedXYZ]]
[VarSet, updatedXYZ, [Val, [MVarGet, memInOut, 10] + [IGet, "Tool:Geometry:Position:Z Position"]]]
[ISet, "Tool:Geometry:Position:Z Position", [Var, updatedXYZ]]
//[IModSet, "Tool:Deformation:Rotate", 1]
//[ISet, "Tool:Deformation:Rotate", [MVarGet, memInOut, 3]]
[IModSet, "Tool:Deformation:Rotate", 1]
[Iset, "Tool:Deformation:Rotate", [MVarGet, memInOut, 3] + [MVarGet, memInOut, 6]]
[IModSet, "Tool:Deformation:Rotate", 2]
[Iset, "Tool:Deformation:Rotate", [MVarGet, memInOut, 5]]
[IModSet, "Tool:Deformation:Rotate", 4]
[Iset, "Tool:Deformation:Rotate", [MVarGet, memInOut, 4]]
[IModSet, "Tool:Deformation:Rotate", [Var, currentRotMod]]
]
,
[Note, "Sorry, there is some error. Perhaps, you forget masking the symmetric region."]
]
]
,
0,
1
]
[ISlider, "ZPlugin:UnPoseSymmetric Master:Rotate X", 0.0, 0.001, -180.0, 180.0, "Rotate with X axis (for Symmetry)",
[VarSet, currentRotMod, [IModGet, "Tool:Deformation:Rotate"]]
[IModSet, "Tool:Deformation:Rotate", 1]
[ISet, "Tool:Deformation:Rotate", [IGet, "ZPlugin:UnPoseSymmetric Master:Rotate X"]]
[IModSet, "Tool:Deformation:Rotate", [Var, currentRotMod]]
[VarSet, rotX, [Var, rotX] + [IGet, "ZPlugin:UnPoseSymmetric Master:Rotate X"]]
[ISet, "ZPlugin:UnPoseSymmetric Master:Rotate X", 0]
// update internal value...
,
0,
1
]
[IButton, "ZPlugin:UnPoseSymmetric Master:Remove outdated rotation", "Remove outdated rotation information.",
[IFreeze,
[RoutineCall, CheckSystem]
// get the name of current active sub tool
[VarSet, subTName, ""]
[VarSet, activeSubT, [SubToolGetActiveIndex]]
[VarSet, activeSubTName, ""]
// select active subtool
[SubToolSelect, [Var, activeSubT]]
[VarSet, subTName, [IGetTitle,Tool:ItemInfo]] // gets the tool name
[VarSet, activeSubTName, [StrExtract, #subTName, 0, [StrLength, #subTName]-2]] // this takes of the end period
// text for dll
[VarSet, textForDll, [StrMerge, [Var, dataDirPath], [Var, activeSubTName], ".GoZ"]]
[FileExecute, [Var, dllPath], "eraseCachedRotation", #textForDll, 0, memInOut, ]
]
,
0,
1
]
[IButton, "ZPlugin:UnPoseSymmetric Master:Load from file", "Load rotation info from file.",
[VarSet, cacheFileName, [FileNameAsk, "JSON(.json)", , "Please select a file to load..."]]
[If, [StrLength, cacheFileName] > 0,
[IFreeze,
[RoutineCall, CheckSystem]
[FileExecute, [Var, dllPath], "loadCacheFile", #cacheFileName, 0, , ]
]
]
,
0,
1
]
[ISwitch, "ZPlugin:UnPoseSymmetric Master:Auto save", 0, "Automatically save the rotation to file.",
[VarSet, cacheFileName, [FileNameAsk, "JSON(.json)", "rotation.json", "Please select a file to save..."]]
[If, [StrLength, cacheFileName] > 0,
[IFreeze,
[RoutineCall, CheckSystem]
[FileExecute, [Var, dllPath], "selectCacheFile", #cacheFileName, 0, , ]
]
]
,
[IFreeze,
[RoutineCall, CheckSystem]
[FileExecute, [Var, dllPath], "selectCacheFile", "", 1, , ]
],
0,
1
]
[IEnable, "ZPlugin:UnPoseSymmetric Master:Auto save"]