Advertisement
eea

therending

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