Advertisement
Guest User

tiers.lua

a guest
Apr 26th, 2021
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | None | 0 0
  1. ----- parameters -----
  2.  
  3. floors = 40 :: int_slider("Floors", 1, 100)
  4. setback = 3 :: int_slider("Setback every", 1, 100)
  5. sides = 6:: int_slider("Sides", 3, 36)
  6. circles = 4:: int_slider("Circles", 1, 10)
  7.  
  8. pillar_width = 1:: float_slider("Pillar Width", 0.2, 10, 0.2)
  9. pillar_height = 6:: float_slider("Pillar Height", 0.2, 10, 0.2)
  10. pillar_spacing = 10:: float_slider("Pillar Spacing", 0.5, 40, 0.5)
  11. beam_height = 1:: float_slider("Beam Height", 0.2, 10, 0.2)
  12.  
  13. ----------------------
  14.  
  15.  
  16. c=col()
  17. c.dim = vec(pillar_width,pillar_height,pillar_width)
  18.  
  19. cbeam = col()
  20. cbeam.dim = vec(pillar_spacing,beam_height,pillar_width)
  21.  
  22. cbeamh = col()
  23. cbeamh.dim = vec(pillar_spacing + 0.5*pillar_width,beam_height,pillar_width)
  24.  
  25. cbeam1 = col()
  26. cbeam1.dim = vec(pillar_spacing + pillar_width,beam_height,pillar_width)
  27.  
  28. t = math.rad(360.0/sides)
  29. a = math.sin(t/2) * pillar_width / 2.0
  30. alpha = math.pi/2 - t/2
  31. mitershort = math.sin(alpha)*a
  32. miterout = math.cos(alpha)*a
  33.  
  34. for r=1,circles do
  35.  local _r = pillar_spacing * r
  36.  
  37.  local cspan = col()
  38.  cspan.dim = vec(2*math.sin(t/2)*(r - 0.5)*pillar_spacing - 2*mitershort,beam_height,pillar_width)
  39.  
  40.  for s=1,sides do
  41.   local y0 = 0
  42.  
  43.   for y=1,math.min(floors, (circles + 1 - r)*setback) do
  44.    local max_r = circles - math.floor((y-1)/setback)
  45.        
  46.    local _t = s*360.0/sides
  47.    
  48.    _x = math.cos(math.rad(_t))
  49.    _z = math.sin(math.rad(_t))
  50.    
  51.    local _c = brk(c)
  52.    _rc = _r - pillar_spacing * 0.5
  53.    _c.pos = vec(_x*_rc, y0 + c.dim.y * 0.5, _z*_rc)
  54.    _c.rot.y = -_t
  55.    
  56.    y0 = y0 + c.dim.y
  57.      
  58.    if max_r > r then
  59.     local _cbeam
  60.     local _adj = 0
  61.     if max_r == 2 then
  62.       _cbeam = brk(cbeam1)
  63.     elseif r == 1 then
  64.       _cbeam = brk(cbeamh)
  65.       _adj = -0.25*pillar_width
  66.     elseif r == max_r - 1 then
  67.       _cbeam = brk(cbeamh)
  68.       _adj = 0.25*pillar_width
  69.     else
  70.       _cbeam = brk(cbeam)
  71.     end
  72.     _cbeam.pos = vec(_x*(_r+_adj), y0 + cbeam.dim.y * 0.5, _z*(_r+_adj))
  73.     _cbeam.rot.y = -_t
  74.    end
  75.    
  76.    if max_r > 1 then
  77.     y0 = y0 + cbeam.dim.y
  78.    end
  79.    
  80.    _ts = math.rad(_t) + t/2
  81.    _xs = math.cos(_ts)
  82.    _zs = math.sin(_ts)
  83.    _rs = _rc * math.cos(t/2) + miterout
  84.    
  85.    local _cspan = brk(cspan)
  86.    _cspan.pos = vec(_xs*_rs, y0 + cspan.dim.y * 0.5, _zs*_rs)
  87.    _cspan.rot.y = -math.deg(_ts) + 90
  88.    y0 = y0 + cspan.dim.y
  89.    
  90.   end
  91.  end
  92. end
  93.  
  94. randomize_colors()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement