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,1564 @@
|
|
|
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
|
+
# pylint: disable=invalid-name, unused-argument
|
|
19
|
+
""" A placeholder interface that takes arguments and does nothing with them """
|
|
20
|
+
from __future__ import absolute_import
|
|
21
|
+
|
|
22
|
+
import copy
|
|
23
|
+
from contextlib import contextmanager
|
|
24
|
+
from functools import wraps
|
|
25
|
+
|
|
26
|
+
from six.moves import map, zip
|
|
27
|
+
|
|
28
|
+
from Qt import QtCore
|
|
29
|
+
from Qt.QtCore import Signal
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
import numpy as np
|
|
33
|
+
except ImportError:
|
|
34
|
+
np = None
|
|
35
|
+
|
|
36
|
+
from alembic.AbcGeom import OPolyMeshSchemaSample
|
|
37
|
+
|
|
38
|
+
from ..commands.alembicCommon import (
|
|
39
|
+
getSampleArray,
|
|
40
|
+
getStaticMeshData,
|
|
41
|
+
getUvSample,
|
|
42
|
+
mkSampleIntArray,
|
|
43
|
+
mkSampleVertexPoints,
|
|
44
|
+
mkUvSample,
|
|
45
|
+
)
|
|
46
|
+
from Qt.QtWidgets import QApplication
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# UNDO STACK INTEGRATION
|
|
50
|
+
@contextmanager
|
|
51
|
+
def undoContext(inst=None):
|
|
52
|
+
"""A context that wraps undo chunks
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
inst : DCC
|
|
57
|
+
An instantiated DCC if available. (Default value = None)
|
|
58
|
+
|
|
59
|
+
"""
|
|
60
|
+
if inst is None:
|
|
61
|
+
DCC.staticUndoOpen()
|
|
62
|
+
else:
|
|
63
|
+
inst.undoOpen()
|
|
64
|
+
try:
|
|
65
|
+
yield
|
|
66
|
+
finally:
|
|
67
|
+
if inst is None:
|
|
68
|
+
DCC.staticUndoClose()
|
|
69
|
+
else:
|
|
70
|
+
inst.undoClose()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def undoable(f):
|
|
74
|
+
"""A decorator that wraps a function in an undoContext"""
|
|
75
|
+
|
|
76
|
+
@wraps(f)
|
|
77
|
+
def stacker(self, *args, **kwargs):
|
|
78
|
+
"""The wrapper closure"""
|
|
79
|
+
with undoContext():
|
|
80
|
+
return f(self, *args, **kwargs)
|
|
81
|
+
|
|
82
|
+
return stacker
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class DummyScene(object):
|
|
86
|
+
"""A dcc scene containing existing dummy objects"""
|
|
87
|
+
|
|
88
|
+
def __init__(self):
|
|
89
|
+
self.items = {}
|
|
90
|
+
|
|
91
|
+
def get(self, tpe, name):
|
|
92
|
+
return self.items.get(tpe, {}).get(name)
|
|
93
|
+
|
|
94
|
+
def add(self, item):
|
|
95
|
+
typeDict = self.items.setdefault(type(item), {})
|
|
96
|
+
typeDict[item.name] = item
|
|
97
|
+
|
|
98
|
+
def remove(self, item):
|
|
99
|
+
typeDict = self.items.setdefault(type(item), {})
|
|
100
|
+
typeDict.pop(item.name, None)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
DB = DummyScene() # Default module level dummy scene
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class DummyAttr(object):
|
|
107
|
+
"""A generic named object attribute"""
|
|
108
|
+
|
|
109
|
+
def __init__(self, name, value, parent):
|
|
110
|
+
self.name = name
|
|
111
|
+
self.value = value
|
|
112
|
+
self.parent = parent
|
|
113
|
+
parent.attrs[name] = self
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class DummyNode(object):
|
|
117
|
+
"""A generic DCC node"""
|
|
118
|
+
|
|
119
|
+
def __init__(self, name, db=DB):
|
|
120
|
+
self.name = name
|
|
121
|
+
self.attrs = {}
|
|
122
|
+
self.ops = []
|
|
123
|
+
if db is not None:
|
|
124
|
+
db.add(self)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class DummySimplex(DummyNode):
|
|
128
|
+
"""A generic simplex node"""
|
|
129
|
+
|
|
130
|
+
def __init__(self, name, parent, db=DB):
|
|
131
|
+
super(DummySimplex, self).__init__(name, db)
|
|
132
|
+
self.definition = ""
|
|
133
|
+
parent.ops.append(self)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class DummyFalloff(DummyNode):
|
|
137
|
+
"""A generic simplex node"""
|
|
138
|
+
|
|
139
|
+
def __init__(self, name, parent, db=DB):
|
|
140
|
+
super(DummyFalloff, self).__init__(name, db)
|
|
141
|
+
self.weightmap = None
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class DummyShape(object):
|
|
145
|
+
"""A generic named blendshape shape"""
|
|
146
|
+
|
|
147
|
+
def __init__(self, name, shapeNode):
|
|
148
|
+
self.name = name
|
|
149
|
+
self.value = 0.0
|
|
150
|
+
self.points = None
|
|
151
|
+
self.shapeNode = shapeNode
|
|
152
|
+
shapeNode.shapes[name] = self
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class DummyBlendshape(DummyNode):
|
|
156
|
+
"""A generic blendshape node"""
|
|
157
|
+
|
|
158
|
+
def __init__(self, name, parent, db=DB):
|
|
159
|
+
# TODO: Just reuse the DummyAttr instead of making an equivalent
|
|
160
|
+
super(DummyBlendshape, self).__init__(name, db)
|
|
161
|
+
self.shapes = {}
|
|
162
|
+
parent.ops.append(self)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class DummyMesh(DummyNode):
|
|
166
|
+
"""A generic mesh"""
|
|
167
|
+
|
|
168
|
+
def __init__(self, name, db=DB):
|
|
169
|
+
super(DummyMesh, self).__init__(name, db)
|
|
170
|
+
self.importPath = ""
|
|
171
|
+
self.faces = None
|
|
172
|
+
self.counts = None
|
|
173
|
+
self.uvs = None
|
|
174
|
+
self.uvFaces = None
|
|
175
|
+
self.verts = None
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class DCC(object):
|
|
179
|
+
""" """
|
|
180
|
+
|
|
181
|
+
program = "dummy"
|
|
182
|
+
|
|
183
|
+
def __init__(self, simplex, stack=None):
|
|
184
|
+
self.simplex = simplex # the abstract representation of the setup
|
|
185
|
+
self.name = simplex.name
|
|
186
|
+
|
|
187
|
+
self.scene = DummyScene()
|
|
188
|
+
self.mesh = None
|
|
189
|
+
self.ctrl = None
|
|
190
|
+
self.shapeNode = None
|
|
191
|
+
self.op = None
|
|
192
|
+
|
|
193
|
+
self._live = True
|
|
194
|
+
self._revision = 0
|
|
195
|
+
# self._shapes = {} # hold the shapes from the .smpx file as a dict
|
|
196
|
+
# self._faces = None # Faces for the mesh (Alembic-style)
|
|
197
|
+
# self._counts = None # Face counts for the mesh (Alembic-style)
|
|
198
|
+
# self._uvs = None # UV data for the mesh
|
|
199
|
+
# self._numVerts = None
|
|
200
|
+
self._falloffs = {} # weightPerVert values
|
|
201
|
+
self.sliderMul = self.simplex.sliderMul
|
|
202
|
+
|
|
203
|
+
def dummyLoad(self, other, pBar=None):
|
|
204
|
+
"""Method to copy the information in a DCC to a DummyDCC
|
|
205
|
+
|
|
206
|
+
Parameters
|
|
207
|
+
----------
|
|
208
|
+
other : DCC
|
|
209
|
+
The DCC to load into the dummy
|
|
210
|
+
pBar : QProgressDialog, optional
|
|
211
|
+
An optional progress dialog (Default value = None)
|
|
212
|
+
|
|
213
|
+
Returns
|
|
214
|
+
-------
|
|
215
|
+
: DummyDCC :
|
|
216
|
+
The new DummyDCC
|
|
217
|
+
"""
|
|
218
|
+
other.getAllShapeVertices(other.simplex.shapes, pBar=pBar)
|
|
219
|
+
|
|
220
|
+
# Load all the data onto the new dummy mesh
|
|
221
|
+
points, faces, counts, uvs, uvFaces = other.getMeshTopology(other.mesh)
|
|
222
|
+
dummyMesh = self.buildRawTopology(
|
|
223
|
+
other.name, points, faces, counts, uvs, uvFaces
|
|
224
|
+
)
|
|
225
|
+
self.loadNodes(self.simplex, dummyMesh)
|
|
226
|
+
|
|
227
|
+
# Re-create the dummy shapes and sliders
|
|
228
|
+
for shape in self.simplex.shapes:
|
|
229
|
+
shape.thing = DummyShape(shape.name, self.shapeNode)
|
|
230
|
+
|
|
231
|
+
for oShape, nShape in zip(other.simplex.shapes, self.simplex.shapes):
|
|
232
|
+
nShape.verts = copy.copy(oShape.verts)
|
|
233
|
+
|
|
234
|
+
self.pushAllShapeVertices(self.simplex.shapes)
|
|
235
|
+
restVerts = self.simplex.restShape.verts
|
|
236
|
+
|
|
237
|
+
for slider in self.simplex.sliders:
|
|
238
|
+
slider.thing = DummyAttr(slider.name, 0.0, self.ctrl)
|
|
239
|
+
|
|
240
|
+
for fo in self.simplex.falloffs:
|
|
241
|
+
fo.thing = DummyFalloff(fo.name, self.scene)
|
|
242
|
+
fo.verts = restVerts
|
|
243
|
+
|
|
244
|
+
def preLoad(self, simp, simpDict, create=True, pBar=None):
|
|
245
|
+
"""Code to execute before loading a simplex system into a dcc
|
|
246
|
+
|
|
247
|
+
Parameters
|
|
248
|
+
----------
|
|
249
|
+
simp : Simplex
|
|
250
|
+
The simplex system that will be created
|
|
251
|
+
simpDict : dict
|
|
252
|
+
The dictionary definition of the simplex to be created
|
|
253
|
+
create : bool
|
|
254
|
+
Whether to create the missing objects in the DCC (Default value = True)
|
|
255
|
+
pBar : QProgressDialog, optional
|
|
256
|
+
An optional progress dialog (Default value = None)
|
|
257
|
+
|
|
258
|
+
Returns
|
|
259
|
+
-------
|
|
260
|
+
: object :
|
|
261
|
+
A generic python object to be used in the post-load
|
|
262
|
+
"""
|
|
263
|
+
return None
|
|
264
|
+
|
|
265
|
+
def postLoad(self, simp, preRet):
|
|
266
|
+
"""Code to execute after loading a simplex system into a dcc
|
|
267
|
+
|
|
268
|
+
Parameters
|
|
269
|
+
----------
|
|
270
|
+
simp : Simplex
|
|
271
|
+
The simplex system that was created
|
|
272
|
+
preRet : object
|
|
273
|
+
The object returnd from the preload method
|
|
274
|
+
|
|
275
|
+
"""
|
|
276
|
+
pass
|
|
277
|
+
|
|
278
|
+
def checkForErrors(self, window):
|
|
279
|
+
""" Check for any DCC specific errors
|
|
280
|
+
|
|
281
|
+
Parameters
|
|
282
|
+
----------
|
|
283
|
+
window : QMainWindow
|
|
284
|
+
The simplex window
|
|
285
|
+
"""
|
|
286
|
+
pass
|
|
287
|
+
|
|
288
|
+
# System IO
|
|
289
|
+
@undoable
|
|
290
|
+
def loadNodes(self, simp, thing, create=True, pBar=None):
|
|
291
|
+
"""Load the nodes from a simplex system onto a thing
|
|
292
|
+
|
|
293
|
+
Parameters
|
|
294
|
+
----------
|
|
295
|
+
simp : Simplex
|
|
296
|
+
The system we're loading for
|
|
297
|
+
thing : object
|
|
298
|
+
The DCC thing we're reading
|
|
299
|
+
create : bool
|
|
300
|
+
Whether to create the missing nodes (Default value = True)
|
|
301
|
+
pBar : QProgressDialog, optional
|
|
302
|
+
An optional progress dialog (Default value = None)
|
|
303
|
+
|
|
304
|
+
"""
|
|
305
|
+
if thing is None:
|
|
306
|
+
thing = DummyMesh(simp.name)
|
|
307
|
+
|
|
308
|
+
self.name = simp.name
|
|
309
|
+
self.mesh = thing
|
|
310
|
+
self.scene.add(self.mesh)
|
|
311
|
+
|
|
312
|
+
self.shapeNode = self.scene.get(DummyBlendshape, self.name)
|
|
313
|
+
|
|
314
|
+
if self.shapeNode is None:
|
|
315
|
+
if not create:
|
|
316
|
+
raise RuntimeError(
|
|
317
|
+
"Blendshape operator not found with creation turned off: {0}".format(
|
|
318
|
+
self.name
|
|
319
|
+
)
|
|
320
|
+
)
|
|
321
|
+
self.shapeNode = DummyBlendshape(self.name, self.mesh, self.scene)
|
|
322
|
+
|
|
323
|
+
self.op = self.scene.get(DummySimplex, self.name)
|
|
324
|
+
if self.op is None:
|
|
325
|
+
if not create:
|
|
326
|
+
raise RuntimeError(
|
|
327
|
+
"Simplex operator not found with creation turned off"
|
|
328
|
+
)
|
|
329
|
+
self.op = DummySimplex(self.name, self.mesh, self.scene)
|
|
330
|
+
|
|
331
|
+
self.ctrl = self.scene.get(DummyNode, self.name)
|
|
332
|
+
if self.ctrl is None:
|
|
333
|
+
if not create:
|
|
334
|
+
raise RuntimeError("Control object not found with creation turned off")
|
|
335
|
+
self.ctrl = DummyNode(self.name, self.scene)
|
|
336
|
+
|
|
337
|
+
def loadConnections(self, simp, pBar=None):
|
|
338
|
+
"""Load the connections that exist in a simplex system
|
|
339
|
+
|
|
340
|
+
Parameters
|
|
341
|
+
----------
|
|
342
|
+
simp : Simplex
|
|
343
|
+
The simplex system to load connections for
|
|
344
|
+
pBar : QProgressDialog, optional
|
|
345
|
+
An optional progress dialog (Default value = None)
|
|
346
|
+
|
|
347
|
+
"""
|
|
348
|
+
pass
|
|
349
|
+
|
|
350
|
+
def getShapeThing(self, shapeName):
|
|
351
|
+
"""Get the DCC Thing for a given shape name
|
|
352
|
+
|
|
353
|
+
Parameters
|
|
354
|
+
----------
|
|
355
|
+
shapeName : str
|
|
356
|
+
The name of the shape to get
|
|
357
|
+
|
|
358
|
+
Returns
|
|
359
|
+
-------
|
|
360
|
+
: object :
|
|
361
|
+
The DCC Thing
|
|
362
|
+
|
|
363
|
+
"""
|
|
364
|
+
return self.shapeNode.shapes.get(shapeName)
|
|
365
|
+
|
|
366
|
+
def getSliderThing(self, sliderName):
|
|
367
|
+
"""Get the DCC Thing for a given slider name
|
|
368
|
+
|
|
369
|
+
Parameters
|
|
370
|
+
----------
|
|
371
|
+
sliderName : str
|
|
372
|
+
The name of the slider to get
|
|
373
|
+
|
|
374
|
+
Returns
|
|
375
|
+
-------
|
|
376
|
+
: object :
|
|
377
|
+
The DCC Thing
|
|
378
|
+
"""
|
|
379
|
+
return self.ctrl.attrs.get(sliderName)
|
|
380
|
+
|
|
381
|
+
@staticmethod
|
|
382
|
+
@undoable
|
|
383
|
+
def buildRestAbc(abcMesh, name):
|
|
384
|
+
"""Build the rest Alembic node in the dcc
|
|
385
|
+
|
|
386
|
+
Parameters
|
|
387
|
+
----------
|
|
388
|
+
abcMesh : IPolyMesh
|
|
389
|
+
The Alembic mesh object
|
|
390
|
+
name : str
|
|
391
|
+
The name of the object to create
|
|
392
|
+
|
|
393
|
+
"""
|
|
394
|
+
mesh = DummyMesh(name) # don't add it to a scene
|
|
395
|
+
|
|
396
|
+
sa = getSampleArray(abcMesh)
|
|
397
|
+
if len(sa.shape) == 3:
|
|
398
|
+
sa = sa[0]
|
|
399
|
+
mesh.verts = sa
|
|
400
|
+
faces, counts = getStaticMeshData(abcMesh)
|
|
401
|
+
uvs = getUvSample(abcMesh)
|
|
402
|
+
|
|
403
|
+
aryType = list if np is None else np.array
|
|
404
|
+
if uvs is not None:
|
|
405
|
+
mesh.uvs = aryType(uvs.getVals())
|
|
406
|
+
mesh.uvFaces = aryType(uvs.getIndices())
|
|
407
|
+
mesh.faces = aryType(faces)
|
|
408
|
+
mesh.counts = aryType(counts)
|
|
409
|
+
|
|
410
|
+
return mesh
|
|
411
|
+
|
|
412
|
+
@staticmethod
|
|
413
|
+
@undoable
|
|
414
|
+
def buildRawTopology(name, points, faces, counts, uvs=None, uvFaces=None):
|
|
415
|
+
"""Build a mesh directly from raw numerical data"""
|
|
416
|
+
# TODO: Move this guy out to the rest of the DCC's
|
|
417
|
+
mesh = DummyMesh(name) # don't add it to a scene
|
|
418
|
+
|
|
419
|
+
aryType = list if np is None else np.array
|
|
420
|
+
mesh.points = aryType(points)
|
|
421
|
+
mesh.faces = aryType(faces)
|
|
422
|
+
mesh.counts = aryType(counts)
|
|
423
|
+
if uvs is not None and uvFaces is not None:
|
|
424
|
+
mesh.uvs = aryType(uvs)
|
|
425
|
+
mesh.uvFaces = aryType(uvFaces)
|
|
426
|
+
return mesh
|
|
427
|
+
|
|
428
|
+
@staticmethod
|
|
429
|
+
def vertCount(mesh):
|
|
430
|
+
"""Get the vert count of the given DCC Object
|
|
431
|
+
|
|
432
|
+
Parameters
|
|
433
|
+
----------
|
|
434
|
+
mesh : object
|
|
435
|
+
The mesh to check
|
|
436
|
+
|
|
437
|
+
Returns
|
|
438
|
+
-------
|
|
439
|
+
: int :
|
|
440
|
+
The Number of verts
|
|
441
|
+
"""
|
|
442
|
+
return len(mesh.verts)
|
|
443
|
+
|
|
444
|
+
@undoable
|
|
445
|
+
def loadAbc(self, abcMesh, js, pBar=None):
|
|
446
|
+
"""Load the shapes from an alembic file onto an already-created system
|
|
447
|
+
|
|
448
|
+
Parameters
|
|
449
|
+
----------
|
|
450
|
+
abcMesh : IPolyMesh
|
|
451
|
+
The Alembic mesh to load shapes from
|
|
452
|
+
js : dict
|
|
453
|
+
The simplex definition dictionary
|
|
454
|
+
pBar : QProgressDialog, optional
|
|
455
|
+
An optional progress dialog (Default value = None)
|
|
456
|
+
|
|
457
|
+
"""
|
|
458
|
+
shapes = js["shapes"]
|
|
459
|
+
if js["encodingVersion"] > 1:
|
|
460
|
+
shapes = [i["name"] for i in shapes]
|
|
461
|
+
pointPositions = getSampleArray(abcMesh)
|
|
462
|
+
for name, ppos in zip(shapes, pointPositions):
|
|
463
|
+
dummyShape = self.shapeNode.shapes[name]
|
|
464
|
+
dummyShape.points = ppos
|
|
465
|
+
|
|
466
|
+
def getAllShapeVertices(self, shapes, pBar=None):
|
|
467
|
+
"""Load all shape vertices into the simplex system for processing
|
|
468
|
+
|
|
469
|
+
Parameters
|
|
470
|
+
----------
|
|
471
|
+
shapes : [Shape, ...]
|
|
472
|
+
A list of simplex Shape objects to get positions for
|
|
473
|
+
|
|
474
|
+
pBar : QProgressDialog, optional
|
|
475
|
+
An optional progress dialog (Default value = None)
|
|
476
|
+
|
|
477
|
+
"""
|
|
478
|
+
for i, shape in enumerate(shapes):
|
|
479
|
+
verts = self.getShapeVertices(shape)
|
|
480
|
+
shape.verts = verts
|
|
481
|
+
|
|
482
|
+
def getShapeVertices(self, shape):
|
|
483
|
+
"""Get the point positions of a shape
|
|
484
|
+
|
|
485
|
+
Parameters
|
|
486
|
+
----------
|
|
487
|
+
shape : Shape
|
|
488
|
+
A simplex Shape object to get the vertices for
|
|
489
|
+
|
|
490
|
+
Returns
|
|
491
|
+
-------
|
|
492
|
+
: np.array :
|
|
493
|
+
A numpy array of the point positions
|
|
494
|
+
|
|
495
|
+
"""
|
|
496
|
+
return shape.thing.points
|
|
497
|
+
|
|
498
|
+
def pushAllShapeVertices(self, shapes, pBar=None):
|
|
499
|
+
"""Push the computed vertex positions for the given shapes back to the DCC
|
|
500
|
+
|
|
501
|
+
Parameters
|
|
502
|
+
----------
|
|
503
|
+
shapes : [Shape, ...]
|
|
504
|
+
A list of simplex Shape objects
|
|
505
|
+
|
|
506
|
+
pBar : QProgressDialog, optional
|
|
507
|
+
An optional progress dialog (Default value = None)
|
|
508
|
+
|
|
509
|
+
"""
|
|
510
|
+
for shape in shapes:
|
|
511
|
+
self.pushShapeVertices(shape)
|
|
512
|
+
|
|
513
|
+
def pushShapeVertices(self, shape):
|
|
514
|
+
"""Push the computed vertex positions for the given shape back to the DCC
|
|
515
|
+
Parameters
|
|
516
|
+
----------
|
|
517
|
+
shape : Shape
|
|
518
|
+
The Simplex Shape object to update
|
|
519
|
+
|
|
520
|
+
"""
|
|
521
|
+
shape.thing.points = shape.verts
|
|
522
|
+
|
|
523
|
+
def loadMeshTopology(self):
|
|
524
|
+
"""Load the mesh topology from the DCC into the simplex interface"""
|
|
525
|
+
# Here in Dummy I either have the data already or I don't, So nothing to do
|
|
526
|
+
pass
|
|
527
|
+
|
|
528
|
+
@staticmethod
|
|
529
|
+
def getMeshTopology(mesh, uvName=None):
|
|
530
|
+
"""Get the topology of a mesh
|
|
531
|
+
|
|
532
|
+
Parameters
|
|
533
|
+
----------
|
|
534
|
+
mesh : object
|
|
535
|
+
The DCC Mesh to read
|
|
536
|
+
uvName : str, optional
|
|
537
|
+
The name of the uv set to read
|
|
538
|
+
|
|
539
|
+
Returns
|
|
540
|
+
-------
|
|
541
|
+
: np.array :
|
|
542
|
+
The vertex array
|
|
543
|
+
: np.array :
|
|
544
|
+
The "faces" array
|
|
545
|
+
: np.array :
|
|
546
|
+
The "counts" array
|
|
547
|
+
: np.array :
|
|
548
|
+
The uv positions
|
|
549
|
+
: np.array :
|
|
550
|
+
The "uvFaces" array
|
|
551
|
+
"""
|
|
552
|
+
return mesh.verts, mesh.faces, mesh.counts, mesh.uvs, mesh.uvFaces
|
|
553
|
+
|
|
554
|
+
def exportAbc(
|
|
555
|
+
self, dccMesh, abcMesh, js, world=False, ensureCorrect=False, pBar=None
|
|
556
|
+
):
|
|
557
|
+
"""Export a .smpx file
|
|
558
|
+
|
|
559
|
+
Parameters
|
|
560
|
+
----------
|
|
561
|
+
dccMesh : object
|
|
562
|
+
The DCC Mesh to export
|
|
563
|
+
abcMesh : OPolyMesh
|
|
564
|
+
The Alembic output mesh
|
|
565
|
+
js : dict
|
|
566
|
+
The definition dictionary
|
|
567
|
+
world : bool
|
|
568
|
+
Do the export in worldspace (Default value = False)
|
|
569
|
+
pBar : QProgressDialog, optional
|
|
570
|
+
An optional progress dialog (Default value = None)
|
|
571
|
+
|
|
572
|
+
"""
|
|
573
|
+
# export the data to alembic
|
|
574
|
+
if dccMesh is None:
|
|
575
|
+
dccMesh = self.mesh
|
|
576
|
+
|
|
577
|
+
shapeDict = {i.name: i for i in self.simplex.shapes}
|
|
578
|
+
|
|
579
|
+
shapeNames = js["shapes"]
|
|
580
|
+
if js["encodingVersion"] > 1:
|
|
581
|
+
shapeNames = [i["name"] for i in shapeNames]
|
|
582
|
+
shapes = [shapeDict[i] for i in shapeNames]
|
|
583
|
+
schema = abcMesh.getSchema()
|
|
584
|
+
|
|
585
|
+
if pBar is not None:
|
|
586
|
+
pBar.show()
|
|
587
|
+
pBar.setMaximum(len(shapes))
|
|
588
|
+
spacerName = "_" * max(list(map(len, shapeNames)))
|
|
589
|
+
pBar.setLabelText("Exporting:\n{0}".format(spacerName))
|
|
590
|
+
QApplication.processEvents()
|
|
591
|
+
|
|
592
|
+
faces = mkSampleIntArray(self.mesh.faces)
|
|
593
|
+
counts = mkSampleIntArray(self.mesh.counts)
|
|
594
|
+
uvs = None
|
|
595
|
+
if self.mesh.uvs is not None and self.mesh.uvFaces is not None:
|
|
596
|
+
uvs = mkUvSample(self.mesh.uvs, self.mesh.uvFaces)
|
|
597
|
+
|
|
598
|
+
for i, shape in enumerate(shapes):
|
|
599
|
+
if pBar is not None:
|
|
600
|
+
pBar.setLabelText("Exporting:\n{0}".format(shape.name))
|
|
601
|
+
pBar.setValue(i)
|
|
602
|
+
QApplication.processEvents()
|
|
603
|
+
if pBar.wasCanceled():
|
|
604
|
+
return
|
|
605
|
+
verts = mkSampleVertexPoints(shape.thing.points)
|
|
606
|
+
if uvs is not None:
|
|
607
|
+
# Alembic doesn't allow for uvs=None for some reason
|
|
608
|
+
abcSample = OPolyMeshSchemaSample(verts, faces, counts, uvs)
|
|
609
|
+
else:
|
|
610
|
+
abcSample = OPolyMeshSchemaSample(verts, faces, counts)
|
|
611
|
+
schema.set(abcSample)
|
|
612
|
+
|
|
613
|
+
def exportOtherAbc(self, dccMesh, abcMesh, js, world=False, pBar=None):
|
|
614
|
+
"""Export a .smpx file of a mesh other than self.mesh
|
|
615
|
+
|
|
616
|
+
Parameters
|
|
617
|
+
----------
|
|
618
|
+
dccMesh : object
|
|
619
|
+
The DCC Mesh to export
|
|
620
|
+
abcMesh : OPolyMesh
|
|
621
|
+
The Alembic output mesh
|
|
622
|
+
js : dict
|
|
623
|
+
The definition dictionary
|
|
624
|
+
world : bool
|
|
625
|
+
Do the export in worldspace (Default value = False)
|
|
626
|
+
pBar : QProgressDialog, optional
|
|
627
|
+
An optional progress dialog (Default value = None)
|
|
628
|
+
|
|
629
|
+
"""
|
|
630
|
+
if dccMesh is None:
|
|
631
|
+
raise ValueError(
|
|
632
|
+
"Export Other requires an explicitly defined mesh to export"
|
|
633
|
+
)
|
|
634
|
+
self.exportAbc(
|
|
635
|
+
dccMesh, abcMesh, js, world=world, ensureCorrect=False, pBar=pBar
|
|
636
|
+
)
|
|
637
|
+
|
|
638
|
+
# Revision tracking
|
|
639
|
+
def getRevision(self):
|
|
640
|
+
"""Get the simplex revision number"""
|
|
641
|
+
return self._revision
|
|
642
|
+
|
|
643
|
+
def incrementRevision(self):
|
|
644
|
+
"""Increment the revision number"""
|
|
645
|
+
self._revision += 1
|
|
646
|
+
return self._revision
|
|
647
|
+
|
|
648
|
+
def setRevision(self, val):
|
|
649
|
+
"""Manually set the revision numer
|
|
650
|
+
|
|
651
|
+
Parameters
|
|
652
|
+
----------
|
|
653
|
+
val : int
|
|
654
|
+
The value to set
|
|
655
|
+
|
|
656
|
+
"""
|
|
657
|
+
self._revision = val
|
|
658
|
+
|
|
659
|
+
# System level
|
|
660
|
+
@undoable
|
|
661
|
+
def renameSystem(self, name):
|
|
662
|
+
"""Rename a simplex system
|
|
663
|
+
|
|
664
|
+
Parameters
|
|
665
|
+
----------
|
|
666
|
+
name : str
|
|
667
|
+
The new name
|
|
668
|
+
|
|
669
|
+
"""
|
|
670
|
+
# TODO
|
|
671
|
+
oldName = self.name
|
|
672
|
+
self.name = name
|
|
673
|
+
# for dd in (DB.nodes, DB.ops, DB.bss, DB.meshes):
|
|
674
|
+
# oo = dd.get(oldName)
|
|
675
|
+
# if oo is not None:
|
|
676
|
+
# oo.name = self.name
|
|
677
|
+
# dd[self.name] = oo
|
|
678
|
+
# dd.pop(oldName, None)
|
|
679
|
+
|
|
680
|
+
@undoable
|
|
681
|
+
def deleteSystem(self):
|
|
682
|
+
"""Delete the current system"""
|
|
683
|
+
# for dd in (DB.nodes, DB.ops, DB.bss, DB.meshes):
|
|
684
|
+
# if self.name in dd:
|
|
685
|
+
# dd.pop(self.name, None)
|
|
686
|
+
# TODO
|
|
687
|
+
self.name = None
|
|
688
|
+
self.simplex = None
|
|
689
|
+
|
|
690
|
+
# Shapes
|
|
691
|
+
@undoable
|
|
692
|
+
def createShape(self, shape, live=False, offset=10):
|
|
693
|
+
"""Create a dcc shape
|
|
694
|
+
|
|
695
|
+
Parameters
|
|
696
|
+
----------
|
|
697
|
+
shape : Shape
|
|
698
|
+
A simplex shape object
|
|
699
|
+
live : bool
|
|
700
|
+
Whether this shape is live-connected (Default value = False)
|
|
701
|
+
offset : float
|
|
702
|
+
The offset of the created shape (Default value = 10)
|
|
703
|
+
|
|
704
|
+
"""
|
|
705
|
+
newShape = DummyShape(shape.name, self.shapeNode)
|
|
706
|
+
newShape.points = copy.copy(self.mesh.verts)
|
|
707
|
+
return newShape
|
|
708
|
+
|
|
709
|
+
@undoable
|
|
710
|
+
def extractWithDeltaShape(self, shape, live=True, offset=10.0):
|
|
711
|
+
"""Make a mesh representing a shape. Can be live or not.
|
|
712
|
+
Also, make a shapenode that is the delta of the change being made
|
|
713
|
+
|
|
714
|
+
Parameters
|
|
715
|
+
----------
|
|
716
|
+
shape :
|
|
717
|
+
|
|
718
|
+
live :
|
|
719
|
+
(Default value = True)
|
|
720
|
+
offset :
|
|
721
|
+
(Default value = 10.0)
|
|
722
|
+
|
|
723
|
+
"""
|
|
724
|
+
pass
|
|
725
|
+
|
|
726
|
+
@undoable
|
|
727
|
+
def extractWithDeltaConnection(self, shape, delta, value, live=True, offset=10.0):
|
|
728
|
+
"""Extract a shape with a live partial delta added in.
|
|
729
|
+
Useful for updating progressive shapes
|
|
730
|
+
|
|
731
|
+
Parameters
|
|
732
|
+
----------
|
|
733
|
+
shape :
|
|
734
|
+
|
|
735
|
+
delta :
|
|
736
|
+
|
|
737
|
+
value :
|
|
738
|
+
|
|
739
|
+
live :
|
|
740
|
+
(Default value = True)
|
|
741
|
+
offset :
|
|
742
|
+
(Default value = 10.0)
|
|
743
|
+
|
|
744
|
+
"""
|
|
745
|
+
pass
|
|
746
|
+
|
|
747
|
+
@undoable
|
|
748
|
+
def extractShape(self, shape, live=True, offset=10.0):
|
|
749
|
+
"""Make a mesh representing a shape. Can be live or not.
|
|
750
|
+
Can also store its starting shape and delta data
|
|
751
|
+
|
|
752
|
+
Parameters
|
|
753
|
+
----------
|
|
754
|
+
shape :
|
|
755
|
+
|
|
756
|
+
live :
|
|
757
|
+
(Default value = True)
|
|
758
|
+
offset :
|
|
759
|
+
(Default value = 10.0)
|
|
760
|
+
|
|
761
|
+
"""
|
|
762
|
+
pass
|
|
763
|
+
|
|
764
|
+
@undoable
|
|
765
|
+
def connectShape(self, shape, mesh=None, live=False, delete=False):
|
|
766
|
+
"""Force a shape to match a mesh
|
|
767
|
+
The "connect shape" button is:
|
|
768
|
+
mesh=None, delete=True
|
|
769
|
+
The "match shape" button is:
|
|
770
|
+
mesh=someMesh, delete=False
|
|
771
|
+
There is a possibility of a "make live" button:
|
|
772
|
+
live=True, delete=False
|
|
773
|
+
|
|
774
|
+
Parameters
|
|
775
|
+
----------
|
|
776
|
+
shape :
|
|
777
|
+
|
|
778
|
+
mesh :
|
|
779
|
+
(Default value = None)
|
|
780
|
+
live :
|
|
781
|
+
(Default value = False)
|
|
782
|
+
delete :
|
|
783
|
+
(Default value = False)
|
|
784
|
+
|
|
785
|
+
"""
|
|
786
|
+
pass
|
|
787
|
+
|
|
788
|
+
@undoable
|
|
789
|
+
def extractPosedShape(self, shape):
|
|
790
|
+
"""???
|
|
791
|
+
|
|
792
|
+
Parameters
|
|
793
|
+
----------
|
|
794
|
+
shape :
|
|
795
|
+
|
|
796
|
+
"""
|
|
797
|
+
pass
|
|
798
|
+
|
|
799
|
+
@undoable
|
|
800
|
+
def zeroShape(self, shape):
|
|
801
|
+
"""Set a shape back to rest
|
|
802
|
+
|
|
803
|
+
Parameters
|
|
804
|
+
----------
|
|
805
|
+
shape : Shape
|
|
806
|
+
The simplex shpae to zero out
|
|
807
|
+
|
|
808
|
+
"""
|
|
809
|
+
shape.thing.points = self.getShapeVertices(self.simplex.restShape)
|
|
810
|
+
|
|
811
|
+
@undoable
|
|
812
|
+
def deleteShape(self, toDelShape):
|
|
813
|
+
"""Delete a shape from the system
|
|
814
|
+
|
|
815
|
+
Parameters
|
|
816
|
+
----------
|
|
817
|
+
toDelShape :
|
|
818
|
+
|
|
819
|
+
"""
|
|
820
|
+
self.shapeNode.shapes.pop(toDelShape.name, None)
|
|
821
|
+
|
|
822
|
+
@undoable
|
|
823
|
+
def renameShape(self, shape, name):
|
|
824
|
+
"""Rename a shape
|
|
825
|
+
|
|
826
|
+
Parameters
|
|
827
|
+
----------
|
|
828
|
+
shape : Shape
|
|
829
|
+
The simplex Shape object to rename
|
|
830
|
+
name : str
|
|
831
|
+
The new name
|
|
832
|
+
|
|
833
|
+
"""
|
|
834
|
+
self.shapeNode.shapes.pop(shape.thing.name, None)
|
|
835
|
+
shape.thing.name = name
|
|
836
|
+
self.shapeNode.shapes[name] = shape.thing
|
|
837
|
+
|
|
838
|
+
@undoable
|
|
839
|
+
def convertShapeToCorrective(self, shape):
|
|
840
|
+
"""???
|
|
841
|
+
|
|
842
|
+
Parameters
|
|
843
|
+
----------
|
|
844
|
+
shape :
|
|
845
|
+
|
|
846
|
+
"""
|
|
847
|
+
pass
|
|
848
|
+
|
|
849
|
+
# Falloffs
|
|
850
|
+
def createFalloff(self, falloff):
|
|
851
|
+
"""Create a per-vert falloff weightmap
|
|
852
|
+
|
|
853
|
+
Parameters
|
|
854
|
+
----------
|
|
855
|
+
falloff : Falloff
|
|
856
|
+
The simplex Falloff object to create
|
|
857
|
+
|
|
858
|
+
"""
|
|
859
|
+
fo = DummyFalloff(falloff.name, self.scene)
|
|
860
|
+
fo.weights = np.zeros(len(self.mesh.verts))
|
|
861
|
+
|
|
862
|
+
def duplicateFalloff(self, falloff, newFalloff):
|
|
863
|
+
"""Create a new falloff from an already existing one
|
|
864
|
+
|
|
865
|
+
Parameters
|
|
866
|
+
----------
|
|
867
|
+
falloff : Falloff
|
|
868
|
+
The already existing falloff
|
|
869
|
+
newFalloff : Falloff
|
|
870
|
+
The newly created falloff to store the newly duplicated data
|
|
871
|
+
|
|
872
|
+
"""
|
|
873
|
+
fo = DummyFalloff(newFalloff.name, self.scene)
|
|
874
|
+
fo.weights = copy.copy(falloff.thing.weights)
|
|
875
|
+
|
|
876
|
+
def deleteFalloff(self, falloff):
|
|
877
|
+
"""Delete a falloff object
|
|
878
|
+
|
|
879
|
+
Parameters
|
|
880
|
+
----------
|
|
881
|
+
falloff : Falloff
|
|
882
|
+
The Falloff object to delete
|
|
883
|
+
|
|
884
|
+
"""
|
|
885
|
+
self.scene.remove(falloff.thing)
|
|
886
|
+
|
|
887
|
+
def setFalloffData(
|
|
888
|
+
self, falloff, splitType, axis, minVal, minHandle, maxHandle, maxVal, mapName
|
|
889
|
+
):
|
|
890
|
+
"""Set the data of a falloff object
|
|
891
|
+
|
|
892
|
+
Parameters
|
|
893
|
+
----------
|
|
894
|
+
falloff :
|
|
895
|
+
|
|
896
|
+
splitType :
|
|
897
|
+
|
|
898
|
+
axis :
|
|
899
|
+
|
|
900
|
+
minVal :
|
|
901
|
+
|
|
902
|
+
minHandle :
|
|
903
|
+
|
|
904
|
+
maxHandle :
|
|
905
|
+
|
|
906
|
+
maxVal :
|
|
907
|
+
|
|
908
|
+
mapName :
|
|
909
|
+
|
|
910
|
+
"""
|
|
911
|
+
# TODO: set the per-vert falloffs
|
|
912
|
+
pass # for eventual live splits
|
|
913
|
+
|
|
914
|
+
def getFalloffThing(self, falloff):
|
|
915
|
+
"""Get the thing for a given falloff
|
|
916
|
+
|
|
917
|
+
Parameters
|
|
918
|
+
----------
|
|
919
|
+
falloff : Falloff
|
|
920
|
+
The simplex falloff object to get
|
|
921
|
+
|
|
922
|
+
"""
|
|
923
|
+
return self.scene.get(DummyFalloff, falloff.name)
|
|
924
|
+
|
|
925
|
+
# Sliders
|
|
926
|
+
@undoable
|
|
927
|
+
def createSlider(self, slider):
|
|
928
|
+
"""Create a slider object
|
|
929
|
+
|
|
930
|
+
Parameters
|
|
931
|
+
----------
|
|
932
|
+
slider : Slider
|
|
933
|
+
The simplex slider object to create
|
|
934
|
+
|
|
935
|
+
"""
|
|
936
|
+
return DummyAttr(slider.name, 0.0, self.ctrl)
|
|
937
|
+
|
|
938
|
+
@undoable
|
|
939
|
+
def renameSlider(self, slider, name):
|
|
940
|
+
"""Rename a slider
|
|
941
|
+
|
|
942
|
+
Parameters
|
|
943
|
+
----------
|
|
944
|
+
slider : Slider
|
|
945
|
+
The slider to rename
|
|
946
|
+
name : str
|
|
947
|
+
The new name
|
|
948
|
+
|
|
949
|
+
"""
|
|
950
|
+
self.ctrl.attrs.pop(slider.thing.name, None)
|
|
951
|
+
self.ctrl.attrs[name] = slider.thing
|
|
952
|
+
slider.thing.name = name
|
|
953
|
+
|
|
954
|
+
@undoable
|
|
955
|
+
def setSliderRange(self, slider):
|
|
956
|
+
"""Set the min and max of a slider
|
|
957
|
+
|
|
958
|
+
Parameters
|
|
959
|
+
----------
|
|
960
|
+
slider : Slider
|
|
961
|
+
The slider to set
|
|
962
|
+
|
|
963
|
+
"""
|
|
964
|
+
pass
|
|
965
|
+
|
|
966
|
+
@undoable
|
|
967
|
+
def deleteSlider(self, toDelSlider):
|
|
968
|
+
"""Delete a slider
|
|
969
|
+
|
|
970
|
+
Parameters
|
|
971
|
+
----------
|
|
972
|
+
toDelSlider : Slider
|
|
973
|
+
The slider to delete
|
|
974
|
+
|
|
975
|
+
"""
|
|
976
|
+
self.ctrl.attrs.pop(toDelSlider.name, None)
|
|
977
|
+
|
|
978
|
+
@undoable
|
|
979
|
+
def addProgFalloff(self, prog, falloff):
|
|
980
|
+
"""
|
|
981
|
+
|
|
982
|
+
Parameters
|
|
983
|
+
----------
|
|
984
|
+
prog :
|
|
985
|
+
|
|
986
|
+
falloff :
|
|
987
|
+
|
|
988
|
+
"""
|
|
989
|
+
pass # for eventual live splits
|
|
990
|
+
|
|
991
|
+
@undoable
|
|
992
|
+
def removeProgFalloff(self, prog, falloff):
|
|
993
|
+
"""
|
|
994
|
+
|
|
995
|
+
Parameters
|
|
996
|
+
----------
|
|
997
|
+
prog :
|
|
998
|
+
|
|
999
|
+
falloff :
|
|
1000
|
+
|
|
1001
|
+
"""
|
|
1002
|
+
pass # for eventual live splits
|
|
1003
|
+
|
|
1004
|
+
@undoable
|
|
1005
|
+
def setSlidersWeights(self, sliders, weights):
|
|
1006
|
+
"""Set the values for the given sliders
|
|
1007
|
+
|
|
1008
|
+
Parameters
|
|
1009
|
+
----------
|
|
1010
|
+
sliders : [Slider, ...]
|
|
1011
|
+
The sliders to set values for
|
|
1012
|
+
weights : [float, ...]
|
|
1013
|
+
The values to set
|
|
1014
|
+
|
|
1015
|
+
"""
|
|
1016
|
+
for slider, val in zip(sliders, weights):
|
|
1017
|
+
slider.thing.value = val
|
|
1018
|
+
|
|
1019
|
+
@undoable
|
|
1020
|
+
def setSliderWeight(self, slider, weight):
|
|
1021
|
+
"""Set the value for a given slider
|
|
1022
|
+
|
|
1023
|
+
Parameters
|
|
1024
|
+
----------
|
|
1025
|
+
slider : Slider
|
|
1026
|
+
The slider
|
|
1027
|
+
weight : float
|
|
1028
|
+
The value
|
|
1029
|
+
|
|
1030
|
+
"""
|
|
1031
|
+
slider.thing.value = weight
|
|
1032
|
+
|
|
1033
|
+
@undoable
|
|
1034
|
+
def updateSlidersRange(self, sliders):
|
|
1035
|
+
"""Update the range of the given sliders
|
|
1036
|
+
|
|
1037
|
+
Parameters
|
|
1038
|
+
----------
|
|
1039
|
+
sliders :
|
|
1040
|
+
|
|
1041
|
+
"""
|
|
1042
|
+
pass
|
|
1043
|
+
|
|
1044
|
+
@undoable
|
|
1045
|
+
def extractTraversalShape(self, trav, shape, live=True, offset=10.0):
|
|
1046
|
+
"""Extract a shape from a traversal progression
|
|
1047
|
+
|
|
1048
|
+
Parameters
|
|
1049
|
+
----------
|
|
1050
|
+
trav :
|
|
1051
|
+
|
|
1052
|
+
shape :
|
|
1053
|
+
|
|
1054
|
+
live :
|
|
1055
|
+
(Default value = True)
|
|
1056
|
+
offset :
|
|
1057
|
+
(Default value = 10.0)
|
|
1058
|
+
|
|
1059
|
+
"""
|
|
1060
|
+
pass
|
|
1061
|
+
|
|
1062
|
+
@undoable
|
|
1063
|
+
def connectTraversalShape(self, trav, shape, mesh=None, live=True, delete=False):
|
|
1064
|
+
"""Connect a shape to a traversal progression
|
|
1065
|
+
|
|
1066
|
+
Parameters
|
|
1067
|
+
----------
|
|
1068
|
+
trav :
|
|
1069
|
+
|
|
1070
|
+
shape :
|
|
1071
|
+
|
|
1072
|
+
mesh :
|
|
1073
|
+
(Default value = None)
|
|
1074
|
+
live :
|
|
1075
|
+
(Default value = True)
|
|
1076
|
+
delete :
|
|
1077
|
+
(Default value = False)
|
|
1078
|
+
|
|
1079
|
+
"""
|
|
1080
|
+
pass
|
|
1081
|
+
|
|
1082
|
+
# Combos
|
|
1083
|
+
@undoable
|
|
1084
|
+
def extractComboShape(self, combo, shape, live=True, offset=10.0):
|
|
1085
|
+
"""Extract a shape from a combo progression
|
|
1086
|
+
|
|
1087
|
+
Parameters
|
|
1088
|
+
----------
|
|
1089
|
+
combo :
|
|
1090
|
+
|
|
1091
|
+
shape :
|
|
1092
|
+
|
|
1093
|
+
live :
|
|
1094
|
+
(Default value = True)
|
|
1095
|
+
offset :
|
|
1096
|
+
(Default value = 10.0)
|
|
1097
|
+
|
|
1098
|
+
"""
|
|
1099
|
+
pass
|
|
1100
|
+
|
|
1101
|
+
@undoable
|
|
1102
|
+
def connectComboShape(self, combo, shape, mesh=None, live=True, delete=False):
|
|
1103
|
+
"""Connect a shape to a combo progression
|
|
1104
|
+
|
|
1105
|
+
Parameters
|
|
1106
|
+
----------
|
|
1107
|
+
combo :
|
|
1108
|
+
|
|
1109
|
+
shape :
|
|
1110
|
+
|
|
1111
|
+
mesh :
|
|
1112
|
+
(Default value = None)
|
|
1113
|
+
live :
|
|
1114
|
+
(Default value = True)
|
|
1115
|
+
delete :
|
|
1116
|
+
(Default value = False)
|
|
1117
|
+
|
|
1118
|
+
"""
|
|
1119
|
+
pass
|
|
1120
|
+
|
|
1121
|
+
@staticmethod
|
|
1122
|
+
def setDisabled(op):
|
|
1123
|
+
"""Disable the output of any simplex systems
|
|
1124
|
+
|
|
1125
|
+
Parameters
|
|
1126
|
+
----------
|
|
1127
|
+
op : The operator to disable
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
Returns
|
|
1131
|
+
-------
|
|
1132
|
+
: object :
|
|
1133
|
+
Some object that will allow us to re-enable the system
|
|
1134
|
+
|
|
1135
|
+
"""
|
|
1136
|
+
return None
|
|
1137
|
+
|
|
1138
|
+
@staticmethod
|
|
1139
|
+
def reEnable(helpers):
|
|
1140
|
+
"""Re-enable a simplex system
|
|
1141
|
+
|
|
1142
|
+
Parameters
|
|
1143
|
+
----------
|
|
1144
|
+
helpers : object
|
|
1145
|
+
The helper object returned from setDisabled
|
|
1146
|
+
|
|
1147
|
+
"""
|
|
1148
|
+
pass
|
|
1149
|
+
|
|
1150
|
+
@undoable
|
|
1151
|
+
def renameCombo(self, combo, name):
|
|
1152
|
+
"""Set the name of a Combo
|
|
1153
|
+
|
|
1154
|
+
Parameters
|
|
1155
|
+
----------
|
|
1156
|
+
combo : Combo
|
|
1157
|
+
The combo to rename
|
|
1158
|
+
name : str
|
|
1159
|
+
The new name
|
|
1160
|
+
|
|
1161
|
+
"""
|
|
1162
|
+
pass
|
|
1163
|
+
|
|
1164
|
+
# Data Access
|
|
1165
|
+
@staticmethod
|
|
1166
|
+
def getSimplexOperators():
|
|
1167
|
+
"""Get all simplex operators in the DCC"""
|
|
1168
|
+
return list(DB.ops.values())
|
|
1169
|
+
|
|
1170
|
+
@staticmethod
|
|
1171
|
+
def getSimplexOperatorsByName(name):
|
|
1172
|
+
"""Get a simplex operator
|
|
1173
|
+
|
|
1174
|
+
Parameters
|
|
1175
|
+
----------
|
|
1176
|
+
name : str
|
|
1177
|
+
The name to search for
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
Returns
|
|
1181
|
+
-------
|
|
1182
|
+
: object :
|
|
1183
|
+
The simplex operator for the DCC
|
|
1184
|
+
|
|
1185
|
+
"""
|
|
1186
|
+
return DB.ops.get(name)
|
|
1187
|
+
|
|
1188
|
+
@staticmethod
|
|
1189
|
+
def getSimplexOperatorsOnObject(thing):
|
|
1190
|
+
"""Get all simplex operators controlling an object
|
|
1191
|
+
|
|
1192
|
+
Parameters
|
|
1193
|
+
----------
|
|
1194
|
+
thing : object
|
|
1195
|
+
A dcc object to check for simplex operators
|
|
1196
|
+
|
|
1197
|
+
Returns
|
|
1198
|
+
-------
|
|
1199
|
+
: [object, ...] :
|
|
1200
|
+
A list of simplex operators
|
|
1201
|
+
|
|
1202
|
+
"""
|
|
1203
|
+
return [o for o in thing.ops if isinstance(o, DummySimplex)]
|
|
1204
|
+
|
|
1205
|
+
@staticmethod
|
|
1206
|
+
def getSimplexString(op):
|
|
1207
|
+
"""Get the simplex string from the given operator
|
|
1208
|
+
|
|
1209
|
+
Parameters
|
|
1210
|
+
----------
|
|
1211
|
+
op : object
|
|
1212
|
+
The Simplex operator to get the definition from
|
|
1213
|
+
|
|
1214
|
+
Returns
|
|
1215
|
+
-------
|
|
1216
|
+
: str :
|
|
1217
|
+
The simplex definition
|
|
1218
|
+
|
|
1219
|
+
"""
|
|
1220
|
+
return op.definition
|
|
1221
|
+
|
|
1222
|
+
@staticmethod
|
|
1223
|
+
def getSimplexStringOnThing(thing, systemName):
|
|
1224
|
+
"""Get the definition on an object by name
|
|
1225
|
+
|
|
1226
|
+
Parameters
|
|
1227
|
+
----------
|
|
1228
|
+
thing : object
|
|
1229
|
+
The DCC object to check for a simplex operator
|
|
1230
|
+
systemName : str
|
|
1231
|
+
The system name to check for
|
|
1232
|
+
|
|
1233
|
+
Returns
|
|
1234
|
+
-------
|
|
1235
|
+
: str :
|
|
1236
|
+
The simplex definition
|
|
1237
|
+
|
|
1238
|
+
"""
|
|
1239
|
+
for op in thing.ops:
|
|
1240
|
+
if op.name == systemName:
|
|
1241
|
+
return op.definition
|
|
1242
|
+
return None
|
|
1243
|
+
|
|
1244
|
+
@staticmethod
|
|
1245
|
+
def setSimplexString(op, val):
|
|
1246
|
+
"""Set the definition string on an object
|
|
1247
|
+
|
|
1248
|
+
Parameters
|
|
1249
|
+
----------
|
|
1250
|
+
op : object
|
|
1251
|
+
The operator to set the definition on
|
|
1252
|
+
val : str
|
|
1253
|
+
The definition to set
|
|
1254
|
+
|
|
1255
|
+
Returns
|
|
1256
|
+
-------
|
|
1257
|
+
|
|
1258
|
+
"""
|
|
1259
|
+
op.definition = val
|
|
1260
|
+
|
|
1261
|
+
@staticmethod
|
|
1262
|
+
def selectObject(thing):
|
|
1263
|
+
"""Select an object in the DCC
|
|
1264
|
+
|
|
1265
|
+
Parameters
|
|
1266
|
+
----------
|
|
1267
|
+
thing :
|
|
1268
|
+
|
|
1269
|
+
"""
|
|
1270
|
+
pass
|
|
1271
|
+
|
|
1272
|
+
def selectCtrl(self):
|
|
1273
|
+
"""Select the system's control object"""
|
|
1274
|
+
pass
|
|
1275
|
+
|
|
1276
|
+
@staticmethod
|
|
1277
|
+
def getObjectByName(name):
|
|
1278
|
+
"""Get an object by name
|
|
1279
|
+
|
|
1280
|
+
Parameters
|
|
1281
|
+
----------
|
|
1282
|
+
name : str
|
|
1283
|
+
The name to search for
|
|
1284
|
+
|
|
1285
|
+
Returns
|
|
1286
|
+
-------
|
|
1287
|
+
: object :
|
|
1288
|
+
The found object
|
|
1289
|
+
|
|
1290
|
+
"""
|
|
1291
|
+
# TODO: maybe also filter by type??
|
|
1292
|
+
# return DB.meshes.get(name)
|
|
1293
|
+
return DB.get(DummyMesh, name)
|
|
1294
|
+
|
|
1295
|
+
@staticmethod
|
|
1296
|
+
def getObjectName(thing):
|
|
1297
|
+
"""Get the name of an object
|
|
1298
|
+
|
|
1299
|
+
Parameters
|
|
1300
|
+
----------
|
|
1301
|
+
thing : object
|
|
1302
|
+
The dcc object to get the name for
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
Returns
|
|
1306
|
+
-------
|
|
1307
|
+
: str :
|
|
1308
|
+
The Object Name
|
|
1309
|
+
|
|
1310
|
+
"""
|
|
1311
|
+
return thing.name
|
|
1312
|
+
|
|
1313
|
+
@staticmethod
|
|
1314
|
+
def staticUndoOpen():
|
|
1315
|
+
"""Open an undo chunk without knowledge of Simplex"""
|
|
1316
|
+
pass
|
|
1317
|
+
|
|
1318
|
+
@staticmethod
|
|
1319
|
+
def staticUndoClose():
|
|
1320
|
+
"""Close an undo chunk without knowledge of Simplex"""
|
|
1321
|
+
pass
|
|
1322
|
+
|
|
1323
|
+
def undoOpen(self):
|
|
1324
|
+
"""Open an undo chunk with knowledge of Simplex"""
|
|
1325
|
+
pass
|
|
1326
|
+
|
|
1327
|
+
def undoClose(self):
|
|
1328
|
+
"""Close an undo chunk with knowledge of Simplex"""
|
|
1329
|
+
pass
|
|
1330
|
+
|
|
1331
|
+
@classmethod
|
|
1332
|
+
def getPersistentFalloff(cls, thing):
|
|
1333
|
+
"""Get a representation of the given object that won't get deleted or garbage collected
|
|
1334
|
+
|
|
1335
|
+
Parameters
|
|
1336
|
+
----------
|
|
1337
|
+
thing : object
|
|
1338
|
+
The thing to get a persistent representation of
|
|
1339
|
+
|
|
1340
|
+
Returns
|
|
1341
|
+
-------
|
|
1342
|
+
: object :
|
|
1343
|
+
The requested persistent object
|
|
1344
|
+
|
|
1345
|
+
"""
|
|
1346
|
+
return cls.getObjectName(thing)
|
|
1347
|
+
|
|
1348
|
+
@classmethod
|
|
1349
|
+
def loadPersistentFalloff(cls, thing):
|
|
1350
|
+
"""Get the usable representation of the given persistent thing
|
|
1351
|
+
|
|
1352
|
+
Parameters
|
|
1353
|
+
----------
|
|
1354
|
+
thing : object
|
|
1355
|
+
A persistent representation
|
|
1356
|
+
|
|
1357
|
+
Returns
|
|
1358
|
+
-------
|
|
1359
|
+
: object :
|
|
1360
|
+
The requested volatile object
|
|
1361
|
+
|
|
1362
|
+
"""
|
|
1363
|
+
return cls.getObjectByName(thing)
|
|
1364
|
+
|
|
1365
|
+
@classmethod
|
|
1366
|
+
def getPersistentShape(cls, thing):
|
|
1367
|
+
"""Get a representation of the given object that won't get deleted or garbage collected
|
|
1368
|
+
|
|
1369
|
+
Parameters
|
|
1370
|
+
----------
|
|
1371
|
+
thing : object
|
|
1372
|
+
The thing to get a persistent representation of
|
|
1373
|
+
|
|
1374
|
+
Returns
|
|
1375
|
+
-------
|
|
1376
|
+
: object :
|
|
1377
|
+
The requested persistent object
|
|
1378
|
+
|
|
1379
|
+
"""
|
|
1380
|
+
return cls.getObjectName(thing)
|
|
1381
|
+
|
|
1382
|
+
@classmethod
|
|
1383
|
+
def loadPersistentShape(cls, thing):
|
|
1384
|
+
"""Get the usable representation of the given persistent thing
|
|
1385
|
+
|
|
1386
|
+
Parameters
|
|
1387
|
+
----------
|
|
1388
|
+
thing : object
|
|
1389
|
+
A persistent representation
|
|
1390
|
+
|
|
1391
|
+
Returns
|
|
1392
|
+
-------
|
|
1393
|
+
: object :
|
|
1394
|
+
The requested volatile object
|
|
1395
|
+
|
|
1396
|
+
"""
|
|
1397
|
+
return cls.getObjectByName(thing)
|
|
1398
|
+
|
|
1399
|
+
@classmethod
|
|
1400
|
+
def getPersistentSlider(cls, thing):
|
|
1401
|
+
"""Get a representation of the given object that won't get deleted or garbage collected
|
|
1402
|
+
|
|
1403
|
+
Parameters
|
|
1404
|
+
----------
|
|
1405
|
+
thing : object
|
|
1406
|
+
The thing to get a persistent representation of
|
|
1407
|
+
|
|
1408
|
+
Returns
|
|
1409
|
+
-------
|
|
1410
|
+
: object :
|
|
1411
|
+
The requested persistent object
|
|
1412
|
+
|
|
1413
|
+
"""
|
|
1414
|
+
return cls.getObjectName(thing)
|
|
1415
|
+
|
|
1416
|
+
@classmethod
|
|
1417
|
+
def loadPersistentSlider(cls, thing):
|
|
1418
|
+
"""Get the usable representation of the given persistent thing
|
|
1419
|
+
|
|
1420
|
+
Parameters
|
|
1421
|
+
----------
|
|
1422
|
+
thing : object
|
|
1423
|
+
A persistent representation
|
|
1424
|
+
|
|
1425
|
+
Returns
|
|
1426
|
+
-------
|
|
1427
|
+
: object :
|
|
1428
|
+
The requested volatile object
|
|
1429
|
+
|
|
1430
|
+
"""
|
|
1431
|
+
return cls.getObjectByName(thing)
|
|
1432
|
+
|
|
1433
|
+
@staticmethod
|
|
1434
|
+
def getSelectedObjects():
|
|
1435
|
+
"""Get the selected objects"""
|
|
1436
|
+
# Here in the dummy interface, we short-circuit this
|
|
1437
|
+
# And return a default selected object called "thing"
|
|
1438
|
+
return [DummyNode("thing")]
|
|
1439
|
+
|
|
1440
|
+
def getFreezeThing(self, combo):
|
|
1441
|
+
return []
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
class SliderDispatch(QtCore.QObject):
|
|
1445
|
+
""" """
|
|
1446
|
+
|
|
1447
|
+
valueChanged = Signal()
|
|
1448
|
+
|
|
1449
|
+
def __init__(self, node, parent=None):
|
|
1450
|
+
super(SliderDispatch, self).__init__(parent)
|
|
1451
|
+
|
|
1452
|
+
def emitValueChanged(self, *args, **kwargs):
|
|
1453
|
+
"""
|
|
1454
|
+
|
|
1455
|
+
Parameters
|
|
1456
|
+
----------
|
|
1457
|
+
*args :
|
|
1458
|
+
|
|
1459
|
+
**kwargs :
|
|
1460
|
+
|
|
1461
|
+
"""
|
|
1462
|
+
self.valueChanged.emit()
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
class Dispatch(QtCore.QObject):
|
|
1466
|
+
""" """
|
|
1467
|
+
|
|
1468
|
+
beforeNew = Signal()
|
|
1469
|
+
afterNew = Signal()
|
|
1470
|
+
beforeOpen = Signal()
|
|
1471
|
+
afterOpen = Signal()
|
|
1472
|
+
undo = Signal()
|
|
1473
|
+
redo = Signal()
|
|
1474
|
+
|
|
1475
|
+
def __init__(self, parent=None):
|
|
1476
|
+
super(Dispatch, self).__init__(parent)
|
|
1477
|
+
|
|
1478
|
+
def connectCallbacks(self):
|
|
1479
|
+
""" """
|
|
1480
|
+
pass
|
|
1481
|
+
|
|
1482
|
+
def disconnectCallbacks(self):
|
|
1483
|
+
""" """
|
|
1484
|
+
pass
|
|
1485
|
+
|
|
1486
|
+
def emitBeforeNew(self, *args, **kwargs):
|
|
1487
|
+
"""
|
|
1488
|
+
|
|
1489
|
+
Parameters
|
|
1490
|
+
----------
|
|
1491
|
+
*args :
|
|
1492
|
+
|
|
1493
|
+
**kwargs :
|
|
1494
|
+
|
|
1495
|
+
"""
|
|
1496
|
+
self.beforeNew.emit()
|
|
1497
|
+
|
|
1498
|
+
def emitAfterNew(self, *args, **kwargs):
|
|
1499
|
+
"""
|
|
1500
|
+
|
|
1501
|
+
Parameters
|
|
1502
|
+
----------
|
|
1503
|
+
*args :
|
|
1504
|
+
|
|
1505
|
+
**kwargs :
|
|
1506
|
+
|
|
1507
|
+
"""
|
|
1508
|
+
self.afterNew.emit()
|
|
1509
|
+
|
|
1510
|
+
def emitBeforeOpen(self, *args, **kwargs):
|
|
1511
|
+
"""
|
|
1512
|
+
|
|
1513
|
+
Parameters
|
|
1514
|
+
----------
|
|
1515
|
+
*args :
|
|
1516
|
+
|
|
1517
|
+
**kwargs :
|
|
1518
|
+
|
|
1519
|
+
"""
|
|
1520
|
+
self.beforeOpen.emit()
|
|
1521
|
+
|
|
1522
|
+
def emitAfterOpen(self, *args, **kwargs):
|
|
1523
|
+
"""
|
|
1524
|
+
|
|
1525
|
+
Parameters
|
|
1526
|
+
----------
|
|
1527
|
+
*args :
|
|
1528
|
+
|
|
1529
|
+
**kwargs :
|
|
1530
|
+
|
|
1531
|
+
"""
|
|
1532
|
+
self.afterOpen.emit()
|
|
1533
|
+
|
|
1534
|
+
def emitUndo(self, *args, **kwargs):
|
|
1535
|
+
"""
|
|
1536
|
+
|
|
1537
|
+
Parameters
|
|
1538
|
+
----------
|
|
1539
|
+
*args :
|
|
1540
|
+
|
|
1541
|
+
**kwargs :
|
|
1542
|
+
|
|
1543
|
+
"""
|
|
1544
|
+
self.undo.emit()
|
|
1545
|
+
|
|
1546
|
+
def emitRedo(self, *args, **kwargs):
|
|
1547
|
+
"""
|
|
1548
|
+
|
|
1549
|
+
Parameters
|
|
1550
|
+
----------
|
|
1551
|
+
*args :
|
|
1552
|
+
|
|
1553
|
+
**kwargs :
|
|
1554
|
+
|
|
1555
|
+
"""
|
|
1556
|
+
self.redo.emit()
|
|
1557
|
+
|
|
1558
|
+
|
|
1559
|
+
DISPATCH = Dispatch()
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
def rootWindow():
|
|
1563
|
+
""" """
|
|
1564
|
+
return None
|