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.
- pysimplex.pyd +0 -0
- simplex_solver-3.0.18.dist-info/METADATA +87 -0
- simplex_solver-3.0.18.dist-info/RECORD +81 -0
- simplex_solver-3.0.18.dist-info/WHEEL +5 -0
- simplex_solver-3.0.18.dist-info/licenses/LICENSE +165 -0
- simplexui/__init__.py +54 -0
- simplexui/channelBox.py +862 -0
- simplexui/comboCheckDialog.py +335 -0
- simplexui/commands/__init__.py +16 -0
- simplexui/commands/alembicCommon.py +1045 -0
- simplexui/commands/applyCorrectives.py +455 -0
- simplexui/commands/buildIceXML.py +443 -0
- simplexui/commands/correctiveInterface.py +271 -0
- simplexui/commands/expandedExport.py +435 -0
- simplexui/commands/hdf5Convert.py +62 -0
- simplexui/commands/mayaCorrectiveInterface.py +164 -0
- simplexui/commands/mesh.py +1086 -0
- simplexui/commands/reorderSimplexPoints.py +103 -0
- simplexui/commands/rigidAlign.py +103 -0
- simplexui/commands/setDelta.xsicompound +60 -0
- simplexui/commands/smpxBlend.py +634 -0
- simplexui/commands/unsubdivide.py +1232 -0
- simplexui/commands/uvTransfer.py +986 -0
- simplexui/commands/xsiCorrectiveInterface.py +136 -0
- simplexui/dragFilter.py +299 -0
- simplexui/falloffDialog.py +476 -0
- simplexui/img/ChefHead.png +0 -0
- simplexui/img/frozen.png +0 -0
- simplexui/interface/__init__.py +30 -0
- simplexui/interface/dummyInterface.py +1564 -0
- simplexui/interface/mayaInterface.py +3197 -0
- simplexui/interface/xsiInterface.py +2944 -0
- simplexui/interfaceModel.py +1040 -0
- simplexui/interfaceModelTrees.py +439 -0
- simplexui/interfaceModel_Test.py +259 -0
- simplexui/items/__init__.py +26 -0
- simplexui/items/accessor.py +217 -0
- simplexui/items/combo.py +855 -0
- simplexui/items/falloff.py +780 -0
- simplexui/items/group.py +295 -0
- simplexui/items/progression.py +745 -0
- simplexui/items/shape.py +444 -0
- simplexui/items/simplex.py +1747 -0
- simplexui/items/slider.py +741 -0
- simplexui/items/stack.py +156 -0
- simplexui/items/traversal.py +969 -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 +260 -0
- simplexui/menu/genericPlugins/checkPossibleCombos.py +47 -0
- simplexui/menu/genericPlugins/exportSplit.py +61 -0
- simplexui/menu/genericPlugins/showFalloffs.py +24 -0
- simplexui/menu/genericPlugins/showTraversals.py +24 -0
- simplexui/menu/genericPlugins/simplexUvTransfer.py +109 -0
- simplexui/menu/genericPlugins/unsubdivide.py +71 -0
- simplexui/menu/mayaPlugins/__init__.py +16 -0
- simplexui/menu/mayaPlugins/exportOther.py +45 -0
- simplexui/menu/mayaPlugins/extractProgressives.py +67 -0
- simplexui/menu/mayaPlugins/freezeCombo.py +251 -0
- simplexui/menu/mayaPlugins/generateShapeIncrementals.py +100 -0
- simplexui/menu/mayaPlugins/importObjs.py +196 -0
- simplexui/menu/mayaPlugins/linearizeTraversal.py +49 -0
- simplexui/menu/mayaPlugins/makeShelfBtn.py +69 -0
- simplexui/menu/mayaPlugins/relaxToSelection.py +77 -0
- simplexui/menu/mayaPlugins/reloadDefinition.py +34 -0
- simplexui/menu/mayaPlugins/snapToNeutral.py +74 -0
- simplexui/menu/mayaPlugins/softSelectToCluster.py +204 -0
- simplexui/menu/mayaPlugins/tweakMix.py +138 -0
- simplexui/menu/mayaPlugins/updateRestShape.py +107 -0
- simplexui/menu/xsiPlugins/__init__.py +16 -0
- simplexui/simplexDialog.py +1391 -0
- simplexui/travCheckDialog.py +393 -0
- simplexui/traversalDialog.py +277 -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 +320 -0
|
@@ -0,0 +1,204 @@
|
|
|
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, print_function
|
|
19
|
+
|
|
20
|
+
import maya.cmds as cmds
|
|
21
|
+
import maya.OpenMaya as om
|
|
22
|
+
from six.moves import range
|
|
23
|
+
|
|
24
|
+
from Qt.QtWidgets import QAction
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def registerTool(window, menu):
|
|
28
|
+
softSelectToClusterACT = QAction("Soft Select To Cluster", window)
|
|
29
|
+
menu.addAction(softSelectToClusterACT)
|
|
30
|
+
softSelectToClusterACT.triggered.connect(softSelectToClusterInterface)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def softSelectToClusterInterface():
|
|
34
|
+
sel = cmds.ls(sl=True, objectsOnly=True)
|
|
35
|
+
if sel:
|
|
36
|
+
name = sel[0].split('|')[-1]
|
|
37
|
+
softSelectToCluster(sel[0], "{0}_Soft".format(name))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def getSoftSelectionValues(myNode, returnSimpleIndices=True):
|
|
41
|
+
"""Get the current soft selection values"""
|
|
42
|
+
softOn = cmds.softSelect(query=True, softSelectEnabled=True)
|
|
43
|
+
richSelList = om.MSelectionList()
|
|
44
|
+
|
|
45
|
+
if softOn:
|
|
46
|
+
richSel = om.MRichSelection()
|
|
47
|
+
try:
|
|
48
|
+
om.MGlobal.getRichSelection(richSel)
|
|
49
|
+
except RuntimeError:
|
|
50
|
+
return []
|
|
51
|
+
richSel.getSelection(richSelList)
|
|
52
|
+
else:
|
|
53
|
+
om.MGlobal.getActiveSelectionList(richSelList)
|
|
54
|
+
toReturn = {}
|
|
55
|
+
if richSelList.isEmpty():
|
|
56
|
+
return toReturn
|
|
57
|
+
|
|
58
|
+
uVal = om.MScriptUtil()
|
|
59
|
+
uVal.createFromInt(0)
|
|
60
|
+
ptru = uVal.asIntPtr()
|
|
61
|
+
|
|
62
|
+
vVal = om.MScriptUtil()
|
|
63
|
+
vVal.createFromInt(0)
|
|
64
|
+
ptrv = vVal.asIntPtr()
|
|
65
|
+
|
|
66
|
+
wVal = om.MScriptUtil()
|
|
67
|
+
wVal.createFromInt(0)
|
|
68
|
+
ptrw = wVal.asIntPtr()
|
|
69
|
+
|
|
70
|
+
iterSel = om.MItSelectionList(richSelList)
|
|
71
|
+
|
|
72
|
+
while not iterSel.isDone():
|
|
73
|
+
component = om.MObject()
|
|
74
|
+
dagPath = om.MDagPath()
|
|
75
|
+
try:
|
|
76
|
+
iterSel.getDagPath(dagPath, component)
|
|
77
|
+
except Exception:
|
|
78
|
+
iterSel.next()
|
|
79
|
+
continue
|
|
80
|
+
|
|
81
|
+
depNode_name = dagPath.fullPathName()
|
|
82
|
+
|
|
83
|
+
# hack in a quick check so it only works with
|
|
84
|
+
# shapes under the given transform
|
|
85
|
+
if not depNode_name.startswith(myNode):
|
|
86
|
+
iterSel.next()
|
|
87
|
+
continue
|
|
88
|
+
|
|
89
|
+
elementIndices = []
|
|
90
|
+
elementWeights = []
|
|
91
|
+
|
|
92
|
+
if component.isNull():
|
|
93
|
+
toReturn[depNode_name] = (elementIndices, elementWeights)
|
|
94
|
+
continue
|
|
95
|
+
|
|
96
|
+
componentFn = om.MFnComponent(component)
|
|
97
|
+
count = componentFn.elementCount()
|
|
98
|
+
ctyp = componentFn.componentType()
|
|
99
|
+
|
|
100
|
+
if ctyp == om.MFn.kMeshPolygonComponent:
|
|
101
|
+
polyIter = om.MItMeshPolygon(dagPath, component)
|
|
102
|
+
setOfVerts = set()
|
|
103
|
+
while not polyIter.isDone():
|
|
104
|
+
connectedVertices = om.MIntArray()
|
|
105
|
+
polyIter.getVertices(connectedVertices)
|
|
106
|
+
for j in range(connectedVertices.length()):
|
|
107
|
+
setOfVerts.add(connectedVertices[j])
|
|
108
|
+
polyIter.next()
|
|
109
|
+
lstVerts = list(setOfVerts)
|
|
110
|
+
lstVerts.sort()
|
|
111
|
+
for vtx in lstVerts:
|
|
112
|
+
elementIndices.append(vtx)
|
|
113
|
+
elementWeights.append(1)
|
|
114
|
+
elif ctyp == om.MFn.kMeshEdgeComponent:
|
|
115
|
+
edgeIter = om.MItMeshEdge(dagPath, component)
|
|
116
|
+
setOfVerts = set()
|
|
117
|
+
while not edgeIter.isDone():
|
|
118
|
+
setOfVerts.add(edgeIter.index(0))
|
|
119
|
+
setOfVerts.add(edgeIter.index(1))
|
|
120
|
+
edgeIter.next()
|
|
121
|
+
lstVerts = list(setOfVerts)
|
|
122
|
+
lstVerts.sort()
|
|
123
|
+
for vtx in lstVerts:
|
|
124
|
+
elementIndices.append(vtx)
|
|
125
|
+
elementWeights.append(1)
|
|
126
|
+
elif ctyp in (om.MFn.kCurveCVComponent, om.MFn.kMeshVertComponent):
|
|
127
|
+
singleFn = om.MFnSingleIndexedComponent(component)
|
|
128
|
+
for i in range(count):
|
|
129
|
+
weight = componentFn.weight(i).influence() if softOn else 1
|
|
130
|
+
elementIndices.append(singleFn.element(i))
|
|
131
|
+
elementWeights.append(weight)
|
|
132
|
+
elif ctyp == om.MFn.kSurfaceCVComponent:
|
|
133
|
+
spansV = cmds.getAttr(depNode_name + ".spansV")
|
|
134
|
+
degreesV = cmds.getAttr(depNode_name + ".degreeV")
|
|
135
|
+
numCVsInV_ = spansV + degreesV
|
|
136
|
+
|
|
137
|
+
doubleFn = om.MFnDoubleIndexedComponent(component)
|
|
138
|
+
for i in range(count):
|
|
139
|
+
weight = componentFn.weight(i).influence() if softOn else 1
|
|
140
|
+
doubleFn.getElement(i, ptru, ptrv)
|
|
141
|
+
u = uVal.getInt(ptru)
|
|
142
|
+
v = vVal.getInt(ptrv)
|
|
143
|
+
if returnSimpleIndices:
|
|
144
|
+
elementIndices.append(numCVsInV_ * u + v)
|
|
145
|
+
else:
|
|
146
|
+
elementIndices.append((u, v))
|
|
147
|
+
elementWeights.append(weight)
|
|
148
|
+
elif ctyp == om.MFn.kLatticeComponent:
|
|
149
|
+
div_s = cmds.getAttr(depNode_name + ".sDivisions")
|
|
150
|
+
div_t = cmds.getAttr(depNode_name + ".tDivisions")
|
|
151
|
+
div_u = cmds.getAttr(depNode_name + ".uDivisions")
|
|
152
|
+
|
|
153
|
+
tripleFn = om.MFnTripleIndexedComponent(component)
|
|
154
|
+
for i in range(count):
|
|
155
|
+
tripleFn.getElement(i, ptru, ptrv, ptrw)
|
|
156
|
+
s = uVal.getInt(ptru)
|
|
157
|
+
t = vVal.getInt(ptrv)
|
|
158
|
+
u = wVal.getInt(ptrw)
|
|
159
|
+
weight = componentFn.weight(i).influence() if softOn else 1
|
|
160
|
+
|
|
161
|
+
if returnSimpleIndices:
|
|
162
|
+
simpleIndex = (u * div_s * div_t) + (t * div_s) + s
|
|
163
|
+
elementIndices.append(simpleIndex)
|
|
164
|
+
else:
|
|
165
|
+
elementIndices.append((s, t, u))
|
|
166
|
+
elementWeights.append(weight)
|
|
167
|
+
|
|
168
|
+
toReturn[depNode_name] = (elementIndices, elementWeights)
|
|
169
|
+
iterSel.next()
|
|
170
|
+
return toReturn
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def softSelectToCluster(tfm, name):
|
|
174
|
+
# Get the manipulator position for the selection
|
|
175
|
+
cmds.setToolTo("Move")
|
|
176
|
+
currentMoveMode = cmds.manipMoveContext("Move", query=True, mode=True)
|
|
177
|
+
cmds.manipMoveContext("Move", edit=True, mode=0) # set to the correct mode
|
|
178
|
+
pos = cmds.manipMoveContext("Move", query=True, position=True) # get the position
|
|
179
|
+
cmds.manipMoveContext("Move", edit=True, mode=currentMoveMode) # and reset
|
|
180
|
+
|
|
181
|
+
tfm = cmds.ls(tfm, long=True)[0]
|
|
182
|
+
vnum = cmds.polyEvaluate(tfm, vertex=True)
|
|
183
|
+
softSelDict = getSoftSelectionValues(tfm)
|
|
184
|
+
|
|
185
|
+
shapes = [k for k in softSelDict if k.startswith(tfm)]
|
|
186
|
+
if not shapes:
|
|
187
|
+
print("No selection found on the given mesh: {0}".format(tfm))
|
|
188
|
+
return
|
|
189
|
+
|
|
190
|
+
elementIndices, elementWeights = softSelDict[shapes[0]]
|
|
191
|
+
weightDict = dict(zip(elementIndices, elementWeights))
|
|
192
|
+
weights = [weightDict.get(i, 0.0) for i in range(vnum)]
|
|
193
|
+
|
|
194
|
+
# Build the Cluster and set the weights
|
|
195
|
+
# Currently this part is polymesh specific
|
|
196
|
+
clusterNode, clusterHandle = cmds.cluster(tfm, name=name)
|
|
197
|
+
attr = "{0}.weightList[0].weights[0:{1}]".format(clusterNode, vnum - 1)
|
|
198
|
+
cmds.setAttr(attr, *weights, size=vnum)
|
|
199
|
+
|
|
200
|
+
# Reposition the cluster
|
|
201
|
+
cmds.xform(clusterHandle, absolute=True, worldSpace=True, pivots=pos)
|
|
202
|
+
clusterShape = cmds.listRelatives(clusterHandle, children=True, shapes=True)
|
|
203
|
+
cmds.setAttr(clusterShape[0] + ".origin", *pos)
|
|
204
|
+
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
import six
|
|
24
|
+
from six.moves import range, zip
|
|
25
|
+
|
|
26
|
+
from ...interface.mayaInterface import disconnected
|
|
27
|
+
from ...interfaceModel import coerceIndexToType
|
|
28
|
+
from ...items import Combo
|
|
29
|
+
from Qt.QtWidgets import QAction
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def registerTool(window, menu):
|
|
33
|
+
tweakMixACT = QAction("Tweak Mix", window)
|
|
34
|
+
menu.addAction(tweakMixACT)
|
|
35
|
+
tweakMixACT.triggered.connect(partial(tweakMixInterface, window))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def tweakMixInterface(window):
|
|
39
|
+
if not window.simplex:
|
|
40
|
+
return
|
|
41
|
+
live = window.uiLiveShapeConnectionACT.isChecked()
|
|
42
|
+
|
|
43
|
+
indexes = window.uiComboTREE.selectedIndexes()
|
|
44
|
+
indexes = coerceIndexToType(indexes, Combo)
|
|
45
|
+
if not indexes:
|
|
46
|
+
return
|
|
47
|
+
combos = [idx.model().itemFromIndex(idx) for idx in indexes]
|
|
48
|
+
combos = list(set(combos))
|
|
49
|
+
tweakMix(window.simplex, combos, live)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def registerContext(tree, clickIdx, indexes, menu):
|
|
53
|
+
window = tree.window()
|
|
54
|
+
live = window.uiLiveShapeConnectionACT.isChecked()
|
|
55
|
+
indexes = coerceIndexToType(indexes, Combo)
|
|
56
|
+
if indexes:
|
|
57
|
+
indexes = list(set(indexes))
|
|
58
|
+
tweakMixACT = menu.addAction("Tweak Mix")
|
|
59
|
+
tweakMixACT.triggered.connect(partial(tweakMixContext, window, indexes, live))
|
|
60
|
+
return True
|
|
61
|
+
return False
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def tweakMixContext(window, indexes, live):
|
|
65
|
+
combos = [idx.model().itemFromIndex(idx) for idx in indexes]
|
|
66
|
+
combos = list(set(combos))
|
|
67
|
+
tweakMix(window.simplex, combos, live)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def tweakMix(simplex, combos, live):
|
|
71
|
+
# first extract the rest shape non-live
|
|
72
|
+
restGeo = simplex.extractRestShape()
|
|
73
|
+
|
|
74
|
+
floatShapes = simplex.getFloatingShapes()
|
|
75
|
+
floatShapes = [i.thing for i in floatShapes]
|
|
76
|
+
|
|
77
|
+
offset = 5
|
|
78
|
+
for combo in combos:
|
|
79
|
+
offset += 5
|
|
80
|
+
|
|
81
|
+
shape = None
|
|
82
|
+
for pp in combo.prog.pairs:
|
|
83
|
+
if pp.value == 1.0:
|
|
84
|
+
shape = pp.shape
|
|
85
|
+
break
|
|
86
|
+
else:
|
|
87
|
+
continue
|
|
88
|
+
|
|
89
|
+
geo = combo.extractShape(shape, live=live, offset=offset)
|
|
90
|
+
# disconnect the controller from the operator
|
|
91
|
+
tweakShapes = []
|
|
92
|
+
with disconnected(simplex.DCC.op) as sliderCnx:
|
|
93
|
+
# disconnect any float shapes
|
|
94
|
+
with disconnected(floatShapes):
|
|
95
|
+
cnx = sliderCnx[simplex.DCC.op]
|
|
96
|
+
for a in six.itervalues(cnx):
|
|
97
|
+
cmds.setAttr(a, 0.0)
|
|
98
|
+
|
|
99
|
+
# set the combo values
|
|
100
|
+
for pair in combo.pairs:
|
|
101
|
+
cmds.setAttr(cnx[pair.slider.thing], pair.value)
|
|
102
|
+
|
|
103
|
+
for shape in simplex.shapes[1:]: # skip the restShape
|
|
104
|
+
shapeVal = cmds.getAttr(shape.thing)
|
|
105
|
+
if shapeVal != 0.0: # maybe handle floating point errors
|
|
106
|
+
tweakShapes.append((shape, shapeVal))
|
|
107
|
+
|
|
108
|
+
tweakMeshes = []
|
|
109
|
+
with disconnected(simplex.DCC.shapeNode) as shapeCnx:
|
|
110
|
+
cnx = shapeCnx[simplex.DCC.shapeNode]
|
|
111
|
+
for a in six.itervalues(cnx):
|
|
112
|
+
cmds.setAttr(a, 0.0)
|
|
113
|
+
for tshape, shapeVal in tweakShapes:
|
|
114
|
+
cmds.setAttr(tshape.thing, shapeVal)
|
|
115
|
+
# print "setAttr", tshape.thing, shapeVal
|
|
116
|
+
tweakMesh = cmds.duplicate(
|
|
117
|
+
simplex.DCC.mesh, name="{0}_Tweak".format(tshape.name)
|
|
118
|
+
)[0]
|
|
119
|
+
tweakMeshes.append(tweakMesh)
|
|
120
|
+
cmds.setAttr(tshape.thing, 0.0)
|
|
121
|
+
|
|
122
|
+
# Yeah, yeah, this is REALLY ugly, but it's quick and it works
|
|
123
|
+
tempBS = cmds.blendShape(geo, name="Temp_BS")
|
|
124
|
+
cmds.blendShape(tempBS, edit=True, target=(geo, 0, restGeo, 1.0))
|
|
125
|
+
cmds.blendShape(tempBS, edit=True, weight=[(0, 1.0)])
|
|
126
|
+
cmds.delete(geo, constructionHistory=True)
|
|
127
|
+
|
|
128
|
+
# build the actual blendshape
|
|
129
|
+
tweakBS = cmds.blendShape(geo, name="Tweak_BS")
|
|
130
|
+
for i, tm in enumerate(tweakMeshes):
|
|
131
|
+
cmds.blendShape(tweakBS, edit=True, target=(geo, i, tm, 1.0))
|
|
132
|
+
tmLen = len(tweakMeshes)
|
|
133
|
+
cmds.blendShape(
|
|
134
|
+
tweakBS, edit=True, weight=list(zip(list(range(tmLen)), [1.0] * tmLen))
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
cmds.delete(tweakMeshes)
|
|
138
|
+
cmds.delete(restGeo)
|
|
@@ -0,0 +1,107 @@
|
|
|
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 textwrap
|
|
21
|
+
from functools import partial
|
|
22
|
+
|
|
23
|
+
import maya.cmds as cmds
|
|
24
|
+
|
|
25
|
+
from Qt.QtWidgets import QAction, QMessageBox
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def registerTool(window, menu):
|
|
29
|
+
updateRestShapeACT = QAction("Update Rest Shape", window)
|
|
30
|
+
menu.addAction(updateRestShapeACT)
|
|
31
|
+
updateRestShapeACT.triggered.connect(partial(updateRestShapeInterface, window))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def updateRestShapeInterface(window):
|
|
35
|
+
sel = cmds.ls(sl=True)
|
|
36
|
+
if not sel:
|
|
37
|
+
QMessageBox.warning(window, "Nothing Selected", "Nothing Selected")
|
|
38
|
+
return
|
|
39
|
+
sel = sel[0]
|
|
40
|
+
mesh = window.simplex.DCC.mesh
|
|
41
|
+
|
|
42
|
+
# TODO, Check vert number and blendshape input connections
|
|
43
|
+
selVerts = cmds.polyEvaluate(sel, vertex=1)
|
|
44
|
+
meshVerts = cmds.polyEvaluate(mesh, vertex=1)
|
|
45
|
+
|
|
46
|
+
if selVerts != meshVerts:
|
|
47
|
+
msg = "Selected object {0} has {1} verts\nBase Object has {2} verts".format(
|
|
48
|
+
sel, selVerts, meshVerts
|
|
49
|
+
)
|
|
50
|
+
QMessageBox.warning(window, "Vert Mismatch", msg)
|
|
51
|
+
return
|
|
52
|
+
|
|
53
|
+
# TODO Check for live connections
|
|
54
|
+
bs = window.simplex.DCC.shapeNode
|
|
55
|
+
cnx = cmds.listConnections(bs, plugs=1, destination=0, type="mesh")
|
|
56
|
+
if cnx:
|
|
57
|
+
cnxs = ", ".join([i.split(".")[0] for i in cnx])
|
|
58
|
+
cnxs = textwrap.fill(cnxs)
|
|
59
|
+
msg = [
|
|
60
|
+
"Some shapes have a live input connection:",
|
|
61
|
+
cnxs,
|
|
62
|
+
"",
|
|
63
|
+
"These shapes will not get the update.",
|
|
64
|
+
"Continue anyway?",
|
|
65
|
+
]
|
|
66
|
+
msg = "\n".join(msg)
|
|
67
|
+
btns = QMessageBox.Ok | QMessageBox.Cancel
|
|
68
|
+
bret = QMessageBox.question(window, "Live Connections", msg, btns)
|
|
69
|
+
if not bret & QMessageBox.Ok:
|
|
70
|
+
return
|
|
71
|
+
|
|
72
|
+
updateRestShape(mesh, sel, window=window)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def updateRestShape(mesh, newRest, window=None):
|
|
76
|
+
allShapes = cmds.listRelatives(mesh, children=1, shapes=1) or []
|
|
77
|
+
noInter = cmds.listRelatives(mesh, children=1, shapes=1, noIntermediate=1) or []
|
|
78
|
+
hist = cmds.listHistory(mesh)
|
|
79
|
+
inter = (set(allShapes) - set(noInter)) & set(hist)
|
|
80
|
+
if not inter:
|
|
81
|
+
if window is not None:
|
|
82
|
+
QMessageBox.warning(
|
|
83
|
+
window, "No Intermediates", "No intermediate meshes found"
|
|
84
|
+
)
|
|
85
|
+
return
|
|
86
|
+
inter = list(inter)
|
|
87
|
+
|
|
88
|
+
if len(inter) == 1:
|
|
89
|
+
orig = inter[0]
|
|
90
|
+
else:
|
|
91
|
+
origs = [i for i in inter if "Orig" in i]
|
|
92
|
+
if len(origs) != 1:
|
|
93
|
+
if window is not None:
|
|
94
|
+
QMessageBox.warning(
|
|
95
|
+
window,
|
|
96
|
+
"Too Many Intermediates",
|
|
97
|
+
"Too Many intermediate meshes found: {0}".format(origs),
|
|
98
|
+
)
|
|
99
|
+
return
|
|
100
|
+
orig = origs[0]
|
|
101
|
+
|
|
102
|
+
outMesh = "{0}.worldMesh[0]".format(newRest)
|
|
103
|
+
inMesh = "{0}.inMesh".format(orig)
|
|
104
|
+
|
|
105
|
+
cmds.connectAttr(outMesh, inMesh, force=1)
|
|
106
|
+
cmds.refresh(force=1)
|
|
107
|
+
cmds.disconnectAttr(outMesh, inMesh)
|
|
@@ -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/>.
|