forked from daz3d/DazBridgeUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDzBridge Script Documentation and Example.dsa
316 lines (276 loc) · 13.7 KB
/
DzBridge Script Documentation and Example.dsa
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
// DAZ Studio version 4.16.0.3 filetype DAZ Script
// DzBridge Script Documentation and Examples
var oBridge = new DzBridgeAction();
var oBridge = new DzBridgeUnityAction();
var oBridge = new DzUnrealAction();
/////////////////////////////////////
//
// Properties
//
/////////////////////////////////////
// NOTE: Each property also has get/set methods for better error checking.
// (integer) nNonInteractiveMode
// 0 == interactive mode (default)
// 1 == noninteractive mode (script)
oBridge.nNonInteractiveMode;
oBridge.getNonInteractiveMode();
oBridge.setNonInteractiveMode(0);
// (QString) sAssetType
// "SkeletalMesh" == rigged mesh, figure
// "StaticMesh" == unrigged mesh, prop
// "Animation" == animation sequence(s)
// "Pose" == single frame
// "Environment" == one or more instances of props
oBridge.sAssetType;
oBridge.getAssetType();
oBridge.setAssetType("SkeletalMesh");
// (QString) sExportFilename
// Filename stem to be used for DTU file
// Default value is the Daz Scene Label string for selected node
oBridge.sExportFilename;
oBridge.getExportFilename();
oBridge.setExportFilename("");
// (QString) sRootFolder
// Destination root folder for export
// For Unreal, Blender bridges, this is an intermediate folder before the final import routine
// For Unity bridge, this is the final destination within the Unity Project's Asset Folder
oBridge.sRootFolder;
oBridge.getRootFolder();
oBridge.setRootFolder("");
// (QString) sProductName
// metadata which is used in batch conversion mode to export the Daz Store Product name
// not used in interactive mode
oBridge.sProductName;
oBridge.getProductName();
oBridge.setProductName("");
// (QString) sProductComponentName
// metadata which is used in batch conversion mode to export the Daz Store Product name
// not used in interactive mode
oBridge.sProductComponentName;
oBridge.getProductComponentName();
oBridge.setProductComponentName("");
// (QStringList) aMorphList
// List of morphs to be exported
// these are internal morph names and not the friendly labels
oBridge.aMorphList;
oBridge.getMorphList();
oBridge.setMorphList([]);
// (boolean) bUseRelativePaths
// false == export DTU file with absolute file paths to Daz Asset Library files (default)
// true == export DTU file with file paths relative to the root of the Daz Asset Library
// Enable this option to make DTU files which are independent of installation paths.
// Must be used in combination with Localize-Jobpool.dsa script to convert back to absolute
// paths for Target Software.
oBridge.bUseRelativePaths;
oBridge.getUseRelativePaths();
oBridge.setUseRelativePaths(false);
// (boolean) bUndoNormalMaps
// true == undo changes to materials, aka remove generated normal maps, after export (default)
// false == keep changes to materials, added normal maps
oBridge.bUndoNormalMaps;
oBridge.getUndoNormalMaps();
oBridge.setUndoNormalMaps(true);
// (QString) sExportFbx
// Override filename for exported FBX
// If empty/blank string, defaults to sExportFilename
oBridge.sExportFbx;
oBridge.getExportFbx();
oBridge.setExportFbx("");
// (DzBasicDialog) wBridgeDialog
// widget to main Bridge Dialog window
// NOTE: returned object is type DzBasicDialog and not type DzBridgeDialog, so member
// functions of DzBridgeDialog will not be accessible.
oBridge.wBridgeDialog;
oBridge.getBridgeDialog();
oBridge.setBridgeDialog(null);
// (DzBasicDialog) wSubdivisionDialog
// widget to Subdivision Dialog window
// NOTE: returned object is type DzBasicDialog and not type DzBridgeSubdivisionDialog,
// so member functions of DzBridgeSubdivisionDialog will not be accessible.
oBridge.wSubdivisionDialog;
oBridge.getSubdivisionDialog();
oBridge.setSubdivisionDialog(null);
// (DzBasicDialog) wMorphSelectionDialog
// widget to Morph Selection Dialog window
// NOTE: returned object is type DzBasicDialog and not type DzBridgeMorphSelectionDialog,
// so member functions of DzBridgeMorphSelectionDialog will not be accessible.
oBridge.wMorphSelectionDialog;
oBridge.getMorphSelectionDialog();
oBridge.setMorphSelectionDialog(null);
// (boolean) bGenerateNormalMaps
// true == Enable Generation of Normal Maps for materials with only Bump Maps
// false == Do not generate normal maps (default)
oBridge.bGenerateNormalMaps;
oBridge.getGenerateNormalMaps();
oBridge.setGenerateNormalMaps(true);
/////////////////////////////////////
//
// Methods
//
/////////////////////////////////////
// (void) readGui(DzBridgeDialog arg)
// Transfer UI data from a Bridge Dialog window to internal Bridge member variables.
// Use prior to calling export operation.
oBridge.readGui(null);
// (void) exportHD(DzProgress arg = null)
// Starts export process, including pre-processing Scene data and exporting FBX and
// DTU files. Will also produce high-definition (HD) fbx with baked subdivision and
// automatically fixes missing bone weights in HD fbx file.
oBridge.exportHD();
// (void) resetToDefaults()
// Reset bridge options to default values. No arguments or return value.
oBridge.resetToDefaults();
// (QString) cleanString(QString arg)
// Returns a copy of <arg> with only alphanumeric characters and underscore ("_").
// In other words, all non alphanumeric characters except underscore are removed,
// including space and hyphen.
// Safe for filesystem names and most programming language identifier names.
oBridge.cleanString("");
// (QString) getMD5(QString arg)
// Returns string result of MD5 hash function applied to contents of a file specific
// by filepath<arg>.
oBridge.getMD5("c:/temp/tempfile.txt");
// (QStringList) getAvailableMorphs(DzNode arg)
// Returns a list of all morphs which can be applied to <arg>.
// The returned values can be used to export morphs via oBridge.aMorphList
oBridge.getAvailableMorphs(null);
// (QStringList) getActiveMorphs(DzNode arg)
// Returns a list of all active morphs for <arg> (morph strength > zero).
// The returned values can be used to export morphs via oBridge.aMorphList
oBridge.getActiveMorphs(null);
// (QImage) makeNormalMapFromHeightMap(QString heightMapFilename, double normalStrength)
// Return a new QImage with a normalmap texture generated from the heightmap passed in
// <heightMapFileName> and modulated by normalStrength.
oBridge.makeNormalMapFromHeightMap("", 1.0);
/////////////////////////////////////
//
// Dialog Classes
//
/////////////////////////////////////
// class DzBridgeDialog
var oBridgeDialog = new DzBridgeDialog();
dzwidget = oBridgeDialog.wAssetNameEdit;
dzwidget = oBridgeDialog.wAssetTypeCombo
dzwidget = oBridgeDialog.wMorphsEnabledCheckBox;
dzwidget = oBridgeDialog.wSubdivisionEnabledCheckBox;
dzwidget = oBridgeDialog.wAdvancedSettingsGroupBox;
dzwidget = oBridgeDialog.wFbxVersionCombo
dzwidget = oBridgeDialog.wShowFbxDialogCheckBox
dzwidget = oBridgeDialog.wEnableNormalMapGenerationCheckBox
dzwidget = oBridgeDialog.wExportMaterialPropertyCSVCheckBox
dzwidget = oBridgeDialog.wTargetPluginInstallerButton
dzwidget = oBridgeDialog.wTargetSoftwareVersionCombo
oBridgeDialog.resetToDefaults();
oBridgeDialog.loadSavedSettings();
// DzBridgeDialog.showTargetPluginInstaller(bool)
// Shows the UI to Install Target Software Plugins inside the Advanced Settings Box
// The UI consist of a dropdown combobox to select software version and a button
// to install the plugin. To retrieve the widgets, please use above propreties:
// oBridgeDialog.wTargetPluginInstallerButton
// oBridgeDialog.wTargetSoftwareVersionCombo
oBridgeDialog.showTargetPluginInstaller(true)
// DzBridgeDialog.renameTargetPluginInstaller(QString)
// Rename the Dialog Label for the Target Plugin Installer widgets
oBridgeDialog.renameTargetPluginInstaller("New Label Name");
// DzBridgeDialog.installEmbeddedArchive(QString, QString)
// Used by the Target Plugin Installer UI to install a specified Zip file which
// is embedded into the Plugin to the specified destination path.
// It then does validation of each file to make sure it extracted and exists on disk.
// Return Values:
// True == Installation success
// False == Installation failed
oBridgeDialog.installEmbeddedArchive("Archive Name", "Destination Path");
// DzBridgeAction.setBridgeDialog(oBridgeDialog)
// Assign the Dialog Widget to be used with the BridgeAction Object.
oBridge.setBridgeDialog(oBridgeDialog);
// NOTE: the following classes MUST have a Scene node selected, otherwise they will crash
if (Scene.getPrimarySelection())
{
// class DzBridgeMorphSelectionDialog
// DzBridgeMorphSelectionDialog.Get(QWidget parent)
// retrieves or instantiates a singleton widget for this class
var oMorphDialog = new DzBridgeMorphSelectionDialog().Get(oBridgeDialog);
// (void) DzBridgeMorphSelectionDialog.PrepareDialog()
// Populates morph selection widgets
oMorphDialog.PrepareDialog();
// (QString) DzBridgeMorphSelectionDialog.GetMorphString()
// returns selection string to be used with FbxExporter
sMorphString = oMorphDialog.GetMorphString();
// (QString) DzBridgeMorphSelectionDialog.GetMorphCSVString()
// returns CSV version of morph selection string
sCsvString = oMorphDialog.GetMorphCSVString();
// (boolean) DzBridgeMorphSelectionDialog.IsAutoJCMEnabled()
// returns true if AutoJCM checkbox is enabled
bEnableJCM = oMorphDialog.IsAutoJCMEnabled();
// (QString) DzBridgeMorphSelectionDialog.GetMorphLabelFromName(QString arg)
// returns friendly label when passed internal morph name via <arg>
oMorphDialog.GetMorphLabelFromName("");
oBridge.setMorphSelectionDialog(oMorphDialog);
// class DzBridgeSubdivisionDialog
// DzBridgeSubdivisionDialog.Get(QWidget parent)
// retrieves or instantiates a singleton widget for this class
var oSubdivisionDialog = new DzBridgeSubdivisionDialog().Get(oBridgeDialog);
// (void) DzBridgeSubdivisionDialog.PrepareDialog()
// Populates subdivision level widgets
oSubdivisionDialog.PrepareDialog();
// (void) DzBridgeSubdivisionDialog.LockSubdivisionProperties(bool bSubdivisionEnabled)
// Locks subdivision properties, used during exportHD() method to control
// mesh definition level.
// If bSubdivisionEnabled is true, then all models are locked at their current
// subdivision level.
// If bSubdivisionEnabled is false, then all models are locked at subdivision level zero.
oSubdivisionDialog.LockSubdivisionProperties(false);
// (void) oSubdivisionDialog.UnlockSubdivisionProperties()
// Unlocks subdivision properties, returning them to settings prior to calling
// LockSubdivisionProperties()
oSubdivisionDialog.UnlockSubdivisionProperties();
// (DzNode) oSubdivisionDialog.FindObject(DzNode parentNode, QString name)
// Recursively searches for a child node within <parentNode> that has name == <name>
// Returns null if no match is found.
oSubdivisionDialog.FindObject(Scene.getPrimarySelection(), "");
// (bool) setSubdivisionLevelByNode(DzNode node, int level)
// Recursively searches for child nodes with the same name as <node> using the
// primary scene selection as a root node. Then sets that child node's subdivision
// level to <level>.
// Returns true if successful. Returns false if no match is found or if <level> is
// greater than the maximum level available in the Subdivision Level dropdown.
oSubdivisionDialog.setSubdivisionLevelByNode(DzNode(), 0);
oBridge.setSubdivisionDialog(oSubdivisionDialog);
}
/////////////////////////////////////
//
// Currently not accessible from default Daz Script Interpreter
//
/////////////////////////////////////
// (bool) copyFile(QFile file, QString dst, bool bReplace = true, bool bCompareFiles = true)
// Copies a file to a destination filepath.
// If bReplace is true, then destination file is removed prior to performing copy.
// Note: on most platforms, the copy operation will fail if destination file exists.
// If bCompare is also true, then destination file is removed only if MD5 comparison of
// the source and destination files are different.
// Returns true if copy operation is performed and false if any copy fails or if any ot the
// optional copy conditions is not met.
// NOTE: currently not practical for scripting because QFile is not registered in default
// DazScript interpreter
// (void) upgradeToHD(QString baseFilePath, QString hdFilePath, QString outFilePath, std::map<std::string, int>* pLookupTable)
// Performs insertion of missing bone weight data for baked subdivision fbx files.
// NOTE: currently not practical for scripting due to std::map<std::string, int> argument.
//oBridge.upgradeToHD("", "", "", null);
// NOTE: Following methods are currently not usable due to DzJsonWriter not registered
// (void) writeDTUHeader(DzJsonWriter writer)
// (void) writeAllMaterials(DzNode* Node, DzJsonWriter& Writer, QTextStream* CVSStream = nullptr, bool bRecursive = false)
// (void) startMaterialBlock(DzNode* Node, DzJsonWriter& Writer, QTextStream* pCVSStream, DzMaterial* Material)
// (void) finishMaterialBlock(DzJsonWriter& Writer)
// (void) writeAllMorphs(DzJsonWriter& Writer)
// (void) writeMorphProperties(DzJsonWriter& writer, const QString& key, const QString& value)
// (void) writeMorphJointLinkInfo(DzJsonWriter& writer, const JointLinkInfo& linkInfo)
// (void) writeAllSubdivisions(DzJsonWriter& Writer)
// (void) writeSubdivisionProperties(DzJsonWriter& writer, const QString& Name, int targetValue)
// (void) writeAllDforceInfo(DzNode* Node, DzJsonWriter& Writer, QTextStream* pCVSStream = nullptr, bool bRecursive = false)
// (void) writeDforceMaterialProperties(DzJsonWriter& Writer, DzMaterial* Material, DzShape* Shape)
// (void) writeDforceModifiers(const QList<DzModifier*>& dforceModifierList, DzJsonWriter& Writer, DzShape* Shape)
// (void) writeEnvironment(DzJsonWriter& writer);
// (void) writeInstances(DzNode* Node, DzJsonWriter& Writer, QMap<QString, DzMatrix3>& WritenInstances, QList<DzGeometry*>& ExportedGeometry, QUuid ParentID = QUuid())
// (void) writeInstance(DzNode* Node, DzJsonWriter& Writer, QUuid ParentID)
// (void) writeAllPoses(DzJsonWriter& writer)
// (void) writeWeightMaps(DzNode Node, DzJsonWriter Stream)