Hi Can, Have you posted / published you full example yet? If so could you reply with a link? Thanks in advance.
Best regards, John On Mon, Aug 3, 2015 at 4:57 PM, Can Olcek <can.ol...@gmail.com> wrote: > Hi Sebastian, > > I have almost completed the example. My original implementation is a > little bit complex than this. Thanks to the couple of private replies and > discussion, I will post it tomorrow. > > But for keyboard inputs, I'm using an event filter. > > Something like this: > > > Code: > > > class QInputFilter : public QObject > { > Q_OBJECT > > protected: > bool eventFilter(QObject *obj, QEvent *event); > > void onKeyPress(QKeyEvent *e); > void onKeyRelease(QKeyEvent *e); > }; > > bool QInputFilter::eventFilter(QObject *obj, QEvent *event) > { > switch(event->type()) > { > case QEvent::KeyPress: > onKeyPress(static_cast<QKeyEvent *>(event)); > break; > case QEvent::KeyRelease: > onKeyRelease(static_cast<QKeyEvent *>(event)); > break; > } > > return QObject::eventFilter(obj, event); > } > > void QInputFilter::onKeyPress(QKeyEvent *e) > { > if(e->isAutoRepeat()) > { > e->ignore(); > return; > } > > unsigned int key = e->key(); > // add pressed keys and add changed keys for current frame > // renderwidget will clear changed keys at the end of frame > Input::PrivateAccess::pressedKeys().insert(key); > Input::PrivateAccess::changedKeys().insert(key); > > e->accept(); > } > > void QInputFilter::onKeyPress(QKeyEvent *e) > { > if(e->isAutoRepeat()) > { > e->ignore(); > return; > } > > unsigned int key = e->key(); > // remove released keys and add changed keys for current frame > // renderwidget will clear changed keys at the end of frame > Input::PrivateAccess::pressedKeys().erase(e->key()); > Input::PrivateAccess::changedKeys().insert(e->key()); > > e->accept(); > } > > > > > > Add input listener to your Qt app: > > > Code: > > > sdt::Author::QInputFilter inputFilter; > app.installEventFilter(&inputFilter); > > > > > > I have almost fully static Input class to access keys and mouse states > during each frame (paintGL()) I've actually tried to implement Unity3D like > approach so inside cull or update traversal I can use Input::getButton(), > Input::getKey(), Input::isKeyUp(), etc. methods. > > I can add full implemention of this to my full example. > > Cheers, > Can > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=64591#64591 > > > > > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- > This email was Anti Virus checked by Astaro Security Gateway. > http://www.sophos.com > > > -- > This email was Anti Virus checked by Astaro Security Gateway. > http://www.sophos.com > -- <http://chyronhego.com/press-release/chyronhego-nab-show-2015-product-preview> <http://chyronhego.com/press-release/chyronhego-nab-show-2015-product-preview> *John Vidar Larring* *| Senior Developer* *ChyronHego Norge AS* *- *Sandakerveien 114a, 0484 Oslo, Norway Office. +47 2279 7030 - Mobile.+47 4889 9795 - www.chyronhego.com
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org