|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Format Specifications |
| 4 | +parent: Collision Model Manager (CM) |
| 5 | +grand_parent: Engine Documentation |
| 6 | +nav_order: 2 |
| 7 | +--- |
| 8 | + |
| 9 | +{: .no_toc } |
| 10 | + |
| 11 | +<details open markdown="block"> |
| 12 | + <summary> |
| 13 | + Table of contents |
| 14 | + </summary> |
| 15 | + {: .text-delta } |
| 16 | +- TOC |
| 17 | +{:toc} |
| 18 | +</details> |
| 19 | + |
| 20 | +The .cm (Collision Model) file format organizes data into sections for vertices, edges, nodes, polygons, and brushes to comprehensively define collision geometry in a game environment. |
| 21 | + |
| 22 | +# Version File |
| 23 | +--- |
| 24 | +The `"CM"` section on the `.cm` file indicates the version of wich this map/model was made on. |
| 25 | + |
| 26 | +{: .doom3 } |
| 27 | + |
| 28 | +> ```cpp |
| 29 | +> CM "1.00" |
| 30 | +> ``` |
| 31 | +
|
| 32 | +{: .prey06 } |
| 33 | +
|
| 34 | +> ```cpp |
| 35 | +> CM "1.00" |
| 36 | +> ``` |
| 37 | +
|
| 38 | +{: .quake4 } |
| 39 | +
|
| 40 | +> ```cpp |
| 41 | +> CM "3" |
| 42 | +> ``` |
| 43 | +
|
| 44 | +
|
| 45 | +# Cyclic redundancy check (CRC) |
| 46 | +--- |
| 47 | +This line is used for checksum purposes, this line is bitwise XOR of all entities's CRC, It is used to tell if the map is outdated |
| 48 | +compared to the .map file. |
| 49 | +
|
| 50 | +```cpp |
| 51 | +115442973 |
| 52 | +``` |
| 53 | +
|
| 54 | +# Collision Model |
| 55 | +--- |
| 56 | +This is the meat and bones of the Collision system, this inlines models for collision purposes, mostly `func_` entities, a basic look of |
| 57 | +`collisionModel`: |
| 58 | +```cpp |
| 59 | + collisionModel "func_static_1" { |
| 60 | + /** Irrelevant Code **/ |
| 61 | + } |
| 62 | +``` |
| 63 | +There's a special code for `collisionModel` that handles worldmap collision: |
| 64 | +```cpp |
| 65 | + collisionModel "worldMap" { |
| 66 | + /** Irrelevant Code **/ |
| 67 | + } |
| 68 | +``` |
| 69 | +`collisionModel` also contains 5 subgroups: `"vertices"`, `"edges"`, `"nodes"`, `"polygons"` and `"brushes"`. |
| 70 | +
|
| 71 | +## Vertices |
| 72 | +A list of vertices used to define the shape of the collision model. Each vertex is represented by a coordinate in 3D space `(x, y, z)`. |
| 73 | +```cpp |
| 74 | + vertices { /* numVertices = */ numverts |
| 75 | + /* vertnum */ ( x y z ) |
| 76 | + } |
| 77 | +``` |
| 78 | +* `numverts` = The number vertices that are in this group. |
| 79 | +* `vertnum` = The vertice that's being proccesed currently. |
| 80 | +* `x, y` and `z` = The position to where this vertex is locate at. |
| 81 | +
|
| 82 | +## Edges |
| 83 | +Defines the edges between vertices. Each edge connects two vertices and is defined by their indices. |
| 84 | +Optionally, additional information can be provided, such as edge direction or properties. |
| 85 | +```cpp |
| 86 | + edges { /* numEdges = */ numedgs |
| 87 | + /* edgenum */ ( start end ) internal numpolys |
| 88 | + } |
| 89 | +``` |
| 90 | +* `numEdges` = The number edges that are in this group. |
| 91 | +* `edgenum` = The edge that's being proccesed currently. |
| 92 | +* `start` = The start position to draw the edge from. |
| 93 | +* `end` = The end position to where the edge ends. |
| 94 | +* `internal` = Tells this edge that it shouldn't collide with internal edges. |
| 95 | +* `numpolys` = X many times this edge is used by poly. |
| 96 | +
|
| 97 | +## Nodes |
| 98 | +This section typically describes the nodes in the collision model's spatial partitioning structure, such as a BSP (Binary Space Partitioning) tree. Nodes are used to efficiently organize and query the collision geometry. |
| 99 | +```cpp |
| 100 | + nodes { |
| 101 | + ( index frontindex backindex ) <optional> |
| 102 | + } |
| 103 | +``` |
| 104 | +* `index` = The plane index. |
| 105 | +* `frontindex` = The front node index used for the BSP tree. |
| 106 | +* `backindex` = The back node index used for the BSP tree. |
| 107 | +
|
| 108 | +{: .note } |
| 109 | +
|
| 110 | +> Nodes are used for spatial partitioning (e.g., in a BSP tree). The exact format can vary depending on the specifics of the partitioning system used. |
| 111 | +
|
| 112 | +## Polygons |
| 113 | +Lists the polygons that make up the collision surfaces. Each polygon is defined by its vertices (or edges) and has additional attributes such as the normal vector, plane equation, and texture information. |
| 114 | +```cpp |
| 115 | + polygons { |
| 116 | + numverts ( index1 index2 ... ) ( normvectx normvecty normvectz ) distance ( bboxmin ) ( bboxmax ) "texture" |
| 117 | + } |
| 118 | +``` |
| 119 | +* `numverts` = The plane indexThe number of vertices this poly has. |
| 120 | +* `index1, index2, ect` = The indexes used to conform the polygon. |
| 121 | +* `normvectx, normvecty` and `normvectz` = Tells the direction of this vector's normal in the X/Y/Z. |
| 122 | +* `distance` = The distance between the polys and the bounding box. |
| 123 | +* `bboxmin` and `bboxmax` = The Min/Max of the bounding box. |
| 124 | +* `texture` = The texture that's assigned to this polygon. |
| 125 | +
|
| 126 | +## Brushes |
| 127 | +Brushes are convex shapes used to define solid areas for collision. Each brush is defined by a set of planes, and each plane is defined by a normal vector and a distance from the origin. Brushes are particularly useful for defining static architecture and level boundaries. |
| 128 | +```cpp |
| 129 | + brushes { |
| 130 | + numplanes { |
| 131 | + ( planenormx planenormy planenormz ) distance |
| 132 | + } ( bboxmin ) ( bboxmax ) <optional> |
| 133 | + } |
| 134 | +``` |
| 135 | +* `numplanes` = The current brush's plane that's being processed. |
| 136 | +* `planenormx, planenormy` and `planenormz` = Tells the direction of this plane normal in the X/Y/Z. |
| 137 | +* `distance` = The distance between the polys and the bounding box. |
| 138 | +* `bboxmin` and `bboxmax` = The Min/Max of the bounding box. |
| 139 | +
|
| 140 | +**Brushes**: define solid volumes through planes. Each plane in a brush contributes to the definition of a convex volume. |
0 commit comments