-
Notifications
You must be signed in to change notification settings - Fork 0
/
classes.lisp
99 lines (88 loc) · 2.09 KB
/
classes.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
(in-package :raytrace)
(defclass ray ()
((origin
:initarg :origin
:reader origin)
(direction
:initarg :direction
:reader direction)
(attenuation
:initarg :attenuation
:reader attenuation)
(refraction-index
:initarg :refraction-index
:initform 1.0
:reader refraction-index)))
(defun make-ray-from-points (start end)
(make-instance 'ray :origin start :direction (calc-direction start end)))
(defun ray-x (ray) (point-x (origin ray)))
(defun ray-y (ray) (point-y (origin ray)))
(defun ray-z (ray) (point-z (origin ray)))
(defun ray-i (ray) (point-x (direction ray)))
(defun ray-j (ray) (point-y (direction ray)))
(defun ray-k (ray) (point-z (direction ray)))
(defmethod look-direction ((ray ray))
(vector-negate (direction ray)))
(defclass scene-object ()
((material
:initarg :material
:reader material)))
(defclass sphere (scene-object)
((center
:initarg :center
:reader center)
(radius
:initarg :radius
:reader radius)))
(defclass ray-intersection ()
((time
:initarg :intersect-time
:reader intersect-time)
(point
:initarg :point
:reader point)
(normal
:initarg :normal
:reader normal)
(intersect-object
:initarg :intersect-object
:reader intersect-object)
(direction
:initarg :direction
:reader direction
:initform 'entering)))
(defclass light ()
((intensity
:initarg :intensity
:reader intensity)
(color
:initarg :color
:reader color)))
(defclass point-light (light)
((point
:initarg :point
:reader point)))
(defclass material ()
((color
:initarg :color
:reader color)
(diffuse-factor
:initarg :diffuse-factor
:reader diffuse-factor)
(specular-factor
:initarg :specular-factor
:reader specular-factor)
(specular-n
:initarg :specular-n
:reader specular-n)
(reflectivity
:initarg :reflectivity
:reader reflectivity)
(transparency
:initarg :transparency
:initform 0.0
:reader transparency)
(refraction-index
:initarg :refraction-index
:initform 1.0
:reader refraction-index)))