Offtopic: Into Commodore 64 (6502) coding, pixeling or music?
Xentax is looking for new members for the C64 activities!
Just drop us a message at forum@xentax.com and join the Scene Team!

Forum rules: Click here

Battlefield 3 & Battlefield 4 mesh files

Post questions about game models here, or help out others!
Post Reply
dainazinas
advanced
Posts: 40
Joined: Tue Jan 31, 2012 8:32 pm
Has thanked: 17 times
Been thanked: 12 times

Battlefield 3 & Battlefield 4 mesh files

Post by dainazinas » Sat Feb 22, 2014 8:15 pm

Hi.

I`ve recently been looking into the game files of bf3/bf4 and mohwf (frostbite2/3). I have written working texture converters for them and a semi working mesh(chunk) to obj converter(based on hex2obj by shakotay).

But I want to breakdown the files further.
Ok so the model files are of two parts
1: the .mesh file (header file) and
2: the .chunk file (payload file).


There still are a few things I don`t quite understand. For instance some of the models have multiple parts in a single mesh. But in game they all are separate models or model parts if you like i.e car body and its wheels are separate models in game, but in game files they are stored as one continuous mesh. Would this info be stored in the .mesh (header) or a .chunk (payload files)?

video http://www.youtube.com/watch?v=URDXPxyoJvU

And I`m also interested in bone weights and bone structures. The skeleton files are in readable format(txt file) and all the skeletal structure is available but now I need to know where the vertex values are stored so I can tie these together.
Here is a section from a .chunk (payload file)

Image

so my question is is this how bone weights are typically stored in mesh files? Or do I got it completely wrong and should look elsewhere?

here are "rat" files https://dl.dropboxusercontent.com/u/881 ... ch/rat.rar

luxox18
mega-veteran
mega-veteran
Posts: 176
Joined: Fri Jul 29, 2011 9:18 pm
Has thanked: 54 times
Been thanked: 41 times

Re: Battlefield 3 & Battlefield 4 mesh files

Post by luxox18 » Sun Feb 23, 2014 12:31 am

weights are stored in files called "bone influences" and bones in one standard bone structure named "skel"---- in BF3 - BF4 - MOHW all this files are inside of chunk files without names , for this is very difficult to find.

but in BFBC - BFBC2 - BF1943 all files have full names and are correctly classified , check the files from this games for find the structure and formats

User avatar
Chipicao
ultra-veteran
ultra-veteran
Posts: 476
Joined: Thu Feb 03, 2011 11:18 am
Has thanked: 42 times
Been thanked: 303 times
Contact:

Re: Battlefield 3 & Battlefield 4 mesh files

Post by Chipicao » Sun Feb 23, 2014 9:48 am

dainazinas wrote:some of the models have multiple parts in a single mesh. But in game they all are separate models or model parts if you like i.e car body and its wheels are separate models in game, but in game files they are stored as one continuous mesh.
It's not uncommon for vehicle parts to be controlled by bones via "hard" animations (blend weights =1). I've seen it in games like GTA IV/V, Driver SF and NFS Rivals.
dainazinas wrote:so my question is is this how bone weights are typically stored in mesh files? Or do I got it completely wrong and should look elsewhere?
I think blend weights are right after bone indices, stored as uint8 and need to be /255 to convert to floats.
Check some vehicle meshes. If the presumed blend weights are always 0xFF you can prove both theories.

Here's my take on the vertex structure. I double-checked normals and tangents in max, there's no doubt about them. So that only leaves one option for blend weights.
Image
Please post any requests or issues with my tools in the appropriate topics.
I'm sorry if I don't reply or if I ignore PMs. My time is very limited.

User avatar
cra0
ultra-veteran
ultra-veteran
Posts: 432
Joined: Fri Apr 27, 2012 9:37 am
Has thanked: 29 times
Been thanked: 184 times
Contact:

Re: Battlefield 3 & Battlefield 4 mesh files

Post by cra0 » Sun Feb 23, 2014 11:43 am

Dumping the vertex shader is always helpful when figuring those out

Code: Select all

HRESULT WINAPI hkCreateVertexShader( ID3D11Device * This, const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage *pClassLinkage, ID3D11VertexShader **ppVertexShader )
{
    ID3DBlob* pBlob = NULL;
    HRESULT hRet = D3DDisassemble( pShaderBytecode, BytecodeLength, 0, "/*========================DUMPED BY D1GITALSLR================================*/ \n", &pBlob );
    char* buffer = (char*)malloc(pBlob->GetBufferSize());
    memcpy(buffer, pBlob->GetBufferPointer(), pBlob->GetBufferSize());
    mFile << buffer;
    mFile << "\r\n\r\n";
    return oCreateVertexShader( This, pShaderBytecode, BytecodeLength, pClassLinkage, ppVertexShader);
}  
Credits to d1gitalSLR @unknowncheats

dainazinas
advanced
Posts: 40
Joined: Tue Jan 31, 2012 8:32 pm
Has thanked: 17 times
Been thanked: 12 times

Re: Battlefield 3 & Battlefield 4 mesh files

Post by dainazinas » Thu Feb 27, 2014 3:49 am

luxox18 wrote:weights are stored in files called "bone influences" and bones in one standard bone structure named "skel"---- in BF3 - BF4 - MOHW all this files are inside of chunk files without names , for this is very difficult to find.

but in BFBC - BFBC2 - BF1943 all files have full names and are correctly classified , check the files from this games for find the structure and formats
Thanks for the info, but those files do not contain per/vertex information.
Chipicao wrote:It's not uncommon for vehicle parts to be controlled by bones via "hard" animations (blend weights =1). I've seen it in games like GTA IV/V, Driver SF and NFS Rivals.
This makes a lot of sense, thanks. So here is a model of vehicle from Battlefield 3 (M_FA_18F_D). But vehicle parts don`t seem to have 0xFF weights but instead uses same bone index x4 , strange... . + this model uses 2 sets of UV`s one for normal and second for diffuse.

Image
I wrote a maxscript that selects vertex`es based on bone indice positions in the chunk file, it seems to work quite well
Here`s the files if anyone wants to check them out. https://dl.dropboxusercontent.com/u/881 ... _18F_D.rar

cra0 wrote:Dumping the vertex shader is always helpful when figuring those out
Thanks, mind elaborating?

User avatar
Chipicao
ultra-veteran
ultra-veteran
Posts: 476
Joined: Thu Feb 03, 2011 11:18 am
Has thanked: 42 times
Been thanked: 303 times
Contact:

Re: Battlefield 3 & Battlefield 4 mesh files

Post by Chipicao » Thu Feb 27, 2014 8:30 pm

dainazinas wrote:vehicle parts don`t seem to have 0xFF weights but instead uses same bone index x4 , strange...
Not strange at all. Since blend weights would always be =1.0 in this model, it makes sense not to include them in order to save space and memory. The game probably detects this in a flag or in the shader.
Please post any requests or issues with my tools in the appropriate topics.
I'm sorry if I don't reply or if I ignore PMs. My time is very limited.

dainazinas
advanced
Posts: 40
Joined: Tue Jan 31, 2012 8:32 pm
Has thanked: 17 times
Been thanked: 12 times

Re: Battlefield 3 & Battlefield 4 mesh files

Post by dainazinas » Mon Mar 03, 2014 4:01 pm

Chipicao wrote:
dainazinas wrote:vehicle parts don`t seem to have 0xFF weights but instead uses same bone index x4 , strange...
Not strange at all. Since blend weights would always be =1.0 in this model, it makes sense not to include them in order to save space and memory. The game probably detects this in a flag or in the shader.

I`m having trouble finding in (*.mesh/aka_header file) something that would indicate the data structure in the .chunk file. What I do know is where the vertex block size, vertex/faceindice count, string name, for each model + total mesh/submesh count. But no reliable UV`s position. Anyone could shed some light on this?
Last edited by dainazinas on Mon Mar 03, 2014 5:26 pm, edited 3 times in total.

User avatar
Chipicao
ultra-veteran
ultra-veteran
Posts: 476
Joined: Thu Feb 03, 2011 11:18 am
Has thanked: 42 times
Been thanked: 303 times
Contact:

Re: Battlefield 3 & Battlefield 4 mesh files

Post by Chipicao » Mon Mar 03, 2014 5:12 pm

This would go a bit faster if you'd share the structure you have identified so far.

Am I correct on the following?
Image

Send me one or two more meshes that have different VB structures than the rat.
Please post any requests or issues with my tools in the appropriate topics.
I'm sorry if I don't reply or if I ignore PMs. My time is very limited.

dainazinas
advanced
Posts: 40
Joined: Tue Jan 31, 2012 8:32 pm
Has thanked: 17 times
Been thanked: 12 times

Re: Battlefield 3 & Battlefield 4 mesh files

Post by dainazinas » Mon Mar 03, 2014 6:01 pm

Chipicao wrote: Send me one or two more meshes that have different VB structures than the rat.

Various models and a rat.hbk(in rat.rar)

https://dl.dropboxusercontent.com/u/881 ... models.rar
https://dl.dropboxusercontent.com/u/881 ... F4/Rat.rar

thanks

dainazinas
advanced
Posts: 40
Joined: Tue Jan 31, 2012 8:32 pm
Has thanked: 17 times
Been thanked: 12 times

Re: Battlefield 3 & Battlefield 4 mesh files

Post by dainazinas » Tue Mar 04, 2014 8:29 pm

Chipicao did you get a chance to have a look at the structures?

I`ve been trying and failing as the offsets I can read are inconsistent.

Please help when you get a chance :)

User avatar
Chipicao
ultra-veteran
ultra-veteran
Posts: 476
Joined: Thu Feb 03, 2011 11:18 am
Has thanked: 42 times
Been thanked: 303 times
Contact:

Re: Battlefield 3 & Battlefield 4 mesh files

Post by Chipicao » Wed Mar 05, 2014 9:18 am

Sorry, I didn't have time to analyze them properly.
The only thing you got wrong in your hbk was the IB offset. What you bookmarked as "Mesh.0 Face Indice Count" is actually the offset in indices for the second mesh. It's just a coincidence that it matches the index count of the first mesh because they are both the same.

When I have some free time I will look more into it.
Please post any requests or issues with my tools in the appropriate topics.
I'm sorry if I don't reply or if I ignore PMs. My time is very limited.

dainazinas
advanced
Posts: 40
Joined: Tue Jan 31, 2012 8:32 pm
Has thanked: 17 times
Been thanked: 12 times

Re: Battlefield 3 & Battlefield 4 mesh files

Post by dainazinas » Fri Mar 07, 2014 6:25 pm

Chipicao wrote:When I have some free time I will look more into it.
I really hope you can help me with the mesh files. As for now I managed to get maxscript to import and name the skeletons(I think it does it properly) however it does not deal with hierarchy just yet, and another script that imports the geometry, it needs some manual input, and that`s where reading the .mesh/header files properly would be super useful.

And thanks for the update Chipicao :)

here are the updated scripts, skeleton, geometry and mesh/header files again. https://dl.dropboxusercontent.com/u/881 ... ch/Rat.rar

LALHW
ultra-n00b
Posts: 9
Joined: Sun Jan 10, 2016 1:37 am

Re: Battlefield 3 & Battlefield 4 mesh files

Post by LALHW » Tue Jan 12, 2016 10:44 pm

Sorry for messing with this old thread, but do you still have the texture converters?

Post Reply