本文整理汇总了C++中TrackedButtonInteractionEvent::getHand方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackedButtonInteractionEvent::getHand方法的具体用法?C++ TrackedButtonInteractionEvent::getHand怎么用?C++ TrackedButtonInteractionEvent::getHand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrackedButtonInteractionEvent
的用法示例。
在下文中一共展示了TrackedButtonInteractionEvent::getHand方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processEvent
bool WaterMaze::processEvent(InteractionEvent * event)
{
KeyboardInteractionEvent * kie = event->asKeyboardEvent();
if (kie)
{
if (kie->getInteraction() == KEY_UP)
{
switch(kie->getKey())
{
case 'n':
//next paradigm
changeParadigm(1);
break;
case 'b':
changeParadigm(-1);
break;
case 'f':
//next trial
changeTrial(1);
break;
case 'a':
//override trial limit add trial
addTrial();
break;
case 's':
// start/abort trail and reset position
startStop();
break;
case 'l':
//load geometry
load();
break;
case 'i':
/* info */
cout << endl << endl;
//running state of application
cout << "Current Running State: " << _state << endl;
//Paradigm ID
cout << "Current Paradigm: " << _paradigms[_currentParadigm]->getID() << endl;
//trials ran
cout << "Trial: " << _paradigms[_currentParadigm]->getTrialNumber() << endl;
//android controller data
if(ComController::instance()->isMaster())
cout << "# of Connected Devices: " << _controller->getNumControllers() << endl;
//volume
cout << "Master Volume: " << _masterVolume << endl;
break;
case 'h':
//help menu
std::cout << "Welcome to WaterMaze!\n" <<
"l - load geometry\n" <<
"n - proceed to next paradigm\n" <<
"s - start/stop trial\n" <<
"f - proceed to next trial\n" <<
"a - override trial limit/add trial\n" <<
"i - info\n" <<
"h - help menu" << std::endl;
break;
case osgGA::GUIEventAdapter::KeySymbol::KEY_Up:
//raise master volume
cout << "Raising Volume" << endl;
_masterVolume = min(1.0, _masterVolume + 0.1);
for(int i = 0; i < _paradigms.size(); ++i)
{
_paradigms[i]->setVolume(_masterVolume);
}
break;
case osgGA::GUIEventAdapter::KeySymbol::KEY_Down:
//lower master volume
cout << "Lowering Volume" << endl;
_masterVolume = max(0.0, _masterVolume - 0.1);
for(int i = 0; i < _paradigms.size(); ++i)
{
_paradigms[i]->setVolume(_masterVolume);
}
break;
}
}
}
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if (tie)
{
if(tie->getHand() == 0 && tie->getButton() == 0)
{
if (tie->getInteraction() == BUTTON_DOWN && !_runningTrial)
{
return true;
}
else if (tie->getInteraction() == BUTTON_DRAG && !_runningTrial)
{
return true;
}
else if (tie->getInteraction() == BUTTON_UP)
{
return false;
}
return false;
}
}
//.........这里部分代码省略.........
示例2: processEvent
bool Sketch::processEvent(InteractionEvent * event)
{
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if(!tie)
{
return false;
}
if(tie->getHand() == 0 && tie->getButton() == 0)
{
if(_csCB->getValue())
{
if(_colorSelector->buttonEvent(tie->getInteraction(),
tie->getTransform()))
{
_color = _colorSelector->getColor();
if(_activeObject)
{
_activeObject->setColor(_color);
}
return true;
}
}
osg::Vec3 point(0,Sketch::instance()->getPointerDistance(),0);
point = point * TrackingManager::instance()->getHandMat(0);
osg::Vec3 distance;
if (!_freezeCB->getValue())
{
point = point * PluginHelper::getWorldToObjectTransform();
}
else
{
}
if (_snapToGridCB->getValue())
{
for (int i = 0; i < 3; ++i)
{
int diff = (int)floor(point[i]) % _gridSize;
point[i] -= diff;
}
distance = point - _lastPoint;
distance[0] = (int)distance[0];
distance[1] = (int)distance[1];
distance[2] = (int)distance[2];
}
else
{
distance = point - _lastPoint;
}
_lastPoint = point;
if (_mode == MOVE)
{
if (tie->getInteraction() == BUTTON_DOWN)
{
bool inSphere = false;
for (int i = 0; i < _shapeList.size(); ++i)
{
if (_shapeList[i]->containsPoint(_lastPoint))
{
_movingList.push_back(_shapeList[i]->getPat());
_movingLayout = false;
inSphere = true;
}
}
for (int i = 0; i < _layoutList.size(); ++i)
{
if (_layoutList[i]->shape->containsPoint(_lastPoint))
{
if (!inSphere)
{
_movingLayout = true;
_movingList.push_back(_layoutList[i]->getPat());
for (int j = 0; j < _layoutList[i]->children.size(); ++j)
{
_movingList.push_back(_layoutList[i]->children[j]);
}
}
}
}
return !_movingList.empty();
}
else if (tie->getInteraction() == BUTTON_DRAG)
{
for (int i = 0; i < _movingList.size(); ++i)
{
// remove child shapes that are dragged out of layouts
if (!_movingLayout)
{
//.........这里部分代码省略.........
示例3: processEvent
//.........这里部分代码省略.........
m.makeTranslate(menuStartPos);
_menuRoot->setMatrix(m);
}
else
{
osg::Vec3 viewerPoint =
TrackingManager::instance()->getHeadMat(0).getTrans();
osg::Vec3 viewerDir = viewerPoint - menuPoint;
viewerDir.z() = 0.0;
osg::Vec3 menuOffset = osg::Vec3(
_widthMap[_myMenu] * _scale / 2.0,0,0);
_menuRoot->setMatrix(osg::Matrix::translate(menuPoint));
}
_menuActive = true;
SceneManager::instance()->closeOpenObjectMenu();
return true;
}
}
}
if(tie->getButton() == _primaryButton
&& (tie->getInteraction() == BUTTON_UP))
{
_timeLastButtonUp = PluginHelper::getProgramDuration();
_clickActive = false;
}
if(0)//_clickActive)
{
if(tie->getHand() == _activeHand)
{
if(tie->getButton() == _primaryButton)
{
_activeItem->processEvent(event);
if(tie->getInteraction() == BUTTON_UP)
{
_clickActive = false;
}
return true;
}
}
return false;
}
else if(tie->getHand() == _activeHand)
{
if (tie->getButton() == _primaryButton
&& (tie->getInteraction() == BUTTON_DOWN))
{
_timeLastButtonUp = PluginHelper::getProgramDuration();
_prevEvent = new InteractionEvent();
_prevEvent->setInteraction(event->getInteraction());
_prevActiveItem = _activeItem;
_clickActive = true;
return true;
}
if(tie->getButton() == _primaryButton
&& tie->getInteraction() == BUTTON_DOUBLE_CLICK)
{
// do click
//std::cout << "Double click" << std::endl;
_prevEvent = NULL;
示例4: processEvent
bool SceneObject::processEvent(InteractionEvent * ie)
{
TrackedButtonInteractionEvent * tie = ie->asTrackedButtonEvent();
if(tie)
{
if(_eventActive && _activeHand != tie->getHand())
{
return false;
}
if(_movable && tie->getButton() == _moveButton)
{
if(tie->getInteraction() == BUTTON_DOWN)
{
_lastHandInv = osg::Matrix::inverse(tie->getTransform());
_lastHandMat = tie->getTransform();
_lastobj2world = getObjectToWorldMatrix();
_eventActive = true;
_moving = true;
_activeHand = tie->getHand();
return true;
}
else if(_moving
&& (tie->getInteraction() == BUTTON_DRAG
|| tie->getInteraction() == BUTTON_UP))
{
processMove(tie->getTransform());
if(tie->getInteraction() == BUTTON_UP)
{
_eventActive = false;
_moving = false;
_activeHand = -2;
}
return true;
}
}
if(_contextMenu && tie->getButton() == _menuButton)
{
if(tie->getInteraction() == BUTTON_DOWN)
{
if(!_myMenu->isVisible())
{
_myMenu->setVisible(true);
osg::Vec3 start(0,0,0), end(0,1000,0);
start = start * tie->getTransform();
end = end * tie->getTransform();
osg::Vec3 p1, p2;
bool n1, n2;
float dist = 0;
if(intersects(start,end,p1,n1,p2,n2))
{
float d1 = (p1 - start).length();
if(n1)
{
d1 = -d1;
}
float d2 = (p2 - start).length();
if(n2)
{
d2 = -d2;
}
if(n1)
{
dist = d2;
}
else if(n2)
{
dist = d1;
}
else
{
if(d1 < d2)
{
dist = d1;
}
else
{
dist = d2;
}
}
}
dist = std::min(dist,
SceneManager::instance()->_menuMaxDistance);
dist = std::max(dist,
SceneManager::instance()->_menuMinDistance);
osg::Vec3 menuPoint(0,dist,0);
menuPoint = menuPoint * tie->getTransform();
osg::Vec3 viewerPoint =
TrackingManager::instance()->getHeadMat(0).getTrans();
osg::Vec3 viewerDir = viewerPoint - menuPoint;
viewerDir.z() = 0.0;
//.........这里部分代码省略.........
示例5: processEvent
bool Sketch::processEvent(InteractionEvent * event)
{
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if(!tie)
{
return false;
}
if(tie->getHand() == 0 && tie->getButton() == 0)
{
if(_csCB->getValue())
{
if(_colorSelector->buttonEvent(tie->getInteraction(), tie->getTransform()))
{
_color = _colorSelector->getColor();
if(_activeObject)
{
_activeObject->setColor(_color);
}
return true;
}
}
if(_activeObject)
{
bool ret = _activeObject->buttonEvent(tie->getInteraction(), tie->getTransform());
if(_activeObject->isDone())
{
finishGeometry();
createGeometry();
}
return ret;
}
}
/*if(hand == 0 && button == 0 && type == BUTTON_DOWN && _mode >= 0)
{
//std::cerr << "Start drawing." << std::endl;
if(_mode == RIBBON)
{
_verts = new Vec3Array(0);
_colors = new Vec4Array(1);
_normals = new Vec3Array(0);
_primitive = new DrawArrays(PrimitiveSet::TRIANGLE_STRIP, 0, 0);
_currentGeometry = new osg::Geometry();
(*_colors)[0] = _color;
_currentGeometry->setVertexArray(_verts);
_currentGeometry->setColorArray(_colors);
_currentGeometry->setNormalArray(_normals);
_currentGeometry->setNormalBinding(Geometry::BIND_PER_VERTEX);
_currentGeometry->setColorBinding(Geometry::BIND_OVERALL);
_currentGeometry->setUseDisplayList(false);
//_currentGeometry->setUseVertexBufferObjects(true);
_currentGeometry->addPrimitiveSet(_primitive);
_sketchGeode->addDrawable(_currentGeometry);
MyComputeBounds * mcb = new MyComputeBounds();
_currentBound = &mcb->_bound;
_currentGeometry->setComputeBoundingBoxCallback(mcb);
osg::Vec3 point(-50.0 * _sizeRV->getValue(), _pointerDistance, 0);
point = point * mat * PluginHelper::getWorldToObjectTransform();
_verts->push_back(point);
_normals->push_back(osg::Vec3(0,0,1));
_currentBound->expandBy(point);
point = osg::Vec3(50.0 * _sizeRV->getValue(), _pointerDistance, 0);
point = point * mat * PluginHelper::getWorldToObjectTransform();
_verts->push_back(point);
_normals->push_back(osg::Vec3(0,0,1));
_currentBound->expandBy(point);
_lastTransform = mat * PluginHelper::getWorldToObjectTransform();
_count = 2;
_primitive->setCount(_count);
_currentGeometry->dirtyBound();
_drawing = true;
}
else if(_mode == LINE)
{
if(_lt == LINE_NONE)
{
//std::cerr << "LINE_NONE" << std::endl;
return false;
}
if(!_drawing)
{
//std::cerr << "Starting Line." << std::endl;
_verts = new Vec3Array(0);
_colors = new Vec4Array(1);
_primitive = new DrawArrays(PrimitiveSet::LINE_STRIP, 0, 0);
//.........这里部分代码省略.........
示例6: processEvent
//.........这里部分代码省略.........
if (_runningTrial)
{
std::cout << "Stopping trial." << std::endl;
_runningTrial = false;
_resetTime = true;
}
else
{
std::cout << "Starting trial." << std::endl;
_runningTrial = true;
}
}
else if (kie->getInteraction() == KEY_UP && kie->getKey() == 'l')
{
std::cout << "Loading geometry." << std::endl;
load(_trials[_currentTrial].width, _trials[_currentTrial].height);
}
else if (kie->getInteraction() == KEY_UP && kie->getKey() == 'h')
{
std::cout << "Welcome to WaterMaze!\n" <<
"l - load geometry\n" <<
"n - next trial\n" <<
"r - repeat trial\n" <<
"b - back to previous trial\n" <<
"p - play/pause\n" <<
"h - help\n" <<
"1-9 - reset position" << std::endl;
}
else if (kie->getInteraction() == KEY_UP && kie->getKey() == '1')
{
if (_runningTrial)
{
return true;
}
osg::Matrixd mat;
mat = _tilePositions[0]->getMatrix();
PluginHelper::setObjectMatrix(mat);
}
else if (kie->getInteraction() == KEY_UP && kie->getKey() == '2')
{
if (_runningTrial)
{
return true;
}
osg::Matrixd mat;
mat = _tilePositions[1]->getMatrix();
PluginHelper::setObjectMatrix(mat);
}
else if (kie->getInteraction() == KEY_UP && kie->getKey() == '3')
{
if (_runningTrial)
{
return true;
}
osg::Matrixd mat;
mat = _tilePositions[2]->getMatrix();
PluginHelper::setObjectMatrix(mat);
}
else if (kie->getInteraction() == KEY_UP && kie->getKey() == '4')
{
if (_runningTrial)
{
return true;
}
osg::Matrixd mat;
mat = _tilePositions[3]->getMatrix();
PluginHelper::setObjectMatrix(mat);
}
}
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if (tie)
{
return false;
if(tie->getHand() == 0 && tie->getButton() == 0)
{
if (tie->getInteraction() == BUTTON_DOWN)
{
return true;
}
else if (tie->getInteraction() == BUTTON_DRAG)
{
return true;
}
else if (tie->getInteraction() == BUTTON_UP)
{
return true;
}
return true;
}
}
return true;
}
示例7: processEvent
bool BoardPopupMenu::processEvent(InteractionEvent * event)
{
if(!_menuActive || !_myMenu || !event->asTrackedButtonEvent())
{
return false;
}
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if(_clickActive)
{
if(tie->getHand() == _activeHand)
{
if(tie->getInteraction() == BUTTON_DRAG
|| tie->getInteraction() == BUTTON_UP)
{
if(tie->getButton() == _primaryButton)
{
BoardMenuSubMenuGeometry * smg =
dynamic_cast<BoardMenuSubMenuGeometry *>(_activeItem);
if(smg && smg->isMenuHead())
{
updateMovement(tie);
}
_activeItem->processEvent(event);
if(tie->getInteraction() == BUTTON_UP)
{
_clickActive = false;
}
return true;
}
}
}
return false;
}
else if(tie->getHand() == _activeHand && tie->getButton() == _primaryButton)
{
if(tie->getInteraction() == BUTTON_DOWN
|| tie->getInteraction() == BUTTON_DOUBLE_CLICK)
{
if(_activeItem)
{
BoardMenuSubMenuGeometry * smg =
dynamic_cast<BoardMenuSubMenuGeometry *>(_activeItem);
if(smg && smg->isMenuHead())
{
osg::Vec3 ray;
ray = _currentPoint[tie->getHand()]
- tie->getTransform().getTrans();
if(!tie->asPointerEvent())
{
_moveDistance = ray.length();
}
else
{
_moveDistance = ray.y();
}
_menuPoint = _currentPoint[tie->getHand()]
* osg::Matrix::inverse(_menuRoot->getMatrix());
updateMovement(tie);
}
else if(smg && !smg->isMenuHead())
{
if(smg->isMenuOpen())
{
closeMenu((SubMenu*)smg->getMenuItem());
}
else
{
openMenu(smg);
}
}
_clickActive = true;
_activeItem->processEvent(event);
return true;
}
return false;
}
}
return false;
}
示例8: processEvent
bool FPTiledWallSceneObject::processEvent(InteractionEvent * ie)
{
if(!_tiledWallMovement)
{
return SceneObject::processEvent(ie);
}
TrackedButtonInteractionEvent * tie = ie->asTrackedButtonEvent();
if(tie)
{
if(_eventActive && _activeHand != tie->getHand())
{
return false;
}
if(_movable && tie->getButton() == _moveButton)
{
//sort of a hack, need to find a better way to disable navigation for this object type
if(getNavigationOn())
{
setNavigationOn(false);
}
if(tie->getInteraction() == BUTTON_DOWN || (_moving
&& (tie->getInteraction() == BUTTON_DRAG
|| tie->getInteraction() == BUTTON_UP)))
{
if(tie->getInteraction() == BUTTON_DOWN)
{
osg::Vec3 lineP1,lineP2(0,1000.0,0),planePoint,planeNormal(0,-1,0);
float w;
lineP1 = lineP1 * tie->getTransform() * getWorldToObjectMatrix();
lineP2 = lineP2 * tie->getTransform() * getWorldToObjectMatrix();
linePlaneIntersectionRef(lineP1,lineP2,planePoint,planeNormal,_movePoint,w);
_eventActive = true;
_moving = true;
_activeHand = tie->getHand();
return true;
}
if(!_moving)
{
return false;
}
// top level
if(!_parent)
{
osg::Vec3 wallPoint;
if(SceneManager::instance()->getPointOnTiledWall(tie->getTransform(),wallPoint))
{
osg::Vec3 soPoint = _movePoint * getObjectToWorldMatrix();
osg::Matrix m;
m.makeTranslate(wallPoint - soPoint);
setTransform(getTransform() * m);
}
}
else
{
osg::Vec3 lineP1,lineP2(0,1000.0,0),planePoint,planeNormal(0,-1,0),intersect;
float w;
lineP1 = lineP1 * tie->getTransform() * _parent->getWorldToObjectMatrix();
lineP2 = lineP2 * tie->getTransform() * _parent->getWorldToObjectMatrix();
if(linePlaneIntersectionRef(lineP1,lineP2,planePoint,planeNormal,intersect,w))
{
osg::Vec3 soPoint = _movePoint * getTransform();
osg::Matrix m;
m.makeTranslate(intersect - soPoint);
setTransform(getTransform() * m);
}
}
if(tie->getInteraction() == BUTTON_UP)
{
_eventActive = false;
_moving = false;
_activeHand = -2;
}
return true;
}
}
}
return SceneObject::processEvent(ie);
}