Advertisement
Silverlan

Untitled

Mar 29th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. local PANEL = {}
  2. function PANEL:PaintModel()
  3.     if(!IsValid(self.Entity)) then return end
  4.     local x, y = self:LocalToScreen(0, 0)
  5.     self:LayoutEntity(self.Entity)
  6.    
  7.     local angCam = Angle(self.camAng.p,self.camAng.y,self.camAng.r)
  8.     local posCam = angCam:Forward() *self.camDistance +self:GetCamPos()
  9.     cam.Start3D(posCam,(self.vLookatPos -posCam):Angle(),self.fFOV,x,y,self:GetSize())
  10.         render.SuppressEngineLighting(true)
  11.         render.SetLightingOrigin(self.Entity:GetPos())
  12.         render.ResetModelLighting(self.colAmbientLight.r /255,self.colAmbientLight.g /255,self.colAmbientLight.b /255)
  13.         render.SetColorModulation(self.colColor.r /255,self.colColor.g /255,self.colColor.b /255)
  14.         render.SetBlend(self.colColor.a /255)
  15.        
  16.         for i = 0,6 do
  17.             local col = self.DirectionalLight[i]
  18.             if(col) then
  19.                 render.SetModelLighting(i,col.r /255,col.g /255,col.b /255)
  20.             end
  21.         end
  22.         self.Entity:DrawModel()
  23.         if(self.m_tbSubEnts) then
  24.             for _, ent in ipairs(self.m_tbSubEnts) do
  25.                 if(ent:IsValid()) then ent:DrawModel() end
  26.             end
  27.         end
  28.        
  29.         render.SuppressEngineLighting(false)
  30.     cam.End3D()
  31.     self.LastPaint = RealTime()
  32. end
  33.  
  34. function PANEL:SetCamDistance(dist)
  35.     self.pnlModel.camDistance = dist
  36. end
  37.  
  38. function PANEL:Init()
  39.     self:SetDrawOnTop(true)
  40.     self:NoClipping(true)
  41. end
  42.  
  43. function PANEL:SetUp()
  44.     self.pnlModel = GAMEMODE:CreateGUI("DModelPanel",self)
  45.     local w,h = self:GetSize()
  46.     self.pnlModel:SetSize(w,h)
  47.     self.pnlModel.m_tbSubEnts = {}
  48.     self.pnlModel:SetPos(0,h *0.06)
  49.     self.pnlModel:SetModel("models/aftokinito/WoT/Misc/Hangar.mdl")
  50.     self.pnlModel:SetFOV(65)
  51.     self.pnlModel:SetCamPos(Vector(100,30,50))
  52.     self.pnlModel:SetLookAt(Vector(0,0,40))
  53.     self.pnlModel:SetPaintedManually(true)
  54.     self.pnlModel.camAng = Angle(0,0,0)
  55.     self.pnlModel.Paint = self.PaintModel
  56.     self:SetCamDistance(0)
  57.     self.pnlModel.LayoutEntity = function(pnl)
  58.         pnl:RunAnimation()
  59.     end
  60.     self:AddModel("models/beat the zombie/WoT/German/tiger_i_body.mdl")
  61. end
  62.  
  63. function PANEL:AddModel(mdl)
  64.     local ent = ClientsideModel(mdl)
  65.     ent:SetNoDraw(true)
  66.     ent:Spawn()
  67.     ent:Activate()
  68.     table.insert(self.pnlModel.m_tbSubEnts,ent)
  69. end
  70.  
  71. function PANEL:Think()
  72. end
  73.  
  74. function PANEL:OnClose()
  75.     local pnlModel = self.pnlModel
  76.     self:Remove()
  77.     pnlModel:Remove()
  78. end
  79.  
  80. function PANEL:Hide()
  81.     self:SetVisible(false)
  82. end
  83.  
  84. function PANEL:Paint()
  85. end
  86.  
  87. function PANEL:PaintOver()
  88.     self.pnlModel:Paint()
  89. end
  90. derma.DefineControl("DHangar","A Hangar",PANEL,"DPanel")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement