Kingdom Under Fire II - dds inside .vap files

Textures, recreate headers, conversions, algorithms and parsing of image files
Amagakuro
Posts: 46
Joined: Wed Sep 23, 2015 4:47 pm

Kingdom Under Fire II - dds inside .vap files

Post by Amagakuro »

Hello guys.
Zaramot on xentax is kindly making a model importer for the game. He discovered that inside some of the .vap files containing the models there're also .dds textures of the mentioned.
Could someone take a look at these files and eventually make a bms script to extract them?
Thanks~

http://www.mediafire.com/file/0pibil913lvzdwn/Hero2.rar
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Kingdom Under Fire II - dds inside .vap files

Post by Allen »

Here is a Noesis script. Supports viewing and exporting textures.

.vap is a texture + mesh package format.
I have took a look at the mesh structure , but lacked bone files. So no support was added.
The mesh store vertices, normals, and tangents? binormal? UV, bone weight, face and other information.

*EDIT*: update added support format 133.
Last edited by Allen on Sat Nov 20, 2021 9:22 am, edited 1 time in total.
Amagakuro
Posts: 46
Joined: Wed Sep 23, 2015 4:47 pm

Re: Kingdom Under Fire II - dds inside .vap files

Post by Amagakuro »

Allen wrote:Here is a Noesis script. Supports viewing and exporting textures.

.vap is a texture + mesh package format.
I have took a look at the mesh structure , but lacked bone files. So no support was added.
The mesh store vertices, normals, and tangents? binormal? UV, bone weight, face and other information.


Bones are in separated files, havok format, since the main interest was texture support i didn't bother adding them. I can attach some of them if you want to give a look.
Thank you nonetheless!

Edit: quick question, some files are getting errors like
"Traceback (most recent call last):
File "C:\Users\LoremIpsum\Downloads\noesisv4459\plugins\python\tex_KingdomUnderFire2_vap.py", line 42, in noepyLoadRGBA
texture = NoeTexture(str(fileIndex), width, height, texData, texFormat)
UnboundLocalError: local variable 'texFormat' referenced before assignment"
or
"Traceback (most recent call last):
File "C:\Users\LoremIpsum\Downloads\noesisv4459\plugins\python\tex_KingdomUnderFire2_vap.py", line 33, in noepyLoadRGBA
texData = bs.readBytes(pixelDataSize)
File "C:\Users\LoremIpsum\Downloads\noesisv4459\plugins\python\inc_noesis.py", line 141, in readBytes
return noesis.bsReadBytes(self.h, numBytes)
MemoryError
WARNING: Not enough texture data for specified image type! (0 vs 0)"
Is it because some of the files doesn't contain textures?
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Kingdom Under Fire II - dds inside .vap files

Post by Allen »

Upload sample(failed one). It should be a new pixel format or as you said dons't have textures file.
Yes. You can upload bone file. I want to take a look. :D
Amagakuro
Posts: 46
Joined: Wed Sep 23, 2015 4:47 pm

Re: Kingdom Under Fire II - dds inside .vap files

Post by Amagakuro »

Here
I uploaded the Unit1 folder,already extracted, also containing a few .vap files from hero folder that aren't working, .vap of unit1 are all not working but that may be 'cause there's no texture inside them.
Files are nameless unfortunately...
havok files are those with some comments from my side there're skeletons and animations, which can also be loaded with
https://forum.xentax.com/viewtopic.php?t=19691 the plugin here or Havok tool 2014.1
LinkOFF
Posts: 88
Joined: Thu Aug 11, 2016 6:52 pm

Re: Kingdom Under Fire II - dds inside .vap files

Post by LinkOFF »

Made a tool for extract textures (based on noesis script). Textures with type 133 (from vap's with error) may be extracted incorrectly. There is 2-channel (red + alpha i suppose) pixel data converted to RGBA32 .
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Kingdom Under Fire II - dds inside .vap files

Post by Allen »

Yes, 133 is a 16BPP image. It seems to be used for the Alpha channel, which should be in R8A8 format, but there are no more samples, so it is not completely certain.
I updated the script to support 133. These days I have been looking at the format of the player model and the NPC model, and I have already figured it out.
hkx file I am trying to understand the XML binary part of the file header, it is not very easy, but the skeleton part of the file is not too complicated, just need to find a way to skip the file header part.
Image
Amagakuro
Posts: 46
Joined: Wed Sep 23, 2015 4:47 pm

Re: Kingdom Under Fire II - dds inside .vap files

Post by Amagakuro »

LinkOFF wrote:Made a tool for extract textures (based on noesis script). Textures with type 133 (from vap's with error) may be extracted incorrectly. There is 2-channel (red + alpha i suppose) pixel data converted to RGBA32 .


Allen wrote:Yes, 133 is a 16BPP image. It seems to be used for the Alpha channel, which should be in R8A8 format, but there are no more samples, so it is not completely certain.
I updated the script to support 133. These days I have been looking at the format of the player model and the NPC model, and I have already figured it out.
hkx file I am trying to understand the XML binary part of the file header, it is not very easy, but the skeleton part of the file is not too complicated, just need to find a way to skip the file header part.
Image


Thank you both, i'll test them scripts when i'll have some free time! :D
Amagakuro
Posts: 46
Joined: Wed Sep 23, 2015 4:47 pm

Re: Kingdom Under Fire II - dds inside .vap files

Post by Amagakuro »

Upping this as i had a big doubt (a tad late... sorry~)
The skeletons and animations container were "changed" to make them rougly compatible with Havok tool.
In case of the animations container only the header was simply changed. The skeleton had a "bigger" change in the files to make it readable.
The Unit1 files i upped have the original files too (.bak), also the hero skeleton weren't fixed so you most likely noticed that something was different mr Allen.
Well... "that's it" wanted to point it out as i dunno if this may change how the script read things or not.
Apologize again as i didn't think it sooner ><
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Kingdom Under Fire II - dds inside .vap files

Post by Allen »

Finally, I finished the importer for the .vap model and .hkx skeleton.

Regarding the previous HkClass data part of the hkx skeleton file, I did not do in-depth research. I used a method of matching string characters to locate the skeleton data.

Image
Image
Image
Image

here is a noesis python script support import: model, textures, skeletons.

*Edit*:
Update , fix a small npc mesh skin/weight bug.
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Kingdom Under Fire II - dds inside .vap files

Post by Allen »

Update , fix a small npc mesh skin/weight bug.
xr79
Posts: 5
Joined: Thu Jan 24, 2019 2:16 pm

Re: Kingdom Under Fire II - dds inside .vap files

Post by xr79 »

Mr Allen, I used the old BMS script to extract the pkg files but was only able to get unnamed vap and dds files, the script for noesis can't pair those two together it seems, would you mind sharing how you extracted the PKG files to get working vap models?
DJ Normality
Posts: 647
Joined: Tue Jul 24, 2018 8:52 am

Re: Kingdom Under Fire II - dds inside .vap files

Post by DJ Normality »

Image

Use Ekey's tool
https://github.com/Ekey/KUF2.PKG.Tool/releases/tag/0.1

Use a bulk renamer and change .w32hkx to .hkx

Now use this modified Noesis script to load models.

Use VGM Toolbox to cut DDS from _Unknown folder
Image

Textures are only hashes though
Image