Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while not shell.run("ESGraphics") do
- shell.run("pastebin","get","kDm3zq5E","ESGraphics")
- if shell.run("ESGraphics") then print("ESGraphics launched") else print("ESGraphics not exist") end
- end
- arg={...}
- radius=arg[1]
- Model={}
- LR={}
- scrX = {}
- scrY = {}
- zoom=30
- render={}
- render[1]= function() --рендер 2
- for i = 1, #Model, 1 do
- local SX=limit(scrX[i],r.sx)
- local SY=limit(scrY[i],r.sy)
- -- gh.text(1,1,1,16,"x:"..SX.."/"..r.sx)
- -- gh.text(1,2,1,16,"y:"..SY.."/"..r.sy)
- gh.point(SX, SY,1,1," ")
- for n = 1, #Model, 1 do
- local SSX=limit(scrX[n],r.sx)
- local SSY=limit(scrY[n],r.sy)
- gh.line(SX, SY,SSX,SSY,1,0,".")
- end
- end
- end
- function limit(n,n1)
- local x=math.min(n,n1)
- local nx=math.max(1,x)
- return nx
- end
- s = {}
- c1 = {}
- PI = math.pi
- for i = 1, 360, 1 do
- s[i] = math.sin(i * (PI / 180))
- c1[i] = math.cos(i * (PI / 180))
- end
- function createsphere(R,quality)
- local mapX=R
- local mapY=R
- local mapZ=R
- local map={}
- for x=-mapZ,mapX,1 do
- map[x]={}
- for y=-mapY,mapY,1 do
- map[x][y]={}
- for z=-mapZ,mapZ,1 do
- map[x][y][z]=false
- end
- end
- end
- local i=0
- for RX=0,math.pi,quality do
- for RY=0,2*math.pi,quality do
- local x= R*math.sin(RX)*math.cos(RY)
- local y= R*math.sin(RX)*math.sin(RY)
- local z= R*math.cos(RX)
- i=i+1
- map[math.floor(x)][math.floor(y)][math.floor(z)]=true
- end
- end
- return map
- end
- map=createsphere(radius,0.7)
- for x=-radius,radius,1 do
- for y=-radius,radius,1 do
- for z=-radius,radius,1 do
- if map[x][y][z] then
- Model[#Model+1]={x*10,y*10,z*10}
- end
- end end end
- -- модель
- for i = 1, #Model, 1 do
- LR[i] = {0,0,0}
- scrX[i] = 0
- scrY[i] = 0
- end
- xCenter = math.floor(r.sx/2)
- yCenter = math.floor(r.sy/2)
- zCenter = 256
- HROT = 0
- VROT = 0
- HROTSpeed = 1
- VROTSpeed = 1
- function ftw()
- for i = 1, #Model, 1 do
- LR[i][1] = (Model[i][1] * -1) * s[HROT+1] + Model[i][2] * c1[HROT+1] -- вычисление вершин
- LR[i][2] = (Model[i][1] * -1) * c1[HROT+1] *s[VROT+1] - Model[i][2] * s[HROT+1] * s[VROT+1] - Model[i][3] * c1[VROT+1] + 1
- LR[i][3] = (Model[i][1] * -1) * c1[HROT+1] *c1[VROT+1] - Model[i][2] * s[HROT+1] * c1[VROT+1] + Model[i][3] * s[VROT+1]
- if (LR[i][3] + zCenter) ~= 0 then
- scrX[i] = math.floor(zoom * (LR[i][1] / (LR[i][3] + zCenter)) + xCenter)
- scrY[i] = math.floor(zoom * (LR[i][2] / (LR[i][3] + zCenter)) + yCenter)
- end
- end
- render[1]()
- HROT =math.mod( HROT + HROTSpeed,360,0)-- повороты
- VROT =math.mod( VROT + VROTSpeed,360,0)
- end
- function math.mod(n,max,x)
- if n>=max then n=x end
- return n
- end
- function draw()
- ftw()
- end
- function update()
- end
- while true do
- r.systemupdate()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement