pyjallib 0.1.9__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 +97 -132
- pyjallib/max/autoClavicleChain.py +173 -0
- pyjallib/max/bip.py +211 -14
- pyjallib/max/bone.py +341 -16
- pyjallib/max/groinBone.py +116 -77
- pyjallib/max/groinBoneChain.py +173 -0
- pyjallib/max/header.py +42 -6
- pyjallib/max/helper.py +3 -21
- pyjallib/max/hip.py +239 -366
- 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 +258 -475
- 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-0.1.9.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 -209
- pyjallib/p4module.py +0 -488
- pyjallib-0.1.9.dist-info/RECORD +0 -41
- {pyjallib-0.1.9.dist-info → pyjallib-0.1.10.dist-info}/WHEEL +0 -0
pyjallib/max/hip.py
CHANGED
@@ -1,366 +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
|
-
|
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
|
-
self.
|
44
|
-
self.
|
45
|
-
self.
|
46
|
-
|
47
|
-
#
|
48
|
-
self.
|
49
|
-
self.
|
50
|
-
self.
|
51
|
-
|
52
|
-
self.
|
53
|
-
self.
|
54
|
-
self.
|
55
|
-
|
56
|
-
|
57
|
-
self.
|
58
|
-
self.
|
59
|
-
self.
|
60
|
-
self.
|
61
|
-
self.
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
self.
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
"""
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
)
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
self.
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
)
|
177
|
-
|
178
|
-
|
179
|
-
self.
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
)
|
191
|
-
|
192
|
-
self.
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
)
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
"""
|
241
|
-
self.gen_helpers()
|
242
|
-
|
243
|
-
self.l_hip_dummy.transform = self.l_thigh_twist.transform
|
244
|
-
self.r_hip_dummy.transform = self.r_thigh_twist.transform
|
245
|
-
|
246
|
-
self.const.assign_pos_const(self.spine_dummy, self.spine)
|
247
|
-
self.const.assign_rot_const_multi(self.spine_dummy, [self.l_thigh_twist, self.r_thigh_twist])
|
248
|
-
self.const.collapse(self.spine_dummy)
|
249
|
-
|
250
|
-
self.l_hip_dummy.parent = self.pelvis
|
251
|
-
self.l_hip_target_dummy.parent = self.pelvis
|
252
|
-
self.l_hip_exp.parent = self.pelvis
|
253
|
-
self.r_hip_dummy.parent = self.pelvis
|
254
|
-
self.r_hip_target_dummy.parent = self.pelvis
|
255
|
-
self.r_hip_exp.parent = self.pelvis
|
256
|
-
self.spine_dummy.parent = self.pelvis
|
257
|
-
|
258
|
-
# 왼쪽 hip dummy의 rotation constraint 설정
|
259
|
-
self.const.assign_rot_list(self.l_hip_dummy)
|
260
|
-
rot_const = rt.Orientation_Constraint()
|
261
|
-
rot_list = self.const.get_rot_list_controller(self.l_hip_dummy)
|
262
|
-
rt.setPropertyController(rot_list, "Available", rot_const)
|
263
|
-
rot_list.setActive(rot_list.count)
|
264
|
-
|
265
|
-
# Constraint 타겟 추가
|
266
|
-
rot_const.appendTarget(self.spine_dummy, self.pelvis_weight)
|
267
|
-
rot_const.appendTarget(self.l_thigh_twist, self.thigh_weight)
|
268
|
-
rot_const.relative = True
|
269
|
-
|
270
|
-
# 오른쪽 hip dummy의 rotation constraint 설정
|
271
|
-
self.const.assign_rot_list(self.r_hip_dummy)
|
272
|
-
rot_const = rt.Orientation_Constraint()
|
273
|
-
rot_list = self.const.get_rot_list_controller(self.r_hip_dummy)
|
274
|
-
rt.setPropertyController(rot_list, "Available", rot_const)
|
275
|
-
rot_list.setActive(rot_list.count)
|
276
|
-
|
277
|
-
# Constraint 타겟 추가
|
278
|
-
rot_const.appendTarget(self.spine_dummy, self.pelvis_weight)
|
279
|
-
rot_const.appendTarget(self.r_thigh_twist, self.thigh_weight)
|
280
|
-
rot_const.relative = True
|
281
|
-
|
282
|
-
self.l_hip_target_dummy.transform = self.l_hip_dummy.transform
|
283
|
-
self.l_hip_exp.transform = self.l_hip_dummy.transform
|
284
|
-
self.r_hip_target_dummy.transform = self.r_hip_dummy.transform
|
285
|
-
self.r_hip_exp.transform = self.r_hip_dummy.transform
|
286
|
-
|
287
|
-
self.l_hip_exp.exposeNode = self.l_hip_dummy
|
288
|
-
self.l_hip_exp.localReferenceNode = self.l_hip_target_dummy
|
289
|
-
self.l_hip_exp.useParent = False
|
290
|
-
|
291
|
-
self.r_hip_exp.exposeNode = self.r_hip_dummy
|
292
|
-
self.r_hip_exp.localReferenceNode = self.r_hip_target_dummy
|
293
|
-
self.r_hip_exp.useParent = False
|
294
|
-
|
295
|
-
self.bone_array = []
|
296
|
-
|
297
|
-
# 왼쪽 Hip 본 생성
|
298
|
-
l_hip_bone = self.bone.create_simple_bone(
|
299
|
-
(self.bone_size * 2),
|
300
|
-
self.name.combine(
|
301
|
-
in_base=self.base_name,
|
302
|
-
in_side=self.name.get_leftStr(),
|
303
|
-
in_real_name="Hip",
|
304
|
-
in_fil_char=self.filtering_char
|
305
|
-
),
|
306
|
-
size=self.bone_size
|
307
|
-
)
|
308
|
-
|
309
|
-
l_hip_bone[0].transform = self.l_thigh.transform
|
310
|
-
self.anim.rotate_local(
|
311
|
-
l_hip_bone[0],
|
312
|
-
(self.rot_dir[0] * 0),
|
313
|
-
(self.rot_dir[1] * 0),
|
314
|
-
(self.rot_dir[2] * 90)
|
315
|
-
)
|
316
|
-
l_hip_bone[0].parent = self.l_hip_dummy
|
317
|
-
self.bone_array.append(l_hip_bone[0])
|
318
|
-
self.bone_array.append(l_hip_bone[1])
|
319
|
-
|
320
|
-
# 오른쪽 Hip 본 생성
|
321
|
-
r_hip_bone = self.bone.create_simple_bone(
|
322
|
-
(self.bone_size * 2),
|
323
|
-
self.name.combine(
|
324
|
-
in_base=self.base_name,
|
325
|
-
in_side=self.name.get_rightStr(),
|
326
|
-
in_real_name="Hip",
|
327
|
-
in_fil_char=self.filtering_char
|
328
|
-
),
|
329
|
-
size=self.bone_size
|
330
|
-
)
|
331
|
-
|
332
|
-
r_hip_bone[0].transform = self.r_thigh.transform
|
333
|
-
self.anim.rotate_local(
|
334
|
-
r_hip_bone[0],
|
335
|
-
(self.rot_dir[0] * 0),
|
336
|
-
(self.rot_dir[1] * 0),
|
337
|
-
(self.rot_dir[2] * 90)
|
338
|
-
)
|
339
|
-
r_hip_bone[0].parent = self.r_hip_dummy
|
340
|
-
self.bone_array.append(r_hip_bone[0])
|
341
|
-
self.bone_array.append(r_hip_bone[1])
|
342
|
-
|
343
|
-
# 위치 스크립트 설정
|
344
|
-
self.assign_position_script(l_hip_bone[0], self.l_hip_exp, in_scale=str(self.x_axis_offset))
|
345
|
-
self.assign_position_script(r_hip_bone[0], self.r_hip_exp, in_scale=str(self.x_axis_offset))
|
346
|
-
|
347
|
-
def del_all(self):
|
348
|
-
"""
|
349
|
-
모든 생성된 본과 헬퍼 객체 삭제
|
350
|
-
"""
|
351
|
-
self.bone.delete_bones_safely(self.bone_array)
|
352
|
-
self.bone.delete_bones_safely(self.helper_array)
|
353
|
-
|
354
|
-
def set_weight(self, in_pelvis_weight, in_thigh_weight):
|
355
|
-
"""
|
356
|
-
골반과 허벅지 가중치 설정
|
357
|
-
|
358
|
-
Args:
|
359
|
-
in_pelvis_weight: 골반 가중치
|
360
|
-
in_thigh_weight: 허벅지 가중치
|
361
|
-
"""
|
362
|
-
self.del_all()
|
363
|
-
self.pelvis_weight = in_pelvis_weight
|
364
|
-
self.thigh_weight = in_thigh_weight
|
365
|
-
|
366
|
-
self.create()
|
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
|
+
|