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,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
|
+
import os
|
|
21
|
+
|
|
22
|
+
from Qt.QtWidgets import QAction
|
|
23
|
+
|
|
24
|
+
dn = os.path.dirname
|
|
25
|
+
SHELF_DEV_BUTTON = f"""
|
|
26
|
+
import os, sys
|
|
27
|
+
|
|
28
|
+
path = r'{dn(dn(dn(dn(__file__))))}'
|
|
29
|
+
path = os.path.normcase(os.path.normpath(path))
|
|
30
|
+
if sys.path[0] != path:
|
|
31
|
+
sys.path.insert(0, path)
|
|
32
|
+
|
|
33
|
+
import simplexui
|
|
34
|
+
if simplexui.SIMPLEX_UI is not None:
|
|
35
|
+
try:
|
|
36
|
+
simplexui.SIMPLEX_UI.close()
|
|
37
|
+
except RuntimeError:
|
|
38
|
+
# In case I closed it myself
|
|
39
|
+
pass
|
|
40
|
+
del simplexui
|
|
41
|
+
|
|
42
|
+
for key, value in sys.modules.items():
|
|
43
|
+
try:
|
|
44
|
+
packPath = value.__file__
|
|
45
|
+
except AttributeError:
|
|
46
|
+
continue
|
|
47
|
+
|
|
48
|
+
packPath = os.path.normcase(os.path.normpath(packPath))
|
|
49
|
+
if packPath.startswith(path):
|
|
50
|
+
sys.modules.pop(key)
|
|
51
|
+
|
|
52
|
+
import simplexui
|
|
53
|
+
simplexui.runSimplexUI()
|
|
54
|
+
|
|
55
|
+
sys.path.pop(0)
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def registerTool(window, menu) -> None:
|
|
60
|
+
makeShelfBtnACT = QAction("Make Shelf Button", window)
|
|
61
|
+
menu.addAction(makeShelfBtnACT)
|
|
62
|
+
makeShelfBtnACT.triggered.connect(makeShelfButton)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def makeShelfButton() -> None:
|
|
66
|
+
pass
|
|
67
|
+
# TODO: Actually, ya know, Add the button to the shelf
|
|
@@ -0,0 +1,76 @@
|
|
|
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 maya.cmds as cmds
|
|
21
|
+
from Qt.QtWidgets import QAction
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def registerTool(window, menu) -> None:
|
|
25
|
+
relaxToSelectionACT = QAction("Relax To Selection", window)
|
|
26
|
+
menu.addAction(relaxToSelectionACT)
|
|
27
|
+
relaxToSelectionACT.triggered.connect(relaxToSelectionInterface)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def relaxToSelectionInterface() -> None:
|
|
31
|
+
sel = cmds.ls(sl=True)
|
|
32
|
+
if len(sel) >= 2:
|
|
33
|
+
relaxToSelection(sel[0], sel[1])
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def relaxToSelection(source, target) -> None:
|
|
37
|
+
"""
|
|
38
|
+
Transfer high-frequency sculpts (like wrinkles) from one shape to another
|
|
39
|
+
|
|
40
|
+
This sets up a delta mush on a detailed mesh (source) before blending to a
|
|
41
|
+
less detailed shape (target). Turning up the deltaMush re-applies the
|
|
42
|
+
high-resolution deltas to that less detailed shape so then blend it back
|
|
43
|
+
into the target
|
|
44
|
+
"""
|
|
45
|
+
sourceDup = cmds.duplicate(source, name="deltaMushMesh")[0]
|
|
46
|
+
targetDup = cmds.duplicate(target, name="targetDup")[0]
|
|
47
|
+
deltaMushRelax = cmds.group(sourceDup, name="deltaMushRelax")
|
|
48
|
+
cmds.hide([sourceDup, targetDup, deltaMushRelax])
|
|
49
|
+
|
|
50
|
+
cmds.addAttr(
|
|
51
|
+
deltaMushRelax,
|
|
52
|
+
longName="smooth_iter",
|
|
53
|
+
attributeType="long",
|
|
54
|
+
minValue=0,
|
|
55
|
+
maxValue=100,
|
|
56
|
+
defaultValue=10,
|
|
57
|
+
)
|
|
58
|
+
smoothIter = f"{deltaMushRelax}.smooth_iter"
|
|
59
|
+
cmds.setAttr(smoothIter, edit=True, keyable=True)
|
|
60
|
+
|
|
61
|
+
blender = cmds.blendShape(targetDup, sourceDup)
|
|
62
|
+
deltaMush = cmds.deltaMush(
|
|
63
|
+
sourceDup,
|
|
64
|
+
smoothingIterations=10,
|
|
65
|
+
smoothingStep=0.5,
|
|
66
|
+
pinBorderVertices=1,
|
|
67
|
+
envelope=1,
|
|
68
|
+
)[0]
|
|
69
|
+
cmds.connectAttr(smoothIter, deltaMush + ".smoothingIterations", force=True)
|
|
70
|
+
|
|
71
|
+
cmds.delete(targetDup)
|
|
72
|
+
finalBlend = cmds.blendShape(sourceDup, target)
|
|
73
|
+
cmds.blendShape(finalBlend, edit=True, weight=((0, 1)))
|
|
74
|
+
cmds.blendShape(blender, edit=True, weight=((0, 1)))
|
|
75
|
+
|
|
76
|
+
cmds.select(deltaMushRelax)
|
|
@@ -0,0 +1,44 @@
|
|
|
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.QtGui import QAction
|
|
23
|
+
from Qt.QtWidgets import QMessageBox
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def registerTool(window, menu) -> None:
|
|
27
|
+
reloadDefinitionACT = QAction("Reload Definition", window)
|
|
28
|
+
menu.addAction(reloadDefinitionACT)
|
|
29
|
+
reloadDefinitionACT.triggered.connect(partial(reloadDefinitionInterface, window))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def reloadDefinitionInterface(window) -> None:
|
|
33
|
+
if window.simplex is None:
|
|
34
|
+
QMessageBox.warning(
|
|
35
|
+
window,
|
|
36
|
+
"Nothing Loaded",
|
|
37
|
+
"No simplex system is loaded",
|
|
38
|
+
)
|
|
39
|
+
return
|
|
40
|
+
reloadDefinition(window.simplex)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def reloadDefinition(simplex) -> None:
|
|
44
|
+
simplex.DCC.setSimplexString(simplex.DCC.op, simplex.dump())
|
|
@@ -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 annotations
|
|
19
|
+
|
|
20
|
+
from functools import partial
|
|
21
|
+
|
|
22
|
+
import maya.cmds as cmds
|
|
23
|
+
from Qt.QtWidgets import QAction
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def registerTool(window, menu) -> None:
|
|
27
|
+
snapShapeToNeutralACT = QAction("Snap Shape To Neutral", window)
|
|
28
|
+
menu.addAction(snapShapeToNeutralACT)
|
|
29
|
+
snapShapeToNeutralACT.triggered.connect(
|
|
30
|
+
partial(snapShapeToNeutralInterface, window)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def snapShapeToNeutralInterface(window) -> None:
|
|
35
|
+
sel = cmds.ls(sl=True)
|
|
36
|
+
if len(sel) >= 2:
|
|
37
|
+
snapShapeToNeutral(sel[0], sel[1])
|
|
38
|
+
elif len(sel) == 1:
|
|
39
|
+
rest = window.simplex.extractRestShape()
|
|
40
|
+
snapShapeToNeutral(sel[0], rest)
|
|
41
|
+
cmds.delete(rest)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def snapShapeToNeutral(source, target) -> None:
|
|
45
|
+
"""
|
|
46
|
+
Take a mesh, and find the closest location on the target head, and snap to that
|
|
47
|
+
Then set up a blendShape so the artist can "paint" in the snapping behavior
|
|
48
|
+
"""
|
|
49
|
+
# Make a duplicate of the source and snap it to the target
|
|
50
|
+
snapShape = cmds.duplicate(source, name="snp")
|
|
51
|
+
cmds.transferAttributes(
|
|
52
|
+
target,
|
|
53
|
+
snapShape,
|
|
54
|
+
transferPositions=1,
|
|
55
|
+
sampleSpace=1, # 0=World, 1=Local, 3=UV
|
|
56
|
+
searchMethod=0, # 0=Along Normal, 1=Closest Location
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Then delete history
|
|
60
|
+
cmds.delete(snapShape, constructionHistory=True)
|
|
61
|
+
cmds.hide(snapShape)
|
|
62
|
+
|
|
63
|
+
# Blend the source to the snappedShape
|
|
64
|
+
bs = cmds.blendShape(snapShape, source)[0]
|
|
65
|
+
cmds.blendShape(bs, edit=True, weight=((0, 1)))
|
|
66
|
+
|
|
67
|
+
# But set the weights back to 0.0 for painting
|
|
68
|
+
numVerts = cmds.polyEvaluate(source, vertex=1)
|
|
69
|
+
setter = f"{bs}.inputTarget[0].inputTargetGroup[0].targetWeights[0:{numVerts - 1}]"
|
|
70
|
+
weights = [0.0] * numVerts
|
|
71
|
+
cmds.setAttr(setter, *weights, size=numVerts)
|
|
@@ -0,0 +1,201 @@
|
|
|
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 maya.cmds as cmds
|
|
21
|
+
import maya.OpenMaya as om
|
|
22
|
+
from Qt.QtWidgets import QAction
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def registerTool(window, menu) -> None:
|
|
26
|
+
softSelectToClusterACT = QAction("Soft Select To Cluster", window)
|
|
27
|
+
menu.addAction(softSelectToClusterACT)
|
|
28
|
+
softSelectToClusterACT.triggered.connect(softSelectToClusterInterface)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def softSelectToClusterInterface() -> None:
|
|
32
|
+
sel = cmds.ls(sl=True, objectsOnly=True)
|
|
33
|
+
if sel:
|
|
34
|
+
name = sel[0].split("|")[-1]
|
|
35
|
+
softSelectToCluster(sel[0], f"{name}_Soft")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def getSoftSelectionValues(myNode, returnSimpleIndices=True):
|
|
39
|
+
"""Get the current soft selection values"""
|
|
40
|
+
softOn = cmds.softSelect(query=True, softSelectEnabled=True)
|
|
41
|
+
richSelList = om.MSelectionList()
|
|
42
|
+
|
|
43
|
+
if softOn:
|
|
44
|
+
richSel = om.MRichSelection()
|
|
45
|
+
try:
|
|
46
|
+
om.MGlobal.getRichSelection(richSel)
|
|
47
|
+
except RuntimeError:
|
|
48
|
+
return []
|
|
49
|
+
richSel.getSelection(richSelList)
|
|
50
|
+
else:
|
|
51
|
+
om.MGlobal.getActiveSelectionList(richSelList)
|
|
52
|
+
toReturn = {}
|
|
53
|
+
if richSelList.isEmpty():
|
|
54
|
+
return toReturn
|
|
55
|
+
|
|
56
|
+
uVal = om.MScriptUtil()
|
|
57
|
+
uVal.createFromInt(0)
|
|
58
|
+
ptru = uVal.asIntPtr()
|
|
59
|
+
|
|
60
|
+
vVal = om.MScriptUtil()
|
|
61
|
+
vVal.createFromInt(0)
|
|
62
|
+
ptrv = vVal.asIntPtr()
|
|
63
|
+
|
|
64
|
+
wVal = om.MScriptUtil()
|
|
65
|
+
wVal.createFromInt(0)
|
|
66
|
+
ptrw = wVal.asIntPtr()
|
|
67
|
+
|
|
68
|
+
iterSel = om.MItSelectionList(richSelList)
|
|
69
|
+
|
|
70
|
+
while not iterSel.isDone():
|
|
71
|
+
component = om.MObject()
|
|
72
|
+
dagPath = om.MDagPath()
|
|
73
|
+
try:
|
|
74
|
+
iterSel.getDagPath(dagPath, component)
|
|
75
|
+
except Exception:
|
|
76
|
+
iterSel.next()
|
|
77
|
+
continue
|
|
78
|
+
|
|
79
|
+
depNode_name = dagPath.fullPathName()
|
|
80
|
+
|
|
81
|
+
# hack in a quick check so it only works with
|
|
82
|
+
# shapes under the given transform
|
|
83
|
+
if not depNode_name.startswith(myNode):
|
|
84
|
+
iterSel.next()
|
|
85
|
+
continue
|
|
86
|
+
|
|
87
|
+
elementIndices = []
|
|
88
|
+
elementWeights = []
|
|
89
|
+
|
|
90
|
+
if component.isNull():
|
|
91
|
+
toReturn[depNode_name] = (elementIndices, elementWeights)
|
|
92
|
+
continue
|
|
93
|
+
|
|
94
|
+
componentFn = om.MFnComponent(component)
|
|
95
|
+
count = componentFn.elementCount()
|
|
96
|
+
ctyp = componentFn.componentType()
|
|
97
|
+
|
|
98
|
+
if ctyp == om.MFn.kMeshPolygonComponent:
|
|
99
|
+
polyIter = om.MItMeshPolygon(dagPath, component)
|
|
100
|
+
setOfVerts = set()
|
|
101
|
+
while not polyIter.isDone():
|
|
102
|
+
connectedVertices = om.MIntArray()
|
|
103
|
+
polyIter.getVertices(connectedVertices)
|
|
104
|
+
for j in range(connectedVertices.length()):
|
|
105
|
+
setOfVerts.add(connectedVertices[j])
|
|
106
|
+
polyIter.next()
|
|
107
|
+
lstVerts = list(setOfVerts)
|
|
108
|
+
lstVerts.sort()
|
|
109
|
+
for vtx in lstVerts:
|
|
110
|
+
elementIndices.append(vtx)
|
|
111
|
+
elementWeights.append(1)
|
|
112
|
+
elif ctyp == om.MFn.kMeshEdgeComponent:
|
|
113
|
+
edgeIter = om.MItMeshEdge(dagPath, component)
|
|
114
|
+
setOfVerts = set()
|
|
115
|
+
while not edgeIter.isDone():
|
|
116
|
+
setOfVerts.add(edgeIter.index(0))
|
|
117
|
+
setOfVerts.add(edgeIter.index(1))
|
|
118
|
+
edgeIter.next()
|
|
119
|
+
lstVerts = list(setOfVerts)
|
|
120
|
+
lstVerts.sort()
|
|
121
|
+
for vtx in lstVerts:
|
|
122
|
+
elementIndices.append(vtx)
|
|
123
|
+
elementWeights.append(1)
|
|
124
|
+
elif ctyp in (om.MFn.kCurveCVComponent, om.MFn.kMeshVertComponent):
|
|
125
|
+
singleFn = om.MFnSingleIndexedComponent(component)
|
|
126
|
+
for i in range(count):
|
|
127
|
+
weight = componentFn.weight(i).influence() if softOn else 1
|
|
128
|
+
elementIndices.append(singleFn.element(i))
|
|
129
|
+
elementWeights.append(weight)
|
|
130
|
+
elif ctyp == om.MFn.kSurfaceCVComponent:
|
|
131
|
+
spansV = cmds.getAttr(depNode_name + ".spansV")
|
|
132
|
+
degreesV = cmds.getAttr(depNode_name + ".degreeV")
|
|
133
|
+
numCVsInV_ = spansV + degreesV
|
|
134
|
+
|
|
135
|
+
doubleFn = om.MFnDoubleIndexedComponent(component)
|
|
136
|
+
for i in range(count):
|
|
137
|
+
weight = componentFn.weight(i).influence() if softOn else 1
|
|
138
|
+
doubleFn.getElement(i, ptru, ptrv)
|
|
139
|
+
u = uVal.getInt(ptru)
|
|
140
|
+
v = vVal.getInt(ptrv)
|
|
141
|
+
if returnSimpleIndices:
|
|
142
|
+
elementIndices.append(numCVsInV_ * u + v)
|
|
143
|
+
else:
|
|
144
|
+
elementIndices.append((u, v))
|
|
145
|
+
elementWeights.append(weight)
|
|
146
|
+
elif ctyp == om.MFn.kLatticeComponent:
|
|
147
|
+
div_s = cmds.getAttr(depNode_name + ".sDivisions")
|
|
148
|
+
div_t = cmds.getAttr(depNode_name + ".tDivisions")
|
|
149
|
+
# div_u = cmds.getAttr(depNode_name + ".uDivisions")
|
|
150
|
+
|
|
151
|
+
tripleFn = om.MFnTripleIndexedComponent(component)
|
|
152
|
+
for i in range(count):
|
|
153
|
+
tripleFn.getElement(i, ptru, ptrv, ptrw)
|
|
154
|
+
s = uVal.getInt(ptru)
|
|
155
|
+
t = vVal.getInt(ptrv)
|
|
156
|
+
u = wVal.getInt(ptrw)
|
|
157
|
+
weight = componentFn.weight(i).influence() if softOn else 1
|
|
158
|
+
|
|
159
|
+
if returnSimpleIndices:
|
|
160
|
+
simpleIndex = (u * div_s * div_t) + (t * div_s) + s
|
|
161
|
+
elementIndices.append(simpleIndex)
|
|
162
|
+
else:
|
|
163
|
+
elementIndices.append((s, t, u))
|
|
164
|
+
elementWeights.append(weight)
|
|
165
|
+
|
|
166
|
+
toReturn[depNode_name] = (elementIndices, elementWeights)
|
|
167
|
+
iterSel.next()
|
|
168
|
+
return toReturn
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def softSelectToCluster(tfm, name: str) -> None:
|
|
172
|
+
# Get the manipulator position for the selection
|
|
173
|
+
cmds.setToolTo("Move")
|
|
174
|
+
currentMoveMode = cmds.manipMoveContext("Move", query=True, mode=True)
|
|
175
|
+
cmds.manipMoveContext("Move", edit=True, mode=0) # set to the correct mode
|
|
176
|
+
pos = cmds.manipMoveContext("Move", query=True, position=True) # get the position
|
|
177
|
+
cmds.manipMoveContext("Move", edit=True, mode=currentMoveMode) # and reset
|
|
178
|
+
|
|
179
|
+
tfm = cmds.ls(tfm, long=True)[0]
|
|
180
|
+
vnum = cmds.polyEvaluate(tfm, vertex=True)
|
|
181
|
+
softSelDict = getSoftSelectionValues(tfm)
|
|
182
|
+
|
|
183
|
+
shapes = [k for k in softSelDict if k.startswith(tfm)]
|
|
184
|
+
if not shapes:
|
|
185
|
+
print(f"No selection found on the given mesh: {tfm}")
|
|
186
|
+
return
|
|
187
|
+
|
|
188
|
+
elementIndices, elementWeights = softSelDict[shapes[0]]
|
|
189
|
+
weightDict = dict(zip(elementIndices, elementWeights))
|
|
190
|
+
weights = [weightDict.get(i, 0.0) for i in range(vnum)]
|
|
191
|
+
|
|
192
|
+
# Build the Cluster and set the weights
|
|
193
|
+
# Currently this part is polymesh specific
|
|
194
|
+
clusterNode, clusterHandle = cmds.cluster(tfm, name=name)
|
|
195
|
+
attr = f"{clusterNode}.weightList[0].weights[0:{vnum - 1}]"
|
|
196
|
+
cmds.setAttr(attr, *weights, size=vnum)
|
|
197
|
+
|
|
198
|
+
# Reposition the cluster
|
|
199
|
+
cmds.xform(clusterHandle, absolute=True, worldSpace=True, pivots=pos)
|
|
200
|
+
clusterShape = cmds.listRelatives(clusterHandle, children=True, shapes=True)
|
|
201
|
+
cmds.setAttr(clusterShape[0] + ".origin", *pos)
|
|
@@ -0,0 +1,136 @@
|
|
|
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 QAction
|
|
24
|
+
|
|
25
|
+
from ...interface.mayaInterface import disconnected
|
|
26
|
+
from ...interfaceModel import coerceIndexToType
|
|
27
|
+
from ...items import Combo
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def registerTool(window, menu) -> None:
|
|
31
|
+
tweakMixACT = QAction("Tweak Mix", window)
|
|
32
|
+
menu.addAction(tweakMixACT)
|
|
33
|
+
tweakMixACT.triggered.connect(partial(tweakMixInterface, window))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def tweakMixInterface(window) -> None:
|
|
37
|
+
if not window.simplex:
|
|
38
|
+
return
|
|
39
|
+
live = window.uiLiveShapeConnectionACT.isChecked()
|
|
40
|
+
|
|
41
|
+
indexes = window.uiComboTREE.selectedIndexes()
|
|
42
|
+
indexes = coerceIndexToType(indexes, Combo)
|
|
43
|
+
if not indexes:
|
|
44
|
+
return
|
|
45
|
+
combos = [idx.model().itemFromIndex(idx) for idx in indexes]
|
|
46
|
+
combos = list(set(combos))
|
|
47
|
+
tweakMix(window.simplex, combos, live)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def registerContext(tree, clickIdx, indexes, menu) -> bool:
|
|
51
|
+
window = tree.window()
|
|
52
|
+
live = window.uiLiveShapeConnectionACT.isChecked()
|
|
53
|
+
indexes = coerceIndexToType(indexes, Combo)
|
|
54
|
+
if indexes:
|
|
55
|
+
indexes = list(set(indexes))
|
|
56
|
+
tweakMixACT = menu.addAction("Tweak Mix")
|
|
57
|
+
tweakMixACT.triggered.connect(partial(tweakMixContext, window, indexes, live))
|
|
58
|
+
return True
|
|
59
|
+
return False
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def tweakMixContext(window, indexes, live) -> None:
|
|
63
|
+
combos = [idx.model().itemFromIndex(idx) for idx in indexes]
|
|
64
|
+
combos = list(set(combos))
|
|
65
|
+
tweakMix(window.simplex, combos, live)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def tweakMix(simplex, combos, live) -> None:
|
|
69
|
+
# first extract the rest shape non-live
|
|
70
|
+
restGeo = simplex.extractRestShape()
|
|
71
|
+
|
|
72
|
+
floatShapes = simplex.getFloatingShapes()
|
|
73
|
+
floatShapes = [i.thing for i in floatShapes]
|
|
74
|
+
|
|
75
|
+
offset = 5
|
|
76
|
+
for combo in combos:
|
|
77
|
+
offset += 5
|
|
78
|
+
|
|
79
|
+
shape = None
|
|
80
|
+
for pp in combo.prog.pairs:
|
|
81
|
+
if pp.value == 1.0:
|
|
82
|
+
shape = pp.shape
|
|
83
|
+
break
|
|
84
|
+
else:
|
|
85
|
+
continue
|
|
86
|
+
|
|
87
|
+
geo = combo.extractShape(shape, live=live, offset=offset)
|
|
88
|
+
# disconnect the controller from the operator
|
|
89
|
+
tweakShapes = []
|
|
90
|
+
with disconnected(simplex.DCC.op) as sliderCnx:
|
|
91
|
+
# disconnect any float shapes
|
|
92
|
+
with disconnected(floatShapes):
|
|
93
|
+
cnx = sliderCnx[simplex.DCC.op]
|
|
94
|
+
for a in cnx.values():
|
|
95
|
+
cmds.setAttr(a, 0.0)
|
|
96
|
+
|
|
97
|
+
# set the combo values
|
|
98
|
+
for pair in combo.pairs:
|
|
99
|
+
cmds.setAttr(cnx[pair.slider.thing], pair.value)
|
|
100
|
+
|
|
101
|
+
for shape in simplex.shapes[1:]: # skip the restShape
|
|
102
|
+
shapeVal = cmds.getAttr(shape.thing)
|
|
103
|
+
if shapeVal != 0.0: # maybe handle floating point errors
|
|
104
|
+
tweakShapes.append((shape, shapeVal))
|
|
105
|
+
|
|
106
|
+
tweakMeshes = []
|
|
107
|
+
with disconnected(simplex.DCC.shapeNode) as shapeCnx:
|
|
108
|
+
cnx = shapeCnx[simplex.DCC.shapeNode]
|
|
109
|
+
for a in cnx.values():
|
|
110
|
+
cmds.setAttr(a, 0.0)
|
|
111
|
+
for tshape, shapeVal in tweakShapes:
|
|
112
|
+
cmds.setAttr(tshape.thing, shapeVal)
|
|
113
|
+
# print "setAttr", tshape.thing, shapeVal
|
|
114
|
+
tweakMesh = cmds.duplicate(
|
|
115
|
+
simplex.DCC.mesh, name=f"{tshape.name}_Tweak"
|
|
116
|
+
)[0]
|
|
117
|
+
tweakMeshes.append(tweakMesh)
|
|
118
|
+
cmds.setAttr(tshape.thing, 0.0)
|
|
119
|
+
|
|
120
|
+
# Yeah, yeah, this is REALLY ugly, but it's quick and it works
|
|
121
|
+
tempBS = cmds.blendShape(geo, name="Temp_BS")
|
|
122
|
+
cmds.blendShape(tempBS, edit=True, target=(geo, 0, restGeo, 1.0))
|
|
123
|
+
cmds.blendShape(tempBS, edit=True, weight=[(0, 1.0)])
|
|
124
|
+
cmds.delete(geo, constructionHistory=True)
|
|
125
|
+
|
|
126
|
+
# build the actual blendshape
|
|
127
|
+
tweakBS = cmds.blendShape(geo, name="Tweak_BS")
|
|
128
|
+
for i, tm in enumerate(tweakMeshes):
|
|
129
|
+
cmds.blendShape(tweakBS, edit=True, target=(geo, i, tm, 1.0))
|
|
130
|
+
tmLen = len(tweakMeshes)
|
|
131
|
+
cmds.blendShape(
|
|
132
|
+
tweakBS, edit=True, weight=list(zip(list(range(tmLen)), [1.0] * tmLen))
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
cmds.delete(tweakMeshes)
|
|
136
|
+
cmds.delete(restGeo)
|