Table of Contents
Defined in various sub-folders under the resource tree <res> (for example, <res>/environments, <res>/flora, <res>/sets/vehicles, etc...), the .primitives files use BinSection (for details on grammar of BinSection files, see BinSection files) to have discrete bits of binary data saved in one file using the BigWorld file system.
The primitive file can contain vertex data, index data, and BSP data.
The section with vertex data contains a small header, followed by the raw vertex data.
Described in BNF format, the file has the following format (the asterisk character —*— indicates that the previous section might appear zero or more times.):
<vertex_format> <number_of_vertices> <raw_vertex_data>
.primitives file format in BNF grammar — Vertex data section
The list below describes the sections in the file:
-
<number_of_vertices>
Number of vertices.
-
<raw_vertex_data>
Actual vertex data, with size equal to sizeof vertex * <number_of_vertices>.
-
<vertex_format>
64-byte field, containing the name of the vertex format (e.g., xyznuv, xyznuvtb, etc...).
The section with index data contains a small header and the raw index data, followed by the primitive groups. The primitive groups define the batches with different materials in the triangle list (these are the same primitive groups referenced from the .visual file — for details on grammar of .visual files, see .visual).
Described in BNF format, the file has the following format (the asterisk character —*— indicates that the previous section might appear zero or more times):
<index_format> <number_of_indices> <number_of_primitive_groups> <raw_index_data> <raw_primitive_data> ::= <primitive_group_data>*<primitive_group_data> ::= <start_idx><num_of_primtvs><start_vrtx><num_of_vrtcs>
.primitives file format in BNF grammar — Index data section
The list below describes the sections in the file:
-
<index_format>
64-byte field, containing the type of index list.
Possible values are list (which mean a 16-bit index list), and list32 (which means a 32-bit index list).
-
<num_of_primtvs>
Number of triangles rendered in this group.
-
<num_of_vrtcs>
Number of vertices used by the triangles in this group.
-
<number_of_indices>
Integer number containing the number of indices.
-
<number_of_primitive_groups>
Integer number containing the number of primitive groups.
-
<raw_index_data>
Actual index data, with size equal to 2*<number_of_vertices> (if <index_format> is list), or 4*<number_of_vertices> (if <index_format> is list32).
-
<raw_primitive_data>
Actual primitive groups data, with size equal to 16*<number_of_primitive_groups>.
This section contains <number_of_primitive_groups> sections <primitive_group_data>.
-
<start_idx>
First index used by this group of triangles.
-
<start_vrtx>
First vertex used by the triangles in this group.
The section with BSP data contains a small header, followed by the raw BSP data.
Described in BNF format, the file has the following format (the asterisk character —*— indicates that the previous section might appear zero or more times):
<bsp_file> ::= <header> <triangle>* <node>* <user_data>* <header> ::= <magic_number> <num_triangles> <max_triangles> <num_nodes> <triangle> ::= <Vector3> <Vector3> <Vector3> <node> ::= <node_flags> <plane_eq> <num_indices> <triangle_index>* <node_flags> ::= <reserved> <is_partitioned> <has_front> <has_back> <plane_eq> ::= <normal><d> <normal> ::= <Vector3> <user_data> ::= <user_data_key> <user_data_blob> <user_data_blob> ::= <blob_size> <byte>*
.primitives file format in BNF grammar — BSP data section
The list below describes the sections in the file:
-
<blob_size>
4-byte unsigned integer containing the number of bytes in the subsequent blob of binary data.
-
<d>
Float value equal to the dot product of <plane_eq> and <normal>.
-
<has_back>
1-bit flag indicating if node has a back child.
-
<has_front>
1-bit flag indicating if node has a front child.
-
<is_partitioned>
1-bit flag indicating if all triangles lie on the node's plane
-
<magic_number>
4-byte number 0x00505342 containing version number in the last byte
-
<max_triangles>
4-byte unsigned integer containing maximum size of all <triangle_index> lists.
-
<normal>
Normal to plane's front.
-
<num_indices>
2-byte unsigned integer containing the number of <triangle_index> sections in current <node> section.
-
<num_nodes>
4-byte unsigned integer containing the number of nodes in <node>.
-
<num_triangles>
4-byte unsigned integer containing the number of triangles in <triangle>.
-
<reserved>
5-bit reserved number 10100.
-
<triangle_index>
2-byte unsigned integer containing the index to the <triangle> section.
-
<triangle>
XYZ position of the triangle's vertices.
-
<user_data_key>
4-byte unsigned integer containing user-defined key associated with data.
-
<Vector3>
Vector composed of 3 float values.