Skip to content

Commit

Permalink
Merge pull request #19 from miu200521358/work_4.03
Browse files Browse the repository at this point in the history
Work 4.03
  • Loading branch information
miu200521358 authored Dec 17, 2019
2 parents b086ed2 + 14574a0 commit c2b8596
Show file tree
Hide file tree
Showing 13 changed files with 1,737 additions and 825 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* text=auto
*.bat text eol=crlf
*.csv text eol=crlf
*.spec text encoding=cp932
*.spec text encoding=shift-jis
56 changes: 56 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
// IntelliSense を使用して利用可能な属性を学べます。
// 既存の属性の説明をホバーして表示します。
// 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: debug_exec",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"pythonPath": "${config:python.pythonPath}",
"stopOnEntry": true,
"args": [
"--vmd_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Motion/ダンス_1人/アンノウン・マザーグース【フィンガータットモーション】 しぱ/アンノウンマザーグース【フィンガータットモーション】1.00.vmd",
// "--vmd_path", "C:/MMD/vmd_sizing/vmd/膝丸_初期手合わせ.vmd",
// "--vmd_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Motion/ダンス_1人/馬と鹿 づなうじ/馬と鹿all3.vmd",
"--trace_pmx_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/刀剣乱舞/112_膝丸/膝丸mkmk009b 刀剣乱舞/膝丸mkmk009b/膝丸mkmk009b.pmx",
// "--trace_pmx_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/艦隊これくしょん/舞風ver2 お宮/舞風ver2武装無し.pmx",
// "--replace_pmx_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/刀剣乱舞/112_膝丸/膝丸1.0 おおかみ/膝丸.pmx",
// "--replace_pmx_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/VOCALOID/鏡音リン/めんぼう式 鏡音リン Ver1.02/めんぼう式 鏡音リン ver1.02.pmx",
// "--replace_pmx_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/VOCALOID/初音ミク/どっと式初音ミク_V3_ver.1.41/どっと式初音ミク_V3.pmx",
// "--replace_pmx_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/漫画/ゴールデンカムイ/サクラコ式尾形百之助ver1.41/サクラコ式尾形百之助(軍服ベルト脚絆無し)ver1.41.pmx",
// "--replace_pmx_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/刀剣乱舞/118_へし切長谷部/へし切長谷部 柴尾式 ver3.0/柴尾式へし切長谷部ver3.0_シャツ.pmx",
// "--replace_pmx_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/刀剣乱舞/025_一期一振/一期一振 peco式 20190316/一期一振_通常衣装_ver1.00.pmx",
"--replace_pmx_path", "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/刀剣乱舞/039_前田藤四郎/前田藤四郎 酢烏賊式 v1.35/前田藤四郎_通常.pmx",
"--avoidance", "0",
"--avoidance_finger", "0",
"--hand_ik", "1",
"--hand_distance", "1.7",
"--floor_hand", "0",
"--floor_hand_up", "1",
"--floor_hand_down", "1",
"--hand_floor_distance", "1.8",
"--leg_floor_distance", "1.5",
"--finger_ik", "1",
"--finger_distance", "1.4",
"--vmd_choice_values", "",
"--rep_choice_values", "",
"--rep_rate_values", "",
"--camera_vmd_path", "",
"--camera_pmx_path", "",
"--camera_y_offset", "0",
"--verbose", "2",
]
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
2 changes: 1 addition & 1 deletion VmdSizing_64bit.spec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exe = EXE(pyz,
a.zipfiles,
a.datas,
[],
name='VmdSizing_4.02_64bit',
name='VmdSizing_4.04_64bit',
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand Down
14 changes: 12 additions & 2 deletions archive/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

�@�uVMD�T�C�W���O�@���[�J���Łv

�@�@ver4.02
�@�@ver4.04

�@�@�@�@�@�@�@�@�@�@�@�@�@�@�@�@�@miu200521358

Expand Down Expand Up @@ -33,6 +33,7 @@
�@�D�@�˂�ǂ땗�ȂǓ��g���傫���قȂ�A���`�㔼�g�Ɏ肪�ђʂ��Ă��܂��ꍇ�ɁA
�@�@�@���Ǝ�̐ڐG������s�����Ƃ��ł��܂��B
�@�E�@������킹��Ȃǂ̃��[�V�����ŁA���̈ʒu���킹�������s�����Ƃ��ł��܂��B(ver3.00)
�@�@�@�t�B���K�[�^�b�g���[�V�����ɂ��Ή����܂���(ver4.03)
�@�F�@���Ɏ���‚�����A�Q�]�񂾂肷�郂�[�V�����ŁA���Ƃ̈ʒu���킹�������s�����Ƃ��ł��܂��B(ver4.00)
�@�G�@�J�������[�V������ϊ��惂�f���ɍ��킹�āA�ʒu�⋗���𒲐��ł��܂��B(ver4.00)

Expand All @@ -49,7 +50,7 @@

�� �����t�@�C���@------------------------------------

�@�EVMDSizing_4.02_xxbit.exe�@�@�@�c�@�c�[���{��(32bit�� or 64bit��)
�@�EVMDSizing_4.04_xxbit.exe�@�@�@�c�@�c�[���{��(32bit�� or 64bit��)
�@�EReadme.txt�@�@�@�@�@�@�@�@�@�@�c�@���h�~
�@�EVMD�T�C�W���OWiki�@�@�@�@�@�@ �c�@Wiki�ւ̃����N
�@�E���[�t�u���T���v���@�@�@�@�@�@�c�@���[�t�u���̃T���v���W�i�ڍׂ͒��Q�Ɓj
Expand Down Expand Up @@ -140,6 +141,15 @@ https://github.com/miu200521358/vmd_sizing

�� �����@----------------------------------------

ver4.04�@�i2019/12/10�j
�@�@�EBugix: ���ʒu���킹�I�v�V�����Łu�Ӑ}���ʃG���[�v���������Ă����̂��C��

ver4.03�@�i2019/12/04�j
�@�@�E�t�B���K�[�^�b�g���[�V�����p�Ɂu�w�ʒu���킹�v�I�v�V�����lj�
�@�@�E���ʒu���킹�I�v�V�����̏����𒲐�
�@�@�E���ʒu���킹�I�v�V�����̃Z���^�[�㉺�p�����[�^�[�������
�@�@�EBugix: ���ʒu���킹�I�v�V�����Łu�Ӑ}���ʃG���[�v���������Ă����̂��C��

ver4.02�@�i2019/11/17�j
�@�@�E���ʒu���킹�I�v�V�����̎��⑫�Ə��̋����������p�����[�^�[�O����
�@�@�E�e�{�[����H�鏈���ŁA�z�ŽQ�ƂŖ������[�v�G���[�ɂȂ����ꍇ�Ɍx�����b�Z�[�W���o�͂���悤�����lj�
Expand Down
46 changes: 44 additions & 2 deletions src/PmxModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def get_bone_vertex_position(self, bone_name, bone_pos, is_target=None, is_only=
bone_idx_list = []
for bk, bv in self.bones.items():
if ((not is_only and bone_name in bk) or (is_only and bone_name == bk)) and bv.index in self.vertices :
logger.info("bk: %s, bv: %s", bk, bv.index)
logger.debug("bk: %s, bv: %s", bk, bv.index)
# ボーン名が指定文字列を含んでおり、かつそのボーンにウェイトが乗っている頂点がある場合、対象
# 特定ボーンのみの場合、ボーン名が一致していることが条件
bone_idx_list.append(bv.index)
Expand All @@ -247,7 +247,7 @@ def get_bone_vertex_position(self, bone_name, bone_pos, is_target=None, is_only=
# ウェイトボーンがない場合、初期値
return QVector3D(), QVector3D(), QVector3D(), QVector3D(), None, None, None, None

logger.info("model: %s, bone_name: %s, bone_idx_list:%s", self.name, bone_name, bone_idx_list)
logger.debug("model: %s, bone_name: %s, bone_idx_list:%s", self.name, bone_name, bone_idx_list)

max_bone_upper_pos = QVector3D(0, -99999, 0)
min_bone_below_pos = QVector3D(0, 99999, 0)
Expand Down Expand Up @@ -385,6 +385,43 @@ def get_wrist_vertex_position(self, direction, arm_qq, wrist_pos):
break

return max_wrist_upper_pos, min_wrist_below_pos

# 指ウェイトの末端頂点の位置を取得する
def get_finger_end_vertex(self, direction, finger_name):
arm_qq = self.calc_arm_stance_rotation(direction)

# 指定ボーン名を含むボーンINDEXリスト
bone_idx_list = []
for bk, bv in self.bones.items():
if "{0}{1}".format(direction, finger_name) in bk and bv.index in self.vertices:
# ボーン名が指定文字列を含んでおり、かつそのボーンにウェイトが乗っている頂点がある場合、対象
bone_idx_list.append(bv.index)

if len(bone_idx_list) == 0:
# ウェイトボーンがない場合、初期値
return QVector3D(), 0

finger_end_vertex = 0
finger_end_pos = QVector3D()
finger_end_vertex_pos = QVector3D()
for bone_idx in bone_idx_list:
for v in self.vertices[bone_idx]:
# 一旦水平にしたときの頂点位置を算出
v_pos = arm_qq.inverted().rotatedVector(v.position - self.bones["{0}ひじ".format(direction)].position)

if direction == "左" and v_pos.x() > finger_end_pos.x():
# 指ボーンにウェイトが乗っていて、かつ末端より大きい(左)の場合、保持
finger_end_pos = v_pos
finger_end_vertex = v.index
finger_end_vertex_pos = v.position

if direction == "右" and v_pos.x() < finger_end_pos.x():
# 指ボーンにウェイトが乗っていて、かつ末端より小さい(右)の場合、保持
finger_end_pos = v_pos
finger_end_vertex = v.index
finger_end_vertex_pos = v.position

return finger_end_vertex_pos, finger_end_vertex

# 自身の腕の角度を算出する
def calc_arm_stance_rotation(self, direction):
Expand Down Expand Up @@ -651,22 +688,27 @@ def create_link_2_top(self, start_bone, ik_links=None, ik_indexes=None):
, "右親指0": ["右手首"]
, "右親指1": ["右親指0", "右手首"]
, "右親指2": ["右親指1"]
, "右親指先": ["右親指2"]
, "右人指0": ["右手首"]
, "右人指1": ["右人指0", "右手首"]
, "右人指2": ["右人指1"]
, "右人指3": ["右人指2"]
, "右人指先": ["右人指3"]
, "右中指0": ["右手首"]
, "右中指1": ["右中指0", "右手首"]
, "右中指2": ["右中指1"]
, "右中指3": ["右中指2"]
, "右中指先": ["右中指3"]
, "右薬指0": ["右手首"]
, "右薬指1": ["右薬指0", "右手首"]
, "右薬指2": ["右薬指1"]
, "右薬指3": ["右薬指2"]
, "右薬指先": ["右薬指3"]
, "右小指0": ["右手首"]
, "右小指1": ["右小指0", "右手首"]
, "右小指2": ["右小指1"]
, "右小指3": ["右小指2"]
, "右小指先": ["右小指3"]
, "右足": ["下半身"]
, "右ひざ": ["右足"]
, "右足首": ["右ひざ"]
Expand Down
36 changes: 36 additions & 0 deletions src/PmxReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,22 @@ def read_pmx_file(self, filepath):
pmx.bones[bone.name] = bone
# インデックス逆引きも登録
pmx.bone_indexes[bone.index] = bone.name

# 指先ボーンがない場合、代替で挿入
for direction in ["左", "右"]:
for (finger_name, end_joint_name) in [("親指", "2"), ("人指", "3"), ("中指", "3"), ("薬指", "3"), ("小指", "3")]:
end_joint_name = "{0}{1}{2}".format(direction, finger_name, end_joint_name)
to_joint_name = "{0}{1}{2}".format(direction, finger_name, "先")

if to_joint_name not in pmx.bones:
_, to_pos = self.calc_tail_pos(pmx, end_joint_name)
to_bone = pmx.Bone(to_joint_name, None, to_pos, -1, 0, 0)

# ボーンのINDEX
to_bone.index = len(pmx.bones.keys())
pmx.bones[to_bone.name] = to_bone
# インデックス逆引きも登録
pmx.bone_indexes[to_bone.index] = to_bone.name

logger.debug("len(bones): %s", len(pmx.bones))

Expand Down Expand Up @@ -650,3 +666,23 @@ def unpack(self, format_size, format):
result = None

return result


# 指定されたボーンの先を取得する
def calc_tail_pos(self, model, fbone):
from_pos = QVector3D()
tail_pos = QVector3D()
to_pos = QVector3D()

if fbone in model.bones:
fv = model.bones[fbone]
from_pos = fv.position
if fv.tail_position != QVector3D():
# 表示先が相対パスの場合、保持
tail_pos = fv.tail_position
to_pos = from_pos + tail_pos
elif fv.tail_index >= 0:
to_pos = model.bones[model.bone_indexes[fv.tail_index]].position
tail_pos = to_pos - from_pos

return tail_pos, to_pos
Loading

0 comments on commit c2b8596

Please sign in to comment.