bMesh - themeldingwars/Documentation GitHub Wiki
bMesh files, which I assume stands for Binary Mesh are used for the majority of the meshes in Firefall, with R5A files holding some UI meshes and the terrain geo being in another.
010 Editor Template
Implementation
- Reader and Writer have been implemented in FauFau: BMesh.cs
Tools
Format
The format is chunk based. Below is the format of each section/chunk or data types.
Header
ID : 5 chars equaling "bMesh"
Version : a short for the version of the format
Padding : 1 byte // Must be 0
Vertex
X : a float
Y : a float
Z : a float
UV
U : a float
V : a float
Vec4
X : an unsigned byte
Y : an unsigned byte
Z : an unsigned byte
d : an unsigned byte
Face
v1 : an int32
v2 : an int32
v3 : an int32
bMeshString
Length : an int32
String[Length] : an ubyte array
Material
Name : a bMeshString
FaceRangeStart : an int32
FaceRangeEnd : an int32
VertRangeStart : an int32
VertRangeEnd : an int32
Bounds
Min : a Vertex (or 3 floats if you prefer)
Max : a Vertex (or 3 floats if you prefer)
Materials
NumMaterials : an int32 saying how many Materials follow
Materials[NumMaterials] : an array of Materials
Reading a bMesh
Pseudo code
Header head = Read();
Bounds bounds = Read();
short padding = Read();
int32 NumVerts = Read();
Vertex Vertices[NumVerts] = Read();
int32 unknown = Read():
int32 NumVertsNormals = Read();
Vec4 Normals[NumVerts] = Read();
int32 NumUVs = Read();
UV UVs[NumVerts] = Read();
int32 marker = Read();
if (marker != 0)
{
Seek(marker*8); // Not sure what these are, most likley related to bones
}
else
{
int32 NumTangents = Read();
Vec4 Tangents[NumTangents] = Read();
}
Int32 marker = Read();
if (marker != 0)
{
Seek(marker*4); // Not sure what these are, bone weights?
int32 unknow = Read(); // Seems to always be 0
int32 NumIndices = Read();
int32 Indices[NumIndices] = Read();
// Bone data normaly follows?
}
else
{
int32 NumIndices = Read();
int32 Indices[NumIndices] = Read();
}
// That was as much as I figured out
Parsing Normals and Tangents
The normals and tangents seem to be encoded in some compressed format, I'm not entirely sure the right way to uncompress them but below is what I did that looks somewhat ok
x = (x/256*100);
Enums
Notes
File version 30 is the most current any version less is out dated and the engine will attpemt to update.