Advertisement
Descaii

Camera 2

Mar 12th, 2014
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.36 KB | None | 0 0
  1. -- Pixel Camera, Part version --
  2. function TraceRay(P1,P2,ignore)
  3.     local Length = (P1.p-P2.p).magnitude
  4.     if Length < 999 then
  5.         return Workspace:findPartOnRay(Ray.new(P1.p,(P1.p-P2.p).unit*Length,ignore))
  6.     else
  7.         return Workspace:findPartOnRay(Ray.new(P1.p,(P1.p-P2.p).unit*999,ignore))
  8.     end
  9. end
  10. Fov = 50
  11. Pixels = 50
  12. SZ = 300
  13. Length = 999
  14. Smooth = false
  15. local UI = Instance.new("Part",script)
  16. UI.Anchored = true
  17. UI.FormFactor = "Custom"
  18. UI.Size = Vector3.new((SZ/20)/2,(SZ/20)/2,1)
  19. UI.CFrame = CFrame.new(0,(SZ/20)/2,20)
  20. local Screen = Instance.new("SurfaceGui",UI)
  21. Screen.CanvasSize = Vector2.new(SZ,SZ)
  22. local Load = Instance.new("TextButton",Screen)
  23. Load.Size = UDim2.new(0,50,0,20)
  24. Load.Text = "Shoot"
  25. Load.ZIndex = 5
  26. Load.Position = UDim2.new(0.5,-25,1,-25)
  27. function Move(Max,Amount)
  28.     return (-math.rad(Max/2))+math.rad(Max)*Amount
  29. end
  30. function Colerp(C1,C2,A)
  31.     return Color3.new(
  32.         C1.r+(C2.r-C1.r)*A,
  33.         C1.g+(C2.g-C1.g)*A,
  34.         C1.b+(C2.b-C1.b)*A
  35.     )
  36. end
  37. Lights = {}
  38. function Light(Position)
  39.     local L = {}
  40.     L.Range = 10
  41.     L.Position = Position
  42.     L.Color = Color3.new(1,1,1)
  43.     table.insert(Lights,L)
  44. end
  45. Light(UI.CFrame.p+Vector3.new(0,0,-20))
  46. TakingShot = false
  47. function TakeShot(CF,Screen)
  48.     if not TakingShot then
  49.         TakingShot = true
  50.         Lights = {}
  51.         Light(CF*CFrame.new(0,0,20))
  52.         wait()
  53.         P = CF*CFrame.Angles(0,0,math.rad(90))
  54.         for i,v in pairs(Screen:GetChildren()) do
  55.             if v.Name == "Pixel" then v:Destroy()  end
  56.         end
  57.         for x = 1,Pixels do
  58.             for y = 1,Pixels do
  59.                 local Hit,Pos = TraceRay(P,P*CFrame.Angles(Move(Fov,x/Pixels),Move(Fov,y/Pixels),0)
  60.                 *CFrame.new(0,0,Length))
  61.                 local IsInSunlight,LPos = TraceRay(CFrame.new(Pos),CFrame.new(Pos+(game.Lighting:GetSunDirection()*-999)))
  62.                 local F = Instance.new("Frame",Screen)
  63.                 F.Name = "Pixel"
  64.                 F.Size = UDim2.new(0,SZ/Pixels,0,SZ/Pixels)
  65.                 F.BorderSizePixel = 0
  66.                 if Hit then
  67.                     local C = Hit.BrickColor.Color
  68.                     F.BackgroundColor3 = C
  69.                     C = Colerp(C,Color3.new(0.5,0.5,0.5),0.5)
  70.                     ypcall(function()
  71.                         if IsInSunlight then
  72.                             if Smooth then
  73.                                 local Mass = 5
  74.                                 local Dis = (Pos-LPos).magnitude
  75.                                 if IsInSunlight:IsA("BasePart") then
  76.                                     local S = (IsInSunlight.Size.X+IsInSunlight.Size.Y+IsInSunlight.Size.Z)
  77.                                     Mass = S
  78.                                 end
  79.                                 local Fin = (Mass-Dis)/Mass
  80.                                 if Dis < Mass then
  81.                                     C = Colerp(C,Color3.new(0,0,0),Fin-IsInSunlight.Transparency)
  82.                                 end
  83.                             else
  84.                                 C = Colerp(C,Color3.new(0,0,0),0.5)
  85.                             end
  86.                         else
  87.                             --C = Colerp(C,Color3.new(0.5,0.5,0.5),0.5)
  88.                         end
  89.                     end)
  90.                     ypcall(function()
  91.                         for i,v in pairs(Lights) do
  92.                             local Dis = (Pos-v.Position).magnitude
  93.                             if Dis < v.Range then
  94.                                 local IsInLight = TraceRay(CFrame.new(v.Position),CFrame.new(Pos))
  95.                                 if not IsInLight then
  96.                                     C = Colerp(C,v.Color,(v.Range-Dis)/v.Range)
  97.                                 end
  98.                             end
  99.                         end
  100.                     end)
  101.                     F.BackgroundColor3 = C
  102.                 else
  103.                     F.BackgroundColor3 = BrickColor.new("Bright blue").Color
  104.                 end
  105.                 F.Position = UDim2.new(0,x*(SZ/Pixels),0,y*(SZ/Pixels))
  106.             end
  107.         end
  108.         wait(5)
  109.         TakingShot = false
  110.     end
  111. end
  112. Load.MouseButton1Click:connect(function()
  113.     print("Taking shot")
  114.     TakeShot(Workspace.CurrentCamera.CoordinateFrame,Screen)
  115. end)
  116.  
  117. --NS(game:GetService("HttpService"):GetAsync("http://pastebin.com/raw.php?i=uZGGFyij"),Workspace)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement