Game Development Reference
In-Depth Information
vector3 worldPosition = m_device->GetViewport().Unproject(vector3(320.f, 360.f, 0.05f), camera.Projection(), camera.View(), mat-
rix::Identity);
We are unprojecting the screen coordinate 320, 360, 0.05 as the position at which we want
todisplaytheanaloggauge(thecoordinatewasarbitrarilychosenforthisexample), unpro-
jecting will give us the corresponding world space coordinate at which we will draw the
quad. The Z component of the position is very small, this is to offset the projection so that
it's just slightly in front of the near clipping plane.
The next step will be to align the quad to the camera as we saw in Screen Aligned Quad
and then apply the rotation matrix on it.
auto transform = matrix::CreateViewAligned(camera.View(), worldPosition);
transform = matrix::CreateUniformScale(m_scale) * rotation * transform;
And finally we can draw the quad using our calculated transformation matrix.
m_quad.Draw(transform, camera.View(), camera.Projection(), m_texture);
With all the pieces in place, the analog gauge is driven by the ratio provided and con-
strained within the specified range. This means that if we have another ratio, a speed, ac-
celeration, altitude, pressure, etc. we can map it to the analog gauge.
Search WWH ::




Custom Search