TorNix~|nR

Object Preview

Recommended Posts

I used this resource ( object_preview ), the ped is showed but when I save it on png, it saves but saves empty

this is the resource on community https://community.multitheftauto.com/index.php?p=resources&s=details&id=11836

any help please? this is the code

local x, y, z = getCameraMatrix()
    local sx, sy = guiGetSize(GUIEditor.staticimage[1], false)
    local skin = createPed(getElementModel(localPlayer), x, y, z)
    local view = exports.object_preview:createObjectPreview(skin, 0, 0, 200, 0, 0, sx, sy, false, false, true)
    exports.object_preview:saveRTToFile(view, "gui_skin.png") 
    exports.object_preview:destroyObjectPreview(view)
    destroyElement(skin)

    guiStaticImageLoadImage(GUIEditor.staticimage[1], "gui_skin.png")

 

Share this post


Link to post

you can't create object preview and save it instantly. Creating preview takes a little amount of time so you'll always get an empty image. setTimer will solve your problem

@TorNix~|nR

  • Like 1

Share this post


Link to post

Thank you it's working, but when I open the panel, every 50 milliseconds the ped automatically disappear, this is the problem

you can see the image, it appears and suddenly disappears every time I open the panel

Code:

 

local x, y, z = getCameraMatrix()
    local sx, sy = guiGetSize(GUIEditor.staticimage[1], false)
    local skin = createPed(getElementModel(localPlayer), x, y, z)
    local view = exports.object_preview:createObjectPreview(skin, 0, 0, 200, 0, 0, sx, sy, false, false, true)
    setTimer(function ( )
    	exports.object_preview:saveRTToFile(view, "gui_skin.png") 
        guiStaticImageLoadImage(GUIEditor.staticimage[1], "gui_skin.png")
    	exports.object_preview:destroyObjectPreview(view)
    	destroyElement(skin)
    end, 50, 1)

Image:

wS0y2LH.jpg

Share this post


Link to post

@TorNix~|nR you should add empty file server side with name "gui_skin.png" and add it to meta.xml with download="false" property or you'll get error on 7-th line

@Ren_712 could you fix a problem above ? object_preview creates 2 objects on screen if second render target's value = true

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.