Game Development Reference
In-Depth Information
Figure 71 - The pivot transformation is relative to the center of the quad.
Onceweareabletorotateourquadwithaproperpivot,weneedtoimplementthebehavior
of our analog control. Since this could be anything, speed, altitude, fuel, etc. We will im-
plement a general version that can be customized or extended as needed.
class analog
{
public:
analog(render::device_direct3d* device)
{}
float& Ratio() { return m_ratio; }
private:
render::quad m_quad;
std::unique_ptr<render::texture> m_texture;
float m_minimum;
float m_range;
float m_ratio;
};
Some analog meters will have their resting position on the left and rise towards the right,
the needle artwork we are using is facing up, this means we will initially need to rotate the
quad by to bring it into a resting position on the left and then . the rotation angle within a
range.Itisalsopossibletonotconstrainthedisplay,inwhichcaseitwillcoverthefull360
degrees possible, and continue winding around.
We will usually constrain the angles because not everything we represent with an analog
display can be negative, or exceed some predetermined maximum. Speed for example is
Search WWH ::




Custom Search