pip install quads python from quads import Quads import numpy as np import pygame from pygame.locals import * python SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 BACKGROUND_COLOR = (0, 0, 0) ROTATION_ANGLE = 0.01 python quads = Quads() vertices = np.array([ [-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1], [-1, -1, -1], [1, -1, -1], [1, 1, -1], [-1, 1, -1] ]) connections = [ (0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 7), (7, 4), (0, 4), (1, 5), (2, 6), (3, 7) ] quads.add(vertices, connections) python pygame.init() screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption("3D Rotation with Quads") python running = True while running: for event in pygame.event.get(): if event.type == QUIT: running = False screen.fill(BACKGROUND_COLOR) quads.rotate(ROTATION_ANGLE, 'x') quads.rotate(ROTATION_ANGLE, 'y') quads.rotate(ROTATION_ANGLE, 'z') for connection in quads.ordered_connections(): pygame.draw.line(screen, (255, 255, 255), connection[0], connection[1]) pygame.display.flip() pygame.quit()


上一篇:
下一篇:
切换中文