Трейсера на mimgui

penta

Участник
Автор темы
42
9
Всем здарова опять, имею проблему с трейсерами которые я попытался перенести на мимгуи, проблема в том что они не отображаются, вроде все есть но не отображается. P.S Код вставлен тот который нужно подправить или изменить, полный код имеет 5к строк
Lua:
imgui.OnInitialize(function()
    local staticObject = imgui.ColorConvertU32ToFloat4(confq.config.staticObject)
    color1 = imgui.new.float[4](staticObject.x, staticObject.y, staticObject.z, staticObject.w)

    local dinamicObject = imgui.ColorConvertU32ToFloat4(confq.config.dinamicObject)
    color2 = imgui.new.float[4](dinamicObject.x, dinamicObject.y, dinamicObject.z, dinamicObject.w)

    local pedP = imgui.ColorConvertU32ToFloat4(confq.config.pedP)
    color3 = imgui.new.float[4](pedP.x, pedP.y, pedP.z, pedP.w)

    local carP = imgui.ColorConvertU32ToFloat4(confq.config.carP)
    color4 = imgui.new.float[4](carP.x, carP.y, carP.z, carP.w)
end)

-- в OnFrame
if imgui.CollapsingHeader(u8"Настроить трейсер пуль") then
    imgui.Separator()
    imgui.PushItemWidth(175)
    if imgui.SliderInt("##secondsBullets", elements.int.secondToClose, 5, 15) then
        confq.config.secondToClose = elements.int.secondToClose[0]
        save()
    end imgui.SameLine() imgui.Text(u8"Время задержки трейсера")
    if imgui.SliderInt("##renderWidthLinesOne", elements.int.widthRenderLineOne, 1, 10) then
        confq.config.widthRenderLineOne = elements.int.widthRenderLineOne[0]
        save()
    end imgui.SameLine() imgui.Text(u8"Толщина линий")
    if imgui.SliderInt('##numberNotMyBullet', elements.int.maxNotMyLines, 10, 300) then
        bulletSync.maxNotMyLines = elements.int.maxNotMyLines[0]
        bulletSync = {lastId = 0, maxLines = elements.int.maxNotMyLines[0]}
        for i = 1, bulletSync.maxLines do
            bulletSync[i] = { other = {time = 0, t = {x,y,z}, o = {x,y,z}, type = 0, color = 0}}
        end
        confq.config.maxNotMyLines = elements.int.maxNotMyLines[0]
        save()
    end imgui.SameLine() imgui.Text(u8"Максимальное количество линий")
  
    imgui.Separator()

    if imgui.Checkbox(u8"[Вкл/выкл] Окончания у трейсеров", elements.checkbox.cbEnd) then
        confq.config.cbEnd = elements.checkbox.cbEnd[0]
        save()
    end

    if imgui.SliderInt('##sizeTraicerEndTwo', elements.int.sizeOffPolygonTwo, 1, 10) then
        confq.config.sizeOffPolygonTwo = elements.int.sizeOffPolygonTwo[0]
        save()
    end imgui.SameLine() imgui.Text(u8"Размер окончания трейсера")

    if imgui.SliderInt('##endNumbersTwo', elements.int.polygonNumberTwo, 2, 10) then
        confq.config.polygonNumberTwo = elements.int.polygonNumberTwo[0]
        save()
    end imgui.SameLine() imgui.Text(u8"Количество углов на окончаниях")

    if imgui.SliderInt('##rotationTwo', elements.int.rotationPolygonTwo, 0, 360) then
        confq.config.rotationPolygonTwo = elements.int.rotationPolygonTwo[0]
        save()
    end imgui.SameLine() imgui.Text(u8"Градус поворота окончания")

    imgui.PopItemWidth()
    imgui.Separator()
    imgui.Text(u8"Укажите цвет трейсера, если игрок попал в: ")
    imgui.PushItemWidth(325)
    if imgui.ColorEdit4("———", color2) then
        confq.config.dinamicObject = imgui.ColorConvertFloat4ToU32(
            imgui.ImVec4( color2[0], color2[1], color2[2], color2[3] )
        )
      
    end imgui.SameLine() imgui.Text(u8"Динамический объект")
  
    if imgui.ColorEdit4("——", color1) then
        confq.config.staticObject = imgui.ColorConvertFloat4ToU32(
            imgui.ImVec4( color1[0], color1[1], color1[2], color1[3] )
        )
    end imgui.SameLine() imgui.Text(u8"Статический объект")
  
    if imgui.ColorEdit4("——————————————", color3) then
        confq.config.pedP = imgui.ColorConvertFloat4ToU32(
            imgui.ImVec4( color3[0], color3[1], color3[2], color3[3] )
        )
    end imgui.SameLine() imgui.Text(u8"Игрока")

    if imgui.ColorEdit4("——", color4) then
        confq.config.carP = imgui.ColorConvertFloat4ToU32(
            imgui.ImVec4( color4[0], color4[1], color4[2], color4[3] )
        )
    end imgui.SameLine() imgui.Text(u8"Машину")
    imgui.PopItemWidth()
    imgui.Separator()
end


function argb2abgr(argb)
    local abgr = bit.bor(
        bit.lshift(bit.band(bit.rshift(argb, 24), 0xFF), 24),
        bit.lshift(bit.band(argb, 0xFF), 16),
        bit.lshift(bit.band(bit.rshift(argb, 8), 0xFF), 8),
        bit.band(bit.rshift(argb, 16), 0xFF)
    )
    return abgr
end



function sampev.onBulletSync(playerid, data)
    if elements.checkbox.bulletTracer[0] then
        if data.center.x ~= 0 then
            if data.center.y ~= 0 then
                if data.center.z ~= 0 then
                    bulletSync.lastId = bulletSync.lastId + 1
                    if bulletSync.lastId < 1 or bulletSync.lastId > bulletSync.maxLines then
                        bulletSync.lastId = 1
                    end
                    bulletSync[bulletSync.lastId].other.time = os.time() + elements.int.secondToClose[0]
                    bulletSync[bulletSync.lastId].other.o.x, bulletSync[bulletSync.lastId].other.o.y, bulletSync[bulletSync.lastId].other.o.z = data.origin.x, data.origin.y, data.origin.z
                    bulletSync[bulletSync.lastId].other.t.x, bulletSync[bulletSync.lastId].other.t.y, bulletSync[bulletSync.lastId].other.t.z = data.target.x, data.target.y, data.target.z
                    if data.targetType == 0 then
                        --bulletSync[bulletSync.lastId].other.color = argb2abgr(255, confq.config.staticObject)
                        bulletSync[bulletSync.lastId].other.color = argb2abgr(255, confq.config.staticObject)
                    elseif data.targetType == 1 then
                        bulletSync[bulletSync.lastId].other.color = argb2abgr(255, confq.config.pedP)
                    elseif data.targetType == 2 then
                        bulletSync[bulletSync.lastId].other.color = argb2abgr(255, confq.config.carP)
                    elseif data.targetType == 3 then
                        bulletSync[bulletSync.lastId].other.color = argb2abgr(255, confq.config.dinamicObject)
                    end
                end
            end
        end
    end
end
 

penta

Участник
Автор темы
42
9
это все конечно круто, но где отрисовка трейсеров?
В это разве не 122 строка? У меня есть еще функция BulletSync

это все конечно круто, но где отрисовка трейсеров?
lua:
        if elements.checkbox.bulletTracer[0] then
            for i = 1, bulletSync.maxLines do
                if bulletSync[i].other.time >= oTime then
                    local result, wX, wY, wZ, wW, wH = convert3DCoordsToScreenEx(bulletSync[i].other.o.x, bulletSync[i].other.o.y, bulletSync[i].other.o.z, true, true)
                    local resulti, pX, pY, pZ, pW, pH = convert3DCoordsToScreenEx(bulletSync[i].other.t.x, bulletSync[i].other.t.y, bulletSync[i].other.t.z, true, true)
                    if result and resulti then
                        local xResolution = memory.getuint32(0x00C17044)
                        if wZ < 1 then
                            wX = xResolution - wX
                        end
                        if pZ < 1 then
                            pZ = xResolution - pZ
                        end 
                        renderDrawLine(wX, wY, pX, pY, elements.int.widthRenderLineOne[0], bulletSync[i].other.color)
                        if elements.checkbox.cbEnd[0] then
                            renderDrawPolygon(pX, pY-1, 3 + elements.int.sizeOffPolygonTwo[0], 3 + elements.int.sizeOffPolygonTwo[0], 1 + elements.int.polygonNumberTwo[0], elements.int.rotationPolygonTwo[0], bulletSync[i].other.color)
                        end
                    end
                end
            end
        end

Но ниче не помогло

Можете тему закрывать, проблема исправлена. 255 значение было лишним
 
Последнее редактирование:
  • Вау
Реакции: Lance_Sterling