Origin of the entities

The origin key in Quake can sometimes be tricky to understand, because the intuitive idea of how it works doesn’t quite fit for brush-based entities in a map. It may be helpful to imagine that the origin key serves double duty; depending on the type of entity, the value should be interpreted as either an absolute position or a relative offset. Let’s break that down in detail.

The easier interpretation of the origin key goes hand in hand with .mdl files (or .spr files, or even on occasion external .bsp files). These models are positioned about a central point, which is invariably chosen to be near the centre-of-mass of the model. The origin key gives the coordinates of the central point, so it’s pretty easy to see it as specifying the absolute coordinates of the entire entity – the offset from the origin of the map

The other interpretation is for brush-based models which are compiled into a map. For these models, the origin key should be thought of as position relative to one’s own starting position. Setting an origin of ‘0 0 64’ on such an entity displaces it vertically by 64 units from where it began. Any such entity can be moved back to its compiled position by setting the origin key to ‘0 0 0’.

It’s worth noting that this division is largely artificial. It is entirely possible to create a .mdl of a statue where the polygons are all off at ‘1000 -500 256’, and position the statue entity at the origin of the map (although rotating this model would be a real pain). Conversely, the rotate_object compiler business creates a brush model whose centre is at the point specified by the info_rotate, and then sets a non-zero origin key to translate the brushes back to their starting position. Nevertheless, it is a helpful mental model to have – external models are absolutely positioned and internal (map-based) models are relatively positioned.

If you are trying to code QuakeC which uses the “centre of mass” of a particular entity – some roughly central point on a visible and solid entity, the origin only works for entities of the first type. However, an alternative exists in the absmin and absmax keys. These give the absolute coordinates of the bounding box of the entity, including any displacement. Crucially, for SOLID_BSP models the bounding box exactly encloses the brushes of the model, so (absmin + absmax) / 2 gives the centre of the bounding box.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.