3 (in-package :lambdamundo
)
5 (defparameter *actors
* (make-array 0 :adjustable t
:fill-pointer
0))
9 ((location :type vertex3d
)
10 (velocity :type vector3d
)
11 (orientation :type quaternion
)
12 (w-velocity :type vector3d
))
14 ((dv :type single-float
:initform
0.0 :accessor dv-of
)
15 (dw :type single-float
:initform
0.0 :accessor dw-of
))))
18 (defmethod initialize-instance :after
((self actor
) &rest args
)
19 (declare (ignore args
))
20 (setf (aref (orientation-of% self
) 3) 1.0)
21 (vector-push-extend self
*actors
*))
23 (def-tuple-op angular-velocity
24 ((vector vector3d
(vx vy vz
))
25 (quat quaternion
(qx qy qz qw
)))
26 "Calculate dq/dt as a quat from an angular velocity"
30 (vector3d-quaternion vector
)
33 (defmethod update-position ((a actor
))
38 (vertex3d-vector3d (location-of a
))
41 (defmethod update-dv ((a actor
))
48 (defmethod update-dw ((a actor
))
49 ;; update angluar velocity
50 (setf (w-velocity-of a
)
51 (vector3d-scale (w-velocity-of a
) (dw-of a
))))
53 (defmethod update-orientation ((a actor
))
55 (setf (orientation-of a
)
61 (orientation-of a
))))))
65 (defmethod update ((a actor
))
69 (update-orientation a
))
72 (defmethod up-of ((a actor
))
73 "Return a tuple vector representing the up axis of the camera."
74 (quaternion-transform-vector3d
75 (vector3d* 0.0 1.0 0.0)
78 (defmethod direction-of ((a actor
))
79 "Return a tuple vector representing the z axis of the camera."
80 (quaternion-transform-vector3d
81 (vector3d* 0.0 0.0 1.0)
84 (defmethod cross-of ((a actor
))
85 "Return a tuple vector representing the x axis of the camera."
86 (quaternion-transform-vector3d
87 (vector3d* 1.0 0.0 0.0)