[Help] Hex2obj

Read or post any tutorial related to file format analysis for modding purposes.
Loginoux
beginner
Posts: 25
Joined: Tue Oct 13, 2015 10:25 am
Has thanked: 3 times

[Help] Hex2obj

Post by Loginoux » Thu Jul 28, 2016 9:48 pm

Hi there...
I need help to find "Face indices" "vertices" and "UVs" from a simple 3d file format... I tried to look at the tutorial himself but i don't understand how they do it...
If someone have another tutorial or any help about hex2obj it will be very kind to show me it :oops:
Thanks

vandarel
ultra-n00b
Posts: 6
Joined: Tue Dec 29, 2015 10:55 pm

Re: [Help] Hex2obj

Post by vandarel » Sat Jul 30, 2016 11:17 pm

Hello,
me too, i don't understand :)

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2611
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 642 times
Been thanked: 1338 times

Re: [Help] Hex2obj

Post by shakotay2 » Sun Jul 31, 2016 5:12 am

You should tell where you got stuck with the tutorial so that I can improve it.

There is no general recipe how to get the vertices, even for simple models.
For the face indices (FIs) the rule is: search for a scrambled alphabet.

Problem is: not every scrambled alphabet you find in 3D data represents FIs.

Simple 3D model formats use floats (4 bytes) for the vertices. (Half float vertices
or even shorts (WORD, 2 bytes) are harder to recognize.)

To find vertices (v) you'll need to find patterns.

From the tutorial it says:
v: xx xx xx nn with nn= 42..44 (these are rough values only, can also be 3F, 40)

where v is a 4 bytes little endian value.
And 'yes', nn can also be 3D, 3E, or even 37 - my bad.
(Also BD if the MSB is set but that's beyond this tutorial.)

Don't know what this is: bytes, floats, endianess? Google for it.

But you don't need to know it. All you have to know is how to recognize patterns.
(If you can't: well, then you're lost - as simple as that.)

Let's have another look at the tutorial sample, hw_bu_000.bm.mod

The scrambled alphabet is to be found somewhere at file offset 0x3B00.
These face indices are integer numbers - they just count the vertices.

The integers consist of two bytes here. 20 00 (little endian) is 0x0020 or 32 decimal.

First vertex has the number 00 so search for the start of the face indices list
at 0x398D. There it reads 00 00 01 00 02 00, this is 0, 1, 2 in decimal.

This means that the vertices 0, 1 and 2 are used to construct the first face (triangle)
of the model.

(Won't bother how to find the end of the face indices list. It's at 0x4844.)

Now for the vertices - I've randomly marked some of them by rectangles:
tut_sample_hw_bu.jpg
You'll find the start address 0x56 by experience or trial & error.

In hex2obj toggle the 'noPtC' (no PointCloud) button to 'PtCld'.

Enter 56 (without the 0x) as vertices startaddress in step 3.
Leave the mode button in step 2 as 'seq' (sequential).
Press the 'mesh' button.

The point cloud of the upper body pops up.

Enter 398D as a face indices start address in step 1. Switch back to 'noPtC'.
Change the count from 500 to 100 or 150, as you wish.

Scroll down in the lower left list box. It reads: max face index: 142.
Enter this value as a count in step 3.

Press the 'go3' button. You happen to see a mesh, don't you?

Looks broken? Yeah, because we didn't use all FIs.

Calculate the number of FIs in two steps: a) you've to subtract the FIs' startaddress (0x398D)
from the endaddress+1 (0x4845) -> 0xEB8= 3768 bytes.

That's the size of the face indices block. b) Divide it by two (since the FIs
are two byte integers) -> FIs count= 1884.

hex2obj: enter 1884 as a count in step 1. Press 'go1', in the listbox there's a
max face index of 457 displayed. It's the highest vertex number.
So we enter this value as a count in step 3.

Pressing 'go3' shows the full upper body of the model.
You do not have the required permissions to view the files attached to this post.
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

devmode
beginner
Posts: 27
Joined: Mon Jun 06, 2016 7:51 pm
Has thanked: 6 times
Been thanked: 5 times

Re: [Help] Hex2obj

Post by devmode » Tue Aug 02, 2016 1:01 am

shakotay2 ,

I'm also "stuck" in your tutorial at the "start address of normals" step:

Previous we getting the size of the uv list = 0xE48

Next, in searching of the uvs start addresses you explain so We should "calculate back" from 12 bytes before, subtract 0xC from FIStart (0x398D), subtract 0xE48 from result and get 0x2B39.

Size of normals list is 0x156C

But for getting the start addresses of normals we need 0x2B2E - 0x156 = 0x15C2.
How obtained 0x2B2E instead 0x2B39?
0x2B2E that's 0x2B39 - 0xB?
You not explain it in tutorial.

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2611
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 642 times
Been thanked: 1338 times

Re: [Help] Hex2obj

Post by shakotay2 » Tue Aug 02, 2016 5:41 am

devmode wrote:But for getting the start addresses of normals we need 0x2B2E - 0x156 = 0x15C2.
How obtained 0x2B2E instead 0x2B39?
0x2B2E that's 0x2B39 - 0xB?
You not explain it in tutorial.
I didn't feel the necessity to explain that because it's plain to see when looking at
hw_bu_000.bm in a hex editor. It's just a string (and a DWord, the length) to skip:
hw_bu-2B2E.JPG
You do not have the required permissions to view the files attached to this post.
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

IAmTheClayman
n00b
Posts: 17
Joined: Mon Aug 01, 2016 1:46 am
Has thanked: 2 times
Been thanked: 2 times

Re: [Help] Hex2obj

Post by IAmTheClayman » Tue Aug 02, 2016 10:00 pm

As a fellow noob who just had an epiphany about all this in the past 24 hours maybe I can help out. Can you attach a copy of the file you're trying to work with?

majidemo
advanced
Posts: 68
Joined: Sun Aug 21, 2016 12:00 am
Has thanked: 27 times
Been thanked: 38 times

Re: [Help] Hex2obj

Post by majidemo » Sun Aug 21, 2016 12:03 pm

What if the format is saved in a way that the face indices first then the UV list? The tutorial assumes that the file format is UV list first then face indices right? because the start address is calculated by subtracting from the start address of the face indices?

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2611
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 642 times
Been thanked: 1338 times

Re: [Help] Hex2obj

Post by shakotay2 » Sun Aug 21, 2016 2:59 pm

majidemo wrote:What if the format is saved in a way that the face indices first then the UV list?
should not matter because you enter the addresses for FIs and uvs independently.
The tutorial assumes that the file format is UV list first then face indices right?
It does for the tutorial sample.
because the start address is calculated by subtracting from the start address of the face indices?
This is just for the tutorial .bm sample that is sequential (was one of the first formats I used hex2obj on). (Meanwhile I experienced that most formats use 'blocked' or 'mixed' mode.)

Finding the uvs' start address in sequential mode is a "matter of experience" (as you can read in the tut).
It also says that there's no common recipe but 'yes', you normally are on a promising track of finding uvs' start address in sequential mode when
subtracting the uvs' block size from the FIs' start address.
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

Sckoofer
ultra-n00b
Posts: 3
Joined: Mon Nov 07, 2016 6:00 pm
Has thanked: 2 times

Re: [Help] Hex2obj

Post by Sckoofer » Mon Nov 07, 2016 6:11 pm

Hi, I copy your tutorial and post in the Zenhax forum.
Dont worry, i say that no was me who created the H2O and the tutorial.
i just copy and paste there, because not have tutorials about it.
And i have a question too:
I want to access the game models of the ratatouille game, i had make a tutorial about "how to replace textures of the any game, simple using hexeditor, dragon upacker and paint." But i dont know how to open the game models for replace them.
If i decompile the game folder i can extract the meshes of character, objects, map?
With your program?
Or not?
Thank you so much!
http://zenhax.com/viewtopic.php?f=4&t=3351

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2611
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 642 times
Been thanked: 1338 times

Re: [Help] Hex2obj

Post by shakotay2 » Mon Nov 07, 2016 6:48 pm

Sckoofer wrote:Dont worry, i say that no was me who created the H2O and the tutorial.
I would not worry even if you told it were yours. :D
If i decompile the game folder i can extract the meshes of character, objects, map?
depends on - you'll need to upload a supposed model file.
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

Sckoofer
ultra-n00b
Posts: 3
Joined: Mon Nov 07, 2016 6:00 pm
Has thanked: 2 times

Re: [Help] Hex2obj

Post by Sckoofer » Mon Nov 07, 2016 11:44 pm

Thank you so much.
Here https://mega.nz/#!5VZDyQDQ!RK5PeSiLbTvh ... sWfFWonTto
I cannot download more on mega, but i can upload! :[
If dont work: http://www.4shared.com/file/TD8Lbylnce/CT_online.html
See for me if i can extract the models, or not.
And the more important, if i can change the coordinates of the objects, and how to do it. :mrgreen:
Thank you so much again.

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2611
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 642 times
Been thanked: 1338 times

Re: [Help] Hex2obj

Post by shakotay2 » Tue Nov 08, 2016 7:23 pm

Sckoofer wrote:See for me if i can extract the models, or not.
CT.DPC contains hundreds of DXT1, DXT5 strings.
So may contain textures, maybe compressed
And the more important, if i can change the coordinates of the objects, and how to do it. :mrgreen:
that's not a matter of hex2obj - it's modding; look for threads/ forums which deal with that, please.
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

Sckoofer
ultra-n00b
Posts: 3
Joined: Mon Nov 07, 2016 6:00 pm
Has thanked: 2 times

Re: [Help] Hex2obj

Post by Sckoofer » Tue Nov 08, 2016 9:30 pm

:(.
WAIT! I won decompile the file! With quickBMS.Please, help me, just one more time :cry:
http://www.4shared.com/rar/lI3zlRM_ce/C ... piled.html
Please, you are my last hope.

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2611
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 642 times
Been thanked: 1338 times

Re: [Help] Hex2obj

Post by shakotay2 » Sat Dec 10, 2016 12:21 am

chunk files; continuing from this thread:
viewtopic.php?f=16&t=13675&start=45

@ekmek: handling the chunk file
I show the steps which should be plain to see for any noob;
if you don't, well, then I fear I can't help.

address 0x5CCE0: start of face indices (FI) list

search for 000001000200, next addresses 0x63F28 and 0x65D88, assumed starts of FIs lists

size of first submeshes FIs' list:
0x63F28 -0x5CCE0= 0x7248= 29256

FIs count: 14628 (words= 2 bytes per index)
resulting in a vertex count of 4848 (lower left listbox)

Finding the FVF size; well, that requires some experience;
you'll gain it after having dealed with some dozens of different mesh formats:

from a glance at the beginning of the file I'd guess for 44.

ShortAll didn't work here, so I switched to half floats.
heads_jingxu_chunk.JPG
Getting the uvs positon is another hurdle for most people; use "trial 'n error"
if the standard addresses for ShortAll/HF formats (from 12, in multiples of four, 16, 20 etc.) don't work.

In this case it's 40.
You do not have the required permissions to view the files attached to this post.
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

ekmek
ultra-n00b
Posts: 8
Joined: Mon Nov 28, 2016 7:53 pm

Re: [Help] Hex2obj

Post by ekmek » Sat Dec 10, 2016 12:54 am

Thanks! That makes more sense. Let me mess around with it

Post Reply