void CinderOpenNISkeleton::drawDebug(Font font) { XnUserID aUsers[15]; XnUInt16 nUsers = 15; gCinderOpenNISkeleton->mUserGenerator.GetUsers(aUsers, nUsers); for (int i = 0; i < nUsers; ++i){ // Do the labels first XnPoint3D com; gCinderOpenNISkeleton->mUserGenerator.GetCoM(aUsers[i], com); gCinderOpenNISkeleton->mDepthGenerator.ConvertRealWorldToProjective(1, &com, &com); glColor4f(1-Colors[i%nColors][0], 1-Colors[i%nColors][1], 1-Colors[i%nColors][2], 1); if (gCinderOpenNISkeleton->mUserGenerator.GetSkeletonCap().IsTracking(aUsers[i])) { // Tracking gl::drawString("Tracking", Vec2i(com.X, com.Y), Color::white(), font ); } else if (gCinderOpenNISkeleton->mUserGenerator.GetSkeletonCap().IsCalibrating(aUsers[i])) { gl::drawString("Calibrating", Vec2i(com.X, com.Y), Color::white(), font ); } else { gl::drawString("Looking for Pose", Vec2i(com.X, com.Y), Color::white(), font ); } if( gCinderOpenNISkeleton->mUserGenerator.GetSkeletonCap().IsTracking(aUsers[i])){ app::console() << "Is Tracking User" << endl; glLineWidth(6.0); glBegin(GL_LINES); glColor4f(1-Colors[aUsers[i]%nColors][0], 1-Colors[aUsers[i]%nColors][1], 1-Colors[aUsers[i]%nColors][2], 1); drawLimbDebug(aUsers[i], XN_SKEL_HEAD, XN_SKEL_NECK); drawLimbDebug(aUsers[i], XN_SKEL_NECK, XN_SKEL_LEFT_SHOULDER); drawLimbDebug(aUsers[i], XN_SKEL_LEFT_SHOULDER, XN_SKEL_LEFT_ELBOW); drawLimbDebug(aUsers[i], XN_SKEL_LEFT_ELBOW, XN_SKEL_LEFT_HAND); drawLimbDebug(aUsers[i], XN_SKEL_NECK, XN_SKEL_RIGHT_SHOULDER); drawLimbDebug(aUsers[i], XN_SKEL_RIGHT_SHOULDER, XN_SKEL_RIGHT_ELBOW); drawLimbDebug(aUsers[i], XN_SKEL_RIGHT_ELBOW, XN_SKEL_RIGHT_HAND); drawLimbDebug(aUsers[i], XN_SKEL_LEFT_SHOULDER, XN_SKEL_TORSO); drawLimbDebug(aUsers[i], XN_SKEL_RIGHT_SHOULDER, XN_SKEL_TORSO); drawLimbDebug(aUsers[i], XN_SKEL_TORSO, XN_SKEL_LEFT_HIP); drawLimbDebug(aUsers[i], XN_SKEL_LEFT_HIP, XN_SKEL_LEFT_KNEE); drawLimbDebug(aUsers[i], XN_SKEL_LEFT_KNEE, XN_SKEL_LEFT_FOOT); drawLimbDebug(aUsers[i], XN_SKEL_TORSO, XN_SKEL_RIGHT_HIP); drawLimbDebug(aUsers[i], XN_SKEL_RIGHT_HIP, XN_SKEL_RIGHT_KNEE); drawLimbDebug(aUsers[i], XN_SKEL_RIGHT_KNEE, XN_SKEL_RIGHT_FOOT); drawLimbDebug(aUsers[i] , XN_SKEL_LEFT_HIP, XN_SKEL_RIGHT_HIP); glEnd(); } } }
/* Drawing methods */ void CinderOpenNISkeleton::debugDrawSkeleton() { glEnable(GL_LINE_SMOOTH); for (int i = 0; i < maxUsers; ++i) { if( mUserGenerator.GetSkeletonCap().IsTracking(currentUsers[i])) { glLineWidth(1.0); glBegin(GL_LINES); glColor4f(Colors[currentUsers[i]%nColors][0], Colors[currentUsers[i]%nColors][1], Colors[currentUsers[i]%nColors][2], 0.5); // HEAD TO NECK drawLimbDebug(currentUsers[i], XN_SKEL_HEAD, XN_SKEL_NECK); // Left Arm drawLimbDebug(currentUsers[i], XN_SKEL_NECK, XN_SKEL_LEFT_SHOULDER); drawLimbDebug(currentUsers[i], XN_SKEL_LEFT_SHOULDER, XN_SKEL_LEFT_ELBOW); drawLimbDebug(currentUsers[i], XN_SKEL_LEFT_ELBOW, XN_SKEL_LEFT_HAND); drawLimbDebug(currentUsers[i], XN_SKEL_LEFT_HAND, XN_SKEL_LEFT_FINGERTIP); // RIGHT ARM drawLimbDebug(currentUsers[i], XN_SKEL_NECK, XN_SKEL_RIGHT_SHOULDER); drawLimbDebug(currentUsers[i], XN_SKEL_RIGHT_SHOULDER, XN_SKEL_RIGHT_ELBOW); drawLimbDebug(currentUsers[i], XN_SKEL_RIGHT_ELBOW, XN_SKEL_RIGHT_HAND); drawLimbDebug(currentUsers[i], XN_SKEL_RIGHT_HAND, XN_SKEL_RIGHT_FINGERTIP); // TORSO drawLimbDebug(currentUsers[i], XN_SKEL_LEFT_SHOULDER, XN_SKEL_TORSO); drawLimbDebug(currentUsers[i], XN_SKEL_RIGHT_SHOULDER, XN_SKEL_TORSO); // LEFT LEG drawLimbDebug(currentUsers[i], XN_SKEL_TORSO, XN_SKEL_LEFT_HIP); drawLimbDebug(currentUsers[i], XN_SKEL_LEFT_HIP, XN_SKEL_LEFT_KNEE); drawLimbDebug(currentUsers[i], XN_SKEL_LEFT_KNEE, XN_SKEL_LEFT_FOOT); // RIGHT LEG drawLimbDebug(currentUsers[i], XN_SKEL_TORSO, XN_SKEL_RIGHT_HIP); drawLimbDebug(currentUsers[i], XN_SKEL_RIGHT_HIP, XN_SKEL_RIGHT_KNEE); drawLimbDebug(currentUsers[i], XN_SKEL_RIGHT_KNEE, XN_SKEL_RIGHT_FOOT); // PELVIS drawLimbDebug(currentUsers[i], XN_SKEL_LEFT_HIP, XN_SKEL_RIGHT_HIP); glEnd(); } } glDisable(GL_LINE_SMOOTH); gl::color(ColorA(1,1,1,1)); }