Offsets

From Data Realms Wiki

Revision as of 23:36, 5 July 2012 by Brendan (Talk | contribs)
Jump to: navigation, search

Offsets define relative positions of many things in Cortex Command. They describe individual points mapping to individual pixels within sprites. Those points are used to position a sprite in relation to another sprite, and Offsets relative to other Offsets. They define where things are, like the gun carried by a soldier, and also where things are emitted from, like the bullets from that gun.

You'll need to understand Cartesian coordinates and arithmetic with positive and negative numbers.

Contents

SpriteOffset

If sprites in Cortex Command were paper drawings, cut out and pinned to a background, the SpriteOffset would be where the push pin goes though the cutout. If you spin the cutout, it spins around the pin. In physics, things spin around their own center of mass. The SpriteOffset provides something similar.

Cortex Command uses pixels, not paper, and pixels have coordinates. Any coordinate system needs an origin-- “X = 0, Y = 0”. The origin works like the push pin for positioning and moving sprites. If you open a sprite's image file in an image editor, all the pixels are positive integers except the pixel up in the top left which is (0,0). But this pixel shouldn't represent the center of mass. The pixel which should-- for this and some other reasons-- is the very center one.
The SpriteOffset is the center pixel's equal, opposite X and Y values that make its coordinates (0,0) when added together. All pixels in the image editor have positive values, so the SpriteOffset ought to be negative. And every pixel in the sprite is offset by this same amount. It's like holding the push pin still and moving the drawing under it, left and up, before sticking the correct spot.

Offsets map to single pixels, but they're measured in vectors for the math deciding where each pixel is drawn. They accept float values. Though you'll never see half a pixel, the math does. Inaccurate values create inaccuracies in drawing pixels.

Offset Coordinates

Since the SpriteOffset sets the origin, coordinates for any other Offsets are relative to it.

Here is where it briefly gets tricky...
Cortex Command's coordinates differ from Cartesian in one important way: the Y (or vertical) axis is inverted-- up is negative-Y. Left is still negative-X, and right positive. This has been tested and checked in-game for all the Offsets described here.

To assign any other Offset to a pixel of the sprite, count how many pixels away it is from the SpriteOffset origin pixel horizontally and vertically, paying attention to which directions are positive and negative.


Offset

Used by Exit hatches on ACRockets and Terrain material bitmaps. Also used by the Gib entity; this is best left to the Gib Editor included in Cortex Command.


Bitmap Offset

Used for static elements on a map, including TerrainObject set pieces, Bunker Backgrounds and Bunker Bits, as well as the old Brain Vault, Rocket Silo, and Wall. Almost all of their vectors are 0,0 but certain Geology objects and the three old Bunker modules use negative vectors.


EmissionOffset

Used by AEmitter entities to define which pixel the things it emits are emitted from, in many ways similar to MuzzleOffset.


ParentOffset

Used to adjust the positioning of things logically attached as a "child" to a sprite. These things are typically sprites themselves or an emitter. Magazines attached to HDFirearms use ParentOffset to position themselves correctly. However, it accepts values beyond the pixel area of the sprite attached to.


JointOffset

Used in connecting animated objects together. It specifies a pixel as a joining point which will be used automatically by anything Cortex Command is setup to join with it. Parts of an Actor's body are joined to each other with via JointOffset, as are various Devices like guns and tools. This applies to Actor types like ADoor, ACRocket, and ACDropShip. Attachable effects and AEmitter also use this.

For HDFirearms, the JointOffset is where the FGArm (foreground arm) Hand is positioned, typically where the trigger is drawn but it has no effect on firing the weapon or tool. If placed too far for an AHuman's Hand to reach, the arm will twitch, trying and failing to reach the JointOffset.


SupportOffset

This defines where the BGArm (background arm) Hand of AHuman is positioned on a Device. Even one-handed devices specify a SupportOffset, though it tends to be close to the JointOffset. Excessive values have the same effect on the BGArm as excessive JointOffsets have on the FGArm.

StanceOffset

Adjustment where the SpriteOffset of a HeldDevice, HDFirearm, or ThrownDevice lines up with the SpriteOffset of the Actors carrying it. If a Device is meant to be carried high, slung low, held forward, or tucked back, this is where it should be specified, not SpriteOffset. Note that changing the StanceOffset does not change other Offsets-- they remain relative to SpriteOffset only. However, excessive values on StanceOffset can put other Offsets beyond reach of an AHuman's Hands.

SharpStanceOffset

Adjustments where a HeldDevice or HDFirearm and an Actor's SpriteOffsets align, but only when stopping to aim. Most weapons (and even the diggers, for some reason) are carried higher to "look down the sights" though it can be set arbitrarily. Like SupportOffset, all other Offsets on the Device stay relative to the SpriteOffset, thus the "move with" the Device.

MuzzleOffset

Defines the pixel where any Round an HDFirearm fires are emitted from. Typically this is the forward tip of the barrel, but it can be placed arbitrarily, even outside the sprite's pixel area.

EjectionOffset

The pixel where any Shell will be emitted from the sprite of an HDFirearm.


StartThrowOffset

Used with TDExplosives such as grenades. Almost always (-12,-5).

EndThrowOffset

Used with TDExplosives such as grenades. Almost always (-12,-5) but sometise (12,-5).


IdleOffset

Used to position the Hand on an Arm when its Actor isn't equipped with any Device, and for the Foot on a Leg when standing.

ExtendedOffset

Defines where the Foot of an Actor is positioned relative to the Actor's SpriteOffset when standing. Note that these coordinates assume the Leg being oriented horizontally as sprites for them are.

ContractedOffset

Used when crouching, this defines where the Foot of an Actor is positioned relative to the Actor's SpriteOffset. Note that these coordinates assume the Leg being oriented horizontally as sprites for them are.

StartOffset

Used in the various LimbPath animation definitions, this specifies a target coordinate for the Limb to move to.

HolsterOffset

Not commonly used, if at all. Cortex Command currently does not "holster" any items when unequipped. Appears in both AHuman and ACRocket definitions.


OpenOffset

Used by doors to specify where the "door" part moves to when it opens.

ClosedOffset

Used by doors to specify where the "door" part moves to when the door is closed.

Personal tools