BRF Format and collision meshes: brief documentation (Pt 1)

Users who are viewing this thread

fisheye

The information here is for documentation purposes only. Modders might find it easier to read the brflib source here:
http://forums.taleworlds.com/viewtopic.php?t=6076
Working link is on page 3 of that thread.

A tool to create collision mesh BRFs is here:
http://forums.taleworlds.com/viewtopic.php?t=7054

Data types:
An int is a 32-bit integer value.

An float is a 32-bit IEEE float.

A string is a 32-bit length value followed by the ASCII string.

A list is a 32-bit value indicating the number of records followed by each of the records. So a string could be thought of as a list of chars.

A Vertex object: is a triple of 3 floats, representing X,Y,Z respectively.

BRF File format

BRFs (presumably, Binary Resource Files) contain all the game's binary resources. Each file consists of a number of collections concatenated together: note that this is not a LIST of collections, the file is just read until the first "end" collection. An identifier within each collection identifies the exact type of collection it is (e.g. a collection of viewable meshes, collision mesh, skeleton/animation). Each collection can only contain one type of data structure.

"EOF" collection:
1. (String) collision mesh identifier: "end"
IMPORTANT: This special collection type, "end", is used to denote the end of the file. YOu MUST end your BRF with this collection, otherwise M&B will crash upon loading.

Collision meshes
Collision meshes are simply descriptions of spaces which are not allowed to intersect in the game's physics engine. So if you want to make an object impassible (or be able to stand on it), you just need to roughly describe the space that it takes up with a collision mesh.

Body (collision mesh) collection:
1. (String) collision mesh identifier: "body"
2. List of collision mesh data structures

Body (collision mesh) data structure:
1. (String) Mesh name, e.g. "bo_shield"
2. Collision object: one of the below

"Composite" collision object data structure:
1. (String) Object type identifier: "composite"
2. List of Collision objects

"Face" collision object data structure:
A face is a two dimensional polygon. Good for walls and floors and such.
1. (String) Object type identifier: "face"
2. List of Vertex Objects (going counterclockwise around the face)
3. (int) unknown (flags?): always set to 4


"Capsule" collision object data structure:
A capsule looks like this:
http://otee.dk/Documentation/Components/class-CapsuleCollider.html
Good for enclosing a solid object, e.g. a chair or pillar. Note that the game's physics engine allows climbing of slopes so a small enough capsule laid lengthwise will be "climbable" by a player. To prevent this, you can put a face on top of it.
1. (String) Object type identifier: "capsule"
2. (float) radius. See diagram.
3. (vertex object) center of first hemisphere.
4. (vertex object) center of second hemisphere.
5. (int) unknown (flags?): always set to 4

"Sphere" collision object data structure:
Good for enclosing objects with identical dimensions in all axes, e.g. a skull, a bowl.
1. (String) Object type identifier: "sphere"
2. (float) radius.
3. (vertex object) center of sphere.
4. (int) unknown (flags?): always set to 4

"Manifold" collision object data structure:
Manifold traditionally refers to a solid 3d object. The format of this object is currently unknown (to me at least).
 
Nicely done. Let me know if you figure out any more of the unknown types, and I'll update the lib. When Lurb gets back he can give you access to check in to the source.
 
Effidian said:
Nicely done. Let me know if you figure out any more of the unknown types, and I'll update the lib. When Lurb gets back he can give you access to check in to the source.

Thanks Effidian. But I won't edit the code if Lurb becomes active again; that is his domain. I might provide some brief documentation and some crude stop-gap tools until he comes online again, this is to keep all the great mod projects going.
 
The BRF lib is shared and filling in unknown types would be welcome by all of us.

Now, his mesh editor is another story... :wink:
 
Back
Top Bottom