Исходник Гайд entityRender | Рисуем сущности в mimgui

Уже давно @chapo меня заебывал просил переписать библиотеку от @imring для mimgui, и я даже начал это делать, но потом забил болт. Но вот у меня наконец-то дошли руки до этого

Описание: Данная библиотека дает возможность рендерить сущности в mimgui. Например: педов, транспорт, объекты.

Видео:

Скриншот:
1738640501189.png


Пример кода:
Lua:
-- Код говно, но мне похуй
local entityRender = require("EntityRender")
local imgui = require 'mimgui'
local renderWindow = imgui.new.bool(true)
local vPos = imgui.new.float[3](0.1, -2.00, 50.0)
local bgColor = imgui.new.float[4](1.0, 1.0, 1.0, 1.0)
local vRotate = imgui.new.float[3](0.0, 0.0, 0.0)
local nModel = imgui.new.int(411)
local nVehicleColor = imgui.new.int[2](0, 0)
local vPos1 = imgui.new.float[3](0.1, -2.00, 50.0)
local bgColor1 = imgui.new.float[4](1.0, 1.0, 1.0, 1.0)
local vRotate1 = imgui.new.float[3](0.0, 0.0, 0.0)
local nModel1 = imgui.new.int(411)
local nVehicleColor1 = imgui.new.int[2](0, 0)
local nTextureId = nil
local nTextureId1 = nil
function main()
    entityRender.init()
    nTextureId = entityRender.addEntity(nModel[0])
    nTextureId1 = entityRender.addEntity(nModel1[0])
end
imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)
local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 600, 300
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        if imgui.Begin('Main Window', renderWindow, imgui.WindowFlags.AlwaysAutoResize) then
            if (entityRender.getD3D9Texture(nTextureId) ~= nil) then
                imgui.Image(entityRender.getD3D9Texture(nTextureId), imgui.ImVec2(255.0, 255.0))
            end
            if (entityRender.getD3D9Texture(nTextureId1) ~= nil) then
                imgui.SameLine()
                imgui.Image(entityRender.getD3D9Texture(nTextureId1), imgui.ImVec2(255.0, 255.0))
            end
            if (imgui.DragFloat3("pos", vPos, 0.1, -100.0, 100.0)) then
                entityRender.setTexturePos(nTextureId, vPos[0], vPos[1], vPos[2])
                entityRender.recreateTexture(nTextureId)
            end
            imgui.SameLine()
            if (imgui.DragFloat3("pos1", vPos1, 0.1, -100.0, 100.0)) then
                entityRender.setTexturePos(nTextureId1, vPos1[0], vPos1[1], vPos1[2])
                entityRender.recreateTexture(nTextureId1)
            end
            if (imgui.DragFloat3("rotate", vRotate, 0.1, -360.0, 360.0)) then
                entityRender.setTextureRotate(nTextureId, vRotate[0], vRotate[1], vRotate[2])
                entityRender.recreateTexture(nTextureId)
            end
          
            imgui.SameLine()
            if (imgui.DragFloat3("rotate1", vRotate1, 0.1, -360.0, 360.0)) then
                entityRender.setTextureRotate(nTextureId1, vRotate1[0], vRotate1[1], vRotate1[2])
                entityRender.recreateTexture(nTextureId1)
            end
            if (imgui.ColorEdit4("bg color", bgColor)) then
                entityRender.setTextureBackground(nTextureId, bgColor[0] * 255, bgColor[1] * 255, bgColor[2] * 255, bgColor[3] * 255)
                entityRender.recreateTexture(nTextureId)
            end
          
            imgui.SameLine()
            if (imgui.ColorEdit4("bg color1", bgColor1)) then
                entityRender.setTextureBackground(nTextureId1, bgColor1[0] * 255, bgColor1[1] * 255, bgColor1[2] * 255, bgColor1[3] * 255)
                entityRender.recreateTexture(nTextureId1)
            end
            imgui.InputInt2("vehicle color", nVehicleColor)
            imgui.SameLine()
            imgui.InputInt2("vehicle color1", nVehicleColor1)
            imgui.InputInt("model", nModel)
            imgui.SameLine()
            imgui.InputInt("model1", nModel1)
            if (imgui.Button("recreate")) then
                entityRender.setTextureModel(nTextureId, nModel[0])
                entityRender.setTextureVehicleColor(nTextureId, nVehicleColor[0], nVehicleColor[1])
                entityRender.recreateTexture(nTextureId)
                entityRender.setTextureModel(nTextureId1, nModel1[0])
                entityRender.setTextureVehicleColor(nTextureId1, nVehicleColor1[0], nVehicleColor1[1])
                entityRender.recreateTexture(nTextureId1)
            end
            imgui.End()
        end
    end
)

Доступные функции:
Lua:
entityRender.init() -- Инициализирует библиотеку. Вызывается один раз перед работой с библиотекой
ptr texturePtr = entityRender.getD3D9Texture() -- Возвращает указатель на IDirect3Texture9 для рендера ImGui::Image
entityRender.recreateTexture(int nId) -- Пересоздает текстуру по её ID
bool result = entityRender.setTexturePos(int nId, float x, float y, float z) -- Устанавливает позицию текстуре по её ID
bool result = entityRender.setTextureRotate(int nId, float x, float y, float z) -- Устанавливает поворот текстуре под её ID
bool result = entityRender.setTextureModel(int nId, int nModelId) -- Устанавливает модель текстуре по её ID
bool result = entityRender.setTextureBackground(int nId, float r, float g, float b, float a) -- Устанавливает цвет заднего фона текстуры по её ID
bool result = entityRender.setTextureVehicleColor(int nId, int nPrimary, int nSecondary) -- Устанавливает цвет транспорту по ID текстуры
bool result = entityRender.deleteTexture(int nId) -- Удаляет текстуру по её ID
entityRender.deleteAllTextures() -- Удаляет всё текстуры
bool result = entityRender.isTextureExist(int nId)
int nId = entityRender.addEntity(int nModelId) -- Создает текстуру с указаной моделью и возвращает её ID

Автор: @ARMOR
Автор оригинальной библиотеки: @imring

Исходник: https://github.com/xARMORx/EntityRender
 

Вложения

  • EntityRender.dll
    176 KB · Просмотры: 4
Последнее редактирование:

Gorskin

🖕
Проверенный
1,354
1,204
Кажись исправлено, проблема была в хуке.
Теперь по другому адресу краш.
Всё так же, листаю тачки и на раз 20-30 крашит всегда по этому адресу.

vx218NfGg4.png
ida_mtbRbYvMFY.png

если надо то участок кода с выбором тачек:
говно:
-- Функция для отображения списка транспорта
function showVehicleList()
    imgui.BeginGroup()
    imgui.Text(u8"Список транспорта. Всего: ("..#gtaVehicles..")")

    -- Поле для ввода поискового запроса
    imgui.PushItemWidth(170)
    if imgui.InputText(u8'Поиск##vehlist', imDATA.buffers.searchVehlist, ffi.sizeof(imDATA.buffers.searchVehlist)) then
        searchVehlist = ffi.string(imDATA.buffers.searchVehlist)
    end
    imgui.PopItemWidth()
    imgui.MainBox("список тс гта", imgui.ImVec2(280,400), 0)
        for _, vehicle in ipairs(gtaVehicles) do

            if not searchVehlist or string.find(string.lower(vehicle.name), string.lower(searchVehlist)) or string.find(tostring(vehicle.id), searchVehlist) then
                if imgui.Selectable(vehicle.name .. " (ID: " .. vehicle.id..")") then
                    imgui.OpenPopup("Vehicle Info")
                    selectedVehicle = vehicle

                    entityRender.setTextureModel(vehiclePopupTextureId, selectedVehicle.id)
                    entityRender.setTextureVehicleColor(vehiclePopupTextureId, 3, 3)
                    entityRender.setTexturePos(vehiclePopupTextureId, -0.6, -6.30, 50.0)
                    entityRender.setTextureRotate(vehiclePopupTextureId, -15.200, 0.0, 315.0)
                    entityRender.setTextureBackground(vehiclePopupTextureId, 0, 0, 0, 0)
                    entityRender.recreateTexture(vehiclePopupTextureId)
                    
                end
            end
        end

        -- Отображение popup с информацией о выбранном транспорте
        if imgui.BeginPopup(u8"Vehicle Info") then
            if selectedVehicle then
                imgui.Text(u8"Название: " .. selectedVehicle.name)
                imgui.Text(u8"ID: " .. selectedVehicle.id)

                if imgui.Button(u8"Добавить в список раздачи") then
                    table.insert(spawnList, {name = selectedVehicle.name, id = selectedVehicle.id})
                    saveSpawnList()
                    imgui.CloseCurrentPopup()
                end
                if imgui.Button(u8"Создать без сетки") then
                    sampSendChat("/veh " .. selectedVehicle.id .. " " .. math.random(0, 100) .. " " .. math.random(0, 100))
                    imgui.CloseCurrentPopup()
                end

                if (entityRender.getD3D9Texture(vehiclePopupTextureId) ~= nil) then
                    imgui.Image(entityRender.getD3D9Texture(vehiclePopupTextureId), imgui.ImVec2(200.0, 200.0))
                end
            end
            imgui.EndPopup()
        end
    imgui.EndChild()
    imgui.EndGroup()
end