From a1130dc2630afb9e29082d915f763a93f01aa944 Mon Sep 17 00:00:00 2001 From: HENDRIX-ZT2 Date: Tue, 26 Sep 2023 16:05:31 +0200 Subject: [PATCH] banis - wrap the rot range --- generated/formats/bani/__init__.py | 10 ++++++++-- plugin/export_banis.py | 4 ++-- source/formats/bani/__init__.py | 10 ++++++++-- version.txt | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/generated/formats/bani/__init__.py b/generated/formats/bani/__init__.py index 8c83f3a4e..cfce348cd 100644 --- a/generated/formats/bani/__init__.py +++ b/generated/formats/bani/__init__.py @@ -6,6 +6,9 @@ import math import numpy as np +# +- +rot_range = 180 + def export_key(key): # this seems to be a modulo equivalent @@ -56,7 +59,7 @@ def load(self, filepath): stream.readinto(keys_packed) keys_float = keys_packed.astype(self.dt_float) print(keys_packed[0, :, ]) - keys_float["euler"] = keys_float["euler"] / 32767.0 * 180 + keys_float["euler"] = keys_float["euler"] / 32767.0 * rot_range # keys_float["euler"] = keys_float["euler"] / 32768.0 * 180 + 90.0 keys_float["euler"][:, :, 0] += 90.0 keys_float["euler"][:, :, 1] += 90.0 @@ -101,7 +104,10 @@ def save(self, filepath): keys_float["euler"][:, :, 0] -= 90.0 keys_float["euler"][:, :, 1] -= 90.0 keys_float["euler"][:, :, 2] += 90.0 - keys_float["euler"] = keys_float["euler"] * 32767.0 / 180 + # wrap if they exceed the valid range + keys_float["euler"][keys_float["euler"] > rot_range] -= rot_range + keys_float["euler"][keys_float["euler"] < -rot_range] += rot_range + keys_float["euler"] = keys_float["euler"] * 32767.0 / rot_range # round parts separately keys_float["euler"].round(out=keys_float["euler"]) keys_float["loc"].round(out=keys_float["loc"]) diff --git a/plugin/export_banis.py b/plugin/export_banis.py index 4472905ab..18a79b012 100644 --- a/plugin/export_banis.py +++ b/plugin/export_banis.py @@ -101,8 +101,8 @@ def save(filepath=""): key = corrector.blender_bind_to_nif_bind(posed_armature_space[bone_i]) # this maybe adds the loc transforms, doesn't seem to correctly transform rot ?? # key = binds[bone_i].inverted() @ key - # key = key @ binds[bone_i].inverted() - key.translation -= binds[bone_i].translation + key = key @ binds[bone_i].inverted() + # key.translation += binds[bone_i].translation frame["loc"][bone_i] = key.translation frame["euler"][bone_i] = [math.degrees(v) for v in key.to_euler()] diff --git a/source/formats/bani/__init__.py b/source/formats/bani/__init__.py index 6237d16b4..1e52862cb 100644 --- a/source/formats/bani/__init__.py +++ b/source/formats/bani/__init__.py @@ -5,6 +5,9 @@ import math import numpy as np +# +- +rot_range = 180 + def export_key(key): # this seems to be a modulo equivalent @@ -55,7 +58,7 @@ def load(self, filepath): stream.readinto(keys_packed) keys_float = keys_packed.astype(self.dt_float) print(keys_packed[0, :, ]) - keys_float["euler"] = keys_float["euler"] / 32767.0 * 180 + keys_float["euler"] = keys_float["euler"] / 32767.0 * rot_range # keys_float["euler"] = keys_float["euler"] / 32768.0 * 180 + 90.0 keys_float["euler"][:, :, 0] += 90.0 keys_float["euler"][:, :, 1] += 90.0 @@ -100,7 +103,10 @@ def save(self, filepath): keys_float["euler"][:, :, 0] -= 90.0 keys_float["euler"][:, :, 1] -= 90.0 keys_float["euler"][:, :, 2] += 90.0 - keys_float["euler"] = keys_float["euler"] * 32767.0 / 180 + # wrap if they exceed the valid range + keys_float["euler"][keys_float["euler"] > rot_range] -= rot_range + keys_float["euler"][keys_float["euler"] < -rot_range] += rot_range + keys_float["euler"] = keys_float["euler"] * 32767.0 / rot_range # round parts separately keys_float["euler"].round(out=keys_float["euler"]) keys_float["loc"].round(out=keys_float["loc"]) diff --git a/version.txt b/version.txt index 9ea711979..023562c56 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -a2570101b - Sun Sep 24 23:15:47 2023 +0200 \ No newline at end of file +c0095aed9 - Mon Sep 25 18:50:21 2023 +0200 \ No newline at end of file