Jump to content
Official BF Editor Forums
Sign in to follow this  
dainiuxxx

Bf3/bf4 Mesh Research

Recommended Posts

So I have been researching the *.mesh and *.chunk files contents that were dumped using FrankElstner`s scripts(Thank you Frank :)/>/>/>/>).

So far I know how to get *.chunk (actual mesh data) file Lod`s GUID`s from *.mesh files.

Mesh_File_Structure.jpg

First Lod0 starts(in this instance) at 000000C8(10 bytes long), Lod1 176 bytes down at 00000188, Lod2 176 bytes down, etc.

I have made a small primitive app to locate and copy over first Lod(0)aka *.chunk file to the *.mesh file dir, based on *.mesh file offset(000000C8).

https://dl.dropboxusercontent.com/u/88155050/BF4/Mesh%20research/LOD%200%20GUID%20READER1.rar

As for geometry within the *.chunk file I can get the models out using ingenious app Hex2Obj made by "Shakotay2".

http://forum.xentax.com/viewtopic.php?f=29&t=10894

Screenshot_2014_01_16_00_31_40.jpg

The model above(AK74_U_1p) consists of a base mesh(0x0005BE60 to 0x00064AEE) and 3 submeshes, #1(0x00064AEE to 0x00064B7E)#2(0x00064B7E to 0x0006527A) etc.

I have made a small app to get these offsets from the *.chunk file to make it easier to work with Hex2Obj.

https://dl.dropboxusercontent.com/u/88155050/BF4/Mesh%20research/Hex2obj%20Extension2.rar

But I am no coder and obviously there is plenty of room for improvement of Bf3/Bf4 mesh tools. So if anyone cares to join forces please let me know.

Any suggestions and comments are well appreciated.

Small addition #

The base mesh and submesh names start offset is "1080bytes" or 0x0480

Edited by dainiuxxx

Share this post


Link to post
Share on other sites

The res seems to contain 4 sections after the header.

1) Contains structures with a0 bytes each. A chunk id is given with an offset of 58 relative to the structure.

2) Contains structures with c0 bytes each. No ids here. Each structure ends with two "lines" (when using 0x10 alignment in the hex editor) which each read FFFFFFFFFFFFFFFFFFFFFFFF00000000.

3) A string section.

4) Payload of some sort?

Header:

8 floats. Unknown purpose. Fourth and eighth float is null.

6 longs. Each long specifies the offset of a structure in the first section. If the section has less than 6 elements, the last few longs are set to null. As a consequence, there cannot be more than 6 guids given in a single res file (or so I believe). What's more, the structures are always a0 bytes and the header has a fixed size too, so one can calculate the offsets anyway without these longs.

2 longs. Absolute string offsets. It works like this:

1) objects/props/puddle/puddle_02_Mesh

2) puddle_02_Mesh (this is a substring of the previous one)

1 int. Hash of the filename or something like that.

4 nullbytes

1 int. Can exceed the size of the res + chunk (even when taken together). Other times is just 1.

1 short. Number of elements in first section, may not exceed 6 (because 6 longs max)

1 short. Number of elements in second section

first section:
4 nulls, ffff, 2 nulls
struct (3 ints): 5 times
	1) small num
	2) offset/size?
	3) null

	Times:
		1) 1, 110, null. maybe size of floats in chunk
		2) 0, 230, null. Offset in res (after strings)
		3) 1, 230, null. Same?
		4) 0, 231, null. 
		5) 0, 231, null.

long. 41 or 40
int. 30
long. 120. maybe size of floats in chunk
guid
ffffffff
8 nulls
3 longs, string offsets
	1) Mesh:objects/props/puddle/puddle_02_Mesh_lod0
	2)      objects/props/puddle/puddle_02_Mesh_lod0
	3)                           puddle_02_Mesh_lod0
h32?
16 nulls

second section:
8 nulls
int, string offset: lambert2
8 nulls
small int, 8
8 nulls
small int, 9
       so maybe that was a struct with 3 ints again.

int, 320
8 nulls

some very odd bytes now

FFFFFFFFFFFFFFFFFFFFFFFF00000000
FFFFFFFFFFFFFFFFFFFFFFFF00000000

About your second tool, note that you need to use the EOF to calculate the last number of faces. I've cleaned up your program and fixed that issue: http://pastebin.com/iciNCS5N

Also note that kiwidog is working on the meshes too right now, though I don't know much about his progress.

Edited by Frankelstner

Share this post


Link to post
Share on other sites

Here is my addition to your work on "puddle_02_mesh 2150530f2f3e5a87 4002000000000000300000007000c000" file.

first section:
       4 nulls, ffff, 2 nulls
       struct (3 ints): 5 times
               1) small num
               2) offset/size?
               3) null

               Times:
                       1) 1, 110, null. maybe size of floats in chunk
                       2) 0, 230, null. Offset in res (after strings)
                       3) 1, 230, null. Same?
                       4) 0, 231, null. 
                       5) 0, 231, null.

       long. 41 or 40
       int. 30
       long. 120. maybe size of floats in chunk ///////this is offset to geometry data structure in chunk
       guid
       ffffffff
       8 nulls
       3 longs, string offsets
               1) Mesh:objects/props/puddle/puddle_02_Mesh_lod0
               2)      objects/props/puddle/puddle_02_Mesh_lod0
               3)                           puddle_02_Mesh_lod0
       h32?
       16 nulls

second section:
       8 nulls
       int, string offset: lambert2
       8 nulls
       small int, 8  ///////this is face count
       8 nulls
       small int, 9  /////// this is vertex count
       so maybe that was a struct with 3 ints again.

       int, 320 //int 32 this could be vertex block size(VB)
       8 nulls

       some very odd bytes now

       FFFFFFFFFFFFFFFFFFFFFFFF00000000
       FFFFFFFFFFFFFFFFFFFFFFFF00000000

And here is the "puddle_02_" folder, including obj file https://dl.dropboxusercontent.com/u/88155050/BF4/Mesh%20research/puddle.rar

Edited by dainiuxxx

Share this post


Link to post
Share on other sites

As far as I know terrain creation in frostbite games is done in runtime using tile based procedural mesh generator more on this here http://dice.se/wp-content/uploads/GDC12_Terrain_in_Battlefield3.pdf

I`m not saying it is not possible, but it is rather unusual way of doing this. I do not know if anyone is working on this.

However I am nearly finished with bf3\bf4\mohwf mesh importer for 3ds max I might take a look at it once I finalize the mesh tools.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×