-
Notifications
You must be signed in to change notification settings - Fork 0
/
scene1.lisp
78 lines (68 loc) · 2.23 KB
/
scene1.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
(load "/home/tom/Documents/lisp_programs/riverend/utilities.lisp")
(load "/home/tom/Documents/lisp_programs/riverend/new.lisp")
(load "/home/tom/Documents/lisp_programs/riverend/tri.lisp")
(defparameter *world* nil)
(defvar eye '(0 0 -700)) ; to be made into an instance of object
(defvar *objects* nil)
(defvar *new-objects* nil)
(defparameter *red* '(255 0 0))
(defparameter *blue* '(0 0 255))
(defparameter *green* '(0 255 0))
(defparameter *white* '(255 255 255))
(defparameter *black* '(0 0 0))
(defparameter *bet-blue* '(140 170 200))
(defvar colors nil)
(setf colors (list *red* *blue* *green* *white*))
(defvar light1)
(setq light1 '(0 0 1))
(defvar env-light)
(setf env-light 0.1)
(defun reset-world () (setf *world* nil))
(defvar *board-functions* nil)
(defun clear-board () (setf *board-functions* nil))
(defun add-board (fn)
(push fn *board-functions*))
(defun grid-board (x y)
(if (or (= 0 (mod x 10))
(= 0 (mod y 10)))
'(123 188 250 255)))
(let ((frame 0)
(reso 5)
(mode 'i))
(defun flip-mode () (setf mode (not mode)))
(defun set-frame (&optional (num 0))
(setf frame num))
(defun next-frame ()
(setf frame (1+ frame)))
(defun set-res (num)
(setf reso num))
(defun render-frame ()
(tracer (format nil "blest/frame~4,'0d.png" frame) reso))
(defun render (stop-frame increment)
(do ((frame 0))
((> frame stop-frame))
(render-frame)
(setf *new-objects* nil)
(dolist (obj *objects*)
(update obj frame))
(setf *objects* *new-objects*)
(incf frame increment))))
(defun step-camera ()
(setf (nth 0 eye) (+ (* (nth 0 eye) (cos (* pi 2 (/ 2 360))))
(* (nth 2 eye) (- (sin (* pi 2 (/ 2 360))))))
(nth 2 eye) (+ (* (nth 0 eye) (sin (* pi 2 (/ 2 360))))
(* (nth 2 eye) (cos (* pi 2 (/ 2 360)))))))
(defmethod update ((a object))
(setf a (funcall (obj-trans a) a)))
(defmethod supdate ((a object))
(setf a (trans-tri-10 a)))
(defun trans-tri-10 (x)
(make-tri (mapcar #'(lambda (y) (vplus y '(10 10 0))) (tri-verts x)) (surf-color x)))
(defmethod tprint ((a tri))
(print (slot-value a 'v1))
(print (slot-value a 'v2))
(print (slot-value a 'v3))
(print (slot-value a 'color)))
(defun print-world ()
(dolist (thing *world*)
(tprint thing)))