pyjallib 0.1.8__py3-none-any.whl → 0.1.10__py3-none-any.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.
- pyjallib/__init__.py +1 -1
- pyjallib/max/ConfigFiles/Default_3DSMaxNamingConfig.json +161 -0
- pyjallib/max/__init__.py +14 -2
- pyjallib/max/anim.py +60 -36
- pyjallib/max/autoClavicle.py +100 -92
- pyjallib/max/autoClavicleChain.py +173 -0
- pyjallib/max/bip.py +211 -14
- pyjallib/max/bone.py +348 -16
- pyjallib/max/constraint.py +29 -38
- pyjallib/max/groinBone.py +109 -39
- pyjallib/max/groinBoneChain.py +173 -0
- pyjallib/max/header.py +40 -6
- pyjallib/max/helper.py +3 -21
- pyjallib/max/hip.py +239 -0
- pyjallib/max/kneeBone.py +517 -0
- pyjallib/max/macro/jal_macro_align.py +11 -10
- pyjallib/max/macro/jal_macro_bone.py +2 -1
- pyjallib/max/macro/jal_macro_constraint.py +2 -1
- pyjallib/max/macro/jal_macro_helper.py +2 -1
- pyjallib/max/macro/jal_macro_link.py +2 -1
- pyjallib/max/macro/jal_macro_select.py +2 -1
- pyjallib/max/mirror.py +1 -1
- pyjallib/max/twistBone.py +259 -476
- pyjallib/max/twistBoneChain.py +162 -0
- pyjallib/max/volumeBone.py +273 -0
- pyjallib/max/volumeBoneChain.py +363 -0
- pyjallib/namePart.py +16 -16
- pyjallib/nameToPath.py +1 -1
- pyjallib/naming.py +15 -16
- pyjallib/namingConfig.py +3 -3
- pyjallib/perforce.py +446 -653
- {pyjallib-0.1.8.dist-info → pyjallib-0.1.10.dist-info}/METADATA +1 -1
- pyjallib-0.1.10.dist-info/RECORD +46 -0
- pyjallib/max/volumePreserveBone.py +0 -171
- pyjallib-0.1.8.dist-info/RECORD +0 -39
- {pyjallib-0.1.8.dist-info → pyjallib-0.1.10.dist-info}/WHEEL +0 -0
pyjallib/max/hip.py
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
"""
|
5
|
+
Hip 모듈 - 3ds Max용 Hip 관련 기능 제공
|
6
|
+
원본 MAXScript의 hip.ms를 Python으로 변환하였으며, pymxs 모듈 기반으로 구현됨
|
7
|
+
"""
|
8
|
+
|
9
|
+
from pymxs import runtime as rt
|
10
|
+
|
11
|
+
# Import necessary service classes for default initialization
|
12
|
+
from .name import Name
|
13
|
+
from .anim import Anim
|
14
|
+
from .helper import Helper
|
15
|
+
from .bone import Bone
|
16
|
+
from .constraint import Constraint
|
17
|
+
|
18
|
+
|
19
|
+
class Hip:
|
20
|
+
"""
|
21
|
+
Hip 관련 기능을 제공하는 클래스.
|
22
|
+
MAXScript의 _Hip 구조체 개념을 Python으로 재구현한 클래스이며,
|
23
|
+
3ds Max의 기능들을 pymxs API를 통해 제어합니다.
|
24
|
+
"""
|
25
|
+
|
26
|
+
def __init__(self, nameService=None, animService=None, helperService=None, boneService=None, constraintService=None):
|
27
|
+
"""
|
28
|
+
클래스 초기화.
|
29
|
+
|
30
|
+
Args:
|
31
|
+
nameService: 이름 처리 서비스 (제공되지 않으면 새로 생성)
|
32
|
+
animService: 애니메이션 서비스 (제공되지 않으면 새로 생성)
|
33
|
+
helperService: 헬퍼 객체 관련 서비스 (제공되지 않으면 새로 생성)
|
34
|
+
boneService: 뼈대 관련 서비스 (제공되지 않으면 새로 생성)
|
35
|
+
constraintService: 제약 관련 서비스 (제공되지 않으면 새로 생성)
|
36
|
+
bipService: Biped 관련 서비스 (제공되지 않으면 새로 생성)
|
37
|
+
"""
|
38
|
+
# 서비스 인스턴스 설정 또는 생성
|
39
|
+
self.name = nameService if nameService else Name()
|
40
|
+
self.anim = animService if animService else Anim()
|
41
|
+
|
42
|
+
# 종속성이 있는 서비스들은 이미 생성된 서비스들을 전달
|
43
|
+
self.helper = helperService if helperService else Helper(nameService=self.name)
|
44
|
+
self.const = constraintService if constraintService else Constraint(nameService=self.name, helperService=self.helper)
|
45
|
+
self.bone = boneService if boneService else Bone(nameService=self.name, animService=self.anim, helperService=self.helper, constraintService=self.const)
|
46
|
+
|
47
|
+
# 기본 속성 초기화
|
48
|
+
self.pelvisWeight = 0.4
|
49
|
+
self.thighWeight = 0.6
|
50
|
+
self.pushAmount = 20
|
51
|
+
|
52
|
+
self.pelvis = None
|
53
|
+
self.thigh = None
|
54
|
+
self.thighTwist = None
|
55
|
+
self.calf = None
|
56
|
+
|
57
|
+
self.pelvisHelper = None
|
58
|
+
self.thighHelper = None
|
59
|
+
self.thighTwistHelper = None
|
60
|
+
self.thighRotHelper = None
|
61
|
+
self.thighPosHelper = None
|
62
|
+
self.thighRotRootHelper = None
|
63
|
+
|
64
|
+
self.helpers = []
|
65
|
+
self.bones = []
|
66
|
+
|
67
|
+
self.posScriptExpression = (
|
68
|
+
"localLimbTm = limb.transform * inverse limbParent.transform\n"
|
69
|
+
"localDeltaTm = localLimbTm * inverse localRotRefTm\n"
|
70
|
+
"\n"
|
71
|
+
"q = localDeltaTm.rotation\n"
|
72
|
+
"\n"
|
73
|
+
"eulerRot = (quatToEuler q order:5)\n"
|
74
|
+
"swizzledRot = (eulerAngles eulerRot.y eulerRot.z eulerRot.x)\n"
|
75
|
+
"\n"
|
76
|
+
"axis = [0,0,1]\n"
|
77
|
+
"\n"
|
78
|
+
"saturatedTwistZ = (swizzledRot.x*axis.x + swizzledRot.y*axis.y + swizzledRot.z*axis.z)/180.0\n"
|
79
|
+
"pushScaleY = (amax 0.0 saturatedTwistZ) * 0.5\n"
|
80
|
+
"\n"
|
81
|
+
"axis = [0,1,0]\n"
|
82
|
+
"saturatedTwistY = (swizzledRot.x*axis.x + swizzledRot.y*axis.y + swizzledRot.z*axis.z)/180.0\n"
|
83
|
+
"pushScaleZ = amax 0.0 saturatedTwistY\n"
|
84
|
+
"\n"
|
85
|
+
"\n"
|
86
|
+
"[0, pushAmount * pushScaleY, -pushAmount * pushScaleZ]\n"
|
87
|
+
)
|
88
|
+
|
89
|
+
def reset(self):
|
90
|
+
"""
|
91
|
+
클래스의 주요 컴포넌트들을 초기화합니다.
|
92
|
+
서비스가 아닌 클래스 자체의 작업 데이터를 초기화하는 함수입니다.
|
93
|
+
|
94
|
+
Returns:
|
95
|
+
self: 메소드 체이닝을 위한 자기 자신 반환
|
96
|
+
"""
|
97
|
+
self.pelvisWeight = 0.4
|
98
|
+
self.thighWeight = 0.6
|
99
|
+
self.pushAmount = 20
|
100
|
+
|
101
|
+
self.pelvis = None
|
102
|
+
self.thigh = None
|
103
|
+
self.thighTwist = None
|
104
|
+
self.calf = None
|
105
|
+
|
106
|
+
self.pelvisHelper = None
|
107
|
+
self.thighHelper = None
|
108
|
+
self.thighTwistHelper = None
|
109
|
+
self.thighRotHelper = None
|
110
|
+
self.thighPosHelper = None
|
111
|
+
self.thighRotRootHelper = None
|
112
|
+
|
113
|
+
self.helpers = []
|
114
|
+
self.bones = []
|
115
|
+
|
116
|
+
return self
|
117
|
+
|
118
|
+
def create_helper(self, inPelvis, inThigh, inThighTwist):
|
119
|
+
if not rt.isValidNode(inPelvis) or not rt.isValidNode(inThigh) or not rt.isValidNode(inThighTwist):
|
120
|
+
return False
|
121
|
+
|
122
|
+
self.pelvis = inPelvis
|
123
|
+
self.thigh = inThigh
|
124
|
+
self.thighTwist = inThighTwist
|
125
|
+
|
126
|
+
filteringChar = self.name._get_filtering_char(inThigh.name)
|
127
|
+
isLower = inThigh.name[0].islower()
|
128
|
+
|
129
|
+
pelvisHelperName = self.name.replace_name_part("RealName", inThigh.name, self.name.get_RealName(inPelvis.name)+filteringChar+"Hip")
|
130
|
+
pelvisHelperName = self.name.replace_name_part("Type", pelvisHelperName, self.name.get_name_part_value_by_description("Type", "Dummy"))
|
131
|
+
pelvisHelper = self.helper.create_point(pelvisHelperName)
|
132
|
+
rt.setProperty(pelvisHelper, "transform", inThigh.transform)
|
133
|
+
pelvisHelper.parent = inPelvis
|
134
|
+
|
135
|
+
tihgTwistHeleprName = self.name.replace_name_part("RealName", inThigh.name, self.name.get_RealName(inThighTwist.name)+filteringChar+"Hip")
|
136
|
+
tihgTwistHeleprName = self.name.replace_name_part("Type", tihgTwistHeleprName, self.name.get_name_part_value_by_description("Type", "Dummy"))
|
137
|
+
thighTwistHelper = self.helper.create_point(tihgTwistHeleprName)
|
138
|
+
rt.setProperty(thighTwistHelper, "transform", inThighTwist.transform)
|
139
|
+
thighTwistHelper.parent = inThighTwist
|
140
|
+
|
141
|
+
tihghRotHelperName = self.name.replace_name_part("RealName", inThigh.name, self.name.get_RealName(inThigh.name)+filteringChar+"Hip")
|
142
|
+
tihghRotHelperName = self.name.replace_name_part("Type", tihghRotHelperName, self.name.get_name_part_value_by_description("Type", "Rotation"))
|
143
|
+
thighRotHelper = self.helper.create_point(tihghRotHelperName)
|
144
|
+
rt.setProperty(thighRotHelper, "transform", inThighTwist.transform)
|
145
|
+
thighRotHelper.parent = inThigh
|
146
|
+
|
147
|
+
thighPosHelperName = self.name.replace_name_part("RealName", inThigh.name, self.name.get_RealName(inThigh.name)+filteringChar+"Hip")
|
148
|
+
thighPosHelperName = self.name.replace_name_part("Type", thighPosHelperName, self.name.get_name_part_value_by_description("Type", "Position"))
|
149
|
+
thighPosHelper = self.helper.create_point(thighPosHelperName)
|
150
|
+
rt.setProperty(thighPosHelper, "transform", inThighTwist.transform)
|
151
|
+
thighPosHelper.parent = thighRotHelper
|
152
|
+
|
153
|
+
thighRotRootHelperName = self.name.replace_name_part("RealName", inThigh.name, self.name.get_RealName(inThigh.name)+filteringChar+"Hip")
|
154
|
+
thighRotRootHelperName = self.name.replace_name_part("Type", thighRotRootHelperName, self.name.get_name_part_value_by_description("Type", "Dummy"))
|
155
|
+
thighRotRootHelper = self.helper.create_point(thighRotRootHelperName)
|
156
|
+
rt.setProperty(thighRotRootHelper, "transform", thighRotHelper.transform)
|
157
|
+
thighRotRootHelper.parent = inThighTwist
|
158
|
+
|
159
|
+
if isLower:
|
160
|
+
pelvisHelper.name = pelvisHelper.name.lower()
|
161
|
+
thighTwistHelper.name = thighTwistHelper.name.lower()
|
162
|
+
thighRotHelper.name = thighRotHelper.name.lower()
|
163
|
+
thighPosHelper.name = thighPosHelper.name.lower()
|
164
|
+
thighRotRootHelper.name = thighRotRootHelper.name.lower()
|
165
|
+
|
166
|
+
self.pelvisHelper = pelvisHelper
|
167
|
+
self.thighTwistHelper = thighTwistHelper
|
168
|
+
self.thighRotHelper = thighRotHelper
|
169
|
+
self.thighPosHelper = thighPosHelper
|
170
|
+
self.thighRotRootHelper = thighRotRootHelper
|
171
|
+
|
172
|
+
self.helpers.append(pelvisHelper)
|
173
|
+
self.helpers.append(thighTwistHelper)
|
174
|
+
self.helpers.append(thighRotHelper)
|
175
|
+
self.helpers.append(thighPosHelper)
|
176
|
+
self.helpers.append(thighRotRootHelper)
|
177
|
+
|
178
|
+
def assing_constraint(self, inCalf, inPelvisWeight=0.6, inThighWeight=0.4, inPushAmount=5.0):
|
179
|
+
self.calf = inCalf
|
180
|
+
self.pelvisWeight = inPelvisWeight
|
181
|
+
self.thighWeight = inThighWeight
|
182
|
+
self.pushAmount = rt.Float(inPushAmount)
|
183
|
+
|
184
|
+
facingDirVec = self.calf.transform.position - self.thigh.transform.position
|
185
|
+
inObjXAxisVec = self.thigh.objectTransform.row1
|
186
|
+
distanceDir = -1.0 if rt.dot(inObjXAxisVec, facingDirVec) > 0 else 1.0
|
187
|
+
|
188
|
+
rotConst = self.const.assign_rot_const_multi(self.thighRotHelper, [self.pelvisHelper, self.thighTwistHelper])
|
189
|
+
rotConst.setWeight(1, self.pelvisWeight * 100.0)
|
190
|
+
rotConst.setWeight(2, self.thighWeight * 100.0)
|
191
|
+
|
192
|
+
localRotRefTm = self.thighRotHelper.transform * rt.inverse(self.thighRotRootHelper.transform)
|
193
|
+
posConst = self.const.assign_pos_script_controller(self.thighPosHelper)
|
194
|
+
posConst.addNode("limb", self.thighRotHelper)
|
195
|
+
posConst.addNode("limbParent", self.thighRotRootHelper)
|
196
|
+
posConst.addConstant("localRotRefTm", localRotRefTm)
|
197
|
+
posConst.addConstant("pushAmount", self.pushAmount*distanceDir)
|
198
|
+
posConst.setExpression(self.posScriptExpression)
|
199
|
+
posConst.update()
|
200
|
+
|
201
|
+
def create_bone(self, inPelvis, inThigh, inThighTwist, inCalf, pushAmount=5.0, inPelvisWeight=0.6, inThighWeight=0.4):
|
202
|
+
if not rt.isValidNode(inPelvis) or not rt.isValidNode(inThigh) or not rt.isValidNode(inThighTwist):
|
203
|
+
return False
|
204
|
+
|
205
|
+
self.create_helper(inPelvis, inThigh, inThighTwist)
|
206
|
+
self.assing_constraint(inCalf, inPelvisWeight, inThighWeight, inPushAmount=pushAmount)
|
207
|
+
|
208
|
+
isLower = inThigh.name[0].islower()
|
209
|
+
hipBoneName = self.name.replace_name_part("RealName", inThigh.name, "Hip")
|
210
|
+
hipBone = self.bone.create_nub_bone(hipBoneName, 2)
|
211
|
+
hipBone.name = self.name.remove_name_part("Nub", hipBone.name)
|
212
|
+
if isLower:
|
213
|
+
hipBone.name = hipBone.name.lower()
|
214
|
+
|
215
|
+
rt.setProperty(hipBone, "transform", inThighTwist.transform)
|
216
|
+
hipBone.parent = inThigh
|
217
|
+
|
218
|
+
self.const.assign_rot_const(hipBone, self.thighRotHelper)
|
219
|
+
self.const.assign_pos_const(hipBone, self.thighPosHelper)
|
220
|
+
|
221
|
+
self.bones.append(hipBone)
|
222
|
+
|
223
|
+
# 결과를 딕셔너리 형태로 준비
|
224
|
+
result = {
|
225
|
+
"Pelvis": inPelvis,
|
226
|
+
"Thigh": inThigh,
|
227
|
+
"ThighTwist": inThighTwist,
|
228
|
+
"Bones": self.bones,
|
229
|
+
"Helpers": self.helpers,
|
230
|
+
"PelvisWeight": inPelvisWeight,
|
231
|
+
"ThighWeight": inThighWeight,
|
232
|
+
"PushAmount": pushAmount
|
233
|
+
}
|
234
|
+
|
235
|
+
# 메소드 호출 후 데이터 초기화
|
236
|
+
self.reset()
|
237
|
+
|
238
|
+
return result
|
239
|
+
|