moving camera from FirstPersonManipulator/StandardManipulator without mouse button

12 views
Skip to first unread message

Rodrigo Dias

unread,
May 11, 2020, 3:39:28 AM5/11/20
to OpenSceneGraph Users
I'm trying to adapt camera movement from FirstPersonManipulator or StandardManipulator. I've found an example here and was able to compile it.

However, I can't seem to find how to move the camera when there's no mouse button pressed. How do I do that?

Rodrigo Dias

unread,
May 11, 2020, 12:40:35 PM5/11/20
to OpenSceneGraph Users
Found out!

Just needed to change the performMovement() function of the derived class, and add an extra else in the end:

    if( buttonMask == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON )
    {
        return performMovementLeftMouseButton( eventTimeDelta, dx, dy );
    }
    else if( ( buttonMask == osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON ) ||
             ( buttonMask == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON && modKeyMask & osgGA::GUIEventAdapter::MODKEY_CTRL ) ||
             ( buttonMask == (osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON | osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON) ) )
    {
        return performMovementMiddleMouseButton( eventTimeDelta, dx, dy );
    }
    else if( buttonMask == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON )
    {
        return performMovementRightMouseButton( eventTimeDelta, dx, dy );
    }
    else
    {
        return performMovementLeftMouseButton( eventTimeDelta, dx, dy ); // <-- HERE
    }

Reply all
Reply to author
Forward
0 new messages