Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Support converting to and from .KF #26

Open
WasmachenDennSachenSo opened this issue Nov 4, 2024 · 4 comments
Open

[Feature]: Support converting to and from .KF #26

WasmachenDennSachenSo opened this issue Nov 4, 2024 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@WasmachenDennSachenSo
Copy link

WasmachenDennSachenSo commented Nov 4, 2024

Expected behavior

The .kf file format as additional conversion option so that animation can be directly imported into Niftools (Blender Addon) or NifSkope without the need of an additional conversion via hkxcmd.

hkxcmd supports converting .hkx to .kf and vice versa. (LE Only)

https://www.niftools.org/pyffi/pyffi/formats/nif.html

@WasmachenDennSachenSo WasmachenDennSachenSo added the enhancement New feature or request label Nov 4, 2024
@SARDONYX-sard
Copy link
Owner

SARDONYX-sard commented Nov 4, 2024

I have been wanting to get one as well.

However, the following points made this impossible, so I did not implement it.

  • I'm not sure of the detailed binary structure of the kf file.
  • Currently I have modified serde (Rust's famous library) to somehow support conversion to hkx and xml
  • The purpose of creating this was to analyze the file structure of hkx (log output for that) and to try to create an alternative to Nemesis

I had to write the following docs to analyze/output hkx binary data.

If there are similar docs, I may be able to make it.

I looked at pyffi nif link, but my understanding and skills were not good enough to understand it. Sorry.

@SARDONYX-sard SARDONYX-sard added the help wanted Extra attention is needed label Nov 4, 2024
@WasmachenDennSachenSo
Copy link
Author

https://github.com/niftools/nifxml/wiki

Maybe this can be of any use? You probably know this already tho ☺️

@SARDONYX-sard
Copy link
Owner

Hmmm, I am not sure of the correspondence between the information in hkx and kf.

I did find information that seems to be the case on the following page. (in the link you wrote).

Test data

./hkxcmd exportkf ".\meshes\actors\character\character assets\skeleton.hkx" ".\meshes\actors\character\animations\1hm_idle.hkx" "1hm_idle.kf"

and then

./hkxc dump .\1hm_idle.kf -o .\1hm_idle_hexdump.kf.txt

00000000: 47 61 6d 65 62 72 79 6f 20 46 69 6c 65 20 46 6f  Gamebryo File Fo
00000010: 72 6d 61 74 2c 20 56 65 72 73 69 6f 6e 20 32 30  rmat, Version 20
00000020: 2e 32 2e 30 2e 37 0a 07 00 02 14 01 0b 00 00 00  .2.0.7..........
00000030: b8 00 00 00 53 00 00 00 01 00 01 00 01 00 04 00  ....S...........
00000040: 14 00 00 00 4e 69 43 6f 6e 74 72 6f 6c 6c 65 72  ....NiController
00000050: 53 65 71 75 65 6e 63 65 12 00 00 00 4e 69 54 65  Sequence....NiTe
00000060: 78 74 4b 65 79 45 78 74 72 61 44 61 74 61 17 00  xtKeyExtraData..
00000070: 00 00 4e 69 54 72 61 6e 73 66 6f 72 6d 49 6e 74  ..NiTransformInt
00000080: 65 72 70 6f 6c 61 74 6f 72 0f 00 00 00 4e 69 54  erpolator....NiT
00000090: 72 61 6e 73 66 6f 72 6d 44 61 74 61 00 00 01 00  ransformData....
000000a0: 02 00 03 00 02 00 03 00 02 00 03 00 02 00 03 00  ................
000000b0: 02 00 03 00 02 00 03 00 02 00 03 00 02 00 03 00  ................
000000c0: 02 00 03 00 02 00 03 00 02 00 03 00 02 00 03 00  ................
000000d0: 02 00 03 00 02 00 03 00 02 00 03 00 02 00 03 00  ................

Obviously kf is binary data as you can see from the reference link, but I am not sure how the data in hkx is converted to binary data in kf.

It remains unclear what each binary data in kf represents.

I looked at the src of hkxcmd a long time ago,

but it uses niflib, a C++ library, and I couldn't figure out what it was doing behind the scenes as well.

@SARDONYX-sard
Copy link
Owner

I finally understood what the document is about the other day.

It appears to be the following.

  • The C++ type is written in XML, so it parses it and automatically generates the type.
  • If binary data ClassName is written, it reads it as per the type information written in XML (deserialize. Once this is parsed, the serializer can do the reverse)

I am still not sure about hkxcmd's Export.

Even if I were to implement it, I think I would have to fork serde_hkx because XML is GPL licensed.
And I am currently developing another program, so it is low priority.

I may work on it after that is done. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants