Куб с углом поворота на дефолт рендерах

Решение
Единственно одну функцию поменять на рендер, и молясь корректировка позиции:

Lua:
function DrawCuboid(size, angle_x, angle_y, center_x, center_y, color)
    angle_x = math.rad(angle_x)
    angle_y = math.rad(angle_y)

    local cuboid_data = {
      points = {
        {-100, -100, -100}, {-100, -100, 100}, {-100, 100, -100},
        {-100, 100, 100}, {100, -100, -100}, {100, -100, 100},
        {100, 100, -100}, {100, 100, 100}
      },
      edges = {
        {0, 1}, {1, 3}, {3, 2}, {2, 0}, {4, 5}, {5, 7},
        {7, 6}, {6, 4}, {0, 4}, {1, 5}, {2, 6}, {3, 7}
      }
    }

    local pos = {x = 645, y = 540}
    local offset = size / 2

    local sin_x = math.sin(angle_x)
    local cos_x = math.cos(angle_x)
    local sin_y =...

Hatiko

13=GG
Проверенный
1,455
587
Единственно одну функцию поменять на рендер, и молясь корректировка позиции:

Lua:
function DrawCuboid(size, angle_x, angle_y, center_x, center_y, color)
    angle_x = math.rad(angle_x)
    angle_y = math.rad(angle_y)

    local cuboid_data = {
      points = {
        {-100, -100, -100}, {-100, -100, 100}, {-100, 100, -100},
        {-100, 100, 100}, {100, -100, -100}, {100, -100, 100},
        {100, 100, -100}, {100, 100, 100}
      },
      edges = {
        {0, 1}, {1, 3}, {3, 2}, {2, 0}, {4, 5}, {5, 7},
        {7, 6}, {6, 4}, {0, 4}, {1, 5}, {2, 6}, {3, 7}
      }
    }

    local pos = {x = 645, y = 540}
    local offset = size / 2

    local sin_x = math.sin(angle_x)
    local cos_x = math.cos(angle_x)
    local sin_y = math.sin(angle_y)
    local cos_y = math.cos(angle_y)

    for i, v in ipairs(cuboid_data['points']) do
      cuboid_data['points'][i][1] = v[1] * size
      cuboid_data['points'][i][2] = v[2] * size
      cuboid_data['points'][i][3] = v[3] * size
    end

    for i, v in ipairs(cuboid_data['points']) do
      local x = v[1]
      local y = v[2]
      local z = v[3]
      cuboid_data['points'][i][1] = x * cos_x - z * sin_x
      cuboid_data['points'][i][3] = z * cos_x + x * sin_x
      z = cuboid_data['points'][i][3]
      cuboid_data['points'][i][2] = y * cos_y - z * sin_y
      cuboid_data['points'][i][3] = z * cos_y + y * sin_y
    end

    for i, v in ipairs(cuboid_data['edges']) do
      local xy_1 = cuboid_data['points'][v[1]+1]
      local xy_2 = cuboid_data['points'][v[2]+1]
     
      renderDrawLine(center_x + xy_1[1] + offset, center_y + xy_1[2] + offset, center_x + xy_2[1] + offset, center_y + xy_2[2] + offset, 1, color)
    end
end