Python1320

Epic 3d plotting

May 17th, 2011
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1. pi=math.pi
  2. sin=math.sin
  3. cos=math.cos
  4. tan=math.tan
  5. log=math.log
  6. local abs=math.abs
  7. local pi=math.pi
  8. local sin=math.sin
  9. local cos=math.cos
  10. local tan=math.tan
  11.  
  12. Msg"[Plot] "print("Initating plotter!")
  13.  
  14. local origin= Vector(-2115.3698730469,3043.1638183594,-15500)
  15.  
  16. local timesx,timesy=15,15
  17.  
  18.  
  19. local function BadNumber(v)
  20.     return !v or v==inf or v==ninf or !(v>=0 or v<=0)
  21. end
  22.  
  23.  
  24.  
  25.  
  26. local mdl="models/Combine_Helicopter/helicopter_bomb01.mdl"
  27. PLOTENTS=PLOTENTS or {}
  28. local PLOTENTS=PLOTENTS
  29.  
  30.  
  31. local range=100
  32. local createmdl=function()
  33.     local ent=SERVER and ents.Create('prop_physics') or ClientsideModel(mdl)
  34.     ent:SetMaterial[[models/debug/debugwhite]]
  35.  
  36.  
  37.     if !ValidEntity(ent) then error"entity limit reched?" end
  38.     table.insert(PLOTENTS,ent)
  39.     ent:SetPos(origin)
  40.     ent:SetModelScale(Vector(5,5,5))
  41. end
  42.  
  43. function KillPlot()
  44.     timer.Remove"1"
  45.     for k,v in pairs(PLOTENTS) do
  46.         if ValidEntity(v) then
  47.             v:Remove()
  48.         end
  49.     end
  50.     table.Empty(PLOTENTS)
  51.     --Msg"[Plot]"print("Killed.")
  52. end
  53. KillPlot()
  54.  
  55. Msg"[Plot] "print("Creating "..timesx*timesy.." entities.")
  56. for i=0,timesx*timesy do
  57.     createmdl()
  58. end
  59. if !PLOT then
  60. function PLOT(x,y,t) return x,sin(y)*5*(0.2+0.8*abs(sin(x/2+t))),cos(y)*5*(0.2+0.8*abs(sin(x/2+t))) end
  61. end
  62.  
  63. local i=0
  64. local range=180
  65.  
  66. local c=FrameTime()
  67. local mdltopos=function(x,y,z)
  68.     x = math.Clamp(x,- 10 , 10 )
  69.     y = math.Clamp(y,- 10 , 10 )
  70.     z = math.Clamp(z,- 10 , 10 )
  71.     if math. BadNumber(x) or math. BadNumber(y) or math. BadNumber(z) then return end
  72.     i=i+1
  73.     local ent=PLOTENTS[i]
  74.     if !ent then i=0 end
  75.     local ent=PLOTENTS[i]
  76.     if ValidEntity(ent) then
  77.         local vec=Vector(x,y,z)*range
  78.         vec:Rotate(Angle(0,CurTime()*10-c,0))
  79.         ent:SetPos(origin+vec)
  80.         ent:SetAngles((vec-origin):Angle())
  81.         local a=127+126*sin(z*0.2)
  82.         --MsgN(z)
  83.  
  84.     end
  85. end
  86.  
  87.  
  88. if !origin then error"no origin" end
  89. local ft=0
  90. timer.Create('1',0,0,function()
  91. ft=ft+FrameTime()
  92.  
  93. for x=0,timesx do
  94.     for y=0,timesy do
  95.         local xx = (x/timesx) * pi*2
  96.         local yy = (y/timesy) * pi*2
  97.         local a,zz,xxx,yyy=pcall(PLOT,xx,yy,ft)
  98.         if !a then zz=0 end
  99.         xx=xxx or xx
  100.         yy=yyy or yy
  101.         mdltopos(xx,yy,zz)--xx,yy,zz)
  102.     end
  103. end
  104. end)
Advertisement
Add Comment
Please, Sign In to add comment