-
Notifications
You must be signed in to change notification settings - Fork 8
/
things.lisp
56 lines (41 loc) · 1.43 KB
/
things.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
(in-package #:play-with-verts)
;;------------------------------------------------------------
;; Light
(defvar *light-pos* (v! 0 30 -5))
;;------------------------------------------------------------
;; Things
(defclass thing ()
((stream
:initarg :stream :initform nil :accessor buf-stream)
(sampler
:initarg :sampler :initform nil :accessor sampler)
(specular-sampler
:initarg :specular :initform nil :accessor specular-sampler)
(pos
:initarg :pos :initform (v! 0 0 0) :accessor pos)
(rot
:initarg :rot :initform (q:identity) :accessor rot)
(scale
:initarg :scale :initform 1f0 :accessor scale)))
(defvar *things* nil)
(defmethod get-model->world-space ((thing thing))
(m4:* (m4:translation (pos thing))
(q:to-mat4 (rot thing))))
(defmethod draw ((pipeline function) (thing thing))
(map-g pipeline (buf-stream thing)
:scale (scale thing)
:model->world (get-model->world-space thing)
:albedo (sampler thing)
:spec-map (specular-sampler thing)))
;;------------------------------------------------------------
;; Floor
(defclass ground (thing)
((stream :initform (box 40 1 40))
(sampler :initform (tex "dirt.jpg"))))
(defun make-ground ()
(push (make-instance 'ground) *things*))
(defmethod update ((thing ground) dt)
nil)
;;------------------------------------------------------------
;; Foo!
;;------------------------------------------------------------