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/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
- from .header import jal
11
-
12
-
13
- class Hip:
14
- """
15
- Hip 관련 기능을 제공하는 클래스.
16
- MAXScript의 _Hip 구조체 개념을 Python으로 재구현한 클래스이며,
17
- 3ds Max의 기능들을 pymxs API를 통해 제어합니다.
18
- """
19
-
20
- def __init__(self):
21
- """
22
- 클래스 초기화.
23
-
24
- Args:
25
- nameService: 이름 처리 서비스 (제공되지 않으면 새로 생성)
26
- animService: 애니메이션 서비스 (제공되지 않으면 새로 생성)
27
- helperService: 헬퍼 객체 관련 서비스 (제공되지 않으면 새로 생성)
28
- boneService: 뼈대 관련 서비스 (제공되지 않으면 새로 생성)
29
- constraintService: 제약 관련 서비스 (제공되지 않으면 새로 생성)
30
- bipService: Biped 관련 서비스 (제공되지 않으면 새로 생성)
31
- """
32
- # 서비스 초기화
33
- self.name = jal.name
34
- self.anim = jal.anim
35
- self.helper = jal.helper
36
- self.bone = jal.bone
37
- self.const = jal.constraint
38
- self.bip = jal.bip
39
-
40
- # 기본 속성 초기화
41
- self.bone_size = 2.0
42
- self.bone_array = []
43
- self.pelvis_weight = 60.0
44
- self.thigh_weight = 40.0
45
- self.x_axis_offset = 0.1
46
-
47
- # 객체 참조 초기화
48
- self.spine_dummy = None
49
- self.l_hip_dummy = None
50
- self.l_hip_target_dummy = None
51
- self.l_hip_exp = None
52
- self.r_hip_dummy = None
53
- self.r_hip_target_dummy = None
54
- self.r_hip_exp = None
55
-
56
- self.pelvis = None
57
- self.spine = None
58
- self.l_thigh = None
59
- self.l_thigh_twist = None
60
- self.r_thigh = None
61
- self.r_thigh_twist = None
62
-
63
- self.helper_array = []
64
-
65
- def init(self, in_bip, in_l_thigh_twist, in_r_thigh_twist,
66
- in_x_axis_offset=0.1,
67
- in_pelvis_weight=60.0, in_thigh_weight=40.0,
68
- in_bone_size=2.0):
69
-
70
- self.bone_size = in_bone_size
71
- self.x_axis_offset = in_x_axis_offset
72
-
73
- self.pelvis_weight = in_pelvis_weight
74
- self.thigh_weight = in_thigh_weight
75
-
76
- self.pelvis = self.bip.get_grouped_nodes(in_bip, "pelvis")[0]
77
- self.spine = rt.biped.getNode(in_bip, rt.Name("spine"), link=1)
78
- self.l_thigh = rt.biped.getNode(in_bip, rt.Name("lleg"), link=1)
79
- self.r_thigh = rt.biped.getNode(in_bip, rt.Name("rleg"), link=1)
80
- self.l_thigh_twist = in_l_thigh_twist
81
- self.r_thigh_twist = in_r_thigh_twist
82
-
83
- self.bone_array = []
84
- self.helper_array = []
85
-
86
- def assign_position_script(self, in_obj, in_exp, in_scale="0.1"):
87
- """
88
- 위치 스크립트 컨트롤러 할당
89
-
90
- Args:
91
- in_obj: 대상 객체
92
- in_exp: 표현식 객체 (ExposeTm)
93
- in_scale: 스케일 값 (문자열)
94
- """
95
- # 위치 리스트 컨트롤러 할당
96
- pos_list = self.const.assign_pos_list(in_obj)
97
-
98
- # 위치 스크립트 컨트롤러 생성
99
- pos_script = rt.position_script()
100
- rt.setPropertyController(pos_list, "Available", pos_script)
101
- pos_list.setActive(pos_list.count)
102
-
103
- # 표현식 객체 추가 및 스크립트 설정
104
- pos_script.AddNode("exp", in_exp)
105
- script_str = ""
106
- script_str += "zRotValue = amin 0.0 exp.localEulerZ\n"
107
- script_str += f"result = [0, zRotValue * {in_scale}, 0]\n"
108
- script_str += "result"
109
-
110
- pos_script.SetExpression(script_str)
111
- pos_script.Update()
112
-
113
- # 마지막 컨트롤러 활성화
114
- self.const.set_active_last(in_obj)
115
-
116
- def update_position_script_scale_value(self, in_obj, in_val):
117
- """
118
- 위치 스크립트 스케일 업데이트
119
-
120
- Args:
121
- in_obj: 대상 객체
122
- in_val: 스케일 값
123
- """
124
- # 위치 리스트 컨트롤러 가져오기
125
- pos_list = self.const.get_pos_list_controller(in_obj)
126
-
127
- if pos_list is not None and pos_list.count >= 3:
128
- # 위치 스크립트 컨트롤러 가져오기
129
- pos_script = rt.getPropertyController(pos_list, "Controller3")
130
-
131
- # pos_script가 Position_Script 형태인지 확인
132
- if rt.classOf(pos_script) == rt.Position_Script:
133
- new_scale = str(in_val)
134
- script_str = ""
135
- script_str += "zRotValue = amin 0.0 exp.localEulerZ\n"
136
- script_str += f"result = [0, zRotValue * {new_scale}, 0]\n"
137
- script_str += "result"
138
-
139
- pos_script.SetExpression(script_str)
140
- pos_script.Update()
141
-
142
- def gen_helpers(self):
143
- """
144
- 헬퍼 객체 생성
145
-
146
- Returns:
147
- 생성된 헬퍼 객체 배열
148
- """
149
- self.spine_dummy = self.helper.create_point(
150
- self.name.combine(in_base=self.base_name,
151
- in_type=self.name.get_dummyStr(),
152
- in_real_name="HipSpine",
153
- in_index="0",
154
- in_fil_char=self.filtering_char),
155
- box_toggle=True, cross_toggle=False, axis_toggle=False
156
- )
157
-
158
- self.l_hip_dummy = self.helper.create_point(
159
- self.name.combine(in_base=self.base_name,
160
- in_type=self.name.get_dummyStr(),
161
- in_side=self.name.get_leftStr(),
162
- in_real_name="Hip",
163
- in_index="0",
164
- in_fil_char=self.filtering_char),
165
- box_toggle=True, cross_toggle=False, axis_toggle=False
166
- )
167
-
168
- self.l_hip_target_dummy = self.helper.create_point(
169
- self.name.combine(in_base=self.base_name,
170
- in_type=self.name.get_dummyStr(),
171
- in_side=self.name.get_leftStr(),
172
- in_real_name="HipTgt",
173
- in_index="0",
174
- in_fil_char=self.filtering_char),
175
- box_toggle=False, cross_toggle=True, axis_toggle=False
176
- )
177
-
178
- # ExposeTm 객체 생성
179
- self.l_hip_exp = rt.ExposeTm(
180
- name=self.name.combine(in_base=self.base_name,
181
- in_type=self.name.get_exposeTMStr(),
182
- in_side=self.name.get_leftStr(),
183
- in_real_name="Hip",
184
- in_index="0",
185
- in_fil_char=self.filtering_char),
186
- size=1,
187
- boxToggle=True,
188
- crossToggle=False,
189
- wirecolor=rt.color(14, 255, 2)
190
- )
191
-
192
- self.r_hip_dummy = self.helper.create_point(
193
- self.name.combine(in_base=self.base_name,
194
- in_type=self.name.get_dummyStr(),
195
- in_side=self.name.get_rightStr(),
196
- in_real_name="Hip",
197
- in_index="0",
198
- in_fil_char=self.filtering_char),
199
- box_toggle=True, cross_toggle=False, axis_toggle=False
200
- )
201
-
202
- self.r_hip_target_dummy = self.helper.create_point(
203
- self.name.combine(in_base=self.base_name,
204
- in_type=self.name.get_dummyStr(),
205
- in_side=self.name.get_rightStr(),
206
- in_real_name="HipTgt",
207
- in_index="0",
208
- in_fil_char=self.filtering_char),
209
- box_toggle=False, cross_toggle=True, axis_toggle=False
210
- )
211
-
212
- # ExposeTm 객체 생성
213
- self.r_hip_exp = rt.ExposeTm(
214
- name=self.name.combine(in_base=self.base_name,
215
- in_type=self.name.get_exposeTMStr(),
216
- in_side=self.name.get_rightStr(),
217
- in_real_name="Hip",
218
- in_index="0",
219
- in_fil_char=self.filtering_char),
220
- size=1,
221
- boxToggle=True,
222
- crossToggle=False,
223
- wirecolor=rt.color(14, 255, 2)
224
- )
225
-
226
- self.helper_array = []
227
- self.helper_array.append(self.spine_dummy)
228
- self.helper_array.append(self.l_hip_dummy)
229
- self.helper_array.append(self.l_hip_target_dummy)
230
- self.helper_array.append(self.l_hip_exp)
231
- self.helper_array.append(self.r_hip_dummy)
232
- self.helper_array.append(self.r_hip_target_dummy)
233
- self.helper_array.append(self.r_hip_exp)
234
-
235
- return self.helper_array
236
-
237
- def create(self):
238
- """
239
- Hip 리깅 생성
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
+