Advertisement
eea

lidar

eea
Sep 10th, 2022 (edited)
1,155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.02 KB | None | 0 0
  1. local l1 = "https://pa"
  2. local l2 = "stebin.c"
  3. local l3 = "om/raw/UZ"
  4. local l4 = "VVh1Un"
  5. local w, h
  6. local whr
  7.  
  8. local displaypoints = {}
  9. local httpserivce = game:GetService("HttpService")
  10. local nn, matrix = loadstring(httpserivce:GetAsync(l1..l2..l3..l4))()
  11. local raytool = Instance.new("Tool", owner.Backpack)
  12. local raypart = Instance.new("Part", raytool)
  13. raypart.Size = Vector3.one
  14. raypart.Name = "Handle"
  15.  
  16. local wfov = math.rad(70)
  17. local hfov = math.rad(70)
  18.  
  19. function toarray(m)
  20.     return matrix:toArray(m)
  21. end
  22.  
  23. function s(x)
  24.     return math.sin(x)
  25. end
  26.  
  27. function m(matir)
  28.     return math.sqrt(matir.Matrix[1][1]^2 + matir.Matrix[2][1]^2 + matir.Matrix[3][1]^2)
  29. end
  30.  
  31. function dist(one, two)
  32.     return m(two - one)
  33. end
  34.  
  35. function c(x)
  36.     return math.cos(x)
  37. end
  38.  
  39. function rotateX(a, v)
  40.     local rxm = {
  41.         {1, 0, 0};
  42.         {0, c(a), -s(a)};
  43.         {0, s(a), c(a)};
  44.     }
  45.     local rx = matrix.new(3, 3)
  46.     rx.set(rxm)
  47.     return rx * v
  48. end
  49.  
  50. function rotateY(a, v)
  51.     local rym = {
  52.         {c(a), 0, s(a)};
  53.         {0, 1, 0};
  54.         {-s(a), 0, c(a)};
  55.     }
  56.     local ry = matrix.new(3, 3)
  57.     ry.set(rym)
  58.     return ry * v
  59. end
  60.  
  61. function rotateZ(a, v)
  62.     local rzm = {
  63.         {c(a), -s(a), 0};
  64.         {s(a), c(a), 0};
  65.         {0, 0, 1};
  66.     }
  67.     local rz = matrix.new(3,3)
  68.     rz.set(rzm)
  69.     return rz * v
  70. end
  71.  
  72. function V3totab(V)
  73.     return {V.X, V.Y, V.Z}
  74. end
  75.  
  76. function tomatrix(t, i)
  77.     return matrix:toMatrix(t, i)
  78. end
  79.  
  80. function updatecam()
  81.     cam.leftmost = rotateZ(cam.rotation[3], rotateX(cam.rotation[1], rotateY(cam.rotation[2]+wfov/2, forward)))
  82.     cam.rightmost = rotateZ(cam.rotation[3], rotateX(cam.rotation[1], rotateY(cam.rotation[2]-wfov/2, forward)))
  83.     cam.bottom = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1]+hfov/2, forward)))
  84.     cam.upper = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1]-hfov/2, forward)))
  85.     cam.right = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1], right)))
  86.     cam.up = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1], up)))
  87.     cam.forward = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1], forward)))
  88. end
  89.  
  90. right = tomatrix({1, 0, 0})
  91. up = tomatrix({0, 1, 0})
  92. forward = tomatrix({0, 0, 1})
  93. cam = {}
  94. cam.rotation =  {0, 0, 0}
  95. cam.position = {0, 0, -6}
  96. cam.leftmost = rotateZ(cam.rotation[3], rotateX(cam.rotation[1], rotateY(cam.rotation[2]+wfov/2, forward)))
  97. cam.rightmost = rotateZ(cam.rotation[3], rotateX(cam.rotation[1], rotateY(cam.rotation[2]-wfov/2, forward)))
  98. cam.bottom = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1]+hfov/2, forward)))
  99. cam.upper = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1]-hfov/2, forward)))
  100. cam.right = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1], right)))
  101. cam.up = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1], up)))
  102. cam.forward = rotateZ(cam.rotation[3], rotateY(cam.rotation[2], rotateX(cam.rotation[1], forward)))
  103.  
  104. function getangle(m1, m2)
  105.     return math.acos(dot(m1, m2)/(m(m1) * m(m2)))
  106. end
  107.  
  108. function dot(m1, m2)
  109.     return m1.Matrix[1][1] * m2.Matrix[1][1] + m1.Matrix[2][1] * m2.Matrix[2][1] + m1.Matrix[3][1] * m2.Matrix[3][1]
  110. end
  111.  
  112. function project(v, avg)
  113.     local campos = tomatrix(cam.position)
  114.     local d = v - campos
  115.     local z = dot(cam.forward, d)
  116.     local x = dist(cam.leftmost, cam.rightmost)*z
  117.     local y = dist(cam.bottom, cam.upper)*z
  118.     local m = matrix.new(2, 1)
  119.     local px = (dot(cam.right, d) + x/2)/x
  120.     local py = (dot(cam.up, d) + y/2)/y
  121.     m.set({{1-px}, {py}})
  122.     return m, z
  123. end
  124.  
  125. local mult = {1, 1}
  126.  
  127. script.Name = "obvious"
  128. local part = Instance.new("Part", script)
  129. local camremote = Instance.new("RemoteEvent",part)
  130. part.Size = Vector3.new(10, 10, .1)
  131. part.Anchored = true
  132. part.Position = Vector3.new(-10, 6, -10)
  133. part.Material = "Glass"
  134. part.Transparency = .5
  135. part.Locked = true
  136.  
  137. NLS([[
  138. local scri = workspace:WaitForChild("obvious")
  139. local par = scri:WaitForChild("Part")
  140. local remote = par:WaitForChild("RemoteEvent")
  141.  
  142. while task.wait() do
  143.     remote:FireServer(workspace.CurrentCamera.CFrame, workspace.CurrentCamera.ViewportSize)
  144. end
  145. ]], owner.Character)
  146.  
  147. camremote.OnServerEvent:Connect(function(plr, cf, vps)
  148.     camcframe = cf
  149.     cam.position = V3totab(cf.Position)
  150.     cam.rotation = {cf:ToOrientation()}
  151.     whr = vps.X/vps.Y
  152.     wfov = math.rad(70) * whr
  153.     part.Size = Vector3.new(10*whr, 10, .1)
  154.     updatecam()
  155.     cam.right = tomatrix(V3totab(cf.RightVector))
  156.     cam.up = tomatrix(V3totab(cf.UpVector))
  157.     cam.forward = tomatrix(V3totab(cf.LookVector))
  158. end)
  159.  
  160. local surfgui = Instance.new("SurfaceGui", part)
  161. surfgui.Face = "Front"
  162. surfgui.ClipsDescendants = false
  163. local background = Instance.new("Frame", surfgui)
  164. background.BackgroundColor3 = Color3.new()
  165. background.Size = UDim2.new(1, 0, 1, 0)
  166. w, h = background.AbsoluteSize.X, background.AbsoluteSize.Y
  167.  
  168. local fo = Instance.new("TextBox", surfgui)
  169. fo.RichText = true
  170. fo.TextScaled = true
  171. fo.Size = UDim2.new(0, 700, 0, 120)
  172. fo.BackgroundTransparency = 1
  173. fo.TextColor3 = Color3.new(1,1,1)
  174. fo.TextXAlignment = 0
  175. fo.TextEditable = false
  176. fo.TextTransparency = .5
  177.  
  178. local mpoints = {}
  179. local frames = {}
  180.  
  181. function addpoint(V, c)
  182.     mpoints[#mpoints+1]=tomatrix(V3totab(V))
  183.     local dpoint = Instance.new("SpawnLocation", surfgui)
  184.     dpoint.Size = Vector3.one
  185.     dpoint.Shape = "Ball"
  186.     dpoint.Anchored = true
  187.     dpoint.Enabled = false
  188.     dpoint.Color = c
  189.     frames[#frames+1]=dpoint
  190. end
  191.  
  192. function printmatrix(m)
  193.     print("rows: "..m.rows)
  194.     print("cols: "..m.cols)
  195.     for x = 1,#m.Matrix do
  196.         local str = "{"
  197.         for y = 1,#m.Matrix[x] do
  198.             str = str..tostring(m.Matrix[x][y])..","
  199.         end
  200.         str = string.sub(str, 1, #str-1)
  201.         str = str.."}"
  202.         print(x, str)
  203.     end
  204. end
  205.  
  206. function updateline(pos1, pos2, theline)
  207.     local dvector = pos2 - pos1
  208.     theline.Size = UDim2.new(0, dvector.Magnitude, 0, theline.AbsoluteSize.Y)
  209.     local angle = math.deg(math.atan2(dvector.Y, dvector.X))
  210.     local pos = (pos1+pos2)/2
  211.     theline.Rotation = angle
  212.     theline.Position = UDim2.new(0, pos.X, 0, pos.Y)
  213. end
  214.  
  215. function line(pos1, pos2, thickness)
  216.     local theline = Instance.new("Frame", surfgui)
  217.     theline.AnchorPoint = Vector2.new(.5, .5)
  218.     theline.BorderSizePixel = 0
  219.     local dvector = pos2 - pos1
  220.     theline.Size = UDim2.new(0, dvector.Magnitude, 0, thickness)
  221.     local angle = math.deg(math.atan2(dvector.Y, dvector.X))
  222.     local pos = (pos1 + pos2)/2
  223.     theline.Rotation = angle
  224.     theline.Position = UDim2.new(0, pos.X, 0, pos.Y)
  225.     return theline
  226. end
  227. function rta(p)
  228.     return p.AbsolutePosition + p.AnchorPoint * p.AbsoluteSize
  229. end
  230.  
  231. raytool.Activated:Connect(function()
  232.     local params = RaycastParams.new()
  233.     params.FilterDescendantsInstances = {owner.Character}
  234.     local newray = workspace:Raycast(camcframe.Position, camcframe.LookVector*6000, params)
  235.     if newray then
  236.         addpoint(newray.Position, newray.Instance.Color)
  237.     end
  238.     if #frames > 490 then
  239.         frames[1]:Destroy()
  240.         table.remove(frames, 1)
  241.         table.remove(mpoints, 1)
  242.     end
  243. end)
  244.  
  245. owner.Chatted:Connect(function(msg)
  246.     if msg:sub(1, 2) == "!a" then
  247.         local pos = loadstring("return "..msg:sub(3,#msg))()
  248.         addpoint(Vector3.new(pos[1], pos[2], pos[3]))
  249.     end
  250. end)
  251.  
  252. --for i = 1,20 do
  253. --    addpoint(Vector3.new(math.random()*10, math.random()*10, math.random()*10))
  254. --end
  255.  
  256. while task.wait() do
  257.     fo.Text = #mpoints
  258.     for i = 1,#mpoints do
  259.         local xy, z = project(mpoints[i])
  260.         local xpos, ypos = toarray(xy)[1]*part.Size.X, toarray(xy)[2]*part.Size.Y
  261.         frames[i].Position = part.Position - Vector3.new(part.Size.X/2, part.Size.Y/2, part.Size.Z) + Vector3.new(xpos, ypos, 0)
  262.         --print((frames[i].Position - part.Position).Z)
  263.         frames[i].Size = Vector3.new(3/z, 3/z, 0)
  264.     end
  265. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement