2 (in-package :lambdamundo
)
4 (defparameter *turtle
* nil
)
6 (defclass turtle
(actor)
7 ((scale :initform
(make-vector3d* 1.0 1.0 1.0) :accessor scale-of
)))
9 (defmethod x-scale-of ((a turtle
))
10 (aref (the (vector single-float
3) (scale-of a
)) (the fixnum
0)))
12 (defmethod y-scale-of ((a turtle
))
14 (aref (the (vector single-float
3) (scale-of a
)) (the fixnum
1))))
16 (defmethod z-scale-of ((a turtle
))
18 (aref (the (vector single-float
3) (scale-of a
)) (the fixnum
2))))
20 (defmethod up ((a turtle
) amount
)
24 (vertex3d-vector3d (location-of a
))
25 (vector3d-scale (up-of a
) amount
)))))
27 (defmethod down ((a turtle
) amount
)
30 (defmethod left ((a turtle
) amount
)
34 (vertex3d-vector3d (location-of a
))
35 (vector3d-scale (cross-of a
) amount
)))))
37 (defmethod right ((a turtle
) amount
)
40 (defmethod forward ((a turtle
) amount
)
44 (vertex3d-vector3d (location-of a
))
45 (vector3d-scale (cross-of a
) amount
)))))
47 (defmethod backward ((a turtle
) amount
)
48 (forward a
(- amount
)))
51 ;; x= red, y =green, z = blue
52 (defmethod render ((a turtle
))
57 (gl:color-3f
1.0 0.0 0.0)
67 (cross-of a
) (x-scale-of a
)))
69 (gl:vertex-3f x y z
)))
73 (gl:color-3f
0.0 1.0 0.0)
83 (up-of a
) (y-scale-of a
)))
85 (gl:vertex-3f x y z
)))
90 (gl:color-3f
0.0 0.0 1.0)
103 (gl:vertex-3f x y z
))))
106 (gl:with-begin gl
:+lines
+