• Ищем качественного (не новичок) разработчиков Xenforo для этого форума! В идеале, чтобы ты был фулл стек программистом. Если у тебя есть что показать, то свяжись с нами по контактным данным: https://t.me/DREDD

Исходник 3D Круг на сюрфе 1 элементом

Эксперт
Эксперт
Статус
Оффлайн
Регистрация
30 Дек 2019
Сообщения
1,966
Реакции
958
Как вы знаете, гений на иммортале, сделал великолепный рендер 3д кругов через треугольники, соответственно, у вас рендерилось point / 2 треугольников, мой шикарный код сделает так, чтобы у вас рендерился всего 1 полигон(гондон) (ну и полилайн для обводки), с вас номер карты(не забудьте ccv код)
друв_манагер.сипипи (draw_manager.cpp)
C++:
Expand Collapse Copy
void render::TexturedPolygon(int n, std::vector<Vertex_t> vertice, Color color)
{
    auto g_VGuiSurface = m_surface();
    static int texture_id = g_VGuiSurface->CreateNewTextureID(true); //
    static unsigned char buf[4] = { 255, 255, 255, 255 };
    g_VGuiSurface->DrawSetTextureRGBA(texture_id, buf, 1, 1); //
    g_VGuiSurface->DrawSetColor(color); //
    g_VGuiSurface->DrawSetTexture(texture_id); //
    g_VGuiSurface->DrawTexturedPolygon(n, vertice.data()); //
}

void render::TexturedPolyline(int n, std::vector<Vertex_t> vertice, Color color)
{
    auto g_VGuiSurface = m_surface();
    static int texture_id = g_VGuiSurface->CreateNewTextureID(true); //
    static unsigned char buf[4] = { 255, 255, 255, 255 };
    g_VGuiSurface->DrawSetTextureRGBA(texture_id, buf, 1, 1); //
    g_VGuiSurface->DrawSetColor(color); //
    g_VGuiSurface->DrawSetTexture(texture_id); //
    g_VGuiSurface->DrawTexturedPolyLine(vertice.data(), n); //
}

void render::Draw3DFilledCircle(const Vector& origin, float radius, Color color, Color color_fill, float points)
{
    auto screen = ZERO;

    if (!math::world_to_screen(origin, screen))
        return;

    static float Step = (M_PI * 2.0f) / (points);
    std::vector<Vertex_t> point;
    for (float lat = 0.f; lat <= M_PI * 2.0f; lat += Step)
    {
        const auto& point3d = Vector(sin(lat), cos(lat), 0.f) * radius;
        Vector point2d;
        if (math::world_to_screen(origin + point3d, point2d))
            point.push_back(Vector2D(point2d.x, point2d.y));
    }
    TexturedPolygon(point.size(), point, color_fill);
    TexturedPolyline(point.size(), point, color);
}

друв_манагер.аш (draw_manager.h)
Код:
Expand Collapse Copy
void Draw3DFilledCircle(const Vector& origin, float radius, Color color, Color color_fill, float point = 72.f);
void TexturedPolygon(int n, std::vector<Vertex_t> vertice, Color color);
void TexturedPolyline(int n, std::vector<Vertex_t> vertice, Color color);

сися(SS):
(я пытался сделать таймер на полилайне как в imgui, как вы можете не получилось)
1628748064794.png

P.S: у кого рендер на емхуи, ждите vertex на imvec2 меняйте, и будут вам кружки
 
...
static float Step = (M_PI * 2.0f) / (points);
std::vector<Vertex_t> point;
for (float lat = 0.f; lat <= M_PI * 2.0f; lat += Step)
{
const auto& point3d = Vector(sin(lat), cos(lat), 0.f) * radius;
Vector point2d;
if (math::world_to_screen(origin + point3d, point2d))
point.push_back(Vector2D(point2d.x, point2d.y));
....
Где-то я это видел... Чутка похоже на реализацию 'sphere' в supremacy; :CoolStoryBob:
 
Последнее редактирование:
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
иди учи рендерить правильно.
 

Вложения

  • 1628755705824.png
    1628755705824.png
    3.6 MB · Просмотры: 433
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Как вы знаете, гений на иммортале, сделал великолепный рендер 3д кругов через треугольники, соответственно, у вас рендерилось point / 2 треугольников, мой шикарный код сделает так, чтобы у вас рендерился всего 1 полигон(гондон) (ну и полилайн для обводки), с вас номер карты(не забудьте ccv код)
друв_манагер.сипипи (draw_manager.cpp)
C++:
Expand Collapse Copy
void render::TexturedPolygon(int n, std::vector<Vertex_t> vertice, Color color)
{
    auto g_VGuiSurface = m_surface();
    static int texture_id = g_VGuiSurface->CreateNewTextureID(true); //
    static unsigned char buf[4] = { 255, 255, 255, 255 };
    g_VGuiSurface->DrawSetTextureRGBA(texture_id, buf, 1, 1); //
    g_VGuiSurface->DrawSetColor(color); //
    g_VGuiSurface->DrawSetTexture(texture_id); //
    g_VGuiSurface->DrawTexturedPolygon(n, vertice.data()); //
}

void render::TexturedPolyline(int n, std::vector<Vertex_t> vertice, Color color)
{
    auto g_VGuiSurface = m_surface();
    static int texture_id = g_VGuiSurface->CreateNewTextureID(true); //
    static unsigned char buf[4] = { 255, 255, 255, 255 };
    g_VGuiSurface->DrawSetTextureRGBA(texture_id, buf, 1, 1); //
    g_VGuiSurface->DrawSetColor(color); //
    g_VGuiSurface->DrawSetTexture(texture_id); //
    g_VGuiSurface->DrawTexturedPolyLine(vertice.data(), n); //
}

void render::Draw3DFilledCircle(const Vector& origin, float radius, Color color, Color color_fill, float points)
{
    auto screen = ZERO;

    if (!math::world_to_screen(origin, screen))
        return;

    static float Step = (M_PI * 2.0f) / (points);
    std::vector<Vertex_t> point;
    for (float lat = 0.f; lat <= M_PI * 2.0f; lat += Step)
    {
        const auto& point3d = Vector(sin(lat), cos(lat), 0.f) * radius;
        Vector point2d;
        if (math::world_to_screen(origin + point3d, point2d))
            point.push_back(Vector2D(point2d.x, point2d.y));
    }
    TexturedPolygon(point.size(), point, color_fill);
    TexturedPolyline(point.size(), point, color);
}

друв_манагер.аш (draw_manager.h)
Код:
Expand Collapse Copy
void Draw3DFilledCircle(const Vector& origin, float radius, Color color, Color color_fill, float point = 72.f);
void TexturedPolygon(int n, std::vector<Vertex_t> vertice, Color color);
void TexturedPolyline(int n, std::vector<Vertex_t> vertice, Color color);

сися(SS):
(я пытался сделать таймер на полилайне как в imgui, как вы можете не получилось)
Посмотреть вложение 165834

P.S: у кого рендер на емхуи, ждите vertex на imvec2 меняйте, и будут вам кружки
а за что отвечает аргумент points?
 
недавно хотел сделать похожую тему, но ты как всегда впереди)
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Назад
Сверху Снизу