Guest User

Untitled

a guest
Apr 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | None | 0 0
  1. VCube = {
  2.     top = {
  3.         fl = Vector(0,0,0),
  4.         fr = Vector(0,0,0),
  5.         bl = Vector(0,0,0),
  6.         br = Vector(0,0,0),
  7.         center = Vector(0,0,0)
  8.     },
  9.    
  10.     bottom = {
  11.         fl = Vector(0,0,0),
  12.         fr = Vector(0,0,0),
  13.         bl = Vector(0,0,0),
  14.         br = Vector(0,0,0),
  15.         center = Vector(0,0,0)
  16.     }
  17. };
  18.  
  19. if ( CLIENT ) then
  20. function VCube:Render()
  21.     local Laser = Material( "cable/redlaser" )
  22.     render.SetMaterial( Laser )
  23.    
  24.         -- Top
  25.     render.DrawBeam( self.top.fl, self.top.fr, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  26.     render.DrawBeam( self.top.bl, self.top.fl, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  27.     render.DrawBeam( self.top.bl, self.top.br, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  28.     render.DrawBeam( self.top.br, self.top.fr, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  29.    
  30.     -- Top to bottom corners
  31.     render.DrawBeam( self.top.fl, self.bottom.fl, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  32.     render.DrawBeam( self.top.fr, self.bottom.fr, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  33.     render.DrawBeam( self.top.bl, self.bottom.bl, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  34.     render.DrawBeam( self.top.br, self.bottom.br, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  35.    
  36.     -- Bottom
  37.     render.DrawBeam( self.bottom.fl, self.bottom.fr, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  38.     render.DrawBeam( self.bottom.bl, self.bottom.fl, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  39.     render.DrawBeam( self.bottom.bl, self.bottom.br, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  40.     render.DrawBeam( self.bottom.br, self.bottom.fr, 5, 1, 1, Color( 0, 0, 255, 255 ) );
  41. end
  42. end
  43.  
  44. function VCube:PointCube( tbl, origin, width, height)
  45.     tbl = tbl or { }
  46.     setmetatable( tbl, self );
  47.     self.__index = self
  48.    
  49.     local bottom_center = Vector( origin.x, origin.y, origin.z - ( height / 2 ) );
  50.     local bottom_fr = Vector( bottom_center.x + (width / 2), bottom_center.x + (width/2), bottom_center.z);
  51.     local bottom_fl = Vector( bottom_center.x - (width / 2), bottom_center.y + (width/2), bottom_center.z);
  52.     local bottom_br = Vector( bottom_center.x + (width / 2), bottom_center.y - (width/2), bottom_center.z);
  53.     local bottom_bl = Vector( bottom_center.x - (width / 2), bottom_center.y - (width/2), bottom_center.z);
  54.     local top_center = Vector( origin.x, origin.y, origin.z + ( height / 2 ) );
  55.     local top_fr = Vector( bottom_center.x + (width / 2), bottom_center.y + (width/2), bottom_center.z + height);
  56.     local top_fl = Vector( bottom_center.x - (width / 2), bottom_center.y + (width/2), bottom_center.z + height);
  57.     local top_br = Vector( bottom_center.x + (width / 2), bottom_center.y - (width/2), bottom_center.z + height);
  58.     local top_bl = Vector( bottom_center.x - (width / 2), bottom_center.y - (width/2), bottom_center.z + height);
  59.    
  60.     tbl.top.fl = top_fl;
  61.     tbl.top.fr = top_fr;
  62.     tbl.top.bl = top_bl;
  63.     tbl.top.br = top_br;
  64.     tbl.top.center = top_center;
  65.    
  66.     tbl.bottom.fl = bottom_fl;
  67.     tbl.bottom.fr = bottom_fr;
  68.     tbl.bottom.bl = bottom_bl;
  69.     tbl.bottom.br = bottom_br;
  70.     tbl.bottom.center = bottom_center;
  71.    
  72.     tbl.center = origin;
  73.     return tbl;
  74. end
Add Comment
Please, Sign In to add comment