本文整理汇总了C++中osgviewer::Viewer::getEventQueue方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewer::getEventQueue方法的具体用法?C++ Viewer::getEventQueue怎么用?C++ Viewer::getEventQueue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgviewer::Viewer
的用法示例。
在下文中一共展示了Viewer::getEventQueue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeEventQueue
void CameraPacket::writeEventQueue(osgViewer::Viewer& viewer)
{
osg::notify(osg::INFO)<<"received events = "<<_events.size()<<std::endl;
// copy the events to osgProducer style events.
viewer.getEventQueue()->appendEvents(_events);
}
示例2: readEventQueue
void CameraPacket::readEventQueue(osgViewer::Viewer& viewer)
{
_events.clear();
viewer.getEventQueue()->copyEvents(_events);
osg::notify(osg::INFO)<<"written events = "<<_events.size()<<std::endl;
}
示例3: readEventQueue
void CameraPacket::readEventQueue(osgViewer::Viewer& viewer)
{
_events.clear();
osgViewer::ViewerBase::Contexts contexts;
viewer.getContexts(contexts);
for(osgViewer::ViewerBase::Contexts::iterator citr =contexts.begin(); citr != contexts.end(); ++citr)
{
osgGA::EventQueue::Events gw_events;
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*citr);
if (gw)
{
gw->checkEvents();
gw->getEventQueue()->copyEvents(gw_events);
}
_events.insert(_events.end(), gw_events.begin(), gw_events.end());
}
viewer.getEventQueue()->copyEvents(_events);
osg::notify(osg::INFO)<<"written events = "<<_events.size()<<std::endl;
}
示例4: update
void SDLIntegration::update(osgViewer::Viewer& viewer)
{
if (_joystick)
{
ValueList newAxisValues;
ValueList newButtonValues;
capture(newAxisValues, newButtonValues);
unsigned int mouseXaxis = 0;
unsigned int mouseYaxis = 1;
float prev_mx = (float)_axisValues[mouseXaxis]/32767.0f;
float prev_my = -(float)_axisValues[mouseYaxis]/32767.0f;
float mx = (float)newAxisValues[mouseXaxis]/32767.0f;
float my = -(float)newAxisValues[mouseYaxis]/32767.0f;
osgGA::EventQueue* eq = viewer.getEventQueue();
double time = eq ? eq->getTime() : 0.0;
osgGA::GUIEventAdapter* previous_event = eq->getCurrentEventState();
float projected_mx = previous_event->getXmin() + (mx+1.0)*0.5*(previous_event->getXmax()-previous_event->getXmin());
float projected_my = previous_event->getYmin() + (my+1.0)*0.5*(previous_event->getYmax()-previous_event->getYmin());
if (mx!=prev_mx || my!=prev_my)
{
eq->mouseMotion(projected_mx, projected_my, time);
}
if (_verbose)
{
for(int ai=0; ai<_numAxes; ++ai)
{
if (newAxisValues[ai]!=_axisValues[ai])
{
std::cout<<"axis "<<ai<<" moved to "<<newAxisValues[ai]<<std::endl;
}
}
}
for(int bi=0; bi<_numButtons; ++bi)
{
if (newButtonValues[bi]!=_buttonValues[bi])
{
if (_verbose)
{
std::cout<<"button "<<bi<<" changed to "<<newButtonValues[bi]<<std::endl;
}
int key = getKeyMapping(bi);
int mouseButton = getMouseButtonMapping(bi);
if (mouseButton>0)
{
if (newButtonValues[bi]==0) eq->mouseButtonRelease(projected_mx,projected_my,mouseButton,time);
else eq->mouseButtonPress(projected_mx,projected_my,mouseButton,time);
}
else if (key>0)
{
if (newButtonValues[bi]==0) eq->keyRelease(key,time);
else eq->keyPress(key,time);
}
}
}
_axisValues.swap(newAxisValues);
_buttonValues.swap(newButtonValues);
}
}