Python1320

NightExcessive

Dec 3rd, 2010
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. --snow_data = nil
  2.  
  3. snow_data = snow_data or {}
  4.  
  5.  
  6. if table.Count(snow_data) == 0 then
  7.  
  8.     local max = 16000
  9.     local grid_size = 512
  10.     local range = max/grid_size
  11.  
  12.     local pos
  13.  
  14.     for x = -range, range do
  15.         x = x * grid_size
  16.         for y = -range, range do
  17.             y = y * grid_size
  18.             for z = -range, range do
  19.                 z = z * grid_size
  20.                
  21.                 pos = Vector(x,y,z)
  22.                 local up = util.QuickTrace(pos, vector_up*max*2)
  23.                 local conents = util.PointContents( pos )
  24.                
  25.                 if (up.HitTexture == "TOOLS/TOOLSSKYBOX" or up.HitTexture == "**empty**") and (conents == CONTENTS_EMPTY or conents == CONTENTS_TESTFOGVOLUME)  then
  26.                     table.insert(snow_data, pos)
  27.                 end
  28.             end
  29.         end
  30.     end
  31.  
  32. end
  33.  
  34. local function FastLength(point)
  35.     return point.x*point.x+point.y*point.y+point.z*point.z
  36. end
  37.  
  38. local draw_these = {}
  39.  
  40. local emitter = ParticleEmitter(EyePos(), false)
  41.  
  42. hook.Add("Think", "snow", function()
  43.     for _, point in pairs(draw_these) do
  44.         if math.random() < 0.95 then continue end
  45.         local particle = emitter:Add("particle/snow", point)
  46.         if (particle) then
  47.             particle:SetVelocity(VectorRand()*70*Vector(1,1,0))
  48.             particle:SetAngles(Angle(math.random(360), math.random(360), math.random(360)))
  49.             particle:SetLifeTime(0)
  50.             particle:SetDieTime(10)
  51.             particle:SetStartAlpha(255)
  52.             particle:SetEndAlpha(0)
  53.             particle:SetStartSize(0)
  54.             particle:SetEndSize(5)
  55.             particle:SetGravity(Vector(0,0,math.Rand(-30, -200)))
  56.             particle:SetCollide(true)
  57.         end
  58.     end
  59. end)
  60.  
  61. local iterations = 10000
  62. local lastkey
  63. timer.Create("hide_points", 1, 0, function()
  64.     local c = #snow_data
  65.     print(c, lastkey, iterations)
  66.     for i=1,iterations do
  67.         local key = (lastkey or 0)+i
  68.         if key > c then key = key-c end
  69.         local point = snow_data[key]
  70.         if FastLength(point - LocalPlayer():EyePos()) < 4000000 then
  71.             draw_these[key] = point
  72.         else
  73.             draw_these[key] = nil
  74.         end
  75.         if i >= iterations then lastkey = key break end
  76.     end
  77. end)
  78.  
  79. do return end
  80.  
  81. --[[ hook.Remove("HUDPaint",1)
  82.  
  83. local mat = Material("sprites/sent_ball")
  84.  
  85. hook.Add("PostDrawOpaqueRenderables", 1, function()
  86.  
  87.     render.SetMaterial(mat)
  88.     for key, point in pairs(draw_these) do
  89.         render.DrawSprite(point, 50, 50, color_white)
  90.     end
  91.    
  92. end)]]
Advertisement
Add Comment
Please, Sign In to add comment