This is a korean MMORPG released back in 2001. The game and the company no longer exists. I've been analyzing the file formats as a personal project for awhile now.
I have already decoded the textures and script files. I only have 2 more files left to decode: .ani
and .obj
. With the extensions, I would guess that the .ani
contains the animation and .obj
contains the 3d models. As the title of my question would suggest. I'm currently working on the .obj
file.
What I Know
.obj
files are actually archives that contains one or more models. But exclusively 3D models (biped) because the textures are found on another archive with the extension .t16
or .tex
.
I'll take the 22nd model inside the file def.obj
as an example. I have also taken it out of the archive and saved it as a file called `def_022.obj.
From here on, I'll call the 22nd model Armor of Eagle
. The next image is the texture for the Armor of Eagle
found on def.t16
:
The Armor of Eagle in-game:
A def_inf.txt
file has this related line:
filename LODstep polycnt
armor_eagle 0 313 // eagle = index 22
In general, the structure of .obj
is:
06 00 00 00 03 00 // don't know what
3C 00 // total number of models in this list
01 00 9E 00 00 00 9E 00 00 00 78 00 00 00 78 00 00 00 // the first model on the list with 0x9E polygons and 0x78 verticies
01 00 64 00 00 00 64 00 00 00 61 00 00 00 61 00 00 00 // the 2nd model
....... // continues until you reach the end of the headers
....... // then the bodies start, actual 3d data
This is how the headers looks:
- Cyan:
- 39 01 00 00 = 313 polygon count
- 18 01 00 00 = 280 vertex count
- AD 00 6B 00 = unknown
About def_022.obj
The face indices start at 0x4C [00 00 01 00...]
and by the looks of it ends at 0x7A2 [...A2 00 A3 00]
I was using the tool called hex2obj 0.24c
but didn't have any luck in guessing the starting points of the vertices and uv list.
- Yellow: seems to me that it is the chunk marker. (because all files start with it)
- Light Blue: is a uint16 seq no., +1 for every model inside the
def.obj
. And it also corresponds to the index of its texture (on the texture archive). - Dark Green: is the face indices.
The Question
- How do I go forward?
- How do I find the address where the UV starts? (books? articles? resources?)
- Lastly, how do I know where the vertices start?
This is all considering that I just analyze the binary and not debug the client itself to see how the client is taking the data.
UPDATE
I noticed a few new things on the file I'm analyzing def_022.obj
. A bytearray gets repeated a lot of times. Although, I'm still not sure of the significance YET. 00 00 80 3F
is also the bytes that each model start with, which I thought was the chunk marker:
- Yellow: is the repeated bytes. You'll also notice that it is usually preceded by the byte
0x3F
or0x3E
and followed by0x0C
and0x0D
and then 3 bytes of0x00
. This pattern gets repeated 185 times. - Cyan: is the area containing the face indices.
- Upon further research I found out that
3f80 0000 = 1
or0000 803f = 1
for little endian. But still don't know the significance, I'm going to dig deeper.
Based on the notes Mr @RadLexus has kindly provided. I was also able to plot the vertices and imported into blender:
Added the normals and UV:
v -13.531700 37.445000 2.338600
vn -0.687800 0.725000 -0.036200
vt 0.583800 0.086300
Then I tried adding the faces:
f 1 2 3
f 1 3 4
f 5 6 7
f 5 7 8
f 9 10 11
...
But still can't figure out how to apply the textures.
UPDATE
So I tried changing my .obj
file to include a few more info about the face values like (just duplicated the value as x/x/x):
f 1/1/1 2/2/2 3/3/3
f 1/1/1 3/3/3 4/4/4
f 5/5/5 6/6/6 7/7/7
I finally got this:
Although it's still wrong, I guess I'm a bit closer.
FINAL UPDATE
Have figured it out. Although, I still don't know what the unknown1 and unknown2 are but it looks good enough:
Note: I know almost nothing about 3D file formats. Other than the basic components of a 3D object.
3f80 0000 = 1
or0000 803f
in little endian (which is what the file uses).