Offsets
From Data Realms Wiki
(Offsets moved to Offset Tutorials) |
(First Draft with all the Offsets I could find in B27) |
||
Line 1: | Line 1: | ||
- | + | Offsets define relative positions of many things in Cortex Command. They describe individual points mapping to individual pixels within [http://en.wikipedia.org/wiki/Sprite_%28computer_graphics%29 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 [[HDFirearm | gun]] carried by a [[AHuman | soldier]], and also where things are emitted from, like the bullets from that gun. | |
+ | |||
+ | You'll need to understand [http://en.wikipedia.org/wiki/Cartesian_coordinate_system Cartesian coordinates] and arithmetic with positive and negative numbers. | ||
+ | |||
+ | == 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 [http://en.wikipedia.org/wiki/Center_of_mass 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 [http://en.wikipedia.org/wiki/Integer 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. <br> | ||
+ | '''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 [http://en.wikipedia.org/wiki/Euclidean_vector#In_Cartesian_space vectors] for the math deciding where each pixel is drawn. They accept [http://en.wikipedia.org/wiki/Floating_point float values]. Though you'll never see half a pixel, the math does. Inaccurate values create inaccuracies in drawing pixels. <br> | ||
+ | |||
+ | === Offset Coordinates === | ||
+ | |||
+ | Since the SpriteOffset sets the origin, coordinates for any other Offsets are relative to it. | ||
+ | |||
+ | Here is where it briefly gets tricky... <br> | ||
+ | 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. | ||
+ | |||
+ | |||
+ | == 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 [[Actors | 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 uses this. | ||
+ | |||
+ | For [[HDFirearm]]s, 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 [[Weapons | weapon]] or [[Tools | 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. | ||
+ | |||
+ | == 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" and items when unequipped. Appears in both AHuman and ACRocket definitions. | ||
+ | |||
+ | |||
+ | == StanceOffset == | ||
+ | |||
+ | Adjustments where the SpriteOffset of a HeldDevice 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''', though it can put them beyond reach of an AHuman's Hands. | ||
+ | |||
+ | |||
+ | == SharpStanceOffset == | ||
+ | |||
+ | Adjustments where a HeldDevice and an Actor's SpriteOffsets align, but only when stopping to aim. Most weapons (and even the [[Tools#Diggers | diggers]], for some reason) are carried higher to "look down the sights". It can also help with shooting over cover without exposing your head. | ||
+ | |||
+ | == 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 [[TDExplosive | TDExplosives]] such as grenades. Almost always (-12,-5). | ||
+ | |||
+ | == EndThrowOffset == | ||
+ | |||
+ | Used with [[TDExplosive | TDExplosives]] such as grenades. Almost always (-12,-5) but sometise (12,-5). | ||
+ | |||
+ | |||
+ | == EmissionOffset == | ||
+ | |||
+ | Used by AEmitter entities to define which pixel the things it emits are emitted from, in many ways similar to MuzzleOffset. | ||
+ | |||
+ | |||
+ | == OpenOffset == | ||
+ | |||
+ | Used by [[ADoor | doors]] to specify where the "door" part moves to when it opens. | ||
+ | |||
+ | == ClosedOffset == | ||
+ | |||
+ | Used by [[ADoor | doors]] to specify where the "door" part moves to when the door is closed. | ||
+ | |||
+ | |||
+ | == 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. | ||
+ | |||
+ | |||
+ | == 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. |
Revision as of 18:01, 5 July 2012
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.
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.
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 uses 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.
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" and items when unequipped. Appears in both AHuman and ACRocket definitions.
StanceOffset
Adjustments where the SpriteOffset of a HeldDevice 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, though it can put them beyond reach of an AHuman's Hands.
SharpStanceOffset
Adjustments where a HeldDevice 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". It can also help with shooting over cover without exposing your head.
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).
EmissionOffset
Used by AEmitter entities to define which pixel the things it emits are emitted from, in many ways similar to MuzzleOffset.
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.
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.
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.