-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.py
39 lines (32 loc) · 1.08 KB
/
render.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from object_3d import *
from camera import *
from projection import *
import pygame as pg
class SoftwareRender:
def __init__(self):
pg.init()
self.RES = self.WIDTH, self.HEIGHT = 800, 600
self.H_WIDTH, self.H_HEIGHT = self.WIDTH // 2, self.HEIGHT // 2
self.FPS = 60
self.screen = pg.display.set_mode(self.RES)
self.clock = pg.time.Clock()
self.create_objects()
def create_objects(self):
self.camera = Camera(self, [0.5, 1, -4])
self.projection = Projection(self)
self.object = Object3D(self)
self.object.translate([0.2, 0.4, 0.2])
self.object.rotate_y(math.pi / 6)
def draw(self):
self.screen.fill(pg.Color('darkslategray'))
self.object.draw()
def run(self):
while True:
self.draw()
[exit() for i in pg.event.get() if i.type == pg.QUIT]
pg.display.set_caption(str(self.clock.get_fps()))
pg.display.flip()
self.clock.tick(self.FPS)
if __name__ == '__main__':
app = SoftwareRender()
app.run()