本文整理汇总了C++中osgga::GUIActionAdapter::requestWarpPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ GUIActionAdapter::requestWarpPointer方法的具体用法?C++ GUIActionAdapter::requestWarpPointer怎么用?C++ GUIActionAdapter::requestWarpPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgga::GUIActionAdapter
的用法示例。
在下文中一共展示了GUIActionAdapter::requestWarpPointer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MouseMove
void InputEventHandler::MouseMove(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
int x0 = ea.getXmin();
int y0 = ea.getYmin();
int x1 = ea.getXmax();
int y1 = ea.getYmax();
int centerX = (x0 + x1) / 2;
int centerY = (y0 + y1) / 2;
if (!m_cursorOn) {
if (!((ea.getX() == centerX) && (ea.getY() == centerY))) {
m_mouseX0 = centerX;
m_mouseY0 = centerY;
m_mouseX1 = ea.getX();
m_mouseY1 = ea.getY();
aa.requestWarpPointer (centerX, centerY);
}
} else {
if (m_mouseMoveCount > (m_frameCount - 64)) {
// track mouse inside frame window
m_mouseX0 = m_mouseX1;
m_mouseY0 = m_mouseY1;
m_mouseX1 = ea.getX();
m_mouseY1 = ea.getY();
}
}
m_mouseMoveCount = m_frameCount;
}
示例2: handle
//.........这里部分代码省略.........
osg::Vec3 forward;
osg::Vec3 right;
forward.set(f.x(), -f.z(), -f.y());
right.set(r.x(), -r.z(), -r.y());
//std::cout << forward.x() << ", " << forward.y() << ", " << forward.z() << std::endl;
std::cout << right.x() << ", " << right.y() << ", " << right.z() << std::endl;
/*
osg::Quat xRot;
xRot.makeRotate(-osg::PI_2, osg::X_AXIS);
osg::Quat yRot;
yRot.makeRotate(osg::PI_2, osg::Y_AXIS);
q = q * xRot * yRot;
*/
switch (ea.getEventType())
{
case osgGA::GUIEventAdapter::FRAME:
//std::cout << "FRAME" << std::endl;
t1 = ea.getTime();
if( m_t0 == 0.0 )
{
m_t0 = ea.getTime();
m_dt = 0.0;
}
else
{
m_dt = t1 - m_t0;
m_t0 = t1;
}
if (m_moveForward)
_eye -= forward * 12.0 * m_dt;
if (m_moveBackward)
_eye += forward * 12.0 * m_dt;
if (m_moveLeft)
_eye += right * 12.0 * m_dt;
if (m_moveRight)
_eye -= right * 12.0 * m_dt;
return false;
break;
case osgGA::GUIEventAdapter::KEYDOWN:
switch (ea.getKey())
{
case 'w':
m_moveForward = true;
return false;
break;
case 'a':
m_moveLeft = true;
return false;
break;
case 'd':
m_moveRight = true;
return false;
break;
case 's':
m_moveBackward = true;
return false;
break;
default:
break;
}
this->flushMouseEventStack();
break;
case osgGA::GUIEventAdapter::KEYUP:
switch (ea.getKey())
{
default:
m_moveForward = false;
m_moveBackward = false;
m_moveLeft = false;
m_moveRight = false;
break;
}
this->flushMouseEventStack();
break;
case osgGA::GUIEventAdapter::MOVE:
moved = true;
break;
}
if (!moved)
{
int _mouseCenterX = (ea.getXmin() + ea.getXmax()) / 2.0f;
int _mouseCenterY = (ea.getYmin() + ea.getYmax()) / 2.0f;
aa.requestWarpPointer(_mouseCenterX, _mouseCenterY);
this->flushMouseEventStack();
}
return result;
}
示例3: handle
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
{
if (ea.getEventType() != osgGA::GUIEventAdapter::FRAME) {
std::cout << ea.getTime() << ": ";
switch(ea.getEventType()) {
case osgGA::GUIEventAdapter::PUSH: std::cout << "PUSH"; break;
case osgGA::GUIEventAdapter::DRAG: std::cout << "DRAG"; break;
case osgGA::GUIEventAdapter::MOVE: std::cout << "MOVE"; break;
case osgGA::GUIEventAdapter::RELEASE: std::cout << "RELEASE"; break;
default: std::cout << ea.getEventType();
}
std::cout << std::endl;
}
switch(ea.getEventType())
{
case osgGA::GUIEventAdapter::FRAME:
if (_cleanupOnNextFrame) {
cleanup(0);
_cleanupOnNextFrame = false;
}
break;
case osgGA::GUIEventAdapter::PUSH:
case osgGA::GUIEventAdapter::DRAG:
case osgGA::GUIEventAdapter::RELEASE:
{
// is this a multi-touch event?
if (!ea.isMultiTouchEvent())
return false;
unsigned int j(0);
// iterate over all touch-points and update the geometry
unsigned num_touch_ended(0);
for(osgGA::GUIEventAdapter::TouchData::iterator i = ea.getTouchData()->begin(); i != ea.getTouchData()->end(); ++i, ++j)
{
const osgGA::GUIEventAdapter::TouchData::TouchPoint& tp = (*i);
float x = ea.getTouchPointNormalizedX(j);
float y = ea.getTouchPointNormalizedY(j);
// std::cout << j << ": " << tp.x << "/" << tp.y <<" "<< x << " " << y << " " << _w << " " << _h << std::endl;
_mats[j]->setMatrix(osg::Matrix::translate((1+x) * 0.5 * _w, (1+y) * 0.5 * _h, 0));
_mats[j]->setNodeMask(0xffff);
std::ostringstream ss;
ss << "Touch " << tp.id;
_texts[j]->setText(ss.str());
switch (tp.phase)
{
case osgGA::GUIEventAdapter::TOUCH_BEGAN:
_drawables[j]->setColor(osg::Vec4(0,1,0,1));
break;
case osgGA::GUIEventAdapter::TOUCH_MOVED:
_drawables[j]->setColor(osg::Vec4(1,1,1,1));
break;
case osgGA::GUIEventAdapter::TOUCH_ENDED:
_drawables[j]->setColor(osg::Vec4(1,0,0,1));
++num_touch_ended;
break;
case osgGA::GUIEventAdapter::TOUCH_STATIONERY:
_drawables[j]->setColor(osg::Vec4(0.8,0.8,0.8,1));
break;
default:
break;
}
}
// hide unused geometry
cleanup(j);
//check if all touches ended
if ((ea.getTouchData()->getNumTouchPoints() > 0) && (ea.getTouchData()->getNumTouchPoints() == num_touch_ended))
{
_cleanupOnNextFrame = true;
}
// reposition mouse-pointer
aa.requestWarpPointer((ea.getWindowX() + ea.getWindowWidth()) / 2.0, (ea.getWindowY() + ea.getWindowHeight()) / 2.0);
}
break;
default:
break;
}
return false;
}