// Render
void SkeletonBitmapApp::draw()
{

	// Clear window
	gl::setViewport( getWindowBounds() );
	gl::clear();
	gl::setMatricesWindow( getWindowSize() );

	// We're capturing
	if ( mKinect->isCapturing() && mTexture ) {
		
		// Draw color image
		gl::color( ColorAf::white() );
		gl::draw( mTexture, getWindowBounds() );
		
		// Scale skeleton to fit
		gl::pushMatrices();
		gl::scale( Vec2f( getWindowSize() ) / Vec2f( mTexture.getSize() ) );

		// Iterate through skeletons
		uint32_t i = 0;
		for ( vector<Skeleton>::const_iterator skeletonIt = mSkeletons.cbegin(); skeletonIt != mSkeletons.cend(); ++skeletonIt, i++ ) {

			// Set color
			gl::color( mKinect->getUserColor( i ) );

			// Draw bones and joints
			for ( Skeleton::const_iterator boneIt = skeletonIt->cbegin(); boneIt != skeletonIt->cend(); ++boneIt ) {
				
				// Get joint positions 
				const Bone& bone		= boneIt->second;
				Vec3f position			= bone.getPosition();
				Vec3f destination		= skeletonIt->at( bone.getStartJoint() ).getPosition();
				Vec2f positionScreen	= Vec2f( mKinect->getSkeletonVideoPos( position ) );
				Vec2f destinationSceen	= Vec2f( mKinect->getSkeletonVideoPos( destination ) );

				// Draw bone
				gl::drawLine( positionScreen, destinationSceen );

				// Draw joint
				gl::drawSolidCircle( positionScreen, 10.0f, 16 );

			}

		}

		gl::popMatrices();

	}

}
Ejemplo n.º 2
0
// Handles window resize
void UiApp::resize()
{
	// Initialize buttons
	float h = (float)getWindowHeight() * 0.333f;
	float w = (float)getWindowWidth() * 0.25f;
	Vec2f position( w, h );
	position -= Vec2f( mButton[ 0 ].getSize() ) * 0.5f;
	for ( size_t i = 0; i < 3; ++i, position.x += w ) {
		mButtonPosition[ i ]	= position;
		mButtonState[ i ]		= false;
	}

	// Initialize slider
	position = Vec2f( w * 2.0f, h * 2.0f );
	mTrackPosition		= position - Vec2f( mTrack.getSize() ) * 0.5f;
	mSliderPosition		= mTrackPosition;
	mSliderPosition.y	-= 45.0f;
}