Looking for help trying to understand intricacies of DModelPanel

I’m trying to draw DModelPanel, and I’m having a tough time trying to get the models lined up the way I want them to. I’m pretty damn confused about how I should go about utilizing the panel’s functions (SetCamPos, SetFOV, SetLookAng, SetLookAt) for changing how you look at the model. Through trials and tribulations I’ve managed to discern SOME axis rotations but then it seems editing one value puts all the others out of wack.

To be clear, I’m trying to draw gun models, and I’d like for every gun model to be centered and looking at its side. How can I best go about getting this done for all of the weapon models I want to draw (there’s anywhere from 40-50)?

Thanks ahead of time for any and all help.

Example 2 here should at least get the model centered:

DModelPanel:SetCamPos



local mdlpnl = vgui.Create( "DModelPanel" )

local mn, mx = mdlpnl.Entity:GetRenderBounds()
local size = 0
size = math.max( size, math.abs( mn.x ) + math.abs( mx.x ) )
size = math.max( size, math.abs( mn.y ) + math.abs( mx.y ) )
size = math.max( size, math.abs( mn.z ) + math.abs( mx.z ) )

mdlpnl:SetFOV( 45 )
mdlpnl:SetCamPos( Vector( size, size, size ) )
mdlpnl:SetLookAt( ( mn + mx ) * 0.5 )


Well, it brings the model into focus, but it’s at an odd angle and zoomed in too far.

You had to detour LayoutEntity

You mean



weaponModelPanel.LayoutEntity = function() return true end


?

I have that written in, yes, I don’t want the model to rotate. The objective is to get the gun centered and side facing forward.

I found outside help.