Advertisement
Patasuss

PukaScan

Jun 2nd, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. @name PukaScan
  2. @inputs DS:wirelink Sun:entity
  3. @outputs
  4. @persist Res WindowRes WindowDist MaxDist CalColor:vector Running E:entity AtX AtY
  5. @trigger
  6.  
  7. if(first())
  8. {
  9.     runOnTick(1)
  10.     Res = 128
  11.     WindowRes = 64
  12.     WindowDist = 64
  13.     MaxDist = 2000
  14.     CalColor = vec(255,255,255) / MaxDist
  15.     Running = 1
  16.     E = entity()
  17.     rangerPersist(1)
  18.     rangerFilter(E)
  19.     rangerFilter(Sun)
  20.    
  21.     holoCreate(1)
  22.     holoScale(1, vec(1,1,1) * 0.3)
  23.     DS[1048572] = Res
  24.     DS[1048573] = Res
  25. }
  26. if(Running)
  27. {
  28. while(perf())
  29. {
  30. WindowPos = E:pos() + E:right()*(-WindowRes/2 + (WindowRes/Res)*AtX) + E:forward()*(-WindowRes/2 + (WindowRes/Res)*AtY) + E:up()*WindowDist
  31. R = rangerOffset(MaxDist, E:pos(), (WindowPos - E:pos()):normalized())
  32. holoPos(1, WindowPos)
  33. AtX++
  34. if(AtX >= Res)
  35. {
  36.     AtX = 0
  37.     AtY++
  38. }
  39. if(AtY >= Res)
  40. {
  41.     Running = 0
  42. }
  43.  
  44.  
  45. #print("X: "+AtX + " Y: "+AtY)
  46. #print("Dist: "+R:distance())
  47.  
  48. Color = CalColor * (MaxDist-R:distance())
  49. #Color = R:hitNormal() * vec(255,255,255)
  50. Dir = Sun:pos() - R:pos()
  51. SunRay = rangerOffset(Dir:length(), R:pos(), Dir:normalized())
  52. if(SunRay:hit())
  53. {
  54.     Color -= vec(1,1,1) * 100
  55. }
  56.  
  57.  
  58. Cell = AtX*Res + (Res-AtY)
  59. DS[Cell] = rgb2digi(Color,0)
  60.  
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement