/
_modifiers.py
97 lines (78 loc) · 2.79 KB
/
_modifiers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/python
from .namespace import NameSpace
import mh
import humanmodifier
import material
import gui
import gui3d
import log
import os
import algos3d
import events3d
from core import G
from codecs import open
class Modifiers(NameSpace):
"""This namespace wraps calls concerning modifiers and targets."""
def __init__(self,api):
self.api = api
NameSpace.__init__(self)
self.human = api.internals.getHuman()
self.trace()
def _threadSafeApplyAllTargets(self):
algos3d.resetObj(self.human.meshData)
for (targetPath, morphFactor) in self.human.targetsDetailStack.items():
algos3d.loadTranslationTarget(self.human.meshData, targetPath, morphFactor, None, 0, 0)
self.human._updateOriginalMeshCoords(self.human.meshData.name, self.human.meshData.coord)
self.human.updateProxyMesh()
self.human.callEvent('onChanged', events3d.HumanEvent(self.human, 'targets'))
self.human.refreshStaticMeshes()
if self.human.isSubdivided():
self.human.updateSubdivisionMesh()
self.human.mesh.calcNormals()
self.human.mesh.update()
else:
self.human.meshData.calcNormals(1, 1)
self.human.meshData.update()
pass
def applyModifier(self, modifierName, power, assumeThreading = False):
modifier = self.human.getModifier(modifierName)
modifier.setValue(power)
if assumeThreading:
self._threadSafeApplyAllTargets()
else:
self.human.applyAllTargets()
mh.redraw()
def applyTarget(self,targetName,power, assumeThreading = False):
self.human.setDetail(mh.getSysDataPath("targets/" + targetName + ".target"), power)
if assumeThreading:
self._threadSafeApplyAllTargets()
else:
self.human.applyAllTargets()
mh.redraw()
def getAppliedTargets(self):
targets = dict()
for target in self.human.targetsDetailStack.keys():
paths = target.split('/data/targets/')
targets[paths[1]] = self.human.targetsDetailStack[target]
return targets
def setAge(self,age):
self.human.setAge(age)
mh.redraw()
def setWeight(self,weight):
self.human.setWeight(weight)
mh.redraw()
def setMuscle(self,muscle):
self.human.setMuscle(muscle)
mh.redraw()
def setHeight(self,height):
self.human.setHeight(height)
mh.redraw()
def setGender(self,gender):
self.human.setGender(gender)
mh.redraw()
def getAvailableModifierNames(self):
return sorted( self.human.getModifierNames() )
def applySymmetryLeft(self):
self.human.applySymmetryLeft()
def applySymmetryRight(self):
self.human.applySymmetryRight()