Skip to content

Commit

Permalink
Use dedicated skeleton for compress/additive
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmheg committed Apr 27, 2022
1 parent 1d2222c commit 2533413
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
12 changes: 6 additions & 6 deletions MultiAssist.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def assist_combine_tag(skeleton_path, animation_path, animation_index, out_path)
else:
dbgprint(f"Saved importable file to {out_path}")

def assist_blend(animation_path, out_path):
def assist_blend(skl_path, animation_path, out_path):
animassist_check()
complete = subprocess.run(["animassist.exe", "7", animation_path, out_path], capture_output=True, encoding="utf8", creationflags=subprocess.CREATE_NO_WINDOW)
complete = subprocess.run(["animassist.exe", "7", skl_path, animation_path, out_path], capture_output=True, encoding="utf8", creationflags=subprocess.CREATE_NO_WINDOW)
dbgprint(f"{complete.returncode}")
dbgprint(f"{complete.stdout}")

Expand All @@ -162,9 +162,9 @@ def assist_repack(mod_path, animation_path, animation_index, out_path):
else:
dbgprint(f"Saved importable file to {out_path}")

def assist_compress(animation_path, out_path):
def assist_compress(skl_path,animation_path, out_path):
animassist_check()
complete = subprocess.run(["animassist.exe", "9", animation_path, out_path], capture_output=True, encoding="utf8", creationflags=subprocess.CREATE_NO_WINDOW)
complete = subprocess.run(["animassist.exe", "9", skl_path, animation_path, out_path], capture_output=True, encoding="utf8", creationflags=subprocess.CREATE_NO_WINDOW)
dbgprint(f"{complete.returncode}")
dbgprint(f"{complete.stdout}")

Expand Down Expand Up @@ -293,9 +293,9 @@ def multi_repack(skeleton_file : str, anim_file : str, mod_file : str, anim_inde
tmp_mod_path = tmp_fbx_path

if additive:
assist_blend(tmp_mod_path,tmp_mod_path)
assist_blend(tmp_skel_path,tmp_mod_path,tmp_mod_path)
if compress:
assist_compress(tmp_mod_path,tmp_mod_path)
assist_compress(tmp_skel_path,tmp_mod_path,tmp_mod_path)

assist_repack(tmp_mod_path,tmp_pap_path,str(anim_index),tmp_out_bin_path)

Expand Down
32 changes: 13 additions & 19 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ int main(int argc, const char** argv) {
anim_index = _wtoi(nargv[4]);
out = convert_from_wstring(nargv[5]).c_str();
}
if (mode == 4) {
if (mode == 4 || mode == 7 || mode == 9) {
skl_hkt = convert_from_wstring(nargv[2]).c_str();
anim_hkt = convert_from_wstring(nargv[3]).c_str();
out = convert_from_wstring(nargv[4]).c_str();
}
if (mode == 5 || mode == 7 || mode == 9) {
if (mode == 5 ) {
anim_hkt = convert_from_wstring(nargv[2]).c_str();
out = convert_from_wstring(nargv[3]).c_str();
}
Expand All @@ -115,7 +115,7 @@ int main(int argc, const char** argv) {
init();
auto loader = new hkLoader();

if (mode == 1 || mode == 2 || mode == 3 || mode == 6) {
if (mode == 1 || mode == 2 || mode == 3 || mode == 6 || mode == 7 || mode == 9) {
skl_root_container = loader->load(skl_hkt);
}
if (mode == 3 || mode == 4 || mode == 6 ) {
Expand Down Expand Up @@ -167,17 +167,14 @@ int main(int argc, const char** argv) {
} else if (mode == 5) {
res = hkSerializeUtil::saveTagfile(anim_root_container, hkRootLevelContainer::staticClass(), stream.getStreamWriter(), nullptr, hkSerializeUtil::SAVE_DEFAULT);
} else if (mode == 7) {

auto* skl_container = reinterpret_cast<hkaAnimationContainer*>(skl_root_container->findObjectByType(hkaAnimationContainerClass.getName()));
hkaAnimationContainer* anim_container = reinterpret_cast<hkaAnimationContainer*>(anim_root_container->findObjectByType(hkaAnimationContainerClass.getName()));;
hkaAnimation* anim_ptr = anim_container->m_animations[0];
auto bind_ptr = anim_container->m_bindings[0];
auto binding_ref = hkRefPtr<hkaAnimationBinding>(bind_ptr);
auto skl_ptr = anim_container->m_skeletons[0];
auto skl_ptr = skl_container->m_skeletons[0];
hkaInterleavedUncompressedAnimation* w = static_cast<hkaInterleavedUncompressedAnimation*>(anim_ptr);

std::cout << bind_ptr->m_transformTrackToBoneIndices.getSize();

/*

hkaAdditiveAnimationUtility::ReferencePoseInput rinput;
rinput.m_originalData = w->m_transforms.begin();
rinput.m_numberOfPoses = w->m_transforms.getSize() / w->m_numberOfTransformTracks;
Expand All @@ -186,24 +183,23 @@ int main(int argc, const char** argv) {
rinput.m_numReferencePose = skl_ptr->m_referencePose.getSize();
rinput.m_transformTrackToBoneIndices = bind_ptr->m_transformTrackToBoneIndices.begin();
rinput.m_numTransformTrackToBoneIndices = bind_ptr->m_transformTrackToBoneIndices.getSize();
*/

/*
hkaAdditiveAnimationUtility::Input input;
input.m_numberOfPoses = w->m_transforms.getSize() / w->m_numberOfTransformTracks; //frames
input.m_numberOfTransformTracks = w->m_numberOfTransformTracks;
input.m_originalData = w->m_transforms.begin();
input.m_baseData = skl_ptr->m_referencePose.begin();

hkaAdditiveAnimationUtility::createAdditiveFromPose(input, w->m_transforms.begin());
*/
hkaAdditiveAnimationUtility::createAdditiveFromReferencePose(rinput, w->m_transforms.begin());

/// Note: For deprecated format, uncomment the define HKA_USE_ADDITIVE_DEPRECATED in hkaAnimation.h
/// also remember to set hkaAnimationBinding::ADDITIVE_DEPRECATED
/// Couldn't get results from ADDITVE_DEPRECATED, ADDITIVE works in XIV, so here we are
/// Source\Animation\Animation\hkaAnimation.h Line #18
binding_ref->m_blendHint = hkaAnimationBinding::ADDITIVE;

anim_container->m_animations[0] = w;
anim_container->m_bindings[0] = binding_ref;

res = hkSerializeDeprecated::getInstance().saveXmlPackfile(anim_root_container, hkRootLevelContainer::staticClass(), stream.getStreamWriter(), packOptions, nullptr, &errOut);
} else if (mode == 8) {
hkaAnimationContainer* anim_container = reinterpret_cast<hkaAnimationContainer*>(anim_root_container->findObjectByType(hkaAnimationContainerClass.getName()));
Expand All @@ -216,10 +212,12 @@ int main(int argc, const char** argv) {
anim_container->m_bindings[anim_index] = mod_binding_ptr;
res = hkSerializeUtil::saveTagfile(anim_root_container, hkRootLevelContainer::staticClass(), stream.getStreamWriter(), nullptr, hkSerializeUtil::SAVE_DEFAULT);
} else if (mode == 9) {
auto* skl_container = reinterpret_cast<hkaAnimationContainer*>(skl_root_container->findObjectByType(hkaAnimationContainerClass.getName()));
auto skl = *skl_container->m_skeletons[0];

auto* anim_container = reinterpret_cast<hkaAnimationContainer*>(anim_root_container->findObjectByType(hkaAnimationContainerClass.getName()));
auto binding_ptr = anim_container->m_bindings[0];
auto binding = *anim_container->m_bindings[0];
auto skl = *anim_container->m_skeletons[0];

/*
hkaPredictiveCompressedAnimation::TrackCompressionParams track_params;
Expand All @@ -234,13 +232,9 @@ int main(int argc, const char** argv) {
track_params.m_staticTranslationTolerance = 0.005;
params.m_parameterPalette[0] = track_params;
*/

auto compressed_anim = new hkaPredictiveCompressedAnimation(binding, skl);
anim_container->m_animations[0] = compressed_anim;
binding_ptr->m_animation = compressed_anim;
std::cout << "\n\nSize:\n" << anim_container->m_animations.getSize();



res = hkSerializeDeprecated::getInstance().saveXmlPackfile(anim_root_container, hkRootLevelContainer::staticClass(), stream.getStreamWriter(), packOptions, nullptr, &errOut);
}
Expand Down

0 comments on commit 2533413

Please sign in to comment.