3 (in-package :lambdamundo
)
6 ((mesh :initarg
:mesh
:accessor mesh-of
)))
9 ;; simple rendering method for debugging
10 (defmethod render ((self mixamesh
:simple-mesh
))
13 (for (values a b c
) in-triangles
(faces-of self
))
23 (gl:with-begin gl
:+lines
+
24 (gl:vertex-3f ax ay az
)
25 (gl:vertex-3f bx by bz
)
26 (gl:vertex-3f bx by bz
)
27 (gl:vertex-3f cx cy cz
)
28 (gl:vertex-3f cx cy cz
)
29 (gl:vertex-3f ax ay az
)))))))
35 (gl:color-3f
1.0 0.0 0.0)
46 (gl:vertex-3f x y z
)))
50 (gl:color-3f
0.0 1.0 0.0)
61 (gl:vertex-3f x y z
)))
66 (gl:color-3f
0.0 0.0 1.0)
77 (gl:vertex-3f x y z
))))
80 (gl:with-begin gl
:+lines
+
85 (defun render-aabb (mesh-aabb)
88 (minx maxx miny maxy minz maxz
)
89 (gl:with-begin gl
:+lines
+
90 (gl:color-3f
1.0 1.0 1.0)
92 (gl:vertex-3f minx miny minz
)
93 (gl:vertex-3f maxx miny minz
)
95 (gl:vertex-3f maxx miny minz
)
96 (gl:vertex-3f maxx miny maxz
)
98 (gl:vertex-3f maxx miny maxz
)
99 (gl:vertex-3f minx miny maxz
)
101 (gl:vertex-3f minx miny maxz
)
102 (gl:vertex-3f minx miny minz
)
104 (gl:vertex-3f minx maxy minz
)
105 (gl:vertex-3f maxx maxy minz
)
107 (gl:vertex-3f maxx maxy minz
)
108 (gl:vertex-3f maxx maxy maxz
)
110 (gl:vertex-3f maxx maxy maxz
)
111 (gl:vertex-3f minx maxy maxz
)
113 (gl:vertex-3f minx maxy maxz
)
114 (gl:vertex-3f minx maxy minz
)
116 (gl:vertex-3f minx miny minz
)
117 (gl:vertex-3f minx maxy minz
)
119 (gl:vertex-3f maxx miny minz
)
120 (gl:vertex-3f maxx maxy minz
)
122 (gl:vertex-3f maxx miny maxz
)
123 (gl:vertex-3f maxx maxy maxz
)
125 (gl:vertex-3f minx miny maxz
)
126 (gl:vertex-3f minx maxy maxz
))))
128 (let ((modelview-matrix (new-matrix44)))
129 (defmethod render ((n npc
))
130 (flet ((npc-modelview-matrix ()
131 (gl:matrix-mode gl
:+modelview
+)
133 (setf modelview-matrix
139 (translation-matrix44 x y z
))))))))
140 ;; (npc-modelview-matrix)
141 (gl:matrix-mode gl
:+modelview
+)
143 (with-vertex3d (location-of n
) (x y z w
)
144 (gl:translate-f x y z
))
145 (gl:scale-f
0.01 0.01 0.01)
147 (render (or (gethash (mesh-of n
) mixamesh
:*compiled-meshes
*)
148 (gethash (mesh-of n
) mixamesh
:*meshes
*)))
149 (let ((aabb (gethash (mesh-of n
) mixamesh
:*bounding-boxes
*)))
154 (defmethod make-npc (mesh)
160 (defmethod destroy ((n npc
))
161 (remhash (mesh-of n
) *bounding-boxes
*)
162 (let ((mesh (gethash (mesh-of n
) *meshes
*))
163 (compiled-mesh (gethash (mesh-of n
) *compiled-meshes
*)))
166 (remhash (mesh-of n
) *meshes
*))
168 (remhash (mesh-of n
) *compiled-meshes
*)
169 (destroy compiled-mesh
))))