2007-05-09 17:34:00 +00:00
--Wire graphics tablet by greenarrow
include ( ' shared.lua ' )
ENT.RenderGroup = RENDERGROUP_BOTH
2007-07-01 16:15:46 +00:00
ENT.paramSetup = false
2007-05-09 17:34:00 +00:00
function ENT : Initialize ( )
2007-07-01 16:15:46 +00:00
self : SetupParams ( )
self.allowDraw = true
2007-05-09 17:34:00 +00:00
end
function ENT : Draw ( )
2007-07-01 16:15:46 +00:00
if ! self.allowDraw then return true end
if ! self.paramsSetup then
self : SetupParams ( )
2007-05-09 17:34:00 +00:00
end
2007-07-01 16:15:46 +00:00
self.Entity : DrawModel ( )
--begin adapted nighteagle code (amazing work with vectors!!!): --Nighteagles has put a lot of work into refining the use of cam3d2d and traces to create cursor screen systems.
2007-05-09 17:34:00 +00:00
local ang = self.Entity : GetAngles ( )
local rot = Vector ( - 90 , 90 , 0 )
2007-07-01 16:15:46 +00:00
ang : RotateAroundAxis ( ang : Right ( ) , rot.x )
ang : RotateAroundAxis ( ang : Up ( ) , rot.y )
2007-05-09 17:34:00 +00:00
ang : RotateAroundAxis ( ang : Forward ( ) , rot.z )
2007-07-01 16:15:46 +00:00
local pos = self.Entity : GetPos ( ) + ( self.Entity : GetForward ( ) * self.z )
2007-05-09 17:34:00 +00:00
2007-07-01 16:15:46 +00:00
cam.Start3D2D ( pos , ang , self.res )
2007-05-09 17:34:00 +00:00
local trace = { }
2007-07-01 16:15:46 +00:00
trace.start = LocalPlayer ( ) : GetShootPos ( )
trace.endpos = ( LocalPlayer ( ) : GetAimVector ( ) * self.workingDistance ) + trace.start
trace.filter = LocalPlayer ( )
2007-05-09 17:34:00 +00:00
local trace = util.TraceLine ( trace )
2007-07-01 16:15:46 +00:00
if ( trace.Entity == self.Entity ) then
local pos = self.Entity : WorldToLocal ( trace.HitPos )
local cx = ( self.x1 - pos.y ) / ( self.x1 - self.x2 )
local cy = ( self.y1 - pos.z ) / ( self.y1 - self.y2 )
2007-05-09 17:34:00 +00:00
2007-07-01 16:15:46 +00:00
--surface.SetDrawColor(0,0,255,255)
--surface.DrawRect(self.x ,self.y, self.w, self.h)
if ( cx >= 0 and cy >= 0 and cx <= 1 and cy <= 1 ) then
surface.SetDrawColor ( 255 , 255 , 255 , 255 )
--surface.SetTexture (surface.GetTextureID ("gui/arrow"))
--surface.DrawTexturedRectRotated (self.x + (self.w * cx) + self.ox, self.y + (self.h * cy) + self.oy, 16, 16, 45)
local curSize = 16
local curWidth = 2
local midX = self.x + ( self.w * cx )
local midY = self.y + ( self.h * cy )
surface.DrawRect ( midX - curSize , midY - curWidth , curSize * 2 , curWidth * 2 )
surface.DrawRect ( midX - curWidth , midY - curSize , curWidth * 2 , curSize * 2 )
2007-05-09 17:34:00 +00:00
end
end
cam.End3D2D ( )
2007-07-01 16:15:46 +00:00
--end adapted nighteagle code
2007-05-09 17:34:00 +00:00
Wire_Render ( self.Entity )
end