Is there any way to use the in-game Icon Editor to get vector positions for DModelPanel?

I’m having so much trouble putting in random numbers in SetLookAt, SetCamPos etc and trying to get the icon in the center of the panel. I noticed there’s a thing called Icon Editor which you can access by right clicking on any icon in the Q menu in sandbox and clicking “Edit Icon”. Is there any way I can use this to get any vector positions which I can use?

Thanks

The IconEditor element uses DAdjustableModelPanel, and this is what you’re looking for. Assuming you’re talking about a model, you can get this as follows:



local f = vgui.Create"DFrame"
f:SetSize(300,300)
f:Center()
f:MakePopup()

local damp = vgui.Create("DAdjustableModelPanel", f)
damp:SetSize(256,256)
damp:Center()
damp:SetModel"<your model path>"
damp.LayoutEntity = function() end -- Stops default rotation
damp:SetLookAt(vector_origin)


The model will only be displayed upon clicking within the panel. Once you have set your desired cam pos, ang and FOV, you can retrieve these with:



damp:GetCamPos()
damp:GetLookAng()
damp:GetFOV()


You can make the panel global if you want to get the values in your console, or just have f:Think() write them in the DFrame. Have a look at DModelPanel for all the available functions.

Don’t statically align your derma elements, use some math so things can be re-sizeable.

If an icon needs to be centered then you can divide the width and height of your DFrame by two to get the center. Then you need to subtract half of the width and height of the icon from that ‘center’ number.



local pw, ph = DFrame:GetSize()
local iw, ih = DIcon:GetSize()
DIcon:SetPos( (pw/2)-(iw/2), (ph/2)-(ih/2) )


The same can be done for a lot of positions. Instead of dividing by two you can multiply by a percent to do quarter/eighths whatever alignments and such.