Вопрос Fixing out of fov Arc

Пользователь
Статус
Оффлайн
Регистрация
6 Сен 2019
Сообщения
173
Реакции[?]
37
Поинты[?]
0
I need help in fixing out of fov arc, here's how it looks like now
1658168515190.png
Here's the code, It draws using the DirectX render Line method
C++:
void CRender::Line(int x, int y, int x2, int y2, D3DCOLOR color)
    Vertex pVertex[2] = { { x, y, 0.0f, 1.0f, color }, { x2, y2, 0.0f, 1.0f, color } };
    m_device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
    m_device->SetTexture(0, nullptr);
    m_device->SetRenderState(D3DRS_LIGHTING, FALSE);
    m_device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
    m_device->SetRenderState(D3DRS_FOGENABLE, FALSE);
    m_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
    m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    m_device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    m_device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
    m_device->SetRenderState(D3DRS_LIGHTING, FALSE);
    m_device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
    DWORD colorwrite, srgbwrite;
    m_device->GetRenderState(D3DRS_COLORWRITEENABLE, &colorwrite);
    m_device->GetRenderState(D3DRS_SRGBWRITEENABLE, &srgbwrite);
    m_device->SetRenderState(D3DRS_COLORWRITEENABLE, 0xffffffff);
    m_device->SetRenderState(D3DRS_SRGBWRITEENABLE, false);
    m_device->DrawPrimitiveUP(D3DPT_LINELIST, 1, &pVertex, sizeof(Vertex));
    m_device->SetRenderState(D3DRS_COLORWRITEENABLE, colorwrite);
    m_device->SetRenderState(D3DRS_SRGBWRITEENABLE, srgbwrite);
}

void PathArcTo(std::vector< Vertex_t >& vertices, const Vector_2D& centre, float radius, float a_min, float a_max, int num_segments, float thickness, Color color)
{
    for (auto i = 0; i < num_segments; i++) {
        const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
        Graphics::Render->Line(centre.x + cos(a) * (radius - thickness), centre.y + sin(a) * (radius - thickness), centre.x + cos(a) * radius, centre.y + sin(a) * radius, color);
    }
}

void CRender::DrawArc(float x, float y, float radius, float min_angle, float max_angle, Color col, float thickness) {
    std::vector< Vertex_t > vertices;


    PathArcTo(vertices, Vector_2D(x, y), radius, DEG2RAD(min_angle), DEG2RAD(max_angle), 128, thickness, col);
}

//out of fov code itself
Graphics::Render->DrawArc(iScreenSizeX / 2, iScreenSizeY / 2, 256, angle - width, angle + width, color, 4.f);
Graphics::Render->DrawArc(iScreenSizeX / 2, iScreenSizeY / 2, 250, angle - width, angle + width, Color(color.r(), color.g(), color.b(), 255.0f * 0.5f), 1.5f);
That's how it supposed to look like (it draws using ImGui render)
1658169175646.png
 
Последнее редактирование:
Сверху Снизу