UnaNancyOwen
5/29/2017 - 2:04 PM

sample.cpp

// Retrieve Body Frame
ComPtr<IBodyFrame> bodyFrame;
const HRESULT ret = bodyFrameReader->AcquireLatestFrame( &bodyFrame );
if( FAILED( ret ) ){
    return;
}

// Retrieve Body Data
std::vector<ComPtr<IBody>> bodies( BODY_COUNT );
ERROR_CHECK( bodyFrame->GetAndRefreshBodyData( static_cast<UINT>( bodies.size() ), &bodies[0] ) );

// Retrieve Joints of All Bodies
std::vector<std::vector<Joint>> alljoints( BODY_COUNT, std::vector<Joint>( JointType::JointType_Count ) );
std::for_each( bodies.begin(), bodies.end(), 
    [&alljoints]( ComPtr<IBody> body ){
        std::vector<Joint> joints( JointType::JointType_Count );
        ERROR_CHECK( body->GetJoints( static_cast<UINT>( joints.size() ), &joints[0] ) );
        alljoints.emplace_back( joints );
        
        /*
        Joint joints[JointType::JointType_Count];
        ERROR_CHECK( body->GetJoints( JointType::JointType_Count, &joints[0] ) );
        alljoints.emplace_back( std::vector<Joint>( &joints[0], &joints[JointType::JointType_Count] ) );
        */
    }
);