Game Development Reference
In-Depth Information
not represented as a negative value but altitude may be negative if the aircraft should fly
below sea level (or the altitude at which the ground is calibrated).
The implementation of the display will vary on its use-case but the goal is to calculate a
ratio, the ratio is used to calculate the angle from its resting position (the lower bound of
the range) to its maximal position (the upper bound of the range).
Ifwearetryingtosimulateacar'sodometer,theneedlemayrangefromitsrestingposition
on the left side which corresponds to the angle π to the maximum on the right which is at
the angle 0.
In order to constrain the speed at some maximum, we will need to define what the maxim-
um speed possible will be, for simplicity we will say it is 100 km/h, if the car is travelling
at 33 km/h, the ratio will be:
This ratio translates to how much has the needle moved within its range.
We need two parameters to simulate our analog display, the m_minimum parameter will be
used to define the starting resting position of the need, and m_range will define how much
can the needle move. Thus for a car odometer display, the needle needs to rest on the left
side.Giventhatourartworkisinitiallyfacingup,thismeanswewillneedtosetitsrotation
to and in order to move it to the right side, on the upper quadrants of the circle we will
subtract the interpolated range.
float angle = m_minimum - ( m_ratio * m_range );
This is important to remember, as different gauges will need to follow this convention. For
anaircraft'saltitudedisplayforexample,theminimumwouldremainthesametomakethe
needle's resting point on the left, but the range will be 2π to allow the needle free move-
ment along the entire circle.
Havingcalculated therotationangleforourquad,wecancreatearotationmatrixalongthe
z axis.
matrix rotation = matrix::CreateRotationZ( angle );
Since we are using a world space quad to simulate our analog gauge, we will take the op-
portunity to project it into screen space.
Search WWH ::




Custom Search