2 (in-package :lambdamundo
)
4 (defclass turtle
(actor)
5 ((scale :initform
(make-vector3d* 1.0 1.0 1.0) :accessor scale-of
)))
7 (defmethod x-scale-of ((a turtle
))
8 (aref (the (vector single-float
3) (scale-of a
)) (the fixnum
0)))
10 (defmethod y-scale-of ((a turtle
))
12 (aref (the (vector single-float
3) (scale-of a
)) (the fixnum
1))))
14 (defmethod z-scale-of ((a turtle
))
16 (aref (the (vector single-float
3) (scale-of a
)) (the fixnum
2))))
18 (defmethod up ((a turtle
) amount
)
22 (vertex3d-vector3d (location-of a
))
23 (vector3d-scale (up-of a
) amount
)))))
25 (defmethod down ((a turtle
) amount
)
28 (defmethod left ((a turtle
) amount
)
32 (vertex3d-vector3d (location-of a
))
33 (vector3d-scale (cross-of a
) amount
)))))
35 (defmethod right ((a turtle
) amount
)
38 (defmethod forward ((a turtle
) amount
)
42 (vertex3d-vector3d (location-of a
))
43 (vector3d-scale (cross-of a
) amount
)))))
45 (defmethod backward ((a turtle
) amount
)
46 (forward a
(- amount
)))
49 ;; x= red, y =green, z = blue
50 (defmethod render ((a turtle
))
54 (gl:color-3f
1.0 0.0 0.0)
64 (cross-of a
) (x-scale-of a
)))
66 (gl:vertex-3f x y z
)))
70 (gl:color-3f
0.0 1.0 0.0)
80 (up-of a
) (y-scale-of a
)))
82 (gl:vertex-3f x y z
)))
87 (gl:color-3f
0.0 0.0 1.0)
100 (gl:vertex-3f x y z
))))
103 (gl:with-begin gl
:+lines
+