コード例 #1
0
ファイル: UiApp.cpp プロジェクト: imclab/Cinder-LeapMotion
// Maps Leap vector to the screen in pixels
Vec2f UiApp::warpVector( const Leap::Vector& v )
{
	Vec3f result	= Vec3f::zero();
	if ( mDevice ) {
		const Leap::Screen& screen = mDevice->getController()->locatedScreens().closestScreen( v );
		
		result		= LeapMotion::toVec3f( screen.project( v, true ) );
	}
	result			*= Vec3f( getWindowSize(), 0.0f );
	result.y		= (float)getWindowHeight() - result.y;
	return result.xy();
}
コード例 #2
0
ファイル: UiApp.cpp プロジェクト: imclab/Cinder-LeapMotion
// Maps pointable's ray to the screen in pixels
Vec2f UiApp::warpPointable( const Leap::Pointable& p )
{
	Vec3f result	= Vec3f::zero();
	if ( mDevice ) {
		const Leap::Screen& screen = mDevice->getController()->locatedScreens().closestScreenHit( p );
		
		result		= LeapMotion::toVec3f( screen.intersect( p, true, 1.0f ) );
	}
	result			*= Vec3f( Vec2f( getWindowSize() ), 0.0f );
	result.y		= (float)getWindowHeight() - result.y;
	return result.xy();
}
コード例 #3
0
vec2 GestureApp::warpPointable( const Leap::Pointable& p )
{
	vec3 result( 0.0f );
	if ( mDevice ) {
		const Leap::Screen& screen = mDevice->getController()->locatedScreens().closestScreenHit( p );
		
		result	= LeapMotion::toVec3( screen.intersect( p, true, 1.0f ) );
	}
	result		*= vec3( vec2( getWindowSize() ), 0.0f );
	result.y	= (float)getWindowHeight() - result.y;
	return vec2( result.x, result.y );
}
コード例 #4
0
vec2 GestureApp::warpVector( const Leap::Vector& v )
{
	vec3 result( 0.0f );
	if ( mDevice ) {
		const Leap::Screen& screen = mDevice->getController()->locatedScreens().closestScreen( v );
		
		result	= LeapMotion::toVec3( screen.project( v, true ) );
	}
	result		*= vec3( getWindowSize(), 0.0f );
	result.y	= (float)getWindowHeight() - result.y;
	return vec2( result.x, result.y );
}
コード例 #5
0
void ImageApp::setup()
{
	gl::enable( GL_TEXTURE_2D );
	
	mDevice = Device::create();
	mDevice->getController()->setPolicyFlags( Leap::Controller::POLICY_IMAGES );
	mDevice->connectEventHandler( [ & ]( Leap::Frame frame )
	{
		mFrame = frame;
	} );

	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mParams = params::InterfaceGl::create( "Params", Vec2i( 200, 105 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,				"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addButton( "Screen shot",	[ & ]() { screenShot(); },	"key=space" );
	mParams->addButton( "Quit",			[ & ]() { quit(); },		"key=q" );
}