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.
- simplex_solver-3.2.2.dist-info/DELVEWHEEL +2 -0
- simplex_solver-3.2.2.dist-info/METADATA +94 -0
- simplex_solver-3.2.2.dist-info/RECORD +84 -0
- simplex_solver-3.2.2.dist-info/WHEEL +5 -0
- simplex_solver.libs/.load-order-simplex_solver-3.2.2 +1 -0
- simplex_solver.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
- simplexui/__init__.py +86 -0
- simplexui/_version.py +1 -0
- simplexui/channelBox.py +867 -0
- simplexui/comboCheckDialog.py +396 -0
- simplexui/commands/__init__.py +16 -0
- simplexui/commands/alembicCommon.py +1148 -0
- simplexui/commands/alembic_walker.py +299 -0
- simplexui/commands/applyCorrectives.py +452 -0
- simplexui/commands/correctiveInterface.py +259 -0
- simplexui/commands/expandedExport.py +434 -0
- simplexui/commands/hdf5Convert.py +62 -0
- simplexui/commands/mayaCorrectiveInterface.py +159 -0
- simplexui/commands/mayatonumpy.py +416 -0
- simplexui/commands/mesh.py +1085 -0
- simplexui/commands/poseblendlib.py +168 -0
- simplexui/commands/reorderSimplexPoints.py +102 -0
- simplexui/commands/replaceDefinitionJson.py +74 -0
- simplexui/commands/rigidAlign.py +97 -0
- simplexui/commands/unsubdivide.py +1222 -0
- simplexui/commands/uvTransfer.py +976 -0
- simplexui/dragFilter.py +334 -0
- simplexui/falloffDialog.py +504 -0
- simplexui/img/ChefHead.png +0 -0
- simplexui/img/frozen.png +0 -0
- simplexui/interface/__init__.py +30 -0
- simplexui/interface/dummyInterface.py +1313 -0
- simplexui/interface/mayaInterface.py +2294 -0
- simplexui/interfaceModel.py +655 -0
- simplexui/interfaceModelTrees.py +456 -0
- simplexui/items/__init__.py +50 -0
- simplexui/items/accessor.py +145 -0
- simplexui/items/combo.py +645 -0
- simplexui/items/dragItem.py +44 -0
- simplexui/items/falloff.py +748 -0
- simplexui/items/group.py +267 -0
- simplexui/items/progression.py +613 -0
- simplexui/items/shape.py +384 -0
- simplexui/items/simplex.py +1734 -0
- simplexui/items/slider.py +632 -0
- simplexui/items/stack.py +147 -0
- simplexui/items/traversal.py +780 -0
- simplexui/items/treeItem.py +441 -0
- simplexui/main.pyw +22 -0
- simplexui/menu/__init__.py +73 -0
- simplexui/menu/dummyPlugins/__init__.py +16 -0
- simplexui/menu/genericPlugins/__init__.py +16 -0
- simplexui/menu/genericPlugins/_builtins.py +270 -0
- simplexui/menu/genericPlugins/checkPossibleCombos.py +48 -0
- simplexui/menu/genericPlugins/exportSplit.py +67 -0
- simplexui/menu/genericPlugins/showFalloffs.py +26 -0
- simplexui/menu/genericPlugins/showTraversals.py +26 -0
- simplexui/menu/genericPlugins/simplexUvTransfer.py +106 -0
- simplexui/menu/genericPlugins/unsubdivide.py +72 -0
- simplexui/menu/mayaPlugins/__init__.py +16 -0
- simplexui/menu/mayaPlugins/exportOther.py +53 -0
- simplexui/menu/mayaPlugins/extractProgressives.py +68 -0
- simplexui/menu/mayaPlugins/freezeCombo.py +247 -0
- simplexui/menu/mayaPlugins/generateShapeIncrementals.py +99 -0
- simplexui/menu/mayaPlugins/importObjs.py +199 -0
- simplexui/menu/mayaPlugins/linearizeTraversal.py +60 -0
- simplexui/menu/mayaPlugins/makeShelfBtn.py +67 -0
- simplexui/menu/mayaPlugins/relaxToSelection.py +76 -0
- simplexui/menu/mayaPlugins/reloadDefinition.py +44 -0
- simplexui/menu/mayaPlugins/snapToNeutral.py +71 -0
- simplexui/menu/mayaPlugins/softSelectToCluster.py +201 -0
- simplexui/menu/mayaPlugins/tweakMix.py +136 -0
- simplexui/menu/mayaPlugins/updateRestShape.py +113 -0
- simplexui/pysimplex.lib +0 -0
- simplexui/pysimplex.pyd +0 -0
- simplexui/simplexDialog.py +1547 -0
- simplexui/travCheckDialog.py +419 -0
- simplexui/traversalDialog.py +299 -0
- simplexui/ui/comboCheckDialog.ui +475 -0
- simplexui/ui/falloffDialog.ui +243 -0
- simplexui/ui/simplexDialog.ui +1458 -0
- simplexui/ui/travCheckDialog.ui +488 -0
- simplexui/ui/traversalDialog.ui +532 -0
- simplexui/utils.py +307 -0
|
@@ -0,0 +1,68 @@
|
|
|
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 ...interfaceModel import coerceIndexToType
|
|
25
|
+
from ...items import Slider
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def registerTool(window, menu) -> None:
|
|
29
|
+
extractProgressivesACT = QAction("Extract Progressive", window)
|
|
30
|
+
menu.addAction(extractProgressivesACT)
|
|
31
|
+
extractProgressivesACT.triggered.connect(
|
|
32
|
+
partial(extractProgressivesInterface, window)
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def registerContext(tree, clickIdx, indexes, menu) -> bool:
|
|
37
|
+
window = tree.window()
|
|
38
|
+
live = window.uiLiveShapeConnectionACT.isChecked()
|
|
39
|
+
sliders = coerceIndexToType(indexes, Slider)
|
|
40
|
+
|
|
41
|
+
multis = []
|
|
42
|
+
for slidx in sliders:
|
|
43
|
+
slider = slidx.model().itemFromIndex(slidx)
|
|
44
|
+
if len(slider.prog.pairs) > 2:
|
|
45
|
+
multis.append(slidx)
|
|
46
|
+
|
|
47
|
+
if multis:
|
|
48
|
+
extractACT = menu.addAction("Extract Progressive")
|
|
49
|
+
extractACT.triggered.connect(partial(extractProgressivesContext, multis, live))
|
|
50
|
+
return True
|
|
51
|
+
return False
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def extractProgressivesContext(indexes, live) -> None:
|
|
55
|
+
sliders = [idx.model().itemFromIndex(idx) for idx in indexes]
|
|
56
|
+
sliders = list(set(sliders))
|
|
57
|
+
for sli in sliders:
|
|
58
|
+
sli.extractProgressive(live=live)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def extractProgressivesInterface(window) -> None:
|
|
62
|
+
live = window.uiLiveShapeConnectionACT.isChecked()
|
|
63
|
+
indexes = window.uiSliderTREE.getSelectedIndexes()
|
|
64
|
+
indexes = coerceIndexToType(indexes, Slider)
|
|
65
|
+
sliders = [idx.model().itemFromIndex(idx) for idx in indexes]
|
|
66
|
+
sliders = list(set(sliders))
|
|
67
|
+
for sli in sliders:
|
|
68
|
+
sli.extractProgressive(live=live)
|
|
@@ -0,0 +1,247 @@
|
|
|
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 annotations
|
|
17
|
+
|
|
18
|
+
from functools import partial
|
|
19
|
+
|
|
20
|
+
from maya import cmds
|
|
21
|
+
|
|
22
|
+
from ...interface.mayaInterface import disconnected
|
|
23
|
+
from ...interfaceModel import coerceIndexToType
|
|
24
|
+
from ...items import Combo
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# UI stuff
|
|
28
|
+
def registerContext(tree, clickIdx, indexes, menu) -> bool:
|
|
29
|
+
# The basicBlendshape deformer is included in simplex_maya
|
|
30
|
+
if not cmds.pluginInfo("simplex_maya", query=True, loaded=True):
|
|
31
|
+
try:
|
|
32
|
+
cmds.loadPlugin("simplex_maya")
|
|
33
|
+
except RuntimeError:
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
comboIdxs = coerceIndexToType(indexes, Combo)
|
|
37
|
+
combos = [cidx.model().itemFromIndex(cidx) for cidx in comboIdxs]
|
|
38
|
+
|
|
39
|
+
if combos:
|
|
40
|
+
freezeAct = menu.addAction("Freeze Combos")
|
|
41
|
+
unfreezeAct = menu.addAction("Un-Freeze Combos")
|
|
42
|
+
freezeAct.triggered.connect(partial(freezeCombosContext, combos, tree, True))
|
|
43
|
+
unfreezeAct.triggered.connect(partial(freezeCombosContext, combos, tree, False))
|
|
44
|
+
return True
|
|
45
|
+
return False
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def freezeCombosContext(combos, tree, doFreeze) -> None:
|
|
49
|
+
if doFreeze:
|
|
50
|
+
for combo in combos:
|
|
51
|
+
if not combo.frozen:
|
|
52
|
+
freezeCombo(combo)
|
|
53
|
+
else:
|
|
54
|
+
for combo in combos:
|
|
55
|
+
if combo.frozen:
|
|
56
|
+
unfreezeCombo(combo)
|
|
57
|
+
|
|
58
|
+
tree.update()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def freezeCombo(combo) -> None:
|
|
62
|
+
"""Freeze a combo so you can change the upstream combos and shapes
|
|
63
|
+
without affecting the result that you sculpted for the given combo
|
|
64
|
+
|
|
65
|
+
In practice, this snapshots the combo, then live-reads the upstream
|
|
66
|
+
shapes from the main blendshape and builds an up-to-date combo. The
|
|
67
|
+
difference between these two meshes is added back into the combo shape
|
|
68
|
+
"""
|
|
69
|
+
simplex = combo.simplex
|
|
70
|
+
|
|
71
|
+
tweakShapeGroups = []
|
|
72
|
+
fullGeos = []
|
|
73
|
+
ppFilter = []
|
|
74
|
+
freezeShapes = []
|
|
75
|
+
|
|
76
|
+
# disconnect the controller from the operator
|
|
77
|
+
with disconnected(simplex.DCC.op) as sliderCnx:
|
|
78
|
+
for _shapeIdx, pp in enumerate(combo.prog.pairs):
|
|
79
|
+
tVal = pp.value
|
|
80
|
+
freezeShape = pp.shape
|
|
81
|
+
if freezeShape.isRest:
|
|
82
|
+
continue
|
|
83
|
+
|
|
84
|
+
freezeShapes.append(freezeShape)
|
|
85
|
+
# zero all the sliders
|
|
86
|
+
cnx = sliderCnx[simplex.DCC.op]
|
|
87
|
+
for a in cnx.values():
|
|
88
|
+
cmds.setAttr(a, 0.0)
|
|
89
|
+
|
|
90
|
+
# set the combo values
|
|
91
|
+
for pair in combo.pairs:
|
|
92
|
+
cmds.setAttr(cnx[pair.slider.thing], pair.value * tVal)
|
|
93
|
+
|
|
94
|
+
tweakPairs = []
|
|
95
|
+
for shape in simplex.shapes[1:]: # skip the restShape
|
|
96
|
+
shapeVal = cmds.getAttr(shape.thing)
|
|
97
|
+
if abs(shapeVal) > 0.0001:
|
|
98
|
+
tweakPairs.append((shape, shapeVal))
|
|
99
|
+
|
|
100
|
+
# Extract this fully-on shape
|
|
101
|
+
fullGeo = cmds.duplicate(
|
|
102
|
+
simplex.DCC.mesh, name=f"{freezeShape.name}_Freeze"
|
|
103
|
+
)[0]
|
|
104
|
+
fullGeos.append(fullGeo)
|
|
105
|
+
|
|
106
|
+
# Clean any orig shapes for now
|
|
107
|
+
interObjs = cmds.ls(
|
|
108
|
+
cmds.listRelatives(fullGeo, shapes=True), intermediateObjects=True
|
|
109
|
+
)
|
|
110
|
+
cmds.delete(interObjs)
|
|
111
|
+
|
|
112
|
+
tweakShapeGroups.append(tweakPairs)
|
|
113
|
+
ppFilter.append(pp)
|
|
114
|
+
|
|
115
|
+
simplex.DCC.primeShapes(combo)
|
|
116
|
+
|
|
117
|
+
shapePlugFmt = (
|
|
118
|
+
".inputTarget[{meshIdx}].inputTargetGroup[{shapeIdx}].inputTargetItem[6000]"
|
|
119
|
+
)
|
|
120
|
+
endPlugs = [
|
|
121
|
+
".inputRelativePointsTarget",
|
|
122
|
+
".inputRelativeComponentsTarget",
|
|
123
|
+
".inputPointsTarget",
|
|
124
|
+
".inputComponentsTarget",
|
|
125
|
+
"",
|
|
126
|
+
]
|
|
127
|
+
shapeNode = simplex.DCC.shapeNode
|
|
128
|
+
helpers = []
|
|
129
|
+
for geo, tweakPairs, pp, freezeShape in zip(
|
|
130
|
+
fullGeos, tweakShapeGroups, ppFilter, freezeShapes
|
|
131
|
+
):
|
|
132
|
+
# build the basicBS node
|
|
133
|
+
bbs = cmds.deformer(geo, type="basicBlendShape")[0]
|
|
134
|
+
helpers.append(bbs)
|
|
135
|
+
idx = 0
|
|
136
|
+
|
|
137
|
+
for shape, val in tweakPairs:
|
|
138
|
+
if shape == freezeShape:
|
|
139
|
+
continue
|
|
140
|
+
# connect the output shape.thing to the basicBS
|
|
141
|
+
|
|
142
|
+
# Create an empty shape. Do it like this to get the automated renaming stuff
|
|
143
|
+
gDup = cmds.duplicate(geo, name=f"{shape.name}_DeltaCnx")[0]
|
|
144
|
+
# The 4th value must be 1.0 so the blendshape auto-names
|
|
145
|
+
cmds.blendShape(bbs, edit=True, target=(geo, idx, gDup, 1.0))
|
|
146
|
+
cmds.blendShape(bbs, edit=True, weight=(idx, -val))
|
|
147
|
+
cmds.delete(gDup)
|
|
148
|
+
|
|
149
|
+
# Connect the shape plugs
|
|
150
|
+
inPlug = bbs + shapePlugFmt
|
|
151
|
+
inPlug = inPlug.format(meshIdx=0, shapeIdx=idx)
|
|
152
|
+
|
|
153
|
+
shapeIdx = simplex.DCC.getShapeIndex(shape)
|
|
154
|
+
outPlug = shapeNode + shapePlugFmt
|
|
155
|
+
outPlug = outPlug.format(meshIdx=0, shapeIdx=shapeIdx)
|
|
156
|
+
|
|
157
|
+
# Must connect the individual child plugs rather than the top
|
|
158
|
+
# because otherwise the input geometry plug overrides these deltas
|
|
159
|
+
for ep in endPlugs:
|
|
160
|
+
cmds.connectAttr(outPlug + ep, inPlug + ep)
|
|
161
|
+
|
|
162
|
+
idx += 1
|
|
163
|
+
|
|
164
|
+
# Connect the basicBS back into freezeShape
|
|
165
|
+
freezeShapeIdx = simplex.DCC.getShapeIndex(pp.shape)
|
|
166
|
+
freezeShapeTarget = shapeNode + shapePlugFmt + ".inputGeomTarget"
|
|
167
|
+
freezeShapeTarget = freezeShapeTarget.format(meshIdx=0, shapeIdx=freezeShapeIdx)
|
|
168
|
+
cmds.connectAttr(geo + ".outMesh", freezeShapeTarget)
|
|
169
|
+
|
|
170
|
+
gShapes = cmds.listRelatives(geo, shapes=True)
|
|
171
|
+
if True:
|
|
172
|
+
# Hide the frozen shapenode under the ctrl as an intermediate shape
|
|
173
|
+
for gs in gShapes:
|
|
174
|
+
cmds.setAttr(gs + ".intermediateObject", 1)
|
|
175
|
+
nn = cmds.parent(gs, simplex.DCC.ctrl, shape=True, relative=True)
|
|
176
|
+
helpers.extend(nn)
|
|
177
|
+
|
|
178
|
+
# Get rid of the extra transform object
|
|
179
|
+
cmds.delete(geo)
|
|
180
|
+
else:
|
|
181
|
+
helpers.extend(cmds.listRelatives(geo, shapes=True))
|
|
182
|
+
|
|
183
|
+
# keep track of the shapes under the ctrl object
|
|
184
|
+
combo.freezeThing = helpers
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def unfreezeCombo(combo) -> None:
|
|
188
|
+
if combo.freezeThing:
|
|
189
|
+
cmds.delete(combo.freezeThing)
|
|
190
|
+
combo.freezeThing = []
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _getDeformerChain(chkObj):
|
|
194
|
+
# Get a deformer chain
|
|
195
|
+
memo = []
|
|
196
|
+
while chkObj and chkObj not in memo:
|
|
197
|
+
memo.append(chkObj)
|
|
198
|
+
|
|
199
|
+
typ = cmds.nodeType(chkObj)
|
|
200
|
+
if typ == "mesh":
|
|
201
|
+
cnx = cmds.listConnections(chkObj + ".inMesh") or [None]
|
|
202
|
+
chkObj = cnx[0]
|
|
203
|
+
elif typ == "groupParts":
|
|
204
|
+
cnx = cmds.listConnections(
|
|
205
|
+
chkObj + ".inputGeometry", destination=False, shapes=True
|
|
206
|
+
) or [None]
|
|
207
|
+
chkObj = cnx[0]
|
|
208
|
+
else:
|
|
209
|
+
cnx = cmds.ls(chkObj, type="geometryFilter") or [None]
|
|
210
|
+
chkObj = cnx[0]
|
|
211
|
+
if chkObj: # we have a deformer
|
|
212
|
+
cnx = cmds.listConnections(chkObj + ".input[0].inputGeometry") or [None]
|
|
213
|
+
chkObj = cnx[0]
|
|
214
|
+
return memo
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def checkFrozen(combo):
|
|
218
|
+
# If the blendshape shape has an incoming connection whose shape name
|
|
219
|
+
# ends with 'FreezeShape' and the shape's parent is the ctrl
|
|
220
|
+
#
|
|
221
|
+
simplex = combo.simplex
|
|
222
|
+
|
|
223
|
+
ret = []
|
|
224
|
+
shapes = combo.prog.getShapes()
|
|
225
|
+
shapes = [i for i in shapes if not i.isRest]
|
|
226
|
+
|
|
227
|
+
shapePlugFmt = (
|
|
228
|
+
".inputTarget[{meshIdx}].inputTargetGroup[{shapeIdx}].inputTargetItem[6000]"
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
for shape in shapes:
|
|
232
|
+
shpIdx = simplex.DCC.getShapeIndex(shape)
|
|
233
|
+
shpPlug = (
|
|
234
|
+
simplex.DCC.shapeNode
|
|
235
|
+
+ shapePlugFmt.format(meshIdx=0, shapeIdx=shpIdx)
|
|
236
|
+
+ ".inputGeomTarget"
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
cnx = cmds.listConnections(shpPlug, shapes=True, destination=False) or []
|
|
240
|
+
for cc in cnx:
|
|
241
|
+
if not cc.endswith("FreezeShape"):
|
|
242
|
+
continue
|
|
243
|
+
par = cmds.listRelatives(cc, parent=True)
|
|
244
|
+
if par and par[0] == simplex.DCC.ctrl:
|
|
245
|
+
# Can't use list history to get the chain because it's a pseudo-cycle
|
|
246
|
+
ret.extend(_getDeformerChain(cc))
|
|
247
|
+
return ret
|
|
@@ -0,0 +1,99 @@
|
|
|
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.QtWidgets import QInputDialog, QMessageBox
|
|
24
|
+
|
|
25
|
+
from ...interfaceModel import coerceIndexToType
|
|
26
|
+
from ...items import Combo, Slider
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def registerContext(tree, clickIdx, indexes, menu) -> bool:
|
|
30
|
+
window = tree.window()
|
|
31
|
+
sliders = coerceIndexToType(indexes, Slider)
|
|
32
|
+
combos = coerceIndexToType(indexes, Combo)
|
|
33
|
+
multis = []
|
|
34
|
+
for grp in [sliders, combos]:
|
|
35
|
+
for idx in grp:
|
|
36
|
+
item = idx.model().itemFromIndex(idx)
|
|
37
|
+
if len(item.prog.pairs) == 2:
|
|
38
|
+
multis.append(idx)
|
|
39
|
+
|
|
40
|
+
if not multis:
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
extractACT = menu.addAction("Generate Incrementals ...")
|
|
44
|
+
extractACT.triggered.connect(
|
|
45
|
+
partial(generateShapeIncrementalsContext, multis, window)
|
|
46
|
+
)
|
|
47
|
+
return True
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def generateShapeIncrementalsContext(indexes, window) -> None:
|
|
51
|
+
idx = indexes[0] # Only on the click index
|
|
52
|
+
slider = idx.model().itemFromIndex(idx)
|
|
53
|
+
if len(slider.prog.pairs) > 2:
|
|
54
|
+
QMessageBox.warning(window, "Warning", "Slider already has incrementals")
|
|
55
|
+
return
|
|
56
|
+
|
|
57
|
+
increments, good = QInputDialog.getInt(
|
|
58
|
+
window, "Increments", "Number of Increments", 4, 1, 100
|
|
59
|
+
)
|
|
60
|
+
if not good:
|
|
61
|
+
return
|
|
62
|
+
|
|
63
|
+
rest = None
|
|
64
|
+
target = None
|
|
65
|
+
maxval = -1.0
|
|
66
|
+
|
|
67
|
+
for pp in slider.prog.pairs:
|
|
68
|
+
if pp.shape.isRest:
|
|
69
|
+
rest = pp.shape
|
|
70
|
+
elif abs(pp.value) > maxval:
|
|
71
|
+
target = pp.shape
|
|
72
|
+
|
|
73
|
+
target.name = target.name + "_100"
|
|
74
|
+
|
|
75
|
+
startObj = slider.extractShape(rest, live=False)
|
|
76
|
+
endObj = slider.extractShape(target)
|
|
77
|
+
shapeDup = cmds.duplicate(endObj, name="shapeDup")[0]
|
|
78
|
+
|
|
79
|
+
bs = cmds.blendShape(startObj, shapeDup)
|
|
80
|
+
|
|
81
|
+
incs = []
|
|
82
|
+
for i in range(1, increments):
|
|
83
|
+
val = float(increments - i) / increments
|
|
84
|
+
percent = int(float(i) * 100 / increments)
|
|
85
|
+
cmds.blendShape(bs, edit=True, weight=((0, val)))
|
|
86
|
+
|
|
87
|
+
nne = endObj.replace("_100_", f"_{percent}_")
|
|
88
|
+
nn = nne.replace("_Extract", "")
|
|
89
|
+
inc = cmds.duplicate(shapeDup, name=nne)
|
|
90
|
+
incs.append((percent, nn, nne))
|
|
91
|
+
|
|
92
|
+
for perc, inc, ince in incs:
|
|
93
|
+
pp = slider.createShape(shapeName=inc, tVal=perc / 100.0)
|
|
94
|
+
pp.shape.connectShape(mesh=ince, live=True)
|
|
95
|
+
|
|
96
|
+
window.uiSliderTREE.model().invalidateFilter()
|
|
97
|
+
|
|
98
|
+
cmds.delete((shapeDup, startObj))
|
|
99
|
+
cmds.select(endObj)
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from functools import partial
|
|
5
|
+
|
|
6
|
+
import maya.cmds as cmds
|
|
7
|
+
import numpy as np
|
|
8
|
+
from Qt.QtGui import QAction
|
|
9
|
+
from Qt.QtWidgets import (
|
|
10
|
+
QApplication,
|
|
11
|
+
QFileDialog,
|
|
12
|
+
QMessageBox,
|
|
13
|
+
QProgressDialog,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
from ...items import Combo, Slider, Traversal
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
from tools.MeshCrawler.commands import setAllVerts
|
|
20
|
+
from tools.MeshCrawler.mesh import Mesh
|
|
21
|
+
from tools.MeshCrawler.meshcrawlerGen import autoCrawlMeshes
|
|
22
|
+
except ImportError:
|
|
23
|
+
autoCrawlMeshes = None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def buildMesh(simplex, mesh):
|
|
27
|
+
topo = simplex.DCC.getMeshTopology(mesh)
|
|
28
|
+
faceIdxs, counts = topo[1], topo[2]
|
|
29
|
+
faces = []
|
|
30
|
+
ptr = 0
|
|
31
|
+
for c in counts:
|
|
32
|
+
faces.append(tuple(faceIdxs[ptr : ptr + c]))
|
|
33
|
+
ptr += c
|
|
34
|
+
return Mesh(topo[0], tuple(faces))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def importSimpleObjs(simplex, orders, pBar) -> None:
|
|
38
|
+
for shapeName, ctrl, shape, path in orders:
|
|
39
|
+
pBar.setValue(pBar.value() + 1)
|
|
40
|
+
pBar.setLabelText(f"Loading Obj :\n{shapeName}")
|
|
41
|
+
QApplication.processEvents()
|
|
42
|
+
if pBar.wasCanceled():
|
|
43
|
+
return
|
|
44
|
+
|
|
45
|
+
mesh = simplex.DCC.importObj(path)
|
|
46
|
+
|
|
47
|
+
if isinstance(ctrl, Slider):
|
|
48
|
+
simplex.DCC.connectShape(shape, mesh=mesh, live=False, delete=True)
|
|
49
|
+
elif isinstance(ctrl, Combo):
|
|
50
|
+
simplex.DCC.connectComboShape(
|
|
51
|
+
ctrl, shape, mesh=mesh, live=False, delete=True
|
|
52
|
+
)
|
|
53
|
+
elif isinstance(ctrl, Traversal):
|
|
54
|
+
simplex.DCC.connectTraversalShape(
|
|
55
|
+
ctrl, shape, mesh=mesh, live=False, delete=True
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def importReorderObjs(simplex, orders, pBar) -> None:
|
|
60
|
+
reoMesh = simplex.DCC.extractShape(simplex.restShape, live=False)
|
|
61
|
+
orderMesh = buildMesh(simplex, reoMesh)
|
|
62
|
+
|
|
63
|
+
memo = {}
|
|
64
|
+
|
|
65
|
+
for shapeName, ctrl, shape, path in orders:
|
|
66
|
+
pBar.setValue(pBar.value() + 1)
|
|
67
|
+
pBar.setLabelText(f"Loading Obj :\n{shapeName}")
|
|
68
|
+
QApplication.processEvents()
|
|
69
|
+
if pBar.wasCanceled():
|
|
70
|
+
return
|
|
71
|
+
|
|
72
|
+
impMesh = simplex.DCC.importObj(path)
|
|
73
|
+
objMesh = buildMesh(simplex, impMesh)
|
|
74
|
+
reo = memo.setdefault(
|
|
75
|
+
objMesh.faceVertArray, autoCrawlMeshes(orderMesh, objMesh)
|
|
76
|
+
)
|
|
77
|
+
verts = simplex.DCC.getNumpyShape(impMesh)
|
|
78
|
+
|
|
79
|
+
setAllVerts(reoMesh, verts[reo])
|
|
80
|
+
|
|
81
|
+
if isinstance(ctrl, Slider):
|
|
82
|
+
simplex.DCC.connectShape(shape, mesh=reoMesh, live=False, delete=False)
|
|
83
|
+
elif isinstance(ctrl, Combo):
|
|
84
|
+
simplex.DCC.connectComboShape(
|
|
85
|
+
ctrl, shape, mesh=reoMesh, live=False, delete=False
|
|
86
|
+
)
|
|
87
|
+
elif isinstance(ctrl, Traversal):
|
|
88
|
+
simplex.DCC.connectTraversalShape(
|
|
89
|
+
ctrl, shape, mesh=reoMesh, live=False, delete=False
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
cmds.delete(reoMesh)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def importObjList(simplex, paths: list[str], pBar, reorder=True) -> None:
|
|
96
|
+
"""Import all given .obj files
|
|
97
|
+
|
|
98
|
+
Parameters
|
|
99
|
+
----------
|
|
100
|
+
paths : list
|
|
101
|
+
The list of .obj files to import
|
|
102
|
+
"""
|
|
103
|
+
shapeDict = {shape.name: shape for shape in simplex.shapes}
|
|
104
|
+
|
|
105
|
+
inPairs = {}
|
|
106
|
+
for path in paths:
|
|
107
|
+
shapeName = os.path.splitext(os.path.basename(path))[0]
|
|
108
|
+
shape = shapeDict.get(shapeName)
|
|
109
|
+
if shape is not None:
|
|
110
|
+
inPairs[shapeName] = path
|
|
111
|
+
else:
|
|
112
|
+
sfx = "_Extract"
|
|
113
|
+
if shapeName.endswith(sfx):
|
|
114
|
+
shapeName = shapeName[: -len(sfx)]
|
|
115
|
+
shape = shapeDict.get(shapeName)
|
|
116
|
+
if shape is not None:
|
|
117
|
+
inPairs[shapeName] = path
|
|
118
|
+
|
|
119
|
+
sliderMasters, comboMasters, travMasters = {}, {}, {}
|
|
120
|
+
for masters in [simplex.sliders, simplex.combos, simplex.traversals]:
|
|
121
|
+
for master in masters:
|
|
122
|
+
for pp in master.prog.pairs:
|
|
123
|
+
shape = shapeDict.get(pp.shape.name)
|
|
124
|
+
if shape is not None:
|
|
125
|
+
if shape.name in inPairs:
|
|
126
|
+
if isinstance(master, Slider):
|
|
127
|
+
sliderMasters[shape.name] = master
|
|
128
|
+
elif isinstance(master, Combo):
|
|
129
|
+
comboMasters[shape.name] = master
|
|
130
|
+
elif isinstance(master, Traversal):
|
|
131
|
+
travMasters[shape.name] = master
|
|
132
|
+
|
|
133
|
+
comboDepth = {}
|
|
134
|
+
for k, v in comboMasters.items():
|
|
135
|
+
depth = len(v.pairs)
|
|
136
|
+
comboDepth.setdefault(depth, {})[k] = v
|
|
137
|
+
|
|
138
|
+
importOrder = []
|
|
139
|
+
for shapeName, slider in sliderMasters.items():
|
|
140
|
+
importOrder.append(
|
|
141
|
+
(shapeName, slider, shapeDict[shapeName], inPairs[shapeName])
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
for depth in sorted(comboDepth.keys()):
|
|
145
|
+
for shapeName, combo in comboDepth[depth].items():
|
|
146
|
+
importOrder.append(
|
|
147
|
+
(shapeName, combo, shapeDict[shapeName], inPairs[shapeName])
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
for shapeName, trav in travMasters.items():
|
|
151
|
+
importOrder.append((shapeName, trav, shapeDict[shapeName], inPairs[shapeName]))
|
|
152
|
+
|
|
153
|
+
if pBar is not None:
|
|
154
|
+
pBar.setMaximum(len(sliderMasters) + len(comboMasters) + len(travMasters))
|
|
155
|
+
|
|
156
|
+
if reorder:
|
|
157
|
+
importReorderObjs(simplex, importOrder, pBar)
|
|
158
|
+
else:
|
|
159
|
+
importSimpleObjs(simplex, importOrder, pBar)
|
|
160
|
+
if pBar is not None:
|
|
161
|
+
pBar.close()
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def registerTool(window, menu) -> None:
|
|
165
|
+
importObjsACT = QAction("Import Obj Folder", window)
|
|
166
|
+
menu.addAction(importObjsACT)
|
|
167
|
+
importObjsACT.triggered.connect(partial(importObjsInterface, window))
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def importObjsInterface(window) -> None:
|
|
171
|
+
if window.simplex is None:
|
|
172
|
+
QMessageBox.warning(
|
|
173
|
+
window,
|
|
174
|
+
"Nothing Loaded",
|
|
175
|
+
"No simplex system is loaded",
|
|
176
|
+
)
|
|
177
|
+
return
|
|
178
|
+
|
|
179
|
+
reorder = True
|
|
180
|
+
if np is None or autoCrawlMeshes is None:
|
|
181
|
+
reorder = False
|
|
182
|
+
|
|
183
|
+
folder = QFileDialog.getExistingDirectory(window, "Import Obj Folder", "")
|
|
184
|
+
|
|
185
|
+
if not os.path.isdir(folder):
|
|
186
|
+
QMessageBox.warning(window, "Warning", "Folder does not exist")
|
|
187
|
+
return
|
|
188
|
+
|
|
189
|
+
paths = os.listdir(folder)
|
|
190
|
+
paths = [i for i in paths if i.endswith((".obj", ".OBJ"))]
|
|
191
|
+
if not paths:
|
|
192
|
+
QMessageBox.warning(window, "Warning", "Folder does not contain any .obj files")
|
|
193
|
+
return
|
|
194
|
+
paths = [os.path.join(folder, p) for p in paths]
|
|
195
|
+
|
|
196
|
+
pBar = QProgressDialog("Loading from Mesh", "Cancel", 0, 100, window)
|
|
197
|
+
pBar.show()
|
|
198
|
+
|
|
199
|
+
importObjList(window.simplex, paths, pBar=pBar, reorder=reorder)
|
|
@@ -0,0 +1,60 @@
|
|
|
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.QtGui import QAction
|
|
24
|
+
from Qt.QtWidgets import QMessageBox
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def registerTool(window, menu) -> None:
|
|
28
|
+
lineTravACT = QAction("Linearize Traversal", window)
|
|
29
|
+
menu.addAction(lineTravACT)
|
|
30
|
+
lineTravACT.triggered.connect(partial(lineTrav, window))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def lineTrav(window) -> None:
|
|
34
|
+
if window.simplex is None:
|
|
35
|
+
QMessageBox.warning(
|
|
36
|
+
window,
|
|
37
|
+
"Nothing Loaded",
|
|
38
|
+
"No simplex system is loaded",
|
|
39
|
+
)
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
simplex = window.simplex
|
|
43
|
+
travDialog = window.travDialog
|
|
44
|
+
sel = travDialog.uiTraversalTREE.getSelectedIndexes()
|
|
45
|
+
travIdx = sel[0]
|
|
46
|
+
trav = travIdx.model().itemFromIndex(travIdx)
|
|
47
|
+
extracted = window.shapeIndexExtract([travIdx])
|
|
48
|
+
rest = simplex.DCC.extractTraversalShape(trav, simplex.restShape, live=False)
|
|
49
|
+
|
|
50
|
+
end = extracted[-1]
|
|
51
|
+
val = len(extracted)
|
|
52
|
+
for i, mesh in enumerate(extracted[:-1]):
|
|
53
|
+
startDup = cmds.duplicate(rest, name="startDup")[0]
|
|
54
|
+
absBlend = cmds.blendShape(end, startDup)
|
|
55
|
+
cmds.blendShape(absBlend, edit=True, weight=((0, (i + 1.0) / val)))
|
|
56
|
+
|
|
57
|
+
finBlend = cmds.blendShape(startDup, mesh)
|
|
58
|
+
cmds.blendShape(finBlend, edit=True, weight=((0, 1)))
|
|
59
|
+
cmds.delete(startDup)
|
|
60
|
+
cmds.delete(rest)
|