;; print active skels and their positions
(bind-func ping-skel
(let ((skel-frame:NUI_SKELETON_FRAME* (zalloc))
(pos:double* (zalloc 100)))
(lambda ()
(kinect_get_skeleton 100 skel-frame)
(kinect-smooth-params skel-frame 0.5 0.5 0.5 0.05 0.04)
(let ((skels:|6,NUI_SKELETON_DATA|* (tref-ptr skel-frame 5))
(i 0))
(dotimes (i 6)
(let ((skel-data:NUI_SKELETON_DATA* (aref-ptr skels i))
(state (tref skel-data 0))
(id (tref skel-data 1))
(position:Vector4* (tref-ptr skel-data 4))
(positions:|20,Vector4|* (tref-ptr skel-data 5))
(states:|20,i32|* (tref-ptr skel-data 6))
(head (aref-ptr positions NUI_SKELETON_POSITION_HEAD))
(spine (aref-ptr positions NUI_SKELETON_POSITION_SPINE))
(sld_c (aref-ptr positions NUI_SKELETON_POSITION_SHOULDER_CENTER))
(sld_r (aref-ptr positions NUI_SKELETON_POSITION_SHOULDER_RIGHT))
(sld_l (aref-ptr positions NUI_SKELETON_POSITION_SHOULDER_LEFT))
(hip_c (aref-ptr positions NUI_SKELETON_POSITION_HIP_CENTER))
(hip_r (aref-ptr positions NUI_SKELETON_POSITION_HIP_RIGHT))
(hip_l (aref-ptr positions NUI_SKELETON_POSITION_HIP_LEFT))
(knee_r (aref-ptr positions NUI_SKELETON_POSITION_KNEE_RIGHT))
(knee_l (aref-ptr positions NUI_SKELETON_POSITION_KNEE_LEFT))
(elbow_r (aref-ptr positions NUI_SKELETON_POSITION_ELBOW_RIGHT))
(elbow_l (aref-ptr positions NUI_SKELETON_POSITION_ELBOW_LEFT))
(hand_r (aref-ptr positions NUI_SKELETON_POSITION_HAND_RIGHT))
(hand_l (aref-ptr positions NUI_SKELETON_POSITION_HAND_LEFT))
(ankle_r (aref-ptr positions NUI_SKELETON_POSITION_ANKLE_RIGHT))
(ankle_l (aref-ptr positions NUI_SKELETON_POSITION_ANKLE_LEFT))
(foot_r (aref-ptr positions NUI_SKELETON_POSITION_FOOT_RIGHT))
(foot_l (aref-ptr positions NUI_SKELETON_POSITION_FOOT_LEFT))
(head-state (aref states NUI_SKELETON_POSITION_HEAD)))
(glPointSize 10.0)
(glEnable GL_COLOR_MATERIAL)
(if (= state 2)
(begin (glBegin GL_POINTS)
(glColor3d 1.0 1.0 0.0)
(glVertex4f (tref head 0) (tref head 1) (tref head 2) (tref head 3))
(glVertex4f (tref spine 0) (tref spine 1) (tref spine 2) (tref spine 3))
(glVertex4f (tref hip_c 0) (tref hip_c 1) (tref hip_c 2) (tref hip_c 3))
(glColor3d 1.0 0.0 0.0)
(glVertex4f (tref sld_c 0) (tref sld_c 1) (tref sld_c 2) (tref sld_c 3))
(glVertex4f (tref hand_r 0) (tref hand_r 1) (tref hand_r 2) (tref hand_r 3))
(glVertex4f (tref hand_l 0) (tref hand_l 1) (tref hand_l 2) (tref hand_l 3))
(glVertex4f (tref sld_r 0) (tref sld_r 1) (tref sld_r 2) (tref sld_r 3))
(glVertex4f (tref sld_l 0) (tref sld_l 1) (tref sld_l 2) (tref sld_l 3))
(glVertex4f (tref elbow_r 0) (tref elbow_r 1) (tref elbow_r 2) (tref elbow_r 3))
(glVertex4f (tref elbow_l 0) (tref elbow_l 1) (tref elbow_l 2) (tref elbow_l 3))
(glColor3d 0.0 1.0 0.0)
(glVertex4f (tref hip_r 0) (tref hip_r 1) (tref hip_r 2) (tref hip_r 3))
(glVertex4f (tref hip_l 0) (tref hip_l 1) (tref hip_l 2) (tref hip_l 3))
;(glVertex4f (tref foot_r 0) (tref foot_r 1) (tref foot_r 2) (tref foot_r 3))
;(glVertex4f (tref foot_l 0) (tref foot_l 1) (tref foot_l 2) (tref foot_l 3))
(glVertex4f (tref knee_r 0) (tref knee_r 1) (tref knee_r 2) (tref knee_r 3))
(glVertex4f (tref knee_l 0) (tref knee_l 1) (tref knee_l 2) (tref knee_l 3))
(glVertex4f (tref ankle_r 0) (tref ankle_r 1) (tref ankle_r 2) (tref ankle_r 3))
(glVertex4f (tref ankle_l 0) (tref ankle_l 1) (tref ankle_l 2) (tref ankle_l 3))
(glEnd)
1)))))
void)))