simplex-solver 3.0.18__37-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 (81) hide show
  1. pysimplex.pyd +0 -0
  2. simplex_solver-3.0.18.dist-info/METADATA +87 -0
  3. simplex_solver-3.0.18.dist-info/RECORD +81 -0
  4. simplex_solver-3.0.18.dist-info/WHEEL +5 -0
  5. simplex_solver-3.0.18.dist-info/licenses/LICENSE +165 -0
  6. simplexui/__init__.py +54 -0
  7. simplexui/channelBox.py +862 -0
  8. simplexui/comboCheckDialog.py +335 -0
  9. simplexui/commands/__init__.py +16 -0
  10. simplexui/commands/alembicCommon.py +1045 -0
  11. simplexui/commands/applyCorrectives.py +455 -0
  12. simplexui/commands/buildIceXML.py +443 -0
  13. simplexui/commands/correctiveInterface.py +271 -0
  14. simplexui/commands/expandedExport.py +435 -0
  15. simplexui/commands/hdf5Convert.py +62 -0
  16. simplexui/commands/mayaCorrectiveInterface.py +164 -0
  17. simplexui/commands/mesh.py +1086 -0
  18. simplexui/commands/reorderSimplexPoints.py +103 -0
  19. simplexui/commands/rigidAlign.py +103 -0
  20. simplexui/commands/setDelta.xsicompound +60 -0
  21. simplexui/commands/smpxBlend.py +634 -0
  22. simplexui/commands/unsubdivide.py +1232 -0
  23. simplexui/commands/uvTransfer.py +986 -0
  24. simplexui/commands/xsiCorrectiveInterface.py +136 -0
  25. simplexui/dragFilter.py +299 -0
  26. simplexui/falloffDialog.py +476 -0
  27. simplexui/img/ChefHead.png +0 -0
  28. simplexui/img/frozen.png +0 -0
  29. simplexui/interface/__init__.py +30 -0
  30. simplexui/interface/dummyInterface.py +1564 -0
  31. simplexui/interface/mayaInterface.py +3197 -0
  32. simplexui/interface/xsiInterface.py +2944 -0
  33. simplexui/interfaceModel.py +1040 -0
  34. simplexui/interfaceModelTrees.py +439 -0
  35. simplexui/interfaceModel_Test.py +259 -0
  36. simplexui/items/__init__.py +26 -0
  37. simplexui/items/accessor.py +217 -0
  38. simplexui/items/combo.py +855 -0
  39. simplexui/items/falloff.py +780 -0
  40. simplexui/items/group.py +295 -0
  41. simplexui/items/progression.py +745 -0
  42. simplexui/items/shape.py +444 -0
  43. simplexui/items/simplex.py +1747 -0
  44. simplexui/items/slider.py +741 -0
  45. simplexui/items/stack.py +156 -0
  46. simplexui/items/traversal.py +969 -0
  47. simplexui/main.pyw +22 -0
  48. simplexui/menu/__init__.py +73 -0
  49. simplexui/menu/dummyPlugins/__init__.py +16 -0
  50. simplexui/menu/genericPlugins/__init__.py +16 -0
  51. simplexui/menu/genericPlugins/_builtins.py +260 -0
  52. simplexui/menu/genericPlugins/checkPossibleCombos.py +47 -0
  53. simplexui/menu/genericPlugins/exportSplit.py +61 -0
  54. simplexui/menu/genericPlugins/showFalloffs.py +24 -0
  55. simplexui/menu/genericPlugins/showTraversals.py +24 -0
  56. simplexui/menu/genericPlugins/simplexUvTransfer.py +109 -0
  57. simplexui/menu/genericPlugins/unsubdivide.py +71 -0
  58. simplexui/menu/mayaPlugins/__init__.py +16 -0
  59. simplexui/menu/mayaPlugins/exportOther.py +45 -0
  60. simplexui/menu/mayaPlugins/extractProgressives.py +67 -0
  61. simplexui/menu/mayaPlugins/freezeCombo.py +251 -0
  62. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +100 -0
  63. simplexui/menu/mayaPlugins/importObjs.py +196 -0
  64. simplexui/menu/mayaPlugins/linearizeTraversal.py +49 -0
  65. simplexui/menu/mayaPlugins/makeShelfBtn.py +69 -0
  66. simplexui/menu/mayaPlugins/relaxToSelection.py +77 -0
  67. simplexui/menu/mayaPlugins/reloadDefinition.py +34 -0
  68. simplexui/menu/mayaPlugins/snapToNeutral.py +74 -0
  69. simplexui/menu/mayaPlugins/softSelectToCluster.py +204 -0
  70. simplexui/menu/mayaPlugins/tweakMix.py +138 -0
  71. simplexui/menu/mayaPlugins/updateRestShape.py +107 -0
  72. simplexui/menu/xsiPlugins/__init__.py +16 -0
  73. simplexui/simplexDialog.py +1391 -0
  74. simplexui/travCheckDialog.py +393 -0
  75. simplexui/traversalDialog.py +277 -0
  76. simplexui/ui/comboCheckDialog.ui +475 -0
  77. simplexui/ui/falloffDialog.ui +243 -0
  78. simplexui/ui/simplexDialog.ui +1458 -0
  79. simplexui/ui/travCheckDialog.ui +488 -0
  80. simplexui/ui/traversalDialog.ui +532 -0
  81. simplexui/utils.py +320 -0
@@ -0,0 +1,71 @@
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 absolute_import
19
+
20
+ import os
21
+ from functools import partial
22
+
23
+ from ...commands.unsubdivide import unsubdivideSimplex
24
+ from Qt import QtCompat
25
+ from Qt.QtWidgets import QAction, QMessageBox, QProgressDialog
26
+
27
+ try:
28
+ import imathnumpy
29
+ except ImportError:
30
+ imathnumpy = None
31
+
32
+
33
+ def registerTool(window, menu):
34
+ if imathnumpy is not None:
35
+ exportUnsubACT = QAction("Un Subdivide Smpx ...", window)
36
+ menu.addAction(exportUnsubACT)
37
+ exportUnsubACT.triggered.connect(partial(exportUnsubInterface, window))
38
+
39
+
40
+ def exportUnsubInterface(window):
41
+ if imathnumpy is None:
42
+ QMessageBox.warning(
43
+ window,
44
+ "No ImathToNumpy",
45
+ "ImathToNumpy is not available here, and it is required to unsubdivide a system",
46
+ )
47
+ return
48
+
49
+ path, _filter = QtCompat.QFileDialog.getOpenFileName(
50
+ window, "Un Subdivide", "", "Simplex (*.smpx)"
51
+ )
52
+
53
+ if not path:
54
+ return
55
+
56
+ outPath = path.replace(".smpx", "_UNSUB.smpx")
57
+ if path == outPath:
58
+ QMessageBox.warning(window, "Unable to rename smpx file: {}".format(path))
59
+ return
60
+
61
+ if os.path.isfile(outPath):
62
+ btns = QMessageBox.Ok | QMessageBox.Cancel
63
+ msg = "Unsub file already exists.\n{0}\nOverwrite?".format(outPath)
64
+ response = QMessageBox.question(window, "File already exists", msg, btns)
65
+ if not response & QMessageBox.Ok:
66
+ return
67
+
68
+ pBar = QProgressDialog("Exporting Unsubdivided smpx File", "Cancel", 0, 100, window)
69
+ pBar.show()
70
+ unsubdivideSimplex(path, outPath, pBar=pBar)
71
+ 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,45 @@
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 absolute_import
19
+
20
+ from functools import partial
21
+
22
+ import maya.cmds as cmds
23
+
24
+ from Qt import QtCompat
25
+ from Qt.QtWidgets import QAction, QProgressDialog
26
+
27
+
28
+ def registerTool(window, menu):
29
+ exportOtherACT = QAction("Export Other", window)
30
+ menu.addAction(exportOtherACT)
31
+ exportOtherACT.triggered.connect(partial(exportOtherInterface, window))
32
+
33
+
34
+ def exportOtherInterface(window):
35
+ sel = cmds.ls(sl=True)
36
+ path, _filter = QtCompat.QFileDialog.getSaveFileName(
37
+ window, "Export Other", "", "Simplex (*.smpx)"
38
+ )
39
+
40
+ pBar = QProgressDialog(
41
+ "Exporting Simplex from Other Mesh", "Cancel", 0, 100, window
42
+ )
43
+ if sel and path:
44
+ window.simplex.exportOther(path, sel[0], world=True, pBar=pBar)
45
+ pBar.close()
@@ -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 absolute_import
19
+
20
+ from functools import partial
21
+
22
+ from ...interfaceModel import coerceIndexToType
23
+ from ...items import Slider
24
+ from Qt.QtWidgets import QAction
25
+
26
+
27
+ def registerTool(window, menu):
28
+ extractProgressivesACT = QAction("Extract Progressive", window)
29
+ menu.addAction(extractProgressivesACT)
30
+ extractProgressivesACT.triggered.connect(
31
+ partial(extractProgressivesInterface, window)
32
+ )
33
+
34
+
35
+ def registerContext(tree, clickIdx, indexes, menu):
36
+ window = tree.window()
37
+ live = window.uiLiveShapeConnectionACT.isChecked()
38
+ sliders = coerceIndexToType(indexes, Slider)
39
+
40
+ multis = []
41
+ for slidx in sliders:
42
+ slider = slidx.model().itemFromIndex(slidx)
43
+ if len(slider.prog.pairs) > 2:
44
+ multis.append(slidx)
45
+
46
+ if multis:
47
+ extractACT = menu.addAction("Extract Progressive")
48
+ extractACT.triggered.connect(partial(extractProgressivesContext, multis, live))
49
+ return True
50
+ return False
51
+
52
+
53
+ def extractProgressivesContext(indexes, live):
54
+ sliders = [idx.model().itemFromIndex(idx) for idx in indexes]
55
+ sliders = list(set(sliders))
56
+ for sli in sliders:
57
+ sli.extractProgressive(live=live)
58
+
59
+
60
+ def extractProgressivesInterface(window):
61
+ live = window.uiLiveShapeConnectionACT.isChecked()
62
+ indexes = window.uiSliderTREE.getSelectedIndexes()
63
+ indexes = coerceIndexToType(indexes, Slider)
64
+ sliders = [idx.model().itemFromIndex(idx) for idx in indexes]
65
+ sliders = list(set(sliders))
66
+ for sli in sliders:
67
+ sli.extractProgressive(live=live)
@@ -0,0 +1,251 @@
1
+ # This file is part of Simplex.
2
+ #
3
+ # Simplex is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU Lesser General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # Simplex is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ from __future__ import absolute_import
17
+
18
+ from functools import partial
19
+
20
+ import six
21
+ from six.moves import zip
22
+
23
+ from maya import cmds
24
+
25
+ from ...interface.mayaInterface import disconnected
26
+ from ...interfaceModel import coerceIndexToType
27
+ from ...items import Combo
28
+
29
+
30
+ # UI stuff
31
+ def registerContext(tree, clickIdx, indexes, menu):
32
+ # The basicBlendshape deformer is included in simplex_maya
33
+ if not cmds.pluginInfo("simplex_maya", query=True, loaded=True):
34
+ try:
35
+ cmds.loadPlugin("simplex_maya")
36
+ except RuntimeError:
37
+ return False
38
+
39
+ comboIdxs = coerceIndexToType(indexes, Combo)
40
+ combos = [cidx.model().itemFromIndex(cidx) for cidx in comboIdxs]
41
+
42
+ if combos:
43
+ freezeAct = menu.addAction("Freeze Combos")
44
+ unfreezeAct = menu.addAction("Un-Freeze Combos")
45
+ freezeAct.triggered.connect(partial(freezeCombosContext, combos, tree, True))
46
+ unfreezeAct.triggered.connect(partial(freezeCombosContext, combos, tree, False))
47
+ return True
48
+ return False
49
+
50
+
51
+ def freezeCombosContext(combos, tree, doFreeze):
52
+ if doFreeze:
53
+ for combo in combos:
54
+ if not combo.frozen:
55
+ freezeCombo(combo)
56
+ else:
57
+ for combo in combos:
58
+ if combo.frozen:
59
+ unfreezeCombo(combo)
60
+
61
+ tree.update()
62
+
63
+
64
+ def freezeCombo(combo):
65
+ """Freeze a combo so you can change the upstream combos and shapes
66
+ without affecting the result that you sculpted for the given combo
67
+
68
+ In practice, this snapshots the combo, then live-reads the upstream
69
+ shapes from the main blendshape and builds an up-to-date combo. The
70
+ difference between these two meshes is added back into the combo shape
71
+ """
72
+ simplex = combo.simplex
73
+
74
+ tweakShapeGroups = []
75
+ fullGeos = []
76
+ ppFilter = []
77
+ freezeShapes = []
78
+
79
+ # disconnect the controller from the operator
80
+ with disconnected(simplex.DCC.op) as sliderCnx:
81
+ for shapeIdx, pp in enumerate(combo.prog.pairs):
82
+ tVal = pp.value
83
+ freezeShape = pp.shape
84
+ if freezeShape.isRest:
85
+ continue
86
+
87
+ freezeShapes.append(freezeShape)
88
+ # zero all the sliders
89
+ cnx = sliderCnx[simplex.DCC.op]
90
+ for a in six.itervalues(cnx):
91
+ cmds.setAttr(a, 0.0)
92
+
93
+ # set the combo values
94
+ for pair in combo.pairs:
95
+ cmds.setAttr(cnx[pair.slider.thing], pair.value * tVal)
96
+
97
+ tweakPairs = []
98
+ for shape in simplex.shapes[1:]: # skip the restShape
99
+ shapeVal = cmds.getAttr(shape.thing)
100
+ if abs(shapeVal) > 0.0001:
101
+ tweakPairs.append((shape, shapeVal))
102
+
103
+ # Extract this fully-on shape
104
+ fullGeo = cmds.duplicate(
105
+ simplex.DCC.mesh, name="{0}_Freeze".format(freezeShape.name)
106
+ )[0]
107
+ fullGeos.append(fullGeo)
108
+
109
+ # Clean any orig shapes for now
110
+ interObjs = cmds.ls(
111
+ cmds.listRelatives(fullGeo, shapes=True), intermediateObjects=True
112
+ )
113
+ cmds.delete(interObjs)
114
+
115
+ tweakShapeGroups.append(tweakPairs)
116
+ ppFilter.append(pp)
117
+
118
+ simplex.DCC.primeShapes(combo)
119
+
120
+ shapePlugFmt = (
121
+ ".inputTarget[{meshIdx}].inputTargetGroup[{shapeIdx}].inputTargetItem[6000]"
122
+ )
123
+ endPlugs = [
124
+ ".inputRelativePointsTarget",
125
+ ".inputRelativeComponentsTarget",
126
+ ".inputPointsTarget",
127
+ ".inputComponentsTarget",
128
+ "",
129
+ ]
130
+ shapeNode = simplex.DCC.shapeNode
131
+ helpers = []
132
+ for geo, tweakPairs, pp, freezeShape in zip(
133
+ fullGeos, tweakShapeGroups, ppFilter, freezeShapes
134
+ ):
135
+ # build the basicBS node
136
+ bbs = cmds.deformer(geo, type="basicBlendShape")[0]
137
+ helpers.append(bbs)
138
+ idx = 0
139
+
140
+ for shape, val in tweakPairs:
141
+ if shape == freezeShape:
142
+ continue
143
+ # connect the output shape.thing to the basicBS
144
+
145
+ # Create an empty shape. Do it like this to get the automated renaming stuff
146
+ gDup = cmds.duplicate(geo, name="{0}_DeltaCnx".format(shape.name))[0]
147
+ # The 4th value must be 1.0 so the blendshape auto-names
148
+ cmds.blendShape(bbs, edit=True, target=(geo, idx, gDup, 1.0))
149
+ cmds.blendShape(bbs, edit=True, weight=(idx, -val))
150
+ cmds.delete(gDup)
151
+
152
+ # Connect the shape plugs
153
+ inPlug = bbs + shapePlugFmt
154
+ inPlug = inPlug.format(meshIdx=0, shapeIdx=idx)
155
+
156
+ shapeIdx = simplex.DCC.getShapeIndex(shape)
157
+ outPlug = shapeNode + shapePlugFmt
158
+ outPlug = outPlug.format(meshIdx=0, shapeIdx=shapeIdx)
159
+
160
+ # Must connect the individual child plugs rather than the top
161
+ # because otherwise the input geometry plug overrides these deltas
162
+ for ep in endPlugs:
163
+ cmds.connectAttr(outPlug + ep, inPlug + ep)
164
+
165
+ idx += 1
166
+
167
+ # Connect the basicBS back into freezeShape
168
+ freezeShapeIdx = simplex.DCC.getShapeIndex(pp.shape)
169
+ freezeShapeTarget = shapeNode + shapePlugFmt + ".inputGeomTarget"
170
+ freezeShapeTarget = freezeShapeTarget.format(meshIdx=0, shapeIdx=freezeShapeIdx)
171
+ cmds.connectAttr(geo + ".outMesh", freezeShapeTarget)
172
+
173
+ gShapes = cmds.listRelatives(geo, shapes=True)
174
+ if True:
175
+ # Hide the frozen shapenode under the ctrl as an intermediate shape
176
+ for gs in gShapes:
177
+ cmds.setAttr(gs + ".intermediateObject", 1)
178
+ nn = cmds.parent(gs, simplex.DCC.ctrl, shape=True, relative=True)
179
+ helpers.extend(nn)
180
+
181
+ # Get rid of the extra transform object
182
+ cmds.delete(geo)
183
+ else:
184
+ helpers.extend(cmds.listRelatives(geo, shapes=True))
185
+
186
+ # keep track of the shapes under the ctrl object
187
+ combo.freezeThing = helpers
188
+
189
+
190
+ def unfreezeCombo(combo):
191
+ if combo.freezeThing:
192
+ cmds.delete(combo.freezeThing)
193
+ combo.freezeThing = []
194
+
195
+
196
+ def _getDeformerChain(chkObj):
197
+ # Get a deformer chain
198
+ memo = []
199
+ while chkObj and chkObj not in memo:
200
+ memo.append(chkObj)
201
+
202
+ typ = cmds.nodeType(chkObj)
203
+ if typ == "mesh":
204
+ cnx = cmds.listConnections(chkObj + ".inMesh") or [None]
205
+ chkObj = cnx[0]
206
+ elif typ == "groupParts":
207
+ cnx = cmds.listConnections(
208
+ chkObj + ".inputGeometry", destination=False, shapes=True
209
+ ) or [None]
210
+ chkObj = cnx[0]
211
+ else:
212
+ cnx = cmds.ls(chkObj, type="geometryFilter") or [None]
213
+ chkObj = cnx[0]
214
+ if chkObj: # we have a deformer
215
+ cnx = cmds.listConnections(chkObj + ".input[0].inputGeometry") or [None]
216
+ chkObj = cnx[0]
217
+ return memo
218
+
219
+
220
+ def checkFrozen(combo):
221
+ # If the blendshape shape has an incoming connection whose shape name
222
+ # ends with 'FreezeShape' and the shape's parent is the ctrl
223
+ #
224
+ simplex = combo.simplex
225
+
226
+ ret = []
227
+ shapes = combo.prog.getShapes()
228
+ shapes = [i for i in shapes if not i.isRest]
229
+
230
+ shapePlugFmt = (
231
+ ".inputTarget[{meshIdx}].inputTargetGroup[{shapeIdx}].inputTargetItem[6000]"
232
+ )
233
+
234
+ for shape in shapes:
235
+ shpIdx = simplex.DCC.getShapeIndex(shape)
236
+ shpPlug = (
237
+ simplex.DCC.shapeNode
238
+ + shapePlugFmt.format(meshIdx=0, shapeIdx=shpIdx)
239
+ + ".inputGeomTarget"
240
+ )
241
+
242
+ cnx = cmds.listConnections(shpPlug, shapes=True, destination=False) or []
243
+ for cc in cnx:
244
+ if not cc.endswith("FreezeShape"):
245
+ continue
246
+ par = cmds.listRelatives(cc, parent=True)
247
+ if par and par[0] == simplex.DCC.ctrl:
248
+ # Can't use list history to get the chain because it's a pseudo-cycle
249
+ ret.extend(_getDeformerChain(cc))
250
+ return ret
251
+
@@ -0,0 +1,100 @@
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 absolute_import
19
+
20
+ from functools import partial
21
+
22
+ import maya.cmds as cmds
23
+ from six.moves import range
24
+
25
+ from ...interfaceModel import coerceIndexToType
26
+ from ...items import Combo, Slider
27
+ from Qt.QtWidgets import QInputDialog, QMessageBox
28
+
29
+
30
+ def registerContext(tree, clickIdx, indexes, menu):
31
+ window = tree.window()
32
+ sliders = coerceIndexToType(indexes, Slider)
33
+ combos = coerceIndexToType(indexes, Combo)
34
+ multis = []
35
+ for grp in [sliders, combos]:
36
+ for idx in grp:
37
+ item = idx.model().itemFromIndex(idx)
38
+ if len(item.prog.pairs) == 2:
39
+ multis.append(idx)
40
+
41
+ if not multis:
42
+ return False
43
+
44
+ extractACT = menu.addAction("Generate Incrementals ...")
45
+ extractACT.triggered.connect(
46
+ partial(generateShapeIncrementalsContext, multis, window)
47
+ )
48
+ return True
49
+
50
+
51
+ def generateShapeIncrementalsContext(indexes, window):
52
+ idx = indexes[0] # Only on the click index
53
+ slider = idx.model().itemFromIndex(idx)
54
+ if len(slider.prog.pairs) > 2:
55
+ QMessageBox.warning(window, "Warning", "Slider already has incrementals")
56
+ return
57
+
58
+ increments, good = QInputDialog.getInt(
59
+ window, "Increments", "Number of Increments", 4, 1, 100
60
+ )
61
+ if not good:
62
+ return
63
+
64
+ rest = None
65
+ target = None
66
+ maxval = -1.0
67
+
68
+ for pp in slider.prog.pairs:
69
+ if pp.shape.isRest:
70
+ rest = pp.shape
71
+ elif abs(pp.value) > maxval:
72
+ target = pp.shape
73
+
74
+ target.name = target.name + "_100"
75
+
76
+ startObj = slider.extractShape(rest, live=False)
77
+ endObj = slider.extractShape(target)
78
+ shapeDup = cmds.duplicate(endObj, name="shapeDup")[0]
79
+
80
+ bs = cmds.blendShape(startObj, shapeDup)
81
+
82
+ incs = []
83
+ for i in range(1, increments):
84
+ val = float(increments - i) / increments
85
+ percent = int(float(i) * 100 / increments)
86
+ cmds.blendShape(bs, edit=True, weight=((0, val)))
87
+
88
+ nne = endObj.replace("_100_", "_{0}_".format(percent))
89
+ nn = nne.replace("_Extract", "")
90
+ inc = cmds.duplicate(shapeDup, name=nne)
91
+ incs.append((percent, nn, nne))
92
+
93
+ for perc, inc, ince in incs:
94
+ pp = slider.createShape(shapeName=inc, tVal=perc / 100.0)
95
+ pp.shape.connectShape(mesh=ince, live=True)
96
+
97
+ window.uiSliderTREE.model().invalidateFilter()
98
+
99
+ cmds.delete((shapeDup, startObj))
100
+ cmds.select(endObj)