ポリゴンの数を増やしてみました。
謎のグルグルができました。
謎のグルグルができました。
import pygame import math import copy pygame.init() window_size = (640, 480) clock = pygame.time.Clock() screen = pygame.display.set_mode(window_size) print (pygame.ver) class PolyDat: def __init__(self,co): self.xyz4 = [(0,0,0),(100,0,0),(100,100,0),(0,100,0)] self.wk4=[] self.co=co#(255,255,0) self.xy4=[] self.sn = 0 def __lt__(self, other): return self.sn > other.sn def draw(self,screen): pygame.draw.polygon(screen, self.co, self.xy4) def conv3d2d(self): del self.xy4[:] for i in range(len(self.wk4)): x,y,z=self.wk4[i] self.xy4.append(self.conv(x,y,z)) def conv(self,x,y,z): d=200 rx=x*d/(d+z)+320 ry=y*d/(d+z)+240 return (rx,ry) def turn(self,ct,st): for i in range(len(self.wk4)): x,y,z=self.wk4[i] rx=x*ct-y*st ry=x*st+y*ct self.wk4[i]=(rx,ry,z) def shift(self,sx,sy,sz): for i in range(len(self.wk4)): x,y,z=self.wk4[i] self.wk4[i]=(x+sx,y+sy,z+sz) def size(self,sx,sy,sz): for i in range(len(self.wk4)): x,y,z=self.wk4[i] self.wk4[i]=(x*sx,y*sy,z*sz) def toWk(self): self.wk4=copy.deepcopy(self.xyz4) def backWk(self): self.xyz4=copy.deepcopy(self.wk4) def dataset(): for i in range(10000): p.append(PolyDat((255,200,60))) for i in range(10000): p[i].toWk() p[i].size(0.5,0.5,0.5) p[i].shift(1000,0,i+1000) p[i].turn(math.cos(i/10),math.sin(i/10)) p[i].conv3d2d() p=[] def main(): dataset() bg_color = (0, 0, 0) end_game = False while not end_game: for event in pygame.event.get(): if event.type == pygame.QUIT: end_game = True screen.fill(bg_color) for i in range(len(p)): p[i].draw(screen) p[i].size(1.1,1.1,1.1) p[i].turn(math.cos(0.01),math.sin(0.01)) p[i].conv3d2d() pygame.display.flip() clock.tick(5) pygame.quit() quit() main()