-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (24 loc) · 1012 Bytes
/
main.py
File metadata and controls
35 lines (24 loc) · 1012 Bytes
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
from scene import Scene
from sphere import Sphere
from light import Light
from vector import Vector3
from renderer import Renderer
# Initialize the scene
scene = Scene()
scene.add_sphere(Sphere(Vector3(0, -1, 3), 1, (255, 0, 0), 500, 0.2))
scene.add_sphere(Sphere(Vector3(2, 0, 4), 1, (0, 0, 255), 500, 0.3))
scene.add_sphere(Sphere(Vector3(-2, 0, 4), 1, (0, 255, 0), 10, 0.4))
scene.add_sphere(Sphere(Vector3(0, -5001, 0), 5000, (255, 255, 0), 1000, 0.5))
scene.add_light(Light("ambient", 0.2))
scene.add_light(Light("point", 0.6, Vector3(2, 1, 0)))
scene.add_light(Light("directional", 0.2, direction=Vector3(1, 4, 4)))
CANVAS_WIDTH = 800
CANVAS_HEIGHT = 600
VIEWPORT_WIDTH = 1
VIEWPORT_HEIGHT = 1
VIEWPORT_DISTANCE = 1
CAMERA_POSITION = Vector3(0, 0, 0)
BACKGROUND_COLOR = (255, 255, 255)
# Create the renderer and render the scene
renderer = Renderer(scene, CANVAS_WIDTH, CANVAS_HEIGHT, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, VIEWPORT_DISTANCE, CAMERA_POSITION, BACKGROUND_COLOR)
renderer.render_scene()