simplex-solver 3.2.2__cp39-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. simplex_solver-3.2.2.dist-info/DELVEWHEEL +2 -0
  2. simplex_solver-3.2.2.dist-info/METADATA +94 -0
  3. simplex_solver-3.2.2.dist-info/RECORD +84 -0
  4. simplex_solver-3.2.2.dist-info/WHEEL +5 -0
  5. simplex_solver.libs/.load-order-simplex_solver-3.2.2 +1 -0
  6. simplex_solver.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
  7. simplexui/__init__.py +86 -0
  8. simplexui/_version.py +1 -0
  9. simplexui/channelBox.py +867 -0
  10. simplexui/comboCheckDialog.py +396 -0
  11. simplexui/commands/__init__.py +16 -0
  12. simplexui/commands/alembicCommon.py +1148 -0
  13. simplexui/commands/alembic_walker.py +299 -0
  14. simplexui/commands/applyCorrectives.py +452 -0
  15. simplexui/commands/correctiveInterface.py +259 -0
  16. simplexui/commands/expandedExport.py +434 -0
  17. simplexui/commands/hdf5Convert.py +62 -0
  18. simplexui/commands/mayaCorrectiveInterface.py +159 -0
  19. simplexui/commands/mayatonumpy.py +416 -0
  20. simplexui/commands/mesh.py +1085 -0
  21. simplexui/commands/poseblendlib.py +168 -0
  22. simplexui/commands/reorderSimplexPoints.py +102 -0
  23. simplexui/commands/replaceDefinitionJson.py +74 -0
  24. simplexui/commands/rigidAlign.py +97 -0
  25. simplexui/commands/unsubdivide.py +1222 -0
  26. simplexui/commands/uvTransfer.py +976 -0
  27. simplexui/dragFilter.py +334 -0
  28. simplexui/falloffDialog.py +504 -0
  29. simplexui/img/ChefHead.png +0 -0
  30. simplexui/img/frozen.png +0 -0
  31. simplexui/interface/__init__.py +30 -0
  32. simplexui/interface/dummyInterface.py +1313 -0
  33. simplexui/interface/mayaInterface.py +2294 -0
  34. simplexui/interfaceModel.py +655 -0
  35. simplexui/interfaceModelTrees.py +456 -0
  36. simplexui/items/__init__.py +50 -0
  37. simplexui/items/accessor.py +145 -0
  38. simplexui/items/combo.py +645 -0
  39. simplexui/items/dragItem.py +44 -0
  40. simplexui/items/falloff.py +748 -0
  41. simplexui/items/group.py +267 -0
  42. simplexui/items/progression.py +613 -0
  43. simplexui/items/shape.py +384 -0
  44. simplexui/items/simplex.py +1734 -0
  45. simplexui/items/slider.py +632 -0
  46. simplexui/items/stack.py +147 -0
  47. simplexui/items/traversal.py +780 -0
  48. simplexui/items/treeItem.py +441 -0
  49. simplexui/main.pyw +22 -0
  50. simplexui/menu/__init__.py +73 -0
  51. simplexui/menu/dummyPlugins/__init__.py +16 -0
  52. simplexui/menu/genericPlugins/__init__.py +16 -0
  53. simplexui/menu/genericPlugins/_builtins.py +270 -0
  54. simplexui/menu/genericPlugins/checkPossibleCombos.py +48 -0
  55. simplexui/menu/genericPlugins/exportSplit.py +67 -0
  56. simplexui/menu/genericPlugins/showFalloffs.py +26 -0
  57. simplexui/menu/genericPlugins/showTraversals.py +26 -0
  58. simplexui/menu/genericPlugins/simplexUvTransfer.py +106 -0
  59. simplexui/menu/genericPlugins/unsubdivide.py +72 -0
  60. simplexui/menu/mayaPlugins/__init__.py +16 -0
  61. simplexui/menu/mayaPlugins/exportOther.py +53 -0
  62. simplexui/menu/mayaPlugins/extractProgressives.py +68 -0
  63. simplexui/menu/mayaPlugins/freezeCombo.py +247 -0
  64. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +99 -0
  65. simplexui/menu/mayaPlugins/importObjs.py +199 -0
  66. simplexui/menu/mayaPlugins/linearizeTraversal.py +60 -0
  67. simplexui/menu/mayaPlugins/makeShelfBtn.py +67 -0
  68. simplexui/menu/mayaPlugins/relaxToSelection.py +76 -0
  69. simplexui/menu/mayaPlugins/reloadDefinition.py +44 -0
  70. simplexui/menu/mayaPlugins/snapToNeutral.py +71 -0
  71. simplexui/menu/mayaPlugins/softSelectToCluster.py +201 -0
  72. simplexui/menu/mayaPlugins/tweakMix.py +136 -0
  73. simplexui/menu/mayaPlugins/updateRestShape.py +113 -0
  74. simplexui/pysimplex.lib +0 -0
  75. simplexui/pysimplex.pyd +0 -0
  76. simplexui/simplexDialog.py +1547 -0
  77. simplexui/travCheckDialog.py +419 -0
  78. simplexui/traversalDialog.py +299 -0
  79. simplexui/ui/comboCheckDialog.ui +475 -0
  80. simplexui/ui/falloffDialog.ui +243 -0
  81. simplexui/ui/simplexDialog.ui +1458 -0
  82. simplexui/ui/travCheckDialog.ui +488 -0
  83. simplexui/ui/traversalDialog.ui +532 -0
  84. simplexui/utils.py +307 -0
@@ -0,0 +1,270 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import annotations
19
+
20
+ from functools import partial
21
+
22
+ from Qt.QtCore import Qt
23
+ from Qt.QtWidgets import QCheckBox, QWidgetAction
24
+
25
+ from ...items import Combo, ComboPair, ProgPair, Progression, Slider
26
+
27
+
28
+ def registerContext(tree, clickIdx, indexes, menu) -> None:
29
+ self = tree.window()
30
+ if tree == self.uiComboTREE:
31
+ registerComboTree(self, clickIdx, indexes, menu)
32
+ if tree == self.uiSliderTREE:
33
+ registerSliderTree(self, clickIdx, indexes, menu)
34
+
35
+
36
+ def registerSliderTree(window, clickIdx, indexes, menu) -> None:
37
+ self = window
38
+ # live = self.uiLiveShapeConnectionACT.isChecked()
39
+ items = [i.model().itemFromIndex(i) for i in indexes]
40
+ types = {}
41
+ for i in items:
42
+ types.setdefault(type(i), []).append(i)
43
+
44
+ activeCount = 0
45
+ for s in self.simplex.sliders:
46
+ if s.value != 0.0:
47
+ activeCount += 1
48
+
49
+ sel = self.simplex.DCC.getSelectedObjects()
50
+
51
+ # anywhere
52
+ addGroupACT = menu.addAction("Add Group")
53
+ addGroupACT.triggered.connect(self.newSliderGroup)
54
+ # anywhere
55
+ if indexes:
56
+ addSliderACT = menu.addAction("Add Slider")
57
+ addSliderACT.triggered.connect(self.newSlider)
58
+ # on/under slider in slider tree
59
+ if ProgPair in types or Slider in types:
60
+ addShapeACT = menu.addAction("Add Shape")
61
+ addShapeACT.triggered.connect(self.newSliderShape)
62
+
63
+ if Slider in types:
64
+ menu.addSeparator()
65
+ setGroupMenu = menu.addMenu("Set Group")
66
+ for group in window.simplex.sliderGroups:
67
+ gAct = setGroupMenu.addAction(group.name)
68
+ gAct.triggered.connect(partial(self.setSelectedSliderGroups, group))
69
+
70
+ setFalloffMenu = menu.addMenu("Set Falloffs")
71
+ sliders = list({i for i in items if isinstance(i, Slider)})
72
+
73
+ foChecks = {}
74
+ interps = set()
75
+ for slider in sliders:
76
+ for fo in slider.prog.falloffs:
77
+ foChecks.setdefault(fo, []).append(slider)
78
+ interps.add(slider.prog.interp.lower())
79
+
80
+ for falloff in window.simplex.falloffs:
81
+ cb = QCheckBox(falloff.name, setFalloffMenu)
82
+ chk = foChecks.get(falloff)
83
+ if not chk:
84
+ cb.setCheckState(Qt.CheckState.Unchecked)
85
+ elif len(chk) != len(sliders):
86
+ cb.setCheckState(Qt.CheckState.PartiallyChecked)
87
+ else:
88
+ cb.setCheckState(Qt.CheckState.Checked)
89
+
90
+ cb.stateChanged.connect(partial(self.setSelectedSliderFalloff, falloff))
91
+
92
+ fAct = QWidgetAction(setFalloffMenu)
93
+ fAct.setDefaultWidget(cb)
94
+ setFalloffMenu.addAction(fAct)
95
+
96
+ setFalloffMenu.addSeparator()
97
+ editFalloffsACT = setFalloffMenu.addAction("Edit Falloffs ...")
98
+ editFalloffsACT.triggered.connect(window.showFalloffDialog)
99
+
100
+ setInterpMenu = menu.addMenu("Set Interpolation")
101
+ for interpName, interpType in Progression.interpTypes:
102
+ act = setInterpMenu.addAction(interpName)
103
+ act.triggered.connect(partial(self.setSelectedSliderInterp, interpType))
104
+ act.setCheckable(True)
105
+ if interpType in interps:
106
+ act.setChecked(True)
107
+
108
+ menu.addSeparator()
109
+
110
+ sep = False
111
+ if activeCount >= 2:
112
+ # if 2 or more are active
113
+ comboActiveACT = menu.addAction("Combo Active")
114
+ comboActiveACT.triggered.connect(self.newActiveCombo)
115
+ sep = True
116
+
117
+ if len(types.get(Slider, [])) >= 2:
118
+ # if 2 or more are selected
119
+ comboSelectedACT = menu.addAction("Combo Selected")
120
+ comboSelectedACT.triggered.connect(self.newSelectedCombo)
121
+ sep = True
122
+
123
+ if sep:
124
+ menu.addSeparator()
125
+
126
+ # anywhere
127
+ if indexes:
128
+ deleteACT = menu.addAction("Delete Selected")
129
+ deleteACT.triggered.connect(self.sliderTreeDelete)
130
+
131
+ menu.addSeparator()
132
+
133
+ if indexes:
134
+ # anywhere
135
+ zeroACT = menu.addAction("Zero Selected")
136
+ zeroACT.triggered.connect(self.zeroSelectedSliders)
137
+ # anywhere
138
+ zeroAllACT = menu.addAction("Zero All")
139
+ zeroAllACT.triggered.connect(self.zeroAllSliders)
140
+
141
+ menu.addSeparator()
142
+
143
+ if ProgPair in types or Slider in types:
144
+ # on shape/slider
145
+ extractShapeACT = menu.addAction("Extract")
146
+ extractShapeACT.triggered.connect(self.shapeExtract)
147
+
148
+ # on shape/slider
149
+ exportShapeACT = menu.addAction("Export Selected ...")
150
+ exportShapeACT.triggered.connect(self.shapeExport)
151
+
152
+ # on shape/slider
153
+ connectShapeACT = menu.addAction("Connect By Name")
154
+ connectShapeACT.triggered.connect(self.shapeConnect)
155
+ if sel:
156
+ # on shape/slider, if there's a selection
157
+ matchShapeACT = menu.addAction("Match To Scene Selection")
158
+ matchShapeACT.triggered.connect(self.shapeMatch)
159
+ # on shape/slider
160
+ clearShapeACT = menu.addAction("Clear")
161
+ clearShapeACT.triggered.connect(self.shapeClear)
162
+
163
+ menu.addSeparator()
164
+
165
+ if indexes:
166
+ # Anywhere
167
+ isolateSelectedACT = menu.addAction("Isolate Selected")
168
+ isolateSelectedACT.triggered.connect(self.sliderIsolateSelected)
169
+
170
+ if self.isSliderIsolate():
171
+ # Anywhere
172
+ exitIsolationACT = menu.addAction("Exit Isolation")
173
+ exitIsolationACT.triggered.connect(self.sliderTreeExitIsolate)
174
+
175
+ menu.addSeparator()
176
+
177
+
178
+ def registerComboTree(window, clickIdx, indexes, menu) -> None:
179
+ self = window
180
+ # live = self.uiLiveShapeConnectionACT.isChecked()
181
+ items = [i.model().itemFromIndex(i) for i in indexes]
182
+ types = {}
183
+ for i in items:
184
+ types.setdefault(type(i), []).append(i)
185
+ sel = self.simplex.DCC.getSelectedObjects()
186
+
187
+ # anywhere
188
+ addGroupACT = menu.addAction("Add Group")
189
+ addGroupACT.triggered.connect(self.newComboGroup)
190
+
191
+ if Combo in types or ComboPair in types or ProgPair in types:
192
+ # on combo, comboPair, or shape
193
+ addShapeACT = menu.addAction("Add Shape")
194
+ addShapeACT.triggered.connect(self.newComboShape)
195
+
196
+ menu.addSeparator()
197
+
198
+ # on combo, comboPair, or shape
199
+ deleteACT = menu.addAction("Delete Selected")
200
+ deleteACT.triggered.connect(self.comboTreeDelete)
201
+
202
+ menu.addSeparator()
203
+
204
+ # combo or below
205
+ setValsACT = menu.addAction("Set Selected Values")
206
+ setValsACT.triggered.connect(self.setSliderVals)
207
+
208
+ setGroupMenu = menu.addMenu("Set Group")
209
+ for group in window.simplex.comboGroups:
210
+ gAct = setGroupMenu.addAction(group.name)
211
+ gAct.triggered.connect(partial(self.setSelectedComboGroups, group))
212
+
213
+ menu.addSeparator()
214
+
215
+ setSolveMenu = menu.addMenu("Set Solve Type")
216
+ solves = set()
217
+ combos = list({i for i in items if isinstance(i, Combo)})
218
+ for combo in combos:
219
+ solves.add(str(combo.solveType))
220
+
221
+ if "None" in solves:
222
+ solves.discard("None")
223
+ solves.add("min")
224
+
225
+ for stName, stVal in Combo.solveTypes:
226
+ if stName != "None":
227
+ act = setSolveMenu.addAction(stName)
228
+ act.setCheckable(True)
229
+ if stVal in solves:
230
+ act.setChecked(True)
231
+ act.triggered.connect(partial(self.setSelectedComboSolveType, stVal))
232
+
233
+ menu.addSeparator()
234
+
235
+ # combo or below
236
+ extractShapeACT = menu.addAction("Extract")
237
+ extractShapeACT.triggered.connect(self.shapeExtract)
238
+
239
+ # combo or below
240
+ exportShapeACT = menu.addAction("Export Selected ...")
241
+ exportShapeACT.triggered.connect(self.shapeExport)
242
+
243
+ # combo or below
244
+ connectShapeACT = menu.addAction("Connect By Name")
245
+ connectShapeACT.triggered.connect(self.shapeConnect)
246
+ if sel:
247
+ # combo or below, if there's a selection
248
+ matchShapeACT = menu.addAction("Match To Scene Selection")
249
+ matchShapeACT.triggered.connect(self.shapeMatch)
250
+ # combo or below
251
+ clearShapeACT = menu.addAction("Clear")
252
+ clearShapeACT.triggered.connect(self.shapeClear)
253
+
254
+ menu.addSeparator()
255
+
256
+ sep = False
257
+ if indexes:
258
+ # anywhere
259
+ isolateSelectedACT = menu.addAction("Isolate Selected")
260
+ isolateSelectedACT.triggered.connect(self.comboIsolateSelected)
261
+ sep = True
262
+
263
+ if self.isComboIsolate():
264
+ # anywhere
265
+ exitIsolationACT = menu.addAction("Exit Isolation")
266
+ exitIsolationACT.triggered.connect(self.comboTreeExitIsolate)
267
+ sep = True
268
+
269
+ if sep:
270
+ menu.addSeparator()
@@ -0,0 +1,48 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import annotations
19
+
20
+ from functools import partial
21
+
22
+ from Qt.QtWidgets import QAction
23
+
24
+ from ...comboCheckDialog import ComboCheckDialog
25
+ from ...items import Slider
26
+
27
+
28
+ def registerTool(window, menu) -> None:
29
+ checkPossibleCombosACT = QAction("Check Possible Combos ...", window)
30
+ menu.addAction(checkPossibleCombosACT)
31
+ checkPossibleCombosACT.triggered.connect(
32
+ partial(checkPossibleCombosInterface, window)
33
+ )
34
+
35
+
36
+ def registerContext(tree, clickIdx, indexes, menu) -> None:
37
+ window = tree.window()
38
+ checkPossibleCombosACT = QAction("Check Possible Combos ...", tree)
39
+ menu.addAction(checkPossibleCombosACT)
40
+ checkPossibleCombosACT.triggered.connect(
41
+ partial(checkPossibleCombosInterface, window)
42
+ )
43
+
44
+
45
+ def checkPossibleCombosInterface(window) -> None:
46
+ sliders = window.uiSliderTREE.getSelectedItems(typ=Slider)
47
+ ccd = ComboCheckDialog(sliders, parent=window)
48
+ ccd.show()
@@ -0,0 +1,67 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import annotations
19
+
20
+ from functools import partial
21
+
22
+ import numpy as np
23
+ from Qt import QtCompat
24
+ from Qt.QtGui import QAction
25
+ from Qt.QtWidgets import QMessageBox, QProgressDialog
26
+
27
+
28
+ def registerTool(window, menu) -> None:
29
+ if np is not None:
30
+ exportSplitACT = QAction("Export Split", window)
31
+ menu.addAction(exportSplitACT)
32
+ exportSplitACT.triggered.connect(partial(exportSplitInterface, window))
33
+
34
+
35
+ def exportSplitInterface(window) -> None:
36
+ if np is None:
37
+ QMessageBox.warning(
38
+ window,
39
+ "No Numpy",
40
+ "Numpy is not available here, an it is required to split a system",
41
+ )
42
+ return
43
+
44
+ if window.simplex is None:
45
+ QMessageBox.warning(
46
+ window,
47
+ "Nothing Loaded",
48
+ "No simplex system is loaded",
49
+ )
50
+ return
51
+
52
+ path, _filter = QtCompat.QFileDialog.getSaveFileName(
53
+ window, "Export Split", "", "Simplex (*.smpx)"
54
+ )
55
+
56
+ if not path:
57
+ return
58
+
59
+ pBar = QProgressDialog("Exporting Split smpx File", "Cancel", 0, 100, window)
60
+ pBar.show()
61
+ try:
62
+ split = window.simplex.split(pBar=pBar)
63
+ split.exportAbc(path, pBar)
64
+ except ValueError as e:
65
+ QMessageBox.warning(window, "Unsplittable", str(e))
66
+ finally:
67
+ pBar.close()
@@ -0,0 +1,26 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import annotations
19
+
20
+ from Qt.QtWidgets import QAction
21
+
22
+
23
+ def registerTool(window, menu) -> None:
24
+ editFalloffsACT = QAction("Edit Falloffs ...", window)
25
+ menu.addAction(editFalloffsACT)
26
+ editFalloffsACT.triggered.connect(window.showFalloffDialog)
@@ -0,0 +1,26 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import annotations
19
+
20
+ from Qt.QtWidgets import QAction
21
+
22
+
23
+ def registerTool(window, menu) -> None:
24
+ showTraversalsACT = QAction("Show Traversals ...", window)
25
+ menu.addAction(showTraversalsACT)
26
+ showTraversalsACT.triggered.connect(window.showTraversalDialog)
@@ -0,0 +1,106 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import annotations
19
+
20
+ import json
21
+
22
+ import numpy as np
23
+
24
+ from ...commands.alembicCommon import buildSmpx, readSmpx
25
+ from ...commands.mesh import Mesh
26
+ from ...commands.uvTransfer import applyTransfer, getVertCorrelation
27
+
28
+
29
+ def simplexUvTransfer(
30
+ srcSmpxPath, tarPath, outPath, srcUvPath=None, tol: float = 0.0001, pBar=None
31
+ ) -> None:
32
+ """Transfer a simplex system onto a mesh through UV space
33
+
34
+ Parameters
35
+ ----------
36
+ srcSmpxPath : str
37
+ The path to the source .smpx file
38
+ tarPath : str
39
+ The path to the mesh to recieve the blendshapes
40
+ outPath : str
41
+ The .smpx path that will be written
42
+ srcUvPath : str
43
+ If the .smpx file doesn't have UV's, then the UV's
44
+ from this mesh wil be used. Defaults to None
45
+ tol : float
46
+ The tolerance for checking if a UV is outside of a poly
47
+ pBar : QProgressDialog
48
+ Optional progress bar
49
+
50
+ """
51
+ if np is None:
52
+ raise RuntimeError("UV Transfer requires Numpy. It is currently unavailable")
53
+
54
+ if pBar is not None:
55
+ pBar.setLabelText("Loading Source Mesh")
56
+ from Qt.QtWidgets import QApplication
57
+
58
+ QApplication.processEvents()
59
+
60
+ srcUvPath = srcUvPath or srcSmpxPath
61
+ if srcUvPath.endswith(".abc") or srcUvPath.endswith(".smpx"):
62
+ src = Mesh.loadAbc(srcUvPath, ensureWinding=False)
63
+ elif srcUvPath.endswith(".obj"):
64
+ src = Mesh.loadObj(srcUvPath, ensureWinding=False)
65
+
66
+ if pBar is not None:
67
+ pBar.setLabelText("Loading Target Mesh")
68
+ from Qt.QtWidgets import QApplication
69
+
70
+ QApplication.processEvents()
71
+ if tarPath.endswith(".abc"):
72
+ tar = Mesh.loadAbc(tarPath, ensureWinding=False)
73
+ elif tarPath.endswith(".obj"):
74
+ tar = Mesh.loadObj(tarPath, ensureWinding=False)
75
+
76
+ jsString, _, srcVerts, _, _, _ = readSmpx(srcSmpxPath)
77
+ js = json.loads(jsString)
78
+ name = js["systemName"]
79
+
80
+ srcFaces = src.faceVertArray
81
+ srcUvFaces = src.uvFaceMap["default"]
82
+ srcUvs = np.array(src.uvMap["default"])
83
+
84
+ tarFaces = tar.faceVertArray
85
+ tarUvFaces = tar.uvFaceMap["default"]
86
+ tarUvs = np.array(tar.uvMap["default"])
87
+ oldTarVerts = np.array(tar.vertArray)
88
+
89
+ corr = getVertCorrelation(
90
+ srcUvFaces, srcUvs, tarFaces, tarUvFaces, tarUvs, tol=tol, pBar=pBar
91
+ )
92
+ tarVerts = applyTransfer(srcVerts, srcFaces, corr, len(oldTarVerts))
93
+
94
+ # Apply as a delta
95
+ deltas = tarVerts - tarVerts[0][None, ...]
96
+ writeVerts = oldTarVerts[None, ...] + deltas
97
+
98
+ buildSmpx(
99
+ outPath,
100
+ writeVerts,
101
+ tarFaces,
102
+ jsString,
103
+ name,
104
+ uvs=tarUvs,
105
+ uvFaces=tarUvFaces,
106
+ )
@@ -0,0 +1,72 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import annotations
19
+
20
+ import os
21
+ from functools import partial
22
+
23
+ from Qt import QtCompat
24
+ from Qt.QtWidgets import QAction, QMessageBox, QProgressDialog
25
+
26
+ from ...commands.unsubdivide import unsubdivideSimplex
27
+
28
+ try:
29
+ import imathnumpy
30
+ except ImportError:
31
+ imathnumpy = None
32
+
33
+
34
+ def registerTool(window, menu) -> None:
35
+ if imathnumpy is not None:
36
+ exportUnsubACT = QAction("Un Subdivide Smpx ...", window)
37
+ menu.addAction(exportUnsubACT)
38
+ exportUnsubACT.triggered.connect(partial(exportUnsubInterface, window))
39
+
40
+
41
+ def exportUnsubInterface(window) -> None:
42
+ if imathnumpy is None:
43
+ QMessageBox.warning(
44
+ window,
45
+ "No ImathToNumpy",
46
+ "ImathToNumpy is not available here, and it is required to unsubdivide a system",
47
+ )
48
+ return
49
+
50
+ path, _filter = QtCompat.QFileDialog.getOpenFileName(
51
+ window, "Un Subdivide", "", "Simplex (*.smpx)"
52
+ )
53
+
54
+ if not path:
55
+ return
56
+
57
+ outPath = path.replace(".smpx", "_UNSUB.smpx")
58
+ if path == outPath:
59
+ QMessageBox.warning(window, f"Unable to rename smpx file: {path}")
60
+ return
61
+
62
+ if os.path.isfile(outPath):
63
+ btns = QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Cancel
64
+ msg = f"Unsub file already exists.\n{outPath}\nOverwrite?"
65
+ response = QMessageBox.question(window, "File already exists", msg, btns)
66
+ if not response & QMessageBox.StandardButton.Ok:
67
+ return
68
+
69
+ pBar = QProgressDialog("Exporting Unsubdivided smpx File", "Cancel", 0, 100, window)
70
+ pBar.show()
71
+ unsubdivideSimplex(path, outPath, pBar=pBar)
72
+ pBar.close()
@@ -0,0 +1,16 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
@@ -0,0 +1,53 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import annotations
19
+
20
+ from functools import partial
21
+
22
+ import maya.cmds as cmds
23
+ from Qt import QtCompat
24
+ from Qt.QtGui import QAction
25
+ from Qt.QtWidgets import QMessageBox, QProgressDialog
26
+
27
+
28
+ def registerTool(window, menu) -> None:
29
+ exportOtherACT = QAction("Export Other", window)
30
+ menu.addAction(exportOtherACT)
31
+ exportOtherACT.triggered.connect(partial(exportOtherInterface, window))
32
+
33
+
34
+ def exportOtherInterface(window) -> None:
35
+ if window.simplex is None:
36
+ QMessageBox.warning(
37
+ window,
38
+ "Nothing Loaded",
39
+ "No simplex system is loaded",
40
+ )
41
+ return
42
+
43
+ sel = cmds.ls(sl=True)
44
+ path, _filter = QtCompat.QFileDialog.getSaveFileName(
45
+ window, "Export Other", "", "Simplex (*.smpx)"
46
+ )
47
+
48
+ pBar = QProgressDialog(
49
+ "Exporting Simplex from Other Mesh", "Cancel", 0, 100, window
50
+ )
51
+ if sel and path:
52
+ window.simplex.exportOther(path, sel[0], world=True, pBar=pBar)
53
+ pBar.close()