本文整理汇总了C++中leapsdk::DeviceRef类的典型用法代码示例。如果您正苦于以下问题:C++ DeviceRef类的具体用法?C++ DeviceRef怎么用?C++ DeviceRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DeviceRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void LeapPalmDirectionApp::update()
{
if ( mLeap && mLeap->isConnected() )
{
mLeap->update();
}
}
示例2: update
// Runs update logic
void LeapApp::update()
{
// Update frame rate
mFrameRate = getAverageFps();
// Toggle fullscreen
if ( mFullScreen != isFullScreen() ) {
setFullScreen( mFullScreen );
}
// Update device
if ( mLeap && mLeap->isConnected() ) {
mLeap->update();
}
}
示例3: setup
// Set up
void LeapApp::setup()
{
// Set up OpenGL
gl::enable( GL_LINE_SMOOTH );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
gl::enable( GL_POLYGON_SMOOTH );
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
// Set up camera
mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 0.01f, 1000.0f );
mCamera.lookAt( Vec3f( 0.0f, 125.0f, 500.0f ), Vec3f( 0.0f, 250.0f, 0.0f ) );
// Start device
mLeap = Device::create();
mLeap->addCallback( &LeapApp::onFrame, this );
// Params
mFrameRate = 0.0f;
mFullScreen = false;
mParams = params::InterfaceGl( "Params", Vec2i( 200, 105 ) );
mParams.addParam( "Frame rate", &mFrameRate, "", true );
mParams.addParam( "Full screen", &mFullScreen, "key=f" );
mParams.addButton( "Screen shot", bind( &LeapApp::screenShot, this ), "key=space" );
mParams.addButton( "Quit", bind( &LeapApp::quit, this ), "key=q" );
}
示例4: shutdown
void ChargesApp::shutdown()
{
mndl::kit::params::PInterfaceGl::save();
mEffectCharge.deinstantiate();
mLeap->removeCallback( mLeapCallbackId );
}
示例5: setup
void ChargesApp::setup()
{
//gl::disableVerticalSync();
gl::Fbo::Format format;
format.enableDepthBuffer( false );
format.setSamples( 4 );
mFbo = gl::Fbo( 1280, 800, format );
mKawaseBloom = mndl::gl::fx::KawaseBloom( mFbo.getWidth(), mFbo.getHeight() );
mEffectCharge.setup();
mEffectCharge.instantiate();
mEffectCharge.setBounds( mFbo.getBounds() );
// Leap
mLeap = LeapSdk::Device::create();
mLeapCallbackId = mLeap->addCallback( &ChargesApp::onFrame, this );
// params
mndl::kit::params::PInterfaceGl::load( "params.xml" );
mParams = mndl::kit::params::PInterfaceGl( "Parameters", Vec2i( 200, 300 ) );
mParams.addPersistentSizeAndPosition();
mParams.addParam( "Fps", &mFps, "", true );
mParams.addSeparator();
mParams.addPersistentParam( "Line width", &mLineWidth, 4.5f, "min=.5 max=10 step=.1" );
mParams.addPersistentParam( "Bloom strength", &mBloomStrength, .8f, "min=0 max=1 step=.05" );
mParams.addPersistentParam( "Finger disapperance thr", &mFingerDisapperanceThreshold, .1f, "min=0 max=2 step=.05" );
mndl::kit::params::PInterfaceGl::showAllParams( false );
}
示例6: setup
void LeapPalmDirectionApp::setup()
{
mLeap = LeapSdk::Device::create();
mCallbackId = mLeap->addCallback( &LeapPalmDirectionApp::onFrame, this );
mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 0.01f, 1000.0f );
mCamera.lookAt( Vec3f( 0.0f, 250.0f, 500.0f ), Vec3f( 0.0f, 250.0f, 0.0f ) );
}
示例7: warpPointable
// Maps pointable's ray to the screen in pixels
Vec2f GestureApp::warpPointable( const Pointable& p )
{
Vec3f result = Vec3f::zero();
if ( mLeap ) {
const Screen& screen = mLeap->getClosestScreen( p );
if ( screen.intersects( p, &result, true ) ) {
result *= Vec3f( Vec2f( getWindowSize() ), 0.0f );
result.y = (float)getWindowHeight() - result.y;
}
}
return result.xy();
}
示例8: update
void BrainbowApp::update()
{
//LEAP
if ( mLeap && mLeap->isConnected() ) {
mLeap->update();
}
//GET HAND
for ( LeapSdk::HandMap::const_iterator handIter = mHands.begin(); handIter != mHands.end(); ++handIter ) {
const LeapSdk::Hand& hand = handIter->second;
// cout << hand.getPosition().x << endl;
// cout << hand.getDirection();
scaledX = (hand.getPosition().x *(getWindowWidth()/400))+(getWindowWidth()/2);
scaledY = (-hand.getPosition().y*(getWindowHeight()/400) + getWindowHeight())*2.5 - 400;
scaledZ = hand.getPosition().z*2+300;
handPos = Vec3f(scaledX, scaledY, scaledZ);
}
//AUDIO
// mAudio.update();
//SCENES
if (sceneOne)
scene1();
if (sceneTwo)
scene2();
//LIGHT
mLight->lookAt( handPos, Vec3f::zero() );
//ROTATE DIAMOND
if (gong)
mDiamond.getModelMatrix().rotate( Vec3f( 0.0f, 0.5f, 0), 0.01f );
}
示例9: warpVector
// Maps Leap vector to the screen in pixels
Vec2f GestureApp::warpVector( const Vec3f& v )
{
Vec3f result = Vec3f::zero();
if ( mLeap ) {
const ScreenMap& screens = mLeap->getScreens();
if ( !screens.empty() ) {
const Screen& screen = screens.begin()->second;
result = screen.project( v, true );
}
}
result *= Vec3f( getWindowSize(), 0.0f );
result.y = (float)getWindowHeight() - result.y;
return result.xy();
}
示例10: setup
void _TBOX_PREFIX_App::setup()
{
// Set up OpenGL
gl::enableAlphaBlending();
gl::enableDepthRead();
gl::enableDepthWrite();
// Set up camera
mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 0.01f, 1000.0f );
mCamera.lookAt( Vec3f( 0.0f, 125.0f, 500.0f ), Vec3f( 0.0f, 250.0f, 0.0f ) );
// Start device
mLeap = LeapSdk::Device::create();
mCallbackId = mLeap->addCallback( &_TBOX_PREFIX_App::onFrame, this );
}
示例11: setup
// Set up
void GestureApp::setup()
{
// Set up OpenGL
gl::enable( GL_POLYGON_SMOOTH );
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
// UI
mBackgroundBrightness = 0.0f;
mBackgroundColor = Colorf( 0.0f, 0.1f, 0.2f );
mCircleResolution = 32;
mDialBrightness = 0.0f;
mDialPosition = Vec2f( 155.0f, 230.0f );
mDialRadius = 120.0f;
mDialSpeed = 0.21f;
mDialValue = 0.0f;
mDialValueDest = mDialValue;
mDotRadius = 3.0f;
mDotSpacing = mDotRadius * 3.0f;
mFadeSpeed = 0.95f;
mKeySpacing = 25.0f;
mKeyRect = Rectf( mKeySpacing, 360.0f + mKeySpacing, 600.0f, 600.0f );
mKeySize = 60.0f;
mPointableRadius = 15.0f;
mSwipeBrightness = 0.0f;
mSwipePos = 0.0f;
mSwipePosDest = mSwipePos;
mSwipePosSpeed = 0.33f;
mSwipeRect = Rectf( 310.0f, 100.0f, 595.0f, 360.0f );
mSwipeStep = 0.033f;
// Sets master offset
resize();
// Lay out keys
float spacing = mKeySize + mKeySpacing;
for ( float y = mKeyRect.y1; y < mKeyRect.y2; y += spacing ) {
for ( float x = mKeyRect.x1; x < mKeyRect.x2; x += spacing ) {
Rectf bounds( x, y, x + mKeySize, y + mKeySize );
Key key( bounds );
mKeys.push_back( key );
}
}
// Start device
mLeap = Device::create();
mCallbackId = mLeap->addCallback( &GestureApp::onFrame, this );
// Enable all gesture types
mLeap->enableGesture( Gesture::Type::TYPE_CIRCLE );
mLeap->enableGesture( Gesture::Type::TYPE_KEY_TAP );
mLeap->enableGesture( Gesture::Type::TYPE_SCREEN_TAP );
mLeap->enableGesture( Gesture::Type::TYPE_SWIPE );
// Params
mFrameRate = 0.0f;
mFullScreen = false;
mParams = params::InterfaceGl( "Params", Vec2i( 200, 105 ) );
mParams.addParam( "Frame rate", &mFrameRate, "", true );
mParams.addParam( "Full screen", &mFullScreen, "key=f" );
mParams.addButton( "Screen shot", bind( &GestureApp::screenShot, this ), "key=space" );
mParams.addButton( "Quit", bind( &GestureApp::quit, this ), "key=q" );
}
示例12: shutdown
void BrainbowApp::shutdown()
{
mLeap->removeCallback( mCallbackId );
mHands.clear();
}
示例13: setup
void BrainbowApp::setup()
{
// LOAD AUDIO
mAudio = AudioCont();
mAudio.setUp();
// START SCENE 1
sceneOne = true;
sceneTwo = false;
// Set up OpenGL
gl::enableAlphaBlending();
gl::enableDepthRead();
gl::enableDepthWrite();
gongTimer.start();
ballTimer.start();
// LIGHTING
//here
glPolygonOffset( 1.0f, 1.0f );
glEnable( GL_LIGHTING );
glEnable( GL_DEPTH_TEST );
mLight = new gl::Light( gl::Light::POINT, 0 );
mLight->lookAt( Vec3f( 1, 5, 1 ), Vec3f (getWindowWidth(), getWindowHeight() * 0.5f, 0.0f ));
mLight->setAmbient( Color( 0.3f, 0.3f, 0.3f ) );
mLight->setDiffuse( Color( 1.0f, 1.0f, 1.0f ) );
mLight->setSpecular( Color( 1.0f, 1.0f, 1.0f ) );
mLight->setShadowParams( 60.0f, 0.5f, 8.0f );
// mLight->update( *mCamera );
mLight->enable();
//LOAD SHAPES
colorSat = 1.0f;
sphereMaterial.setSpecular( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
sphereMaterial.setDiffuse( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
sphereMaterial.setAmbient( ColorA(colorSat-0.3f, colorSat, colorSat, .05f ) );
sphereMaterial.setShininess( 1.0f );
sphereMaterial.setEmission(ColorA(1, 1, 1, 1 ));
gl::Material cylMaterial;
cylMaterial.setSpecular( ColorA(0, 1.0f, 1.0f, .2f ));
cylMaterial.setDiffuse( ColorA(0, 1.0f, 1.0f, .2f ) );
cylMaterial.setAmbient( ColorA(0, 1.0f, 1.0f, .2f ) );
cylMaterial.setShininess( 600.0f );
cylMaterial.setEmission(ColorA(1, 1, 1, 1 ));
gl::Material curMaterial;
curMaterial.setSpecular( ColorA(1, .5, 0, .5f ));
curMaterial.setDiffuse( ColorA(1, .5, 0, .5f ) );
curMaterial.setAmbient( ColorA(1, 1.0f, 1.0f, .05f ) );
curMaterial.setShininess( 600.0f );
curMaterial.setEmission(ColorA(1, 1, 1, 1 ));
discMaterial.setSpecular( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
discMaterial.setDiffuse( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
discMaterial.setAmbient( ColorA(colorSat-0.3f, colorSat, colorSat, .05f ) );
discMaterial.setShininess( 600.0f );
discMaterial.setEmission(ColorA(1, 1, 1, 1 ));
initShadowMap();
mCloud = SphereCloud(0, 70);
mDiamond = gl::DisplayList( GL_COMPILE );
mDiamond.newList();
gl::drawSphere(Vec3f(0, 0, 0), 300, 4);
mDiamond.endList();
mDiamond.setMaterial( sphereMaterial );
mCyl = gl::DisplayList( GL_COMPILE );
mCyl.newList();
// gl::drawCylinder(200, 200, 200);
gl::drawColorCube(Vec3f(0, 0, 0), Vec3f(300, 300, 300));
mCyl.endList();
mCyl.setMaterial(cylMaterial);
mCur = gl::DisplayList( GL_COMPILE );
mCur.newList();
gl::drawSphere(Vec3f(0, 0, 0), 5);
mCur.endList();
mCur.setMaterial(curMaterial);
mDisc = gl::DisplayList( GL_COMPILE );
mDisc.newList();
gl::drawSolidCircle(Vec2f(0, 0), 60, 6);
mDisc.endList();
mDisc.setMaterial( discMaterial );
// START LEAP
mLeap = LeapSdk::Device::create();
mCallbackId = mLeap->addCallback( &BrainbowApp::onFrame, this );
//.........这里部分代码省略.........
示例14: update
// Runs update logic
void GestureApp::update()
{
// Update frame rate
mFrameRate = getAverageFps();
// Toggle fullscreen
if ( mFullScreen != isFullScreen() ) {
setFullScreen( mFullScreen );
}
// Update device
if ( mLeap && mLeap->isConnected() ) {
mLeap->update();
}
const vector<Leap::Gesture>& gestures = mFrame.getGestures();
for ( vector<Leap::Gesture>::const_iterator iter = gestures.begin(); iter != gestures.end(); ++iter ) {
Gesture::Type type = iter->type();
if ( type == Gesture::Type::TYPE_CIRCLE ) {
// Cast to circle gesture
const Leap::CircleGesture& gesture = (Leap::CircleGesture)*iter;
// Control dial
mDialBrightness = 1.0f;
mDialValueDest = gesture.progress();
} else if ( type == Gesture::Type::TYPE_KEY_TAP ) {
// Cast to circle gesture and read data
const Leap::KeyTapGesture& gesture = (Leap::KeyTapGesture)*iter;
Vec2f center = warpVector( fromLeapVector( gesture.position() ) );
center -= mOffset;
// Press key
for ( vector<Key>::iterator iter = mKeys.begin(); iter != mKeys.end(); ++iter ) {
if ( iter->mBounds.contains( center ) ) {
iter->mBrightness = 1.0f;
break;
}
}
} else if ( type == Gesture::Type::TYPE_SCREEN_TAP ) {
// Turn background white for screen tap
mBackgroundBrightness = 1.0f;
} else if ( type == Gesture::Type::TYPE_SWIPE ) {
// Cast to swipe gesture and read data
const Leap::SwipeGesture& gesture = (Leap::SwipeGesture)*iter;
ci::Vec2f a = warpVector( fromLeapVector( gesture.startPosition() ) );
ci::Vec2f b = warpVector( fromLeapVector( gesture.position() ) );
// Update swipe position
mSwipeBrightness = 1.0f;
if ( gesture.state() == Gesture::State::STATE_STOP ) {
mSwipePosDest = b.x < a.x ? 0.0f : 1.0f;
} else {
float step = mSwipeStep;
mSwipePosDest += b.x < a.x ? -step : step;
}
mSwipePosDest = math<float>::clamp( mSwipePosDest, 0.0f, 1.0f );
}
}
// UI animation
mDialValue = lerp( mDialValue, mDialValueDest, mDialSpeed );
mSwipePos = lerp( mSwipePos, mSwipePosDest, mSwipePosSpeed );
mBackgroundBrightness *= mFadeSpeed;
mDialBrightness *= mFadeSpeed;
mSwipeBrightness *= mFadeSpeed;
for ( vector<Key>::iterator iter = mKeys.begin(); iter != mKeys.end(); ++iter ) {
iter->mBrightness *= mFadeSpeed;
}
}
示例15: update
void ChargesApp::update()
{
mFps = getAverageFps();
// Update device
if ( mLeap && mLeap->isConnected() )
{
mLeap->update();
}
vector< int32_t > currentFingersIds;
for ( const std::pair< int32_t, LeapSdk::Hand > hand : mHands )
{
const LeapSdk::FingerMap &fingers = hand.second.getFingers();
for ( const auto &fkv : fingers )
{
int32_t id = fkv.first;
const LeapSdk::Finger &finger = fkv.second;
currentFingersIds.push_back( id );
// new finger?
if ( mActiveFingers.find( id ) == mActiveFingers.end() )
{
mActiveFingers[ id ] = mTimestamp;
mEffectCharge.addCursor( id, 0.f, 0.f, 1.f ); // init with (0, 0), will be updated below
}
// update finger
const LeapSdk::ScreenMap &screens = mLeap->getScreens();
if ( screens.begin() != screens.end() )
{
mActiveFingers[ id ] = mTimestamp;
const LeapSdk::Screen &screen = screens.begin()->second;
Vec3f normPos;
screen.intersects( finger, normPos, true, 1.5f ); // normalized screen coordinates with 1.5 clamp ratio
Vec2f fingertip = normPos.xy() * Vec2f( mFbo.getSize() );
Vec3f screenPos;
screen.intersects( finger, screenPos, false, 1.5f ); // screen coordinates with 1.5 clamp ratio
float d = screenPos.distance( finger.getPosition() );
const float dMin = 50.f;
const float dMax = 500.f;
const float sMin = 1.f;
const float sMax = 100.f;
d = math< float >::clamp( d, dMin, dMax );
float strength = lmap( d, dMin, dMax, sMax, sMin );
mEffectCharge.updateCursor( id, fingertip.x, fingertip.y, strength );
}
}
}
// erase disappeared fingers
int64_t disappearThr = mFingerDisapperanceThreshold * 1000000;
for ( auto it = mActiveFingers.begin(); it != mActiveFingers.end(); )
{
int32_t id = it->first;
if ( find( currentFingersIds.begin(), currentFingersIds.end(), id ) == currentFingersIds.end() )
{
// seen earlier than the threshold?
if ( mTimestamp - it->second > disappearThr )
{
mEffectCharge.removeCursor( id );
it = mActiveFingers.erase( it );
}
else
{
it++;
}
}
else
{
it++;
}
}
}