Page 1 of 1

[PS3] Knight Contract .hxt models

Posted: Wed Apr 17, 2013 6:00 pm
by zaramot
Could someone help me to figure out [PS3]Knights Contract .hxt format? I see face indices and something like a vertex buffer. Though I can't parse them, I'm missing something. Need some tips from people experienced in format reversing.
http://www.mediafire.com/?r3dla86uicf7gsm

Re: [PS3] Knight Contract .hxt models

Posted: Thu Apr 18, 2013 5:11 pm
by zaramot
Figure out vertices , should work fine now. Still have issue with face indices, can't find face count to parse them right.

Re: [PS3] Knight Contract .hxt models

Posted: Thu Apr 18, 2013 8:34 pm
by shakotay2
zaramot wrote:Still have issue with face indices, can't find face count to parse them right.
For chr053.hxt this should be vertex cnt (511) and face indices count (1318) for a submesh (hand and forearm):

Code: Select all

Offset    0  1  2  3  4  5   6  7   8  9   A  B  C   D  E  F

027330   01 00 00 00 08 <00 00 01  FF> 00 00 00 12 <00 00 05
027340   26> 00 00
Max face index is 511 so this seems to be ok, but1318/3= 439.33 leaves a reminder and the mesh appears full of holes.
...
f 511 504 508
f 505 505 501
f 501 502 510
2d533:
# face index min/max: 1 / 511

Re: [PS3] Knight Contract .hxt models

Posted: Thu Apr 18, 2013 8:52 pm
by zaramot
Yes, you're totally right. Mesh full of holes, it's the same problem I've had, thought indices count is bad.

Re: [PS3] Knight Contract .hxt models

Posted: Thu Apr 18, 2013 9:41 pm
by shakotay2
I thought the faces might be quads instead of triangles but that's not the solution.

So I would recommend to examine a small and simple mesh (a box for example) to get a clue what's going on here.

Re: [PS3] Knight Contract .hxt models

Posted: Fri Apr 19, 2013 8:14 am
by zaramot
Yes, I already checked small model, it's a character's blade model the one on the first pic. It appears each model has second face indices count at the end of the file? It's always -2, for example first one is 1060 - second one 1058, 2082/2080. Here's blade model.

EDIT: count 1158 fits nicely since 1158/3=386. Still sword mesh full of holes. Any ideas?

Re: [PS3] Knight Contract .hxt models

Posted: Fri Apr 19, 2013 11:48 am
by chrrox
did you try triangle strips?

Re: [PS3] Knight Contract .hxt models

Posted: Fri Apr 19, 2013 1:06 pm
by zaramot
No I didn't, since I'm new in formats reversing, could you please, give an example of maxscript?

Re: [PS3] Knight Contract .hxt models

Posted: Fri Apr 19, 2013 2:03 pm
by shakotay2
@chrrox: good idea! thx. :)
zaramot wrote:No I didn't, since I'm new in formats reversing, could you please, give an example of maxscript?
I'm not a maxscripter but here's the idea:
After reading the face indices 1 2 3 4 5 6 7 8 9 for example
build 7 faces such as
f 1 2 3
f 2 3 4
f 3 4 5
...
f 7 8 9

This is the result:
Image

Still little errors (?). Maybe groups of ten face indices to be read?
Or use reverse order of face indices for every 2nd face?
Maybe chrrox will know...

These are the faces I got for chr176.hxt:
# 0x7ecf:

f 1 2 3
f 2 3 3
f 3 3 4
f 3 4 4
f 4 4 4 // hmm, confusing
f 4 4 5
f 4 5 6

Re: [PS3] Knight Contract .hxt models

Posted: Fri Apr 19, 2013 11:45 pm
by chrrox
something like this

Code: Select all

FaceIndexTableStart = ftell f
fseek f FaceIndexOffset#seek_set
FaceDirection = 1
f1 = ReadBEword f + 1   --read face indices, games are start form 0, but Max start from 1
f2 = ReadBEword f  + 1   --so we add 1 to each index
for i = 3 to FaceBytes do (    --already readf 2 verts, so start from 3	
f3 = ReadBEword f  + 1
FaceDirection *= -1	
if (f3 != f1) AND (f3 != f2) then (   --if not idential verts, create face
if FaceDirection > 0 then append Face_array [f1,f2,f3]     --base on face direction to create face
else append Face_array [f1,f3,f2]
)
f1 = f2     --shift the verts
f2 = f3
)
fseek f FaceIndexTableStart#seek_set
)

Re: [PS3] Knight Contract .hxt models

Posted: Sat Apr 20, 2013 8:25 am
by shakotay2
Perfect! :) thx, chrrox.
The sword faces look now like this:

# 0x1763:
f 1 3 2
f 3 4 3
f 4 4 5
f 4 6 5
f 5 6 7
f 7 6 8
f 8 6 3
f 6 9 3
f 3 9 2
f 9 10 2
f 2 10 11
f 10 12 11
f 11 12 13
f 13 12 14
f ... ... ...

edit: chr053.hxt
Image

Re: [PS3] Knight Contract .hxt models

Posted: Sat Apr 20, 2013 8:58 am
by zaramot
Thank you very much chrrox :) . It helped with the sword mesh, will try with other models.

EDIT: Works fine, guess I found where are UV's.

Re: [PS3] Knight Contract .hxt models

Posted: Sun Feb 15, 2015 12:02 pm
by Szkaradek123
about hxt format:

1.beginning

Code: Select all

go to offset 140
int32 - imageCount
skip 20 bytes
int32 - charCount
string = get charCount bytes
skip 108 bytes

repeat*imageCount {
	int32 - charCount
	string = get charCount bytes
	skip 44 bytes
	int32 - count
	skip count bytes
	skip 168 bytes
	}
	
#section .ddm	
string = get 4 bytes
skip 164 bytes
int32 - unk
int32 - type of data for skeletons (get from python script)
int32 - boneCount
start - get current offset
boneNameList = get boneCount bytes #numbers as  bone names
parentNameList = get boneCount bytes #numbers as bone parent names

here was problem with ending this section and i tried absolute padding (from 0 offset), but without success.
Finally i used relative padding (from start offset) and it works. In this case pad = 8 bytes.
I have problems with skeleton ,bone map for vertex groups, vertex items.
Here is script for importing textured meshes (not all are supported) without skinning and skeleton.
It requires Blender 249 and Python 26.
How use:
1. run Blender249.blend
2. in Blender Text Window press alt+p and select hxt file

For unpacking models from archive: viewtopic.php?f=10&t=6949
For unpacking textures: viewtopic.php?f=18&t=7026

Re: [PS3] Knight Contract .hxt models

Posted: Mon Feb 16, 2015 11:53 am
by raykingnihong
Hi Szkaradek123,Thank you very much for the great work, the script runs very well.