bool EyeSluggerRendererEx::updateObjectFrame() { if (m_holdMode == HOLD_NORMAL) { return EyeSluggerRenderer::updateObjectFrame(); } else if (m_holdMode == HOLD_IN_HAND) { const float OFFSET = 200; UserDetector* ud = m_henshinDetector->getUserDetector(); m_origin = ud->getSkeletonJointPosition(XU_SKEL_RIGHT_HAND); XV3 fv = -(m_origin - ud->getSkeletonJointPosition(XU_SKEL_NECK)); XV3 uv = fv.cross(ud->getSkeletonJointPosition(XU_SKEL_LEFT_SHOULDER) - ud->getSkeletonJointPosition(XU_SKEL_RIGHT_SHOULDER)); uv.normalizeM(); m_origin -= uv * OFFSET; m_objectFrame.SetOrigin(m_origin.X, m_origin.Y, m_origin.Z); m_objectFrame.SetForwardVector(fv.X, fv.Y, fv.Z); m_objectFrame.SetUpVector(uv.X, uv.Y, uv.Z); m_objectFrame.Normalize(); return true; } else { return false; } }
void WorldRenderer::getHenshinData(XnUserID* pUserID, const XnLabel** ppLabel, XV3* pHeadCenter, XV3* pHeadDirection) { UserDetector* userDetector = m_ball_manager->user_detector(); XnUserID userID = *pUserID = userDetector->getTrackedUserID(); if (userID) { SceneMetaData smd; userDetector->getUserGenerator()->GetUserPixels(userID, smd); *ppLabel = smd.Data(); XV3 ps[2]; //ps[0].assign(m_kkhStatus->center); ps[0].assign(userDetector->getSkeletonJointPosition(XN_SKEL_HEAD)); ps[1].assign(userDetector->getSkeletonJointPosition(XN_SKEL_NECK)); m_depthGen->ConvertRealWorldToProjective(3, ps, ps); normalizeProjective(&ps[0]); normalizeProjective(&ps[1]); //normalizeProjective(&ps[2]); //*pLightCenter = ps[0]; *pHeadCenter = ps[0]; *pHeadDirection = ps[0] - ps[1]; } }