Skip to content

Commit

Permalink
Merge pull request #8 from miu200521358/develop
Browse files Browse the repository at this point in the history
ver2.01.01
  • Loading branch information
miu200521358 authored Nov 19, 2022
2 parents 42cc28e + 4c3bd9b commit e1e4d07
Show file tree
Hide file tree
Showing 20 changed files with 393 additions and 57 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,6 @@ dmypy.json

history.json
*.zip
src/example.py
test/resources/サンプルモデル.pmx
test/resources/サンプルモーション.vmd
9 changes: 9 additions & 0 deletions archive/β版Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
���@rivision
----------------------------------------------------------------

Vroid2Pmx_2.01.01_��03 (2022/11/04) miumiu
�E�e�w�̊p�x��␳���鏈����lj�

Vroid2Pmx_2.01.01_��02 (2022/09/18)
�E��֘A���_���Ȃ������ꍇ�ɁA�㕪���������X�L�b�v����悤����lj�

Vroid2Pmx_2.01.01_��01 (2022/08/06)
�E�lj��e�N�X�`���ǂݍ��ݎ���Permission�G���[���o��ꍇ���������̂��C��

Vroid2Pmx_2.01.00_��02 (2022/07/12)
�E�g�̍��̂̏d���ύX�i���d���z�����ɏ��Ă�悤�j
�E��������PmxTailor�p�ݒ�t�@�C�����������̔���~�X���Ă��̂ŏC��
Expand Down
16 changes: 13 additions & 3 deletions rivision.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@ Vroid2Pmx_2.01.00_
�E�g�̍��̂̏d���ύX�i���d���z�����ɏ��Ă�悤�j
�E��������PmxTailor�p�ݒ�t�@�C�����������̔���~�X���Ă��̂ŏC��

https://fire.st/ppnorQy
Vroid2Pmx_2.01.01_��01 (2022/08/06) miumiu
�E�lj��e�N�X�`���ǂݍ��ݎ���Permission�G���[���o��ꍇ���������̂��C��

https://fire.st/lcIKYIg
Vroid2Pmx_2.01.01_��02 (2022/09/18) miumiu
�E��֘A���_���Ȃ������ꍇ�ɁA�㕪���������X�L�b�v����悤����lj�

https://fire.st/trLePJj
Vroid2Pmx_2.01.01_��03 (2022/11/03) miumiu
�E�e�w�̊p�x��␳���鏈����lj�


Vroid2Pmx_1.01.00_��13 ���������[�X���܂����I
Expand All @@ -278,10 +289,9 @@ https://com.nicovideo.jp/community/co5387214



https://fire.st/pXqiu5x
https://fire.st/trLePJj
<br>
<br>
�E�g�̍��̂̏d���ύX�i���d���z�����ɏ��Ă�悤�j<br>
�E��������PmxTailor�p�ݒ�t�@�C�����������̔���~�X���Ă��̂ŏC��<br>
�E�e�w�̊p�x��␳���鏈����lj�<br>
<br>
���Ўg���Ă��������āA���z�E�s��񍐓����肢�������܂��B<br>
2 changes: 1 addition & 1 deletion src/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from utils.MLogger import MLogger
from utils import MFileUtils

VERSION_NAME = "2.01.00"
VERSION_NAME = "2.01.01"

# 指数表記なし、有効小数点桁数6、30を超えると省略あり、一行の文字数200
np.set_printoptions(suppress=True, precision=6, threshold=30, linewidth=200)
Expand Down
4 changes: 3 additions & 1 deletion src/locale/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,5 +409,7 @@
"-- PmxTailor用設定ファイル出力準備2": "--Preparation for output of configuration file for PmxTailor 2",
"-- -- PmxTailor用設定ファイル出力準備2 (%s)": "---- Preparation for output of configuration file for PmxTailor 2 ( %s)",
"-- 身体剛体準備終了": "--Completion of body rigid body preparation",
"-- -- 身体剛体[%s]": "---- Body Rigid Body [ %s]"
"-- -- 身体剛体[%s]": "---- Body Rigid Body [ %s]",
"舌関連頂点が見つからなかったため、舌分離処理をスキップします": "No tongue-related vertices found, skipping tongue separation processing",
"-- Aスタンス・親指調整終了": "-- Finished A stance/thumb adjustment"
}
4 changes: 3 additions & 1 deletion src/locale/ja_JP/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,5 +409,7 @@
"-- PmxTailor用設定ファイル出力準備2": "-- PmxTailor用設定ファイル出力準備2",
"-- -- PmxTailor用設定ファイル出力準備2 (%s)": "-- -- PmxTailor用設定ファイル出力準備2 (%s)",
"-- 身体剛体準備終了": "-- 身体剛体準備終了",
"-- -- 身体剛体[%s]": "-- -- 身体剛体[%s]"
"-- -- 身体剛体[%s]": "-- -- 身体剛体[%s]",
"舌関連頂点が見つからなかったため、舌分離処理をスキップします": "舌関連頂点が見つからなかったため、舌分離処理をスキップします",
"-- Aスタンス・親指調整終了": "-- Aスタンス・親指調整終了"
}
4 changes: 3 additions & 1 deletion src/locale/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -412,5 +412,7 @@
"-- PmxTailor用設定ファイル出力準備2": "-- 准备输出 PmxTailor 2 的配置文件",
"-- -- PmxTailor用設定ファイル出力準備2 (%s)": "---- 准备输出 PmxTailor 2 的配置文件 (%s)",
"-- 身体剛体準備終了": "--完成刚体刚体准备",
"-- -- 身体剛体[%s]": "---- Body 刚体 [%s]"
"-- -- 身体剛体[%s]": "---- Body 刚体 [%s]",
"舌関連頂点が見つからなかったため、舌分離処理をスキップします": "未找到舌相关顶点,跳过舌分离处理",
"-- Aスタンス・親指調整終了": "-- 完成了姿势/拇指调整"
}
119 changes: 70 additions & 49 deletions src/service/VroidExportService.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def vroid2pmx(self):
if not model:
return False

model = self.transfer_astance(model)
model = self.transfer_stance(model)
if not model:
return False

Expand Down Expand Up @@ -788,7 +788,7 @@ def create_body_rigidbody(self, model: PmxModel):

return model

def transfer_astance(self, model: PmxModel):
def transfer_stance(self, model: PmxModel):
# 各頂点
all_vertex_relative_poses = {}
for vertex in model.vertex_dict.values():
Expand Down Expand Up @@ -851,22 +851,38 @@ def transfer_astance(self, model: PmxModel):
trans_vs = MServiceUtils.calc_relative_position(model, bone_links, VmdMotion(), 0)

if "右" in ",".join(list(bone_links.all().keys())):
astance_qq = MQuaternion.fromEulerAngles(0, 0, 35)
arm_astance_qq = MQuaternion.fromEulerAngles(0, 0, 35)
arm_bone_name = "右腕"
thumb0_stance_qq = MQuaternion.fromEulerAngles(0, 8, 0)
thumb0_bone_name = "右親指0"
thumb1_stance_qq = MQuaternion.fromEulerAngles(0, 24, 0)
thumb1_bone_name = "右親指1"
elif "左" in ",".join(list(bone_links.all().keys())):
astance_qq = MQuaternion.fromEulerAngles(0, 0, -35)
arm_astance_qq = MQuaternion.fromEulerAngles(0, 0, -35)
arm_bone_name = "左腕"
thumb0_stance_qq = MQuaternion.fromEulerAngles(0, -8, 0)
thumb0_bone_name = "左親指0"
thumb1_stance_qq = MQuaternion.fromEulerAngles(0, -24, 0)
thumb1_bone_name = "左親指1"
else:
astance_qq = MQuaternion.fromEulerAngles(0, 0, 0)
arm_astance_qq = MQuaternion.fromEulerAngles(0, 0, 0)
arm_bone_name = ""
thumb0_bone_name = ""
thumb1_bone_name = ""

mat = MMatrix4x4()
mat.setToIdentity()
for vi, (bone_name, trans_v) in enumerate(zip(bone_links.all().keys(), trans_vs)):
mat.translate(trans_v)
if bone_name == arm_bone_name:
# 腕だけ回転させる
mat.rotate(astance_qq)
# 腕回転させる
mat.rotate(arm_astance_qq)
elif bone_name == thumb0_bone_name:
# 親指0回転させる
mat.rotate(thumb0_stance_qq)
elif bone_name == thumb1_bone_name:
# 親指1回転させる
mat.rotate(thumb1_stance_qq)

if bone_name not in trans_bone_vecs:
trans_bone_vecs[bone_name] = mat * MVector3D()
Expand Down Expand Up @@ -1005,7 +1021,7 @@ def transfer_astance(self, model: PmxModel):
model.vertex_dict[vertex_idx].position = vertex_vec
model.vertex_dict[vertex_idx].normal = vertex_normal.normalized()

logger.info("-- Aスタンス調整終了")
logger.info("-- Aスタンス・親指調整終了")

return model

Expand Down Expand Up @@ -1733,51 +1749,56 @@ def reconvert_bone(self, model: PmxModel):
tongue_poses.append(v.position.data())
v.deform = Bdef1(model.bones["舌1"].index)

# 舌ボーン位置配置
tongue1_pos = np.max(tongue_poses, axis=0)
model.bones["舌1"].position = MVector3D(0, tongue1_pos[1], tongue1_pos[2])
tongue4_pos = np.min(tongue_poses, axis=0)
model.bones["舌4"].position = MVector3D(0, tongue4_pos[1], tongue4_pos[2])
model.bones["舌2"].position = model.bones["舌1"].position + (
(model.bones["舌4"].position - model.bones["舌1"].position) * 0.4
)
model.bones["舌3"].position = model.bones["舌1"].position + (
(model.bones["舌4"].position - model.bones["舌1"].position) * 0.7
)

for from_bone_name, to_bone_name in [("舌1", "舌2"), ("舌2", "舌3"), ("舌3", "舌4")]:
# ローカル軸
model.bones[from_bone_name].local_x_vector = (
model.bones[to_bone_name].position - model.bones[from_bone_name].position
).normalized()
model.bones[from_bone_name].local_z_vector = MVector3D.crossProduct(
model.bones[from_bone_name].local_x_vector, MVector3D(0, -1, 0)
).normalized()
model.bones["舌4"].local_x_vector = model.bones["舌3"].local_x_vector.copy()
model.bones["舌4"].local_z_vector = model.bones["舌3"].local_z_vector.copy()
if tongue_poses and tongue_vertices and tongue_vidxs:
# 舌ボーン位置配置
tongue1_pos = np.max(tongue_poses, axis=0)
model.bones["舌1"].position = MVector3D(0, tongue1_pos[1], tongue1_pos[2])
tongue4_pos = np.min(tongue_poses, axis=0)
model.bones["舌4"].position = MVector3D(0, tongue4_pos[1], tongue4_pos[2])
model.bones["舌2"].position = model.bones["舌1"].position + (
(model.bones["舌4"].position - model.bones["舌1"].position) * 0.4
)
model.bones["舌3"].position = model.bones["舌1"].position + (
(model.bones["舌4"].position - model.bones["舌1"].position) * 0.7
)

for vertex in tongue_vertices:
for from_bone_name, to_bone_name in [("舌1", "舌2"), ("舌2", "舌3"), ("舌3", "舌4")]:
tongue_distance = model.bones[to_bone_name].position.z() - model.bones[from_bone_name].position.z()
vertex_distance = vertex.position.z() - model.bones[from_bone_name].position.z()

if np.sign(tongue_distance) == np.sign(vertex_distance):
# 範囲内である場合、ウェイト分布
vertex.deform = Bdef2(
model.bones[to_bone_name].index,
model.bones[from_bone_name].index,
vertex_distance / tongue_distance,
# ローカル軸
model.bones[from_bone_name].local_x_vector = (
model.bones[to_bone_name].position - model.bones[from_bone_name].position
).normalized()
model.bones[from_bone_name].local_z_vector = MVector3D.crossProduct(
model.bones[from_bone_name].local_x_vector, MVector3D(0, -1, 0)
).normalized()
model.bones["舌4"].local_x_vector = model.bones["舌3"].local_x_vector.copy()
model.bones["舌4"].local_z_vector = model.bones["舌3"].local_z_vector.copy()

for vertex in tongue_vertices:
for from_bone_name, to_bone_name in [("舌1", "舌2"), ("舌2", "舌3"), ("舌3", "舌4")]:
tongue_distance = (
model.bones[to_bone_name].position.z() - model.bones[from_bone_name].position.z()
)
vertex_distance = vertex.position.z() - model.bones[from_bone_name].position.z()

if np.sign(tongue_distance) == np.sign(vertex_distance):
# 範囲内である場合、ウェイト分布
vertex.deform = Bdef2(
model.bones[to_bone_name].index,
model.bones[from_bone_name].index,
vertex_distance / tongue_distance,
)

# 舌頂点モーフを削除
for morph in model.org_morphs.values():
if morph.morph_type == 1:
# 頂点モーフの場合
without_tongue_offsets = []
for offset in morph.offsets:
if offset.vertex_index not in tongue_vidxs:
without_tongue_offsets.append(offset)
morph.offsets = without_tongue_offsets
# 舌頂点モーフを削除
for morph in model.org_morphs.values():
if morph.morph_type == 1:
# 頂点モーフの場合
without_tongue_offsets = []
for offset in morph.offsets:
if offset.vertex_index not in tongue_vidxs:
without_tongue_offsets.append(offset)
morph.offsets = without_tongue_offsets
else:
logger.warning("舌関連頂点が見つからなかったため、舌分離処理をスキップします", decoration=MLogger.DECORATION_BOX)

logger.info("-- ボーンデータ調整終了")

Expand Down
2 changes: 1 addition & 1 deletion vroid2pmx.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exe = EXE(pyz,
a.zipfiles,
a.datas,
[],
name='Vroid2Pmx_2.01.00',
name='Vroid2Pmx_2.01.01',
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand Down
Loading

0 comments on commit e1e4d07

Please sign in to comment.