void BubbleDisplay::DrawBackground(const ViewArea& radarView, float trackSize)
{
    if (!radarView.IsActive())
        return;

    GFXColor groundColor = radarView.GetColor();

    // Split octagon
    float size = 3.0 * std::max(trackSize, 3.0f);
    float xground = size / g_game.x_resolution;
    float yground = size / g_game.y_resolution;
    Vector center = radarView.Scale(Vector(0.0, 0.0, 0.0));

    Impl::LineElements::value_type base_index = Impl::LineElements::value_type(impl->lines.size());
    
    // Don't overflow the index type
    if (base_index < (std::numeric_limits<Impl::LineElements::value_type>::max() - 8)) {
        impl->lines.insert(center.x - xground, center.y - yground / 2, center.z, groundColor);
        impl->lines.insert(center.x - xground / 2, center.y - yground, center.z, groundColor);
        impl->lines.insert(center.x + xground / 2, center.y - yground, center.z, groundColor);
        impl->lines.insert(center.x + xground, center.y - yground / 2, center.z, groundColor);
        impl->lines.insert(center.x - xground, center.y + yground / 2, center.z, groundColor);
        impl->lines.insert(center.x - xground / 2, center.y + yground, center.z, groundColor);
        impl->lines.insert(center.x + xground / 2, center.y + yground, center.z, groundColor);
        impl->lines.insert(center.x + xground, center.y + yground / 2, center.z, groundColor);
        impl->lineIndices.push_back(base_index + 0);
        impl->lineIndices.push_back(base_index + 1);
        impl->lineIndices.push_back(base_index + 1);
        impl->lineIndices.push_back(base_index + 2);
        impl->lineIndices.push_back(base_index + 2);
        impl->lineIndices.push_back(base_index + 3);
        impl->lineIndices.push_back(base_index + 4);
        impl->lineIndices.push_back(base_index + 5);
        impl->lineIndices.push_back(base_index + 5);
        impl->lineIndices.push_back(base_index + 6);
        impl->lineIndices.push_back(base_index + 6);
        impl->lineIndices.push_back(base_index + 7);
    }
}
Пример #2
0
void SphereDisplay::DrawBackground(const Sensor& sensor, const ViewArea& radarView)
{
    // Split crosshair

    if (!radarView.IsActive())
        return;

    GFXColor groundColor = radarView.GetColor();

    float velocity = sensor.GetPlayer()->GetWarpVelocity().Magnitude();
    float logvelocity = 3.0; // std::log10(1000.0);
    if (velocity > 1000.0)
    {
        // Max logvelocity is log10(speed_of_light) = 10.46
        logvelocity = std::log10(velocity);
    }
    const float size = 3.0 * logvelocity; // [9; 31]
    const float xground = size / g_game.x_resolution;
    const float yground = size / g_game.y_resolution;
    Vector center = radarView.Scale(Vector(0.0, 0.0, 0.0));

    GFXEnable(SMOOTH);
    GFXLineWidth(1);
    GFXColorf(groundColor);
    GFXBegin(GFXLINE);
    GFXVertexf(Vector(center.x - 2.0 * xground, center.y, center.z));
    GFXVertexf(Vector(center.x - xground, center.y, center.z));
    GFXVertexf(Vector(center.x + 2.0 * xground, center.y, center.z));
    GFXVertexf(Vector(center.x + xground, center.y, center.z));
    GFXVertexf(Vector(center.x, center.y - 2.0 * yground, center.z));
    GFXVertexf(Vector(center.x, center.y - yground, center.z));
    GFXVertexf(Vector(center.x, center.y + 2.0 * yground, center.z));
    GFXVertexf(Vector(center.x, center.y + yground, center.z));
    GFXEnd();
    GFXDisable(SMOOTH);
}