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
))
56 (gl:color-3f
1.0 0.0 0.0)
66 (cross-of a
) (x-scale-of a
)))
68 (gl:vertex-3f x y z
)))
72 (gl:color-3f
0.0 1.0 0.0)
82 (up-of a
) (y-scale-of a
)))
84 (gl:vertex-3f x y z
)))
89 (gl:color-3f
0.0 0.0 1.0)
102 (gl:vertex-3f x y z
))))
105 (gl:with-begin gl
:+lines
+
111 (defun make-turtle (x y z
)
115 (make-instance 'turtle
)))
116 (setf (location-of result
) (vertex3d* x y z
1.0))
117 (setf *turtle
* result
)