Permalink
Browse files

"Fix" DAdjustableModelPanel model not being visible

  • Loading branch information...
1 parent 9cfcdd7 commit fbe169b68a19bd73b57fc387d1384e9c52095a44 @robotboy655 robotboy655 committed Apr 11, 2015
Showing with 15 additions and 23 deletions.
  1. +15 −23 garrysmod/lua/vgui/dadjustablemodelpanel.lua
@@ -1,21 +1,13 @@
---[[ _
- ( )
- _| | __ _ __ ___ ___ _ _
- /'_` | /'__`\( '__)/' _ ` _ `\ /'_` )
-( (_| |( ___/| | | ( ) ( ) |( (_| |
-`\__,_)`\____)(_) (_) (_) (_)`\__,_)
-
---]]
+
local PANEL = {}
AccessorFunc( PANEL, "m_bFirstPerson", "FirstPerson" )
-
function PANEL:Init()
self.mx = 0
self.my = 0
- self.aLookAngle = Angle( 0, 0, 0 )
+ --self.aLookAngle = Angle( 0, 0, 0 ) -- "Fix" model not being visible if no cam pos/angles are set
end
@@ -24,9 +16,9 @@ function PANEL:OnMousePressed( mousecode )
self:MouseCapture( true )
self.Capturing = true
self.MouseKey = mousecode
-
+
self:SetFirstPerson( true )
-
+
self:CaptureMouse()
end
@@ -44,27 +36,27 @@ end
function PANEL:CaptureMouse()
local x, y = input.GetCursorPos()
-
+
local dx = x - self.mx
local dy = y - self.my
-
+
local centerx, centery = self:LocalToScreen( self:GetWide() * 0.5, self:GetTall() * 0.5 )
input.SetCursorPos( centerx, centery )
self.mx = centerx
self.my = centery
-
+
return dx, dy
end
function PANEL:FirstPersonControls()
-
+
local x, y = self:CaptureMouse()
local scale = self:GetFOV() / 180
x = x * -0.5 * scale
y = y * 0.5 * scale
-
+
if ( self.MouseKey == MOUSE_LEFT ) then
if ( input.IsShiftDown() ) then y = 0 end
@@ -75,23 +67,23 @@ function PANEL:FirstPersonControls()
return
end
-
+
-- Look around
self.aLookAngle = self.aLookAngle + Angle( y, x, 0 )
-
+
local Movement = Vector( 0, 0, 0 )
-
+
-- TODO: Use actual key bindings, not hardcoded keys.
if ( input.IsKeyDown( KEY_W ) || input.IsKeyDown( KEY_UP ) ) then Movement = Movement + self.aLookAngle:Forward() end
if ( input.IsKeyDown( KEY_S ) || input.IsKeyDown( KEY_DOWN ) ) then Movement = Movement - self.aLookAngle:Forward() end
if ( input.IsKeyDown( KEY_A ) || input.IsKeyDown( KEY_LEFT ) ) then Movement = Movement - self.aLookAngle:Right() end
if ( input.IsKeyDown( KEY_D ) || input.IsKeyDown( KEY_RIGHT ) ) then Movement = Movement + self.aLookAngle:Right() end
if ( input.IsKeyDown( KEY_SPACE ) || input.IsKeyDown( KEY_SPACE ) ) then Movement = Movement + self.aLookAngle:Up() end
if ( input.IsKeyDown( KEY_LCONTROL ) || input.IsKeyDown( KEY_LCONTROL ) ) then Movement = Movement - self.aLookAngle:Up() end
-
+
local scale = 0.5
if ( input.IsShiftDown() ) then scale = 4.0 end
-
+
self.vCamPos = self.vCamPos + Movement * scale
end
@@ -100,7 +92,7 @@ function PANEL:OnMouseWheeled( dlta )
local scale = self:GetFOV() / 180
self.fFOV = self.fFOV + dlta * -10.0 * scale
-
+
end
function PANEL:OnMouseReleased( mousecode )

0 comments on commit fbe169b

Please sign in to comment.