-
Автор темы
- #1
draw_manager.cpp
misc.cpp
ну да как бы так
ss:
Код:
void render::arc(float x, float y, float radius, float min_angle, float max_angle, Color col, float thickness)
{
arc_poly(Vector(x, y, 0), radius, DEG2RAD(min_angle), DEG2RAD(max_angle), 32, 4.5, Color(255, 255, 255));
}
void render::arc_poly(const Vector& center, float radius, float a_min, float a_max, float num_segments, float thiccboi, Color color) {
if (!m_surface())
return;
if (radius == 0.0f) return;
Vector2D prevpos;
prevpos.x = 0;
prevpos.y = 0;
for (int i = 0; i <= num_segments; i++)
{
auto a = a_min + (i / num_segments) * (a_max - a_min);
auto a_next = a_min + ((i + 1) / num_segments) * (a_max - a_min);
Vector2D renderat;
renderat.x = center.x + cos(a) * radius;
renderat.y = center.y + sin(a) * radius;
Vector2D renderat_next;
renderat_next.x = center.x + cos(a_next) * radius;
renderat_next.y = center.y + sin(a_next) * radius;
Vector2D top;
top.x = renderat.x - (cos(a) * thiccboi);
top.y = renderat.y - (sin(a) * thiccboi);
Vector2D top_next;
top_next.x = renderat.x - (cos(a_next) * thiccboi);
top_next.y = renderat.y - (sin(a_next) * thiccboi);
Vertex_t verts[3] = {
Vertex_t(top),
Vertex_t(prevpos),
Vertex_t(renderat)
};
Vertex_t verts1[3] = {
Vertex_t(renderat),
Vertex_t(top_next),
Vertex_t(top)
};
auto surface = m_surface();
static int texture = surface->CreateNewTextureID(true);
unsigned char buffer[4] = { 255, 255, 255, 255 };
surface->DrawSetTextureRGBA(texture, buffer, 1, 1);
surface->DrawSetColor(color);
surface->DrawSetTexture(texture);
if (prevpos.x != 0)
{
surface->DrawTexturedPolygon(3, verts);
if (i != num_segments) {
surface->DrawTexturedPolygon(3, verts1);
}
}
else {
surface->DrawTexturedPolygon(3, verts1);
}
prevpos = renderat;
}
}
Код:
void misc::PovArrows(player_t* e, Color color)
{
auto isOnScreen = [](Vector origin, Vector& screen) -> bool
{
if (!math::world_to_screen(origin, screen))
return false;
static int iScreenWidth, iScreenHeight;
m_engine()->GetScreenSize(iScreenWidth, iScreenHeight);
auto xOk = iScreenWidth > screen.x;
auto yOk = iScreenHeight > screen.y;
return xOk && yOk;
};
Vector screenPos;
if (isOnScreen(e->GetAbsOrigin(), screenPos))
return;
Vector viewangles;
m_engine()->GetViewAngles(viewangles);
static int wid, heigth;
m_engine()->GetScreenSize(wid, heigth);
auto angleYawRad = viewangles.y - math::calculate_angle(g_ctx.globals.eye_pos, e->GetAbsOrigin()).y - 90;
float width = 10.f;
render::get().arc(wid / 2, heigth / 2, /*250*/ 106, angleYawRad - width, angleYawRad + width, Color(255, 1, 1), 4.f);
render::get().arc(wid / 2, heigth / 2, /*256*/ 100, angleYawRad - width, angleYawRad + width, Color(255, 1, 1), 1.5f);
}
ss:
Последнее редактирование: