Advertisement
TheNewScripter

Roblox Image Loader - Voxel

Aug 2nd, 2014
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. -- download JAR from https://db.tt/xz74eYUa --
  2. local image = require(169714428):Get()
  3. local origin = CFrame.new(0, 5, 0)
  4. local scale = 0.2
  5.  
  6. function makeVoxel(pos, color, trans)
  7.     if trans == 255 then return end
  8.  
  9.     local v = Instance.new("Part", Workspace.Base)
  10.     v.Anchored = true
  11.     v.CanCollide = false
  12.     v.Size = Vector3.new(1, 1, 1)
  13.     v.TopSurface = 0
  14.     v.Transparency = 1 - (trans / 255)
  15.     v.BottomSurface = 0
  16.     v.CFrame = origin * CFrame.new(-(#image / 4), 0, -(#image[1] / 4)) * CFrame.new(pos.X / 2, pos.Y, pos.Z / 2)
  17.  
  18.     local sm = Instance.new("SpecialMesh", v)
  19.     sm.MeshId = "http://www.roblox.com/asset/?id=9856898"
  20.     sm.TextureId = "http://www.roblox.com/asset/?id=48358980"
  21.     sm.Scale = Vector3.new(scale, scale, scale)
  22.     sm.VertexColor = color
  23. end
  24.  
  25. for y = 1, #image[1] do
  26.     for x = #image, 1, -1 do
  27.         makeVoxel(CFrame.new(x * scale, 0, y * scale), Vector3.new(image[x][y][1], image[x][y][2], image[x][y][3]) / 255, image[x][y][4])
  28.     end
  29.     wait()
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement