<div dir="ltr"><div><div><div>Hi Can,<br><br></div>Have you posted / published you full example yet? If so could you reply with a link? Thanks in advance.<br><br></div>Best regards,<br></div>John<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 3, 2015 at 4:57 PM, Can Olcek <span dir="ltr"><<a href="mailto:can.olcek@gmail.com" target="_blank">can.olcek@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Sebastian,<br>
<br>
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.<br>
<br>
But for keyboard inputs, I'm using an event filter.<br>
<br>
Something like this:<br>
<br>
<br>
Code:<br>
<br>
<br>
class QInputFilter : public QObject<br>
{<br>
Q_OBJECT<br>
<br>
protected:<br>
bool eventFilter(QObject *obj, QEvent *event);<br>
<br>
void onKeyPress(QKeyEvent *e);<br>
void onKeyRelease(QKeyEvent *e);<br>
};<br>
<br>
bool QInputFilter::eventFilter(QObject *obj, QEvent *event)<br>
{<br>
switch(event->type())<br>
{<br>
case QEvent::KeyPress:<br>
onKeyPress(static_cast<QKeyEvent *>(event));<br>
break;<br>
case QEvent::KeyRelease:<br>
onKeyRelease(static_cast<QKeyEvent *>(event));<br>
break;<br>
}<br>
<br>
return QObject::eventFilter(obj, event);<br>
}<br>
<br>
void QInputFilter::onKeyPress(QKeyEvent *e)<br>
{<br>
if(e->isAutoRepeat())<br>
{<br>
e->ignore();<br>
return;<br>
}<br>
<br>
unsigned int key = e->key();<br>
// add pressed keys and add changed keys for current frame<br>
// renderwidget will clear changed keys at the end of frame<br>
Input::PrivateAccess::pressedKeys().insert(key);<br>
Input::PrivateAccess::changedKeys().insert(key);<br>
<br>
e->accept();<br>
}<br>
<br>
void QInputFilter::onKeyPress(QKeyEvent *e)<br>
{<br>
if(e->isAutoRepeat())<br>
{<br>
e->ignore();<br>
return;<br>
}<br>
<br>
unsigned int key = e->key();<br>
// remove released keys and add changed keys for current frame<br>
// renderwidget will clear changed keys at the end of frame<br>
Input::PrivateAccess::pressedKeys().erase(e->key());<br>
Input::PrivateAccess::changedKeys().insert(e->key());<br>
<br>
e->accept();<br>
}<br>
<br>
<br>
<br>
<br>
<br>
Add input listener to your Qt app:<br>
<br>
<br>
Code:<br>
<br>
<br>
sdt::Author::QInputFilter inputFilter;<br>
app.installEventFilter(&inputFilter);<br>
<br>
<br>
<br>
<br>
<br>
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.<br>
<br>
I can add full implemention of this to my full example.<br>
<br>
Cheers,<br>
Can<br>
<span class=""><br>
------------------<br>
Read this topic online here:<br>
</span><a href="http://forum.openscenegraph.org/viewtopic.php?p=64591#64591" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=64591#64591</a><br>
<span class="im HOEnZb"><br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
<br>
--<br>
</span><div class="HOEnZb"><div class="h5">This email was Anti Virus checked by Astaro Security Gateway. <a href="http://www.sophos.com" rel="noreferrer" target="_blank">http://www.sophos.com</a><br>
<br>
<br>
--<br>
This email was Anti Virus checked by Astaro Security Gateway. <a href="http://www.sophos.com" rel="noreferrer" target="_blank">http://www.sophos.com</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"> <br>
<a href="http://chyronhego.com/press-release/chyronhego-nab-show-2015-product-preview" target="_blank"> </a><a href="http://chyronhego.com/press-release/chyronhego-nab-show-2015-product-preview" target="_blank"><img alt="" src="http://logo.chyronhego.net/IBC-2015.jpg" style="width:350px;height:50px"></a><br>
<br>
<span style="font-family:arial,helvetica,sans-serif"><span style="font-size:11px"><strong>John Vidar Larring</strong> <strong>| <span style="color:rgb(169,169,169)"><em>Senior Developer</em></span></strong><br>
<br>
<strong>ChyronHego Norge AS</strong> <strong>- </strong>Sandakerveien 114a, 0484 Oslo, Norway<br>
Office. +47 2279 7030 - Mobile.+47 4889 9795 - <a href="http://www.chyronhego.com" target="_blank">www.chyronhego.com</a></span></span></div>
</div>