Advertisement
jig487

throwAway

Aug 15th, 2021 (edited)
1,182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. local indList = {
  2.     1, 1, 1,
  3.     2, 2, 2,
  4.     3, 3, 3,
  5.     4, 4, 4,
  6. }
  7.  
  8. local vertList = {
  9.     1, 1, 1, 0,
  10.     2, 2, 2, 0,
  11.     3, 3, 3, 0,
  12.     4, 4, 4, 0,
  13.     5, 5, 5, 0,
  14.     6, 6, 6, 0,
  15.     7, 7, 7, 0,
  16. }
  17.  
  18. local function sortVerts(iL,vL) --vL == vertice list, iL == index list
  19.     local vList = {}
  20.     for i = 1, #iL, 3 do --Load a triangle at a time into the vList to draw in the next loop.
  21.         vList[i]=   {x= vL[ iL[i]   ], y= vL[ iL[i]+1   ], z= vL[ iL[i]+2   ] } --Target vertex1's x/y and z
  22.         vList[i+1]= {x= vL[ iL[i+1] ], y= vL[ iL[i+1]+1 ], z= vL[ iL[i+1]+2 ] } --Target vertex2's x/y and z
  23.         vList[i+2]= {x= vL[ iL[i+2] ], y= vL[ iL[i+2]+1 ], z= vL[ iL[i+2]+2 ] } --Target vertex3's x/y and z
  24.     end
  25.     return vList
  26. end
  27.  
  28. list = sortVerts(indList,vertList)
  29.  
  30. for i,val in ipairs(list) do
  31.     print(val.x,val.y,val.z)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement