Brushes - cterveen/upkg GitHub Wiki
Brushes are the building blocks of an Unreal Tournament maps geometry.
Objects
A brush object consists of three parts: a Brush object, a Model object and a Polys object. The Brush contains the brush properties, Brush.Brush is an object reference to the Model object. The Model contains some unknown information, what I've seen doesn't fit with what's documented. An object reference to the Polys is included in the Model. The Polys contains the information of each of the polys of the Brush.
Brush object
A brush object contains a series of object properties.
Format
- objectproperties
Object properties
- Brush = Object reference to the Model object
- CsgOper = Brush CsgTypes (CSG_Active, CSG_Add, CSG_Substract, CSG_Intersect, CSG_Deintersect)
- Location = Location of the Pivot (red cross in Unreal Ed) from the centre (0,0,0)
- MainScale = Brush scaling and transformation (X, Y, Z, Sheerrate, Sheeraxis)
- PolyFlags = Flags for each of the polys (see UT_Package_Format document)
- PostScale = Brush scaling and transformation (X, Y, Z, Sheerrate, Sheeraxis)
- PrePivot = The location of the 'center' (brush coloured dot in UnrealEd) of the polys from the 'Pivot' (red cross in UnrealEd)
- Region = Object Reference to the zone a brush is in
- Rotation = Brush rotation (Roll (x-axis), Pitch (y-axis), Yaw (z-axis))
- RotationRate = (Based on Unreal Wiki: The rotation speed of the Brush, this implies contiuous movement)
Model object
The model object does not behave like descriped in Antonio Cordero's project for most Unreal Tournament maps. The only thing I could manage to find is that the 55th byte after the object properties contains an index with an object reference towards the Polys object. There are however maps with a different model which I have yet to explore.
Format
- objectproperties
- 54 bytes - no idea
- index - export property polys
- 14 bytes - no idea
Object properties
- none?
Polys object
The Polys object contains the polys of the Brush. Each poly exists of one or more vertices and the associated properties.
Format
- objectproperties
- long - numPolys
- long - arrayLength
- each arrayLength
- index - numcoords
- float - base_x
- float - base_y
- float - base_z
- float - normal_x
- float - normal_y
- float - normal_z
- float - texu_x
- float - texu_y
- float - texu_z
- float - texv_x
- float - texv_y
- float - texv_z
- each numcoords
- float x
- float y
- float z
- long - polyflags
- index - actor
- index - texture
- index - itemname
- index - ilink
- index - ibrushpoly
- short - panu
- short - panv
Object properties
- none?
Recreating the geometry
The geometry is made up from vertices defined in the Polys object. Vertices are the corner coordinates of a polygon (a surface). The polygons together make the geometry of the brush.
The location of each vertex can be calculated by the following transformations:
- Mainscale (scale)
- Rotation.Roll (rotate)
- Rotation.Pitch (rotate)
- Rotation.Yaw (rotate)
- Postscale (scale)
- PrePivot (move)
- Location (move)
Scaling
The scale is calculated from the Pivot. A negative scale therefore implies that the vertex is mirrored from the pivot.
Rotation
The number of degrees to rotate can be calculated by:
Degrees.Roll = (Rotation.Roll / 65536) * 360 * direction
The direction can be 1 or -1 and may differ between the rotators and scripts, currently I use 1 for Roll and -1 for Pitch and Yaw.
Move
Moving just adds the movement to the vertex coordinates.
Note
These transformations work directly on the vertex. However, I think the UT way is to do these transformations for the vertices based on the center and then the transformation of the center based on the Pivot so the center moves along with the vertices.
It's possible to delete the Brush, I think the geometry is then stored in the Models. I have yet to explore these packages.
Texture
To be explored.