Advertisement
Jak92

Renderbound hint? (Keep model in camera view)

Aug 8th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.62 KB | None | 0 0
  1. local currModelNr
  2.  
  3.     if (istable(job.model)) then
  4.          currModelNr = 1
  5.         jobModel = job.model[currModelNr]
  6.     else
  7.        currModelNr = nil
  8.     end
  9.  
  10.     local playermodel = jobDetailsPanel:Add("DModelPanel")
  11.     playermodel:SetPos(-50, 0)
  12.     playermodel:SetSize(400, 800)
  13.     playermodel:SetModel(jobModel)
  14.  
  15.     local mn, mx = playermodel.Entity:GetRenderBounds()
  16.     local size = 0
  17.     size = math.max( size, math.abs(mn.x) + math.abs(mx.x) )
  18.     size = math.max( size, math.abs(mn.y) + math.abs(mx.y) )
  19.     size = math.max( size, math.abs(mn.z) + math.abs(mx.z) )
  20.  
  21.     playermodel:SetFOV( 15 )
  22.     playermodel:SetCamPos( Vector( size + 180, size, size ) )
  23.     playermodel:SetLookAt( (mn + mx) * 0.3 )
  24.  
  25.     function playermodel:LayoutEntity( Entity ) return end -- disables default rotation
  26.    
  27.     -- Right Arrow for playermodel change
  28.     if (istable(job.model)) then
  29.         local arrowRightButton = jobDetailsPanel:Add("DButton")
  30.         arrowRightButton:SetText("")
  31.         arrowRightButton:SetPos(230, 260)
  32.         arrowRightButton:SetSize(23, 43)
  33.  
  34.         arrowRightButton.DoClick = function()
  35.             if (currModelNr != nil) then
  36.                 if isstring(job.model[currModelNr + 1]) then
  37.                     currModelNr = currModelNr + 1
  38.                     jobModel = job.model[currModelNr]
  39.                     playermodel:SetModel(jobModel)
  40.                     DarkRP.setPreferredJobModel(jobindex, jobModel)
  41.                 end
  42.             end
  43.         end
  44.  
  45.         arrowRightButton.Paint = function(self, w, h)
  46.             surface.SetDrawColor(VoidF4.Colors.White)
  47.             surface.SetMaterial(VoidF4.Icons.ArrowRight)
  48.             surface.DrawTexturedRect(0, 0, 23, 43)
  49.         end
  50.  
  51.  
  52.         -- Left Arrow for playermodel change
  53.         local arrowLeftButton = jobDetailsPanel:Add("DButton")
  54.         arrowLeftButton:SetText("")
  55.         arrowLeftButton:SetPos(30, 260)
  56.         arrowLeftButton:SetSize(23, 43)
  57.  
  58.         arrowLeftButton.DoClick = function()
  59.             if (currModelNr != nil) then
  60.                 if isstring(job.model[currModelNr - 1]) then
  61.                     currModelNr = currModelNr - 1
  62.                     jobModel = job.model[currModelNr]
  63.                     playermodel:SetModel(jobModel)
  64.                     DarkRP.setPreferredJobModel(jobindex, jobModel)
  65.                 end
  66.             end
  67.         end
  68.  
  69.         arrowLeftButton.Paint = function(self, w, h)
  70.             surface.SetDrawColor(VoidF4.Colors.White)
  71.             surface.SetMaterial(VoidF4.Icons.ArrowLeft)
  72.             surface.DrawTexturedRect(0, 0, 23, 43)
  73.         end
  74.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement