Skip to content

Commit

Permalink
add option to not compress animation
Browse files Browse the repository at this point in the history
  • Loading branch information
0ceal0t committed Apr 18, 2022
1 parent 7bea339 commit 22f2948
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
4 changes: 3 additions & 1 deletion BlenderAssist/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,17 @@ int main(int argc, const char** argv) {
hkStringBuf anim_in; // original animation
hkStringBuf anim_out; // pap animation out
hkStringBuf check_if_bound;
hkStringBuf compress_anim;

anim_idx = convert_from_wstring(nargv[2]).c_str();
bin_in = convert_from_wstring(nargv[3]).c_str();
skl_in = convert_from_wstring(nargv[4]).c_str();
anim_in = convert_from_wstring(nargv[5]).c_str();
anim_out = convert_from_wstring(nargv[6]).c_str();
check_if_bound = convert_from_wstring(nargv[7]).c_str();
compress_anim = convert_from_wstring(nargv[8]).c_str();

return pack_anim(anim_idx, bin_in, skl_in, anim_in, anim_out, check_if_bound);
return pack_anim(anim_idx, bin_in, skl_in, anim_in, anim_out, check_if_bound, compress_anim);
}
else if (operation.compare("pack_skel") == 0) {
hkStringBuf bin_in;
Expand Down
30 changes: 18 additions & 12 deletions BlenderAssist/pack_anim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ void read(hkRefPtr<hkaInterleavedUncompressedAnimation> anim, hkRefPtr<hkaAnimat
}
}

int packHavok(const hkStringBuf anim_idx_str, const hkStringBuf bin_in, const hkStringBuf skl_in, const hkStringBuf anim_in, const hkStringBuf anim_out, const hkStringBuf check_if_bound_str) {
int packHavok(const hkStringBuf anim_idx_str, const hkStringBuf bin_in, const hkStringBuf skl_in, const hkStringBuf anim_in, const hkStringBuf anim_out, const hkStringBuf check_if_bound_str, const hkStringBuf compress_anim_str) {
int anim_idx = std::stoi(anim_idx_str.cString());
bool checkIfOriginalBound = std::stoi(check_if_bound_str.cString()) == 1;
bool compress_anim = std::stoi(compress_anim_str.cString()) == 1;

hkRootLevelContainer* skl_root_container;
hkRootLevelContainer* anim_root_container;
Expand Down Expand Up @@ -133,18 +134,23 @@ int packHavok(const hkStringBuf anim_idx_str, const hkStringBuf bin_in, const hk

hkRefPtr<hkaInterleavedUncompressedAnimation> storeAnim = new hkaInterleavedUncompressedAnimation();

hkaSplineCompressedAnimation::TrackCompressionParams tparams;
hkaSplineCompressedAnimation::AnimationCompressionParams aparams;
//tparams.m_rotationTolerance = 0.001f;
//tparams.m_rotationQuantizationType = hkaSplineCompressedAnimation::TrackCompressionParams::THREECOMP40;

read(storeAnim, binding, skl, stream, checkIfOriginalBound);

auto final_anim = new hkaSplineCompressedAnimation( *storeAnim.val(), tparams, aparams );
binding->m_animation = final_anim;
anim_container->m_animations[anim_idx] = final_anim;
printf("Compress animation %d\n", compress_anim);

auto anim = hkRefPtr<hkaAnimation>(anim_ptr);
if (compress_anim) {
hkaSplineCompressedAnimation::TrackCompressionParams tparams;
hkaSplineCompressedAnimation::AnimationCompressionParams aparams;
//tparams.m_rotationTolerance = 0.001f;
//tparams.m_rotationQuantizationType = hkaSplineCompressedAnimation::TrackCompressionParams::THREECOMP40;
auto final_anim = new hkaSplineCompressedAnimation( *storeAnim.val(), tparams, aparams );
binding->m_animation = final_anim;
anim_container->m_animations[anim_idx] = final_anim;
}
else {
binding->m_animation = storeAnim;
anim_container->m_animations[anim_idx] = storeAnim;
}

// ========================

Expand All @@ -157,7 +163,7 @@ int packHavok(const hkStringBuf anim_idx_str, const hkStringBuf bin_in, const hk
}
}

int pack_anim(const hkStringBuf anim_idx_str, const hkStringBuf bin_in, const hkStringBuf skl_in_sklb, const hkStringBuf anim_in_pap, const hkStringBuf anim_out_pap, const hkStringBuf check_if_bound_str) {
int pack_anim(const hkStringBuf anim_idx_str, const hkStringBuf bin_in, const hkStringBuf skl_in_sklb, const hkStringBuf anim_in_pap, const hkStringBuf anim_out_pap, const hkStringBuf check_if_bound_str, const hkStringBuf compress_anim_str) {
PapFile papFile;
papFile.read(anim_in_pap);

Expand All @@ -173,7 +179,7 @@ int pack_anim(const hkStringBuf anim_idx_str, const hkStringBuf bin_in, const hk
sklbFile.writeHavok(original_skl_temp);

auto new_anim_temp = concat(baseDir, "new_anim_temp.hkx");
auto res = packHavok(anim_idx_str, bin_in, original_skl_temp, original_anim_temp, new_anim_temp, check_if_bound_str);
auto res = packHavok(anim_idx_str, bin_in, original_skl_temp, original_anim_temp, new_anim_temp, check_if_bound_str, compress_anim_str);

papFile.replaceHavok(new_anim_temp);
papFile.writePap(anim_out_pap);
Expand Down
2 changes: 1 addition & 1 deletion BlenderAssist/pack_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#include <Common/Base/hkBase.h>
#include <Common/Base/Container/String/hkStringBuf.h>

int pack_anim(const hkStringBuf anim_idx_str, const hkStringBuf bin_in, const hkStringBuf skl_in, const hkStringBuf anim_in, const hkStringBuf anim_out, const hkStringBuf check_if_bound_str);
int pack_anim(const hkStringBuf anim_idx_str, const hkStringBuf bin_in, const hkStringBuf skl_in, const hkStringBuf anim_in, const hkStringBuf anim_out, const hkStringBuf check_if_bound_str, const hkStringBuf compress_anim_str);

#endif //BLENDERASSIST_PACK_ANIM_H
2 changes: 1 addition & 1 deletion BlenderAssistAddon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name" : "BlenderAssist",
"author" : "ocealot",
"description" : "Export custom animations for FFXIV",
"version": (1, 3, 1),
"version": (1, 3, 2),
"blender" : (2, 80, 0),
"location" : "3D View > Tools (Right Side) > BlenderAssist",
"warning" : "",
Expand Down
14 changes: 13 additions & 1 deletion BlenderAssistAddon/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class BlenderAssistProperties(PropertyGroup):
name = "Only animate same bones as original animation",
default = False
)
compress_anim: BoolProperty(
name = "Compress animation data",
default = True
)

exclude_bones: CollectionProperty(type=data.ExcludeBone)
editing_exclude_bones: BoolProperty(default=False)
Expand Down Expand Up @@ -165,10 +169,15 @@ def execute(self, context):
anim_in = state.input_pap
skl_in = state.input_sklb
anim_idx = str(state.anim_idx)

check_original_bound = "0"
if state.check_original_bound:
check_original_bound = "1"

compress_anim = "0"
if state.compress_anim:
compress_anim = "1"

dirname = os.path.dirname(os.path.abspath(__file__))

basename = os.path.basename(output_pap)
Expand All @@ -185,7 +194,8 @@ def execute(self, context):
print("Finished exporting to bin")
command = dirname + '/bin/blenderassist.exe'
print(command + " " + str(anim_idx) + " " + anim_bin_file + " " + skl_in + " " + anim_in + " -> " + output_pap)
subprocess.run([command, 'pack_anim', str(anim_idx), anim_bin_file, skl_in, anim_in, output_pap, check_original_bound])
print(check_original_bound, compress_anim)
subprocess.run([command, 'pack_anim', str(anim_idx), anim_bin_file, skl_in, anim_in, output_pap, check_original_bound, compress_anim])

return {'FINISHED'}

Expand Down Expand Up @@ -227,6 +237,8 @@ def draw(self, context):

layout.prop(state, "check_original_bound")

layout.prop(state, "compress_anim")

layout.label(text="Skeleton SKLB")
col = layout.column(align=True)
col.prop(state, "input_sklb", text="")
Expand Down
Binary file modified BlenderAssistAddon/bin/blenderassist.exe
Binary file not shown.

0 comments on commit 22f2948

Please sign in to comment.