Working with axis orientation origin
It contains the advice or opinions of one or more of the Valve Developer Community's contributors.
This page is not an encyclopedia article, nor is it one of the Valve Developer Community's policies or guidelines, as it has not been thoroughly vetted by the community.
Some essays represent widespread norms; others only represent minority viewpoints.
Contents
WORKING WITH ROTATION AND AXES
INTRODUCTION:
Most, if not all dynamic prop objects from the SDK Source can be rotated. In keeping with a three-dimensioned universe, prop objects can be rotated around all three axes: Pitch Yaw Roll (Y Z X).
A common difficulty with staging rotating objects in the map, is getting them to rotate (as we would naturally expect them to), no matter what their orientation and position on the map is.
ROTATION AROUND THE AXIS:
Rotation around the axis is measured as the movement of a line's angle (expressed as degrees) around a given origin. A line's angle can be incremented from 0 to 359 degrees (Or 1 to 360 degrees). Below is a brief description of the three axes.
- Pitch (Y) - Forward/Backward rotation
- Yaw (Z) - Directional (North, South, East, West) rotation
- Roll (X) - Tilt (right,Left) rotation
WORKING WITH ROTATION AND ORIENTATION
The (Y Z X) Point of intersection (or vector) within a given prop, will describe (and is in fact, determined by) the physical attitude, orientation and (hand) of the prop, with respect to a given origin in the prop's universe. The following description will attempt to explain how attitude, orientation and hand of an object effects our perception (and prop manipulation) of rotation around the axis.
Suppose you have a pen.
- If you hold the pen vertically, (where the tip points upright) in front of you, the pitch orientation of the pen is 90 degrees (Y). While holding the pen, if you unscrew its cap, the rotation of the cap occurs (counter-clockwise direction) along the (Z) axis.
- Take the same pen and hold it horizontally (so it lays flat on its side) in front of you. The pitch orientation of the pen is now 0 degrees (Y). The cap also now rotates (back, toward you) along the (Y) axis.
- Finally, swivel the pen (while it is horizontal) so that you can only see the end of it in front of you. The pitch orientation of the pen is still 0 degrees (Y). But, now the cap rotates (left) along the (X) axis.
Absolute vs Relative:
In each case, rotation along the axes appeared to change, simply from re-orientation of the pen. The absolute (real value) orientation of the pen is dependent on an absolute origin somewhere in the universe. The proof is that; regardless of which axis a rotation occurs on, and no matter where you stand, if the pen lays down, the pitch orientation of the object is 0 degrees. Likewise, when the pen is raised straight up, its pitch is 90 degrees, and so on.
Which Assessment is Correct
Say you were floating in space, and you happened to turn upside down as you viewed the pen. In absolute terms, the pitch orientation of the pen is still 90 degrees. However, as far as you are concerned, the pen 's pitch appears to be -90 degrees. Which assessment is correct? (In Valve's world, you always can trust that the map's pitch level is always at 0 degrees).
The Appearance of Rotation
The appearance of Rotation along a given axis also depends on an absolute origin. However, the impact of relative perspective can be illustrated:
- If the pen exercise had been conducted on the south edge of a circle, and another person had observed the exercise from the west edge of the circle, the pen-cap's rotation along the (X) axis, as perceived from the south, would appear as a rotation along the (Y) axis, as perceived from the west, and so on.
AN ILLUSTRATION OF RELATIVE PERSPECTIVE
Consider how all this might apply when attempting to position and orientate a button prop object in a map.
In the image example: Rotating Button, the orientation of each button differs on each of the console panels. The info_start_player entity is facing due north (0 degrees) in accordance with the map's absolute origin. The Pitch Yaw Roll settings for each button are:
- -45 0 0 (North panel)
- -45 -90 0 (East Panel)
- -45 180 0 (South Panel)
- -45 -270 0(West Panel)
Use of negative values
- Some settings are expressed as negative values. Though the prop model's (Y) default is 0 degrees, (when we first add it to the map), it so happens that this model's image detail is represented by the back (south side) of a button and not its opposing flat (north) side. If we set this button's pitch (Y) to positive (+) 45 degrees, the button would actually be resting upside-down on its back, with a 45 degree pitch up. This will expose the flat side of the button. (And might yield a 'no-draw-fragment' effect on what the player sees.) An angle of minus (-) 45 degrees will move the pitch forward, so that the back of the button (the detail) is exposed and allows to button to be fitted and aligned to an equipment console panel, which also has a -45 degree slant.
- Likewise, some of the (Z) settings in the illustration are expressed as negative values. Our natural inclination is to set the button's (Z) value to 90 degrees (for East) and -270 degrees (for West). Again, the orientation of the button necessarily requires that its back-side be exposed for the proper detail effect. This means that its hand must be adjusted for negative values. (or... you can use positive values, but they must be swapped, such that the East button's (Z) value is set to 270 and the west button's (Z) value is set to 90.)
- Keep in mind, that the position of the button (that is...which panel to place it in...) is not the primary concern here. It's the orientation of the button, which counts here. (So that it can then ultimately be positioned in the right context).
ORIGIN
Description
Origin can be defined as a source, from which all relevant values and references are derived. It also infers absolute center. Origin is expressed as (X Y Z) , representing Length, Width and Height, respectively. (Note: This is not to be confused with Pitch Yaw Roll (Y Z X)).
Grid Units and Scales
In Valve, a map's origin is deemed the center of the map, and its values are: 0, 0, 0. From there, we can increment units of (X Y Z) on any scale that is suitable. For example, if each unit on a grid represented 20 feet, we could draw a texture brush and effectively build a block in our world, that is:
- (4 units by 5 units by 2 units) or (80' long x 100' wide x 40' high).
Exploiting Origin
- Origin helps us determine ambience in a map. For example, an env_sun entity can be placed west of the map's origin, along with a light_environment that points its light (from west to East), effectively giving the player a sense that the time of day is approaching dusk. Like wise; if the positions were reversed, it may seem like dawn.
- An entity's origin can be manipulated for certain physics (rotational) effects, such as pulley systems, trap doors, or centrifuges. For example: An attached wheel on a spinning axel will rotate evenly, 360 degrees, when centered and aligned with the end of the axel. If you move the wheel's origin away from the axel's origin, the wheel's rotation now translates as a tethered orbit around the axel. (Makes for a great weapon-trap if the circumference is wide enough and the NPC or player doesn't see it coming...)