void BubbleDisplay::Draw(const Sensor& sensor,
                         VSSprite *frontSprite,
                         VSSprite *rearSprite)
{
    assert(frontSprite || rearSprite); // There should be at least one radar display

    radarTime += GetElapsedTime();

    leftRadar.SetSprite(frontSprite);
    rightRadar.SetSprite(rearSprite);
    
    impl->clear();

    if (frontSprite)
        frontSprite->Draw();
    if (rearSprite)
        rearSprite->Draw();

    Sensor::TrackCollection tracks = sensor.FindTracksInRange();

    Animate();

    GFXEnable(DEPTHTEST);
    GFXEnable(DEPTHWRITE);
    GFXEnable(SMOOTH);

    for (Sensor::TrackCollection::const_iterator it = tracks.begin(); it != tracks.end(); ++it)
    {
        if (it->GetPosition().z < 0)
        {
            // Draw tracks behind the ship
            DrawTrack(sensor, rightRadar, *it);
        }
        else
        {
            // Draw tracks in front of the ship
            DrawTrack(sensor, leftRadar, *it);
        }
    }
    DrawBackground(leftRadar, currentTargetMarkerSize);
    DrawBackground(rightRadar, currentTargetMarkerSize);

    impl->flush();

    GFXPointSize(1);
    GFXDisable(DEPTHTEST);
    GFXDisable(DEPTHWRITE);
    GFXDisable(SMOOTH);
}
예제 #2
0
void SphereDisplay::Draw(const Sensor& sensor,
                         VSSprite *frontSprite,
                         VSSprite *rearSprite)
{
    assert(frontSprite || rearSprite); // There should be at least one radar display

    radarTime += GetElapsedTime();

    leftRadar.SetSprite(frontSprite);
    rightRadar.SetSprite(rearSprite);

    if (frontSprite)
        frontSprite->Draw();
    if (rearSprite)
        rearSprite->Draw();

    Sensor::TrackCollection tracks = sensor.FindTracksInRange();

    // FIXME: Consider using std::sort instead of the z-buffer
    GFXEnable(DEPTHTEST);
    GFXEnable(DEPTHWRITE);

    DrawBackground(sensor, leftRadar);
    DrawBackground(sensor, rightRadar);

    for (Sensor::TrackCollection::const_iterator it = tracks.begin(); it != tracks.end(); ++it)
    {
        static bool  draw_both       =
            XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "draw_blips_on_both_radar", "false" ));
        if (it->GetPosition().z < 0 || draw_both)
        {
            // Draw tracks behind the ship
            DrawTrack(sensor, rightRadar, *it,true);
        }
        if (it->GetPosition().z >= 0 || draw_both)
        {
            // Draw tracks in front of the ship
            DrawTrack(sensor, leftRadar, *it);
        }
    }

    GFXPointSize(1);
    GFXDisable(DEPTHTEST);
    GFXDisable(DEPTHWRITE);
}