Advertisement
asshousotn

test3d

Apr 29th, 2025 (edited)
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. local tris = {
  2.     -- SOUTH
  3.     { 0.0, 0.0, 0.0,    0.0, 1.0, 0.0,    1.0, 1.0, 0.0 },
  4.     { 0.0, 0.0, 0.0,    1.0, 1.0, 0.0,    1.0, 0.0, 0.0 },
  5.     -- NORTH                                                    
  6.     { 1.0, 0.0, 1.0,    1.0, 1.0, 1.0,    0.0, 1.0, 1.0 },
  7.     { 1.0, 0.0, 1.0,    0.0, 1.0, 1.0,    0.0, 0.0, 1.0 },
  8.     -- EAST                                                      
  9.     { 1.0, 0.0, 0.0,    1.0, 1.0, 0.0,    1.0, 1.0, 1.0 },
  10.     { 1.0, 0.0, 0.0,    1.0, 1.0, 1.0,    1.0, 0.0, 1.0 },
  11.     -- WEST                                                      
  12.     { 0.0, 0.0, 1.0,    0.0, 1.0, 1.0,    0.0, 1.0, 0.0 },
  13.     { 0.0, 0.0, 1.0,    0.0, 1.0, 0.0,    0.0, 0.0, 0.0 },
  14.     -- TOP                                                      
  15.     { 0.0, 1.0, 0.0,    0.0, 1.0, 1.0,    1.0, 1.0, 1.0 },
  16.     { 0.0, 1.0, 0.0,    1.0, 1.0, 1.0,    1.0, 1.0, 0.0 },
  17.     -- BOTTOM                                                    
  18.     { 1.0, 0.0, 1.0,    0.0, 0.0, 1.0,    0.0, 0.0, 0.0 },
  19.     { 1.0, 0.0, 1.0,    0.0, 0.0, 0.0,    1.0, 0.0, 0.0 },
  20. };
  21. local gpu = peripheral.wrap("tm_gpu")
  22. gpu.refreshSize()
  23. gpu.setSize(64)
  24. local gl = gpu.createWindow3D(1, 1, 768, 320)
  25. gl.glFrustum(90, 0.1, 1000)
  26. gl.glDirLight(0, 0, -1)
  27. local rot = 0
  28. while true do
  29.     gl.clear()
  30.     gl.glDisable(0xDE1)
  31.     gl.glTranslate(0, 1, 3)
  32.     gl.glRotate(rot, 0, 1, 0)
  33.     gl.glRotate(rot, 0, 0, 1)
  34.     rot = rot + 3
  35.     gl.glBegin()
  36.     --gl.glColor(0, 0, 255)
  37.     for k,v in pairs(tris) do
  38.         local ci = math.floor((k - 1) / 2)
  39.         gl.glVertex(v[1], v[2], v[3])
  40.         local cv = 255
  41.         if ci % 2 == 0 then
  42.             cv = 127
  43.         end
  44.         if math.floor(ci / 2) == 0 then
  45.             gl.glColor(cv, 0, 0)
  46.         elseif math.floor(ci / 2) == 1 then
  47.             gl.glColor(0, cv, 0)
  48.         else
  49.             gl.glColor(0, 0, cv)
  50.         end
  51.         gl.glVertex(v[4], v[5], v[6])
  52.         gl.glVertex(v[7], v[8], v[9])
  53.     end
  54.     gl.glEnd()
  55.     gl.render()
  56.     gl.sync()
  57.     gpu.sync()
  58.     sleep(0.01)
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement