OpenRA Weapon Positioning
Friday 9 April 2010 - Filed under Uncategorized
People have been confused about this (mostly my fault, because the weapon positions in the official version of the code have been horribly wrong for a while), so here’s how the various offsets work.
There are three spaces involved:
- Unit-space. offsets[0] is the displacement of the turret (or fixed gun) along the longitudinal axis of the unit. offsets[1] is the displacement along the lateral axis. These rotate as the unit rotates, with some slight eccentricity to match the RA art’s projection. Here:
- Screen-space. offsets[2] and offsets[3] are screen space displacements for the turret, applied after the unit rotation is taken into account. [2] is the positive X screen-space axis; [3] is the positive Y screen-space axis. I don’t think I need to draw a picture for this one.
- Turret-space. Since we allow more than one weapon to be mounted on a turret, and more than one “barrel” for each weapon, we also have local displacements relative to the turret’s orientation. Turret space positions are triples: [0] is the displacement along the turret’s longitudinal axis; [1] is the displacement along the turret’s lateral axis, and [2] is the angle deviation, where 256 is a full circle. For multiple-barrel weapons (a missile battery such as on DD, for example, or dual missile launchers on 4TNK), we have multiple sets of offsets, end on end. Here’s how 4TNK is set up:
2010-04-09 » admin