Ember

TraceDisplay

Aug 14th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. @name TraceDisplay
  2. @inputs [Display]:wirelink
  3. @outputs [D F]:number [C]:entity
  4. @persist [E]:entity [H J P R Resolution S]:number
  5.  
  6. if(dupefinished())
  7. {
  8. reset()
  9. }
  10.  
  11. if(first())
  12. {
  13. #Configurables
  14. Resolution = 16
  15. Scale = 250
  16.  
  17. #More variables
  18. R = Resolution * Resolution - 1
  19. S = Scale / Resolution
  20. P = 0
  21.  
  22. #Initialize the digital screen
  23. Display[1048574] = 0 #Reset Screen and whatever was on it will be cleared.
  24. Display[1048569] = 3 #Set color mode to 3
  25. Display[1048575] = 1 #Apply changes
  26. Display[1048572] = Resolution #Set new resolution on Y (Height)
  27. Display[1048573] = Resolution #Set new resolution on X (Width)
  28.  
  29. #Stiff
  30. E = entity()
  31.  
  32. Pos = E:pos()
  33. Scale = 1
  34. Alpha = 255
  35.  
  36. #X Axis
  37. holoCreate(0, Pos, vec(Scale, Scale, Scale))
  38. holoModel(0, "cube")
  39. holoColor(0, vec(255, 0, 0), Alpha)
  40.  
  41. #Y Axis
  42. holoCreate(1, Pos, vec(Scale, Scale, Scale))
  43. holoModel(1, "cube")
  44. holoColor(1, vec(0, 255, 0), Alpha)
  45.  
  46. #Z Axis
  47. holoCreate(2, Pos, vec(Scale, Scale, Scale))
  48. holoModel(2, "cube")
  49. holoColor(2, vec(0, 0, 255), Alpha)
  50.  
  51. #Pause then begin
  52. timer("Run", 1000)
  53. }
  54.  
  55. function number lerp(A:number, B:number, C:number)
  56. {
  57. return A + C * (B - A)
  58. }
  59.  
  60. function void scan()
  61. {
  62. B = E:up()
  63. A = E:pos() + B + E:right() * (P % Resolution - Resolution / 2) * S + E:forward() * (floor(P / Resolution) - Resolution / 2) * S
  64.  
  65. holoPos(0, A)
  66.  
  67. Trace = rangerOffset(16000, A, B)
  68.  
  69. J = H > 0 ? Trace:distance() : lerp(J, Trace:distance(), 1/H)
  70. H++
  71. D = max(127 - (Trace:distance() - J) / 5, 0)
  72. C = Trace:entity()
  73. F = 2 - C:isValid()
  74. G = 2 - C:isPlayer()
  75.  
  76. holoPos(1, Trace:pos())
  77.  
  78. Display[P] = rgb2digi(vec(D / F, D, D / G), 3)
  79.  
  80. #Wrap the points
  81. if(P == R)
  82. {
  83. P = 0
  84. }
  85. else
  86. {
  87. P++
  88. }
  89. }
  90.  
  91. #Begin code
  92. if(clk("Run"))
  93. {
  94. #Trace
  95. #H = rangerOffset(16000, E:pos(), E:up())
  96. H = 0
  97. J = 0#H:distance()
  98. #holoPos(2, H:pos())
  99.  
  100. scan()
  101. scan()
  102. scan()
  103. scan()
  104. scan()
  105. scan()
  106. scan()
  107. scan()
  108. scan()
  109. scan()
  110.  
  111. scan()
  112. scan()
  113. scan()
  114. scan()
  115. scan()
  116. scan()
  117. scan()
  118. scan()
  119. scan()
  120. scan()
  121.  
  122. #
  123.  
  124. #Loop
  125. timer("Run", 10)
  126. }
Advertisement
Add Comment
Please, Sign In to add comment