本文整理汇总了C++中TrackedButtonInteractionEvent::setInteraction方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackedButtonInteractionEvent::setInteraction方法的具体用法?C++ TrackedButtonInteractionEvent::setInteraction怎么用?C++ TrackedButtonInteractionEvent::setInteraction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrackedButtonInteractionEvent
的用法示例。
在下文中一共展示了TrackedButtonInteractionEvent::setInteraction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateButtonEvents
void TrackingManager::generateButtonEvents()
{
int numEvents;
TrackedButtonInteractionEvent * events = NULL;
if(ComController::instance()->isMaster())
{
std::vector<TrackedButtonInteractionEvent*> eventList;
for(int j = 0; j < _numHands; j++)
{
unsigned int bit = 1;
unsigned int newMask = getHandButtonMask(j);
//std::cerr << "ButtonMask: " << newMask << std::endl;
for(int i = 0; i < _genHandDefaultButtonEvents[j].size(); i++)
{
if(!_genHandDefaultButtonEvents[j][i])
{
bit = bit << 1;
continue;
}
//std::cerr << "last mask " << _lastButtonMask << " new mask " << newMask << " bit: " << bit << " " << (newMask & bit) << " " << (_lastButtonMask & bit) << std::endl;
if(((_lastHandButtonMask[j] & bit) != (newMask & bit))
|| ((_lastHandButtonMask[j] & bit) && (newMask & bit)))
{
//std::cerr << "last mask " << _lastButtonMask << " new mask " << newMask << std::endl;
TrackedButtonInteractionEvent * buttonEvent =
new TrackedButtonInteractionEvent();
if((_lastHandButtonMask[j] & bit) && (newMask & bit))
{
buttonEvent->setInteraction(BUTTON_DRAG);
}
else if(_lastHandButtonMask[j] & bit)
{
buttonEvent->setInteraction(BUTTON_UP);
}
else
{
buttonEvent->setInteraction(BUTTON_DOWN);
}
buttonEvent->setButton(i);
// set current pointer info
buttonEvent->setTransform(_handMatList[j]);
buttonEvent->setHand(j);
eventList.push_back(buttonEvent);
}
bit = bit << 1;
}
_lastHandButtonMask[j] = newMask;
}
numEvents = eventList.size();
ComController::instance()->sendSlaves(&numEvents,sizeof(int));
if(numEvents)
{
events = new TrackedButtonInteractionEvent[numEvents];
for(int i = 0; i < numEvents; i++)
{
events[i] = *eventList[i];
delete eventList[i];
}
ComController::instance()->sendSlaves(events,
numEvents * sizeof(TrackedButtonInteractionEvent));
}
}
else
{
ComController::instance()->readMaster(&numEvents,sizeof(int));
if(numEvents)
{
events = new TrackedButtonInteractionEvent[numEvents];
ComController::instance()->readMaster(events,
numEvents * sizeof(TrackedButtonInteractionEvent));
}
}
TrackedButtonInteractionEvent * ie;
for(int i = 0; i < numEvents; i++)
{
ie = new TrackedButtonInteractionEvent();
*ie = events[i];
InteractionManager::instance()->addEvent(ie);
}
if(events)
{
delete[] events;
}
}
示例2: generateThreadButtonEvents
void TrackingManager::generateThreadButtonEvents()
{
TrackedButtonInteractionEvent * buttonEvent;
for(int j = 0; j < _numHands; j++)
{
unsigned int bit = 1;
unsigned int newMask = _threadHandButtonMasks[j];
//std::cerr << "ButtonMask: " << newMask << std::endl;
for(int i = 0; i < _genHandDefaultButtonEvents[j].size(); i++)
{
if(!_genHandDefaultButtonEvents[j][i])
{
bit = bit << 1;
continue;
}
//std::cerr << "last mask " << _lastButtonMask << " new mask " << newMask << " bit: " << bit << " " << (newMask & bit) << " " << (_lastButtonMask & bit) << std::endl;
if((_threadLastHandButtonMask[j] & bit) != (newMask & bit))
{
buttonEvent = new TrackedButtonInteractionEvent();
//std::cerr << "last mask " << _lastButtonMask << " new mask " << newMask << std::endl;
if(_threadLastHandButtonMask[j] & bit)
{
buttonEvent->setInteraction(BUTTON_UP);
}
else
{
buttonEvent->setInteraction(BUTTON_DOWN);
}
buttonEvent->setButton(i);
// set current pointer info
if(getIsHandThreaded(j))
{
buttonEvent->setTransform(_threadHandMatList[j]);
}
else
{
buttonEvent->setTransform(_handMatList[j]);
}
buttonEvent->setHand(j);
//_threadEvents.push((InteractionEvent*)buttonEvent);
genComTrackEvents->processEvent(buttonEvent);
}
else if((_threadLastHandButtonMask[j] & bit) && (newMask & bit))
{
buttonEvent = new TrackedButtonInteractionEvent();
buttonEvent->setInteraction(BUTTON_DRAG);
buttonEvent->setButton(i);
// set current pointer info
if(getIsHandThreaded(j))
{
buttonEvent->setTransform(_threadHandMatList[j]);
}
else
{
buttonEvent->setTransform(_handMatList[j]);
}
buttonEvent->setHand(j);
//_threadEvents.push((InteractionEvent*)buttonEvent);
genComTrackEvents->processEvent(buttonEvent);
}
bit = bit << 1;
}
_threadLastHandButtonMask[j] = newMask;
}
}
示例3: update
//.........这里部分代码省略.........
for(int i = 0; i < _handButtonList.size(); i++)
{
std::cerr << "Button: " << i << " hand: " << _handButtonList[i].first << " handButton: " << _handButtonList[i].second << " valid: " << _handValidList[i] << std::endl;
}
}
}
_handListInit = true;
}
osg::Matrix m = InteractionManager::instance()->getMouseMat();
osg::Vec3 pos = m.getTrans();
osg::Quat rot = m.getRotate();
_mouseBody.x = pos.x();
_mouseBody.y = pos.y();
_mouseBody.z = pos.z();
_mouseBody.qx = rot.x();
_mouseBody.qy = rot.y();
_mouseBody.qz = rot.z();
_mouseBody.qw = rot.w();
_mouseButtonMask = InteractionManager::instance()->getMouseButtonMask();
int mouseWheel = InteractionManager::instance()->getMouseWheel();
if(mouseWheel > 0)
{
_mouseValuator = 1.0;
}
else if(mouseWheel < 0)
{
_mouseValuator = -1.0;
}
else
{
_mouseValuator = 0.0;
}
if(!_handButtonList.size())
{
return;
}
std::queue<InteractionEvent *,std::list<InteractionEvent *> > tempQueue;
//std::cerr << "Mouse queue size: " << InteractionManager::instance()->_mouseQueue.size() << std::endl;
while(InteractionManager::instance()->_mouseQueue.size())
{
MouseInteractionEvent * mie = dynamic_cast<MouseInteractionEvent*>(InteractionManager::instance()->_mouseQueue.front());
if(!mie)
{
tempQueue.push(InteractionManager::instance()->_mouseQueue.front());
InteractionManager::instance()->_mouseQueue.pop();
continue;
}
InteractionManager::instance()->_mouseQueue.pop();
if(mie->getButton() < 0 || mie->getButton() >= _handButtonList.size() || !_handValidList[mie->getButton()])
{
tempQueue.push(mie);
continue;
}
InteractionEvent * event;
if(TrackingManager::instance()->getHandTrackerType(_handButtonList[mie->getButton()].first) == TrackerBase::MOUSE)
{
mie->setHand(_handButtonList[mie->getButton()].first);
mie->setButton(_handButtonList[mie->getButton()].second);
event = mie;
}
else
{
TrackedButtonInteractionEvent * tie = new TrackedButtonInteractionEvent;
tie->setInteraction(mie->getInteraction());
tie->setHand(_handButtonList[mie->getButton()].first);
tie->setButton(_handButtonList[mie->getButton()].second);
int hsystem, hindex;
TrackingManager::instance()->getHandAddress(_handButtonList[mie->getButton()].first,hsystem,hindex);
if(TrackingManager::instance()->getTrackingSystem(hsystem))
{
TrackerBase::TrackedBody * body = TrackingManager::instance()->getTrackingSystem(hsystem)->getBody(hindex);
tie->setTransform(TrackingManager::instance()->getHandTransformFromTrackedBody(_handButtonList[mie->getButton()].first,body));
}
delete mie;
event = tie;
}
eventMap[event->getEventType()].push_back(event);
}
// put unusable events back in the mouse interaction queue so they will be cleaned up later
while(tempQueue.size())
{
InteractionManager::instance()->_mouseQueue.push(tempQueue.front());
tempQueue.pop();
}
}