Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Extracting models from binary files

Post questions about game models here, or help out others!
Post Reply
rithesh
ultra-n00b
Posts: 4
Joined: Sun Apr 26, 2020 6:05 pm
Has thanked: 1 time
Been thanked: 1 time

Extracting models from binary files

Post by rithesh »

I am trying to build a tool to export and import binary models from an old DX9 game. The models are packed in a single file and I have managed to extract the relevant parts in hexadecimal.

The data below corresponds to a simple rectangle plane in the game. (First image is the Vertex Buffer and the second image is the Indices)

Image

Vertex Buffer

Code: Select all

[8B F6 00 00] [65 09 03 00] [80 FF 80 FF] [FF FF FF FF] [00 00 00 00] [00 00 00 00]
[8B F6 00 00] [9B F6 03 00] [80 FF 80 FF] [FF FF FF FF] [00 00 00 00] [00 00 80 3F]
[75 09 00 00] [65 09 03 00] [80 FF 80 FF] [FF FF FF FF] [00 00 80 3F] [00 00 00 00]
[75 09 00 00] [9B F6 03 00] [80 FF 80 FF] [FF FF FF FF] [00 00 80 3F] [00 00 80 3F]
Indices

Code: Select all

[00 00] [01 00] [02 00] [03 00] [02 00] [01 00]
By analyzing the Vertex buffer, I have concluded that it was using the following format. Basically the stride is 24 bytes.

Code: Select all

struct CUSTOMVERTEX
{
    CUSTOMVERTEX(FLOAT fx, FLOAT fy, FLOAT fz, DWORD dwcolor, FLOAT fu, FLOAT fv) :
        X(fx), Y(fy), Z(fz), COLOR(dwcolor), U(fu), V(fv) {}
    FLOAT X, Y, Z;
    DWORD COLOR;
    FLOAT U, V;
};
I believe the vertex buffer is not in the correct format since i am getting NAN values when I convert them to 32bit floats. Any idea how I can convert these vertices and indices to any 3D file format so that I can open them using blender or 3DS?
Last edited by rithesh on Sun Jul 18, 2021 1:34 pm, edited 3 times in total.
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4287
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1148 times
Been thanked: 2242 times

Re: Project3 extracting models from binary files

Post by shakotay2 »

Sample file?
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
rithesh
ultra-n00b
Posts: 4
Joined: Sun Apr 26, 2020 6:05 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Project3 extracting models from binary files

Post by rithesh »

Last edited by rithesh on Sun Jul 18, 2021 1:36 pm, edited 1 time in total.
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4287
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1148 times
Been thanked: 2242 times

Re: Project3 extracting models from binary files

Post by shakotay2 »

here's your cube (file 2):
.
cube.png
File 1: there's floats (6x4 floats) (bounding box I think, not tested) and float uvs, funny. Strange combination with short vertices.

(Correct me if I'm wrong: are there 321 identical cubes in file 1? :D )

(Sword is from file 2.)
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
rithesh
ultra-n00b
Posts: 4
Joined: Sun Apr 26, 2020 6:05 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Project3 extracting models from binary files

Post by rithesh »

Thanks a lot! I didn't expect short vertices. :D
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4287
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1148 times
Been thanked: 2242 times

Re: Project3 extracting models from binary files

Post by shakotay2 »

Here's a tool for conversion to obj, roughly tested only:
Make_obj-Project3-test.zip
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4287
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1148 times
Been thanked: 2242 times

Re: Project3 extracting models from binary files

Post by shakotay2 »

File 1 (1696 meshes, maybe more), all in one clump:
.
file 1.jpg
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
rithesh
ultra-n00b
Posts: 4
Joined: Sun Apr 26, 2020 6:05 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Project3 extracting models from binary files

Post by rithesh »

Works great! Thanks a ton.

How are the short vertices converted to float in your tool?
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4287
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1148 times
Been thanked: 2242 times

Re: Project3 extracting models from binary files

Post by shakotay2 »

Code: Select all

void log_short_Verts(DWORD addrV, DWORD Vcnt, BYTE vStride)
{
    char *pFBuf ;
    BYTE i, l ;
    int nValue[2] ;
    DWORD k ;
    float lPosXYZ ;

    pFBuf = (char *) lpFBuf ;
    pFBuf += addrV ;
    for (k=0;k < Vcnt;k++) {
        fprintf( stream, "v ") ;
	for (l=0;l<3;l++) {
	    for (i=0;i<2;i++) {						// 1x Word
		nValue[i] = (*pFBuf & 255) ; pFBuf++ ;
	    }
            lPosXYZ= nValue[0] + nValue[1]*256 ;
            if (lPosXYZ>32767) lPosXYZ -= 65536;
	    fprintf( stream, "%f ", lPosXYZ/256.0) ;
	}
	fprintf( stream, "\n") ;
	pFBuf += vStride-6 ;
    }
}
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
Post Reply