-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.lisp
47 lines (44 loc) · 2.56 KB
/
test.lisp
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
40
41
42
43
44
45
46
47
(require :asdf)
(require :ray-tracer)
(in-package :ray-tracer)
(defun test (image-width image-height &optional (bound-objects t))
(let ((camera (look-at (vector3 2.0 2.0 20.0)
(vector3 0.0 0.0 0.0)
(vector3 0.0 1.0 0.0)
1.0))
(lights (list (make-light :location (vector3 -5.0 5.0 5.0)
:color (color 0.0 0.0 1.0))
(make-light :location (vector3 5.0 5.0 5.0)
:color (color 1.0 0.0 0.0))
(make-light :location (vector3 0.0 5.0 -5.0)
:color (color 0.0 1.0 0.0))))
(shapes (list (make-sphere :location (vector3 -2.0 0.0 0.0) :radius 1.0)
(make-sphere :location (vector3 0.0 1.0 0.0) :radius 1.0)
(make-sphere :location (vector3 2.0 0.0 0.0) :radius 1.0)
(make-plane :distance-from-origin -1.0))))
(write-targa "/Users/mika/projects/lisp/ray-tracer/test.tga"
(render-scene (make-scene :objects (mapcar #'(lambda (shape) (make-object :shape shape :color white)) shapes)
:lights lights)
camera image-width image-height bound-objects))))
(defun test-2 (image-width image-height &optional (bound-objects t))
(let ((camera (look-at (vector3 8.0 2.0 5.0)
(vector3 0.0 0.0 0.0)
(vector3 0.0 1.0 0.0)
1.0))
(lights (list (make-light :location (vector3 -5.0 5.0 5.0)
:color (color 0.0 0.0 1.0))
(make-light :location (vector3 5.0 5.0 5.0)
:color (color 1.0 0.0 0.0))
(make-light :location (vector3 0.0 5.0 -5.0)
:color (color 0.0 1.0 0.0))))
(shapes (let ((l nil))
(dotimes (row 10)
(dotimes (col 10)
(setq l (cons (make-sphere :location (vector3 (+ -5.0 col) (+ -5.0 row) 0.0)
:radius 0.5)
l))))
l)))
(write-targa "/Users/mika/projects/lisp/ray-tracer/test.tga"
(render-scene (make-scene :objects (mapcar #'(lambda (shape) (make-object :shape shape :color white)) shapes)
:lights lights)
camera image-width image-height bound-objects))))