Re: [osg-users] QOpenGLWidget in osgQt

2017-03-09 Thread Pierre-Jean Petitprez
Hi Glenn and others,

A fellow OSG user once posted a hack to get OSG FBO working nicely with 
QOpenGLWidget. I have used it myself and it works as intended, though it is not 
a really "clean" solution as it involves overriding some OSG classes's 
behaviour.
More info in the related thread: 
http://forum.openscenegraph.org/viewtopic.php?t=15097

Maybe that helps,

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70459#70459





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Android third party dependencies link is dead

2016-09-09 Thread Pierre-Jean Petitprez

Hi dear OSG users,

The link to the third party dependencies that were available for Android 
(see the bottom of this page 
http://www.openscenegraph.org/index.php/documentation/platform-specifics/android/44-building-openscenegraph-for-android-3-0-3-0-1) 
is unfortunately currently dead.
I personaly have them (downloaded before the link went dead) but is 
there by any chance a possibility to reupload them on an official OSG 
repository so that the official documentation can be updated with a 
working link?


By the way for those who would need them I have uploaded them on my 
personal Dropbox (meaning the link might become dead one day or another) :

https://www.dropbox.com/s/5wmax2ns4f5x2ib/3rdpartyAndroid.zip?dl=0

Thank you,

Pierre-Jean
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Deleting osg::Image that is shallow copied

2016-08-16 Thread Pierre-Jean Petitprez

Hi Robert and Christian,

Thank you for your answers.  Now I understand why my expectations on 
using the shallow copy were not working.

So I will just share the same osg::Image.
Also thanks for pointing out the allocation mode, it can be very useful 
if I want to manually manage the _data pointer.


Thanks for your help,

Cheers
Pierre-Jean

Le 16/08/2016 à 13:21, Robert Osfield a écrit :

Hi Pierre-Jean,

The osg::Image constructor doesn't support shallow copy for the
internal image data, it will allocated a new image block and copy
across the data.  This means for the image data itself it's effective
a deep copy.

A shallow copy would be technically possible by would force one to
start reference counting the image data.  However, this doesn't make
any sense in the context of an osg::Image, if you want to share the
image data then you should be sharing the osg::Image object not the
internal data it holds.

My recommendation is not to do a shallow copy at all, but just share
the osg::Image.


Robert.

On 16 August 2016 at 10:27, Pierre-Jean Petitprez
<pierre-jean.petitp...@inria.fr> wrote:

Hi,

In my application I have two osg::Images, the second one is a shallow copy of 
the first one thanks to the copy constructor.
Is it safe to delete the first image and keep only the second one, or should I 
use deep copy instead?
My tests showed me that the data is still reachable but when looking at the 
image destructor it clearly deallocates the data.

Thanks for enlightening me,

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68380#68380





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Deleting osg::Image that is shallow copied

2016-08-16 Thread Pierre-Jean Petitprez

Hi Sebastian,

What do you mean by "reachable"? Deallocation doesn't mean the memory 
is cleaned or something. So having a raw pointer to the deallocated 
memory might give you the same data as long as no one is allocating 
memory there.


I mean that after the first image is deleted, I still can use and 
perform operations on the data through the second image. To rewrite my 
question, I would like to know if data in an image is deallocated (and 
so it is not safe to perform operations on it through the second image) 
when it's shallow copied. I guess it is but I am not 100% sure.


Thank you,

Pierre-Jean

Cheers
Sebastian


Thanks for enlightening me,

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68380#68380





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 




___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Deleting osg::Image that is shallow copied

2016-08-16 Thread Pierre-Jean Petitprez
Hi,

In my application I have two osg::Images, the second one is a shallow copy of 
the first one thanks to the copy constructor.
Is it safe to delete the first image and keep only the second one, or should I 
use deep copy instead? 
My tests showed me that the data is still reachable but when looking at the 
image destructor it clearly deallocates the data.

Thanks for enlightening me,

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68380#68380





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] osgShadow with GLES

2016-07-04 Thread Pierre-Jean Petitprez
Hi,

I would like to use the osgShadow soft shadow map on an Android device (with 
GLES 2).
I have already written my own Phong shader for my objects which works very 
well. Now I would like to add the shadow map. I have taken the shader code from 
the SoftShadowMap.cpp file and I have adapted it to add it in my own shader.
But this does not seem to work, the applied shadow map is always fully white.

Maybe this has to do with the texture coordinates that are used.

Can someone enlighten me on using osgShadow with GLES 2 ?

Thank you!

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=67987#67987





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Shadow projected on the opposite side too

2016-04-28 Thread Pierre-Jean Petitprez

Hi Robert,

Sorry for the missing information. I use SoftShadow technique, but 
tested with other techniques and they always produce the same effect.
And indeed I have a second light which is linked to the camera (moves 
with the camera). I totaly forgot this light and I think it does not 
work well with osgShadow which can manage only one shadow caster light.


Cheers,
Pierre-Jean.

Le 28/04/2016 15:40, Robert Osfield a écrit :

Hi Pierre,

I think there is probably a couple of issues.

You don't say which osgShadow::ShadowTechnique you use, it may well be 
you've picked a very simple one that isn't capable of handling this 
type of geometry combination.


Second, shadows on back faces should be the same colour as the back 
face because essentially there are same thing - a face without any 
direct lighting.  The lighting model for you data is clearly not 
coherent between the shadow and the back face.  I don't know how 
you've set up your lighting but clearly something is amiss here.  Are 
you using a different light sources?  Do you have ambient lighting 
different between the shadow and box rendering?


Robert.



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Shadow projected on the opposite side too

2016-04-28 Thread Pierre-Jean Petitprez

Hi Sebastian and Christian,
Thanks for your answers.

This might have to do with wrong culling mode or geometry for the 
shadowmap-generation. The culling mode should be front-face and your 
geometry should be correct (e.g. if you do front-face culling you 
should have some "inner" sides to contribute to depth.Can you tell us 
what GPU you are on, and what geometry is showing this problem?


For the geometry, it's a simple osg::Box in my example, but it does the 
same with all models that I tried (.obj objects generally).
I am on Nvidia Quadro FX 580. I have no problems using culling modes and 
everything related to face culling works as expected, that's why I 
thought it was in the osgShadow implementation.


Cheers,


Le 28/04/2016 14:50, Sebastian Messerschmidt a écrit :

Hi Pierre-Jean.

This might have to do with wrong culling mode or geometry for the 
shadowmap-generation. The culling mode should be front-face and your 
geometry should be correct (e.g. if you do front-face culling you 
should have some "inner" sides to contribute to depth.
Can you tell us what GPU you are on, and what geometry is showing this 
problem?


Cheers
Sebastian



Hi dear OSG users,

I'm wondering how to correctly use osgShadow. As you can see on the 
file I have attached, the shadow map is projected on the receiving 
object also on a face which should normaly not receive the shadow 
from the sphere (on my example the light is at the top right corner). 
It behaves like if the top face did not stop the light to continue 
its path through the object (which is not transparent).
My example is with soft shadow but I tested with other techniques and 
it is the same behaviour.


Is there a way to avoid such behaviour with osgShadow ?
Thank you.

Cheers,
Pierre-Jean


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Shadow projected on the opposite side too

2016-04-28 Thread Pierre-Jean Petitprez

Hi dear OSG users,

I'm wondering how to correctly use osgShadow. As you can see on the file 
I have attached, the shadow map is projected on the receiving object 
also on a face which should normaly not receive the shadow from the 
sphere (on my example the light is at the top right corner). It behaves 
like if the top face did not stop the light to continue its path through 
the object (which is not transparent).
My example is with soft shadow but I tested with other techniques and it 
is the same behaviour.


Is there a way to avoid such behaviour with osgShadow ?
Thank you.

Cheers,
Pierre-Jean
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG 3.2.1 and Qt5 Widget integration

2016-03-04 Thread Pierre-Jean Petitprez
Hi Wojtek,

When using this code I get the same result as you, the StatsHandler camera 
doesn't display on top of the other cameras. I guess it comes from the hack 
that makes the main camera render last or something like that. My hack was to 
add the StatsHandler camera into my own scene graph so that it will be rendered 
in the correct order.
I've inherited from the osgViewer::Viewer and reimplemented the addEventHandler 
method:

Code:
void addEventHandler(osgGA::GUIEventHandler *eventHandler)
{
osgViewer::Viewer::addEventHandler(eventHandler);

osgViewer::StatsHandler *stats = 
dynamic_cast(eventHandler);
if(stats)
{
osg::Camera* camera = stats->getCamera();
getSceneData()->asGroup()->addChild(camera);
}
}



It's ugly but at least I get the statsHandler back.
If anyone has a better solution, I'd be happy to see it.

I hope it'll work for you.
Cheers, 
Pierre-Jean


karcios wrote:
> Hi,
> 
> After changing 
> 
> Code:
> 
> void RenderStageEx::drawInner(osg::RenderInfo& renderInfo, 
> osgUtil::RenderLeaf*& previous, bool& doCopyTexture)
> 
> 
> 
> 
> I lost 's' key  - stats handler stopped working,
> looks like problem with another camera.
> 
> Any help?
> 
> Cheers,
> Wojtek


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66485#66485





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Custom shader not working on Mac OS

2016-02-19 Thread Pierre-Jean Petitprez

Hi Sebastian,

setUseVertexAttributeAliasing should be active, when you are using 
osg_Vertex etc.
It might be, that the driver on your first machine simply assigns the 
"in-slot" accidentally to the correct input.

Are there any outputs on the console?
My mistake, my shader should obviously use gl_Vertex, and not 
osg_Vertex. I failed a copy/paste and did not double-checked.
But to answer your question, there is no console output at all (no 
warnings or fails) related to the shaders, even with osg::setNotifyLevel 
set to most verbose option.
I will check my shader as soon as I can but I'm almost sure the problem 
was from this gl_Vertex mistake.


Thank you,
Pierre-Jean




If this is not working two hints:
1. #pragma version 150 compatibility
The version is epxected to be the first line in any shader.
2.Use gl_ instead on osg_ attributes and uniforms for testing fixed 
function.





I saw a strange thing in the log : on Mac gl_MultiTexCoord0 is 
converted to  osg_MultiTexCoord0 even if 
setUseVertexAttributeAliasing is set to false. On Linux

gl_MultiTexCoord0 is not converted and is keeped.
By the way if I set setUseVertexAttributeAliasing to true and replace 
gl_MultiTexCoord0 by osg_MultiTexCoord0, my model is properly visible 
(but I don't want that because I lose fixed pipeline functions).
Cannot say anything on the first issue, but you are not "loosing" any 
functionality by using the aliasing. OSG will simply replace gl_ names 
with its osg_ aliases when uploading the shader to the driver. All 
other functions will still work as expected.


Has anybody an idea of where this behavior comes from ?
As I said,  drivers will do stuff behind your back. So a shader with 
obvious errors might run one machine while failing on another.


Cheers
Sebastian


Thank you!

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66344#66344





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Custom shader not working on Mac OS

2016-02-18 Thread Pierre-Jean Petitprez
Hi,

I try to port my app from Linux to Mac OS (El Capitan) using OSG 3.2.
I wrote a simple system of shaders to apply a texture on a model:

Vertex shader :

Code:

attribute vec4 osg_Vertex;
uniform mat4 osg_ModelViewProjectionMatrix;
varying vec4 texCoord0;

void main(void)
{
gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
texCoord0 = gl_MultiTexCoord0;
}



Fragment shader :

Code:

uniform sampler2D tex;
varying vec4 texCoord0;

void main(void)
{
gl_FragColor = texture2D(tex, texCoord0.st);
}




While it works as expected on Linux, on Mac my model is not displayed at all (I 
only see the default blue background). There is no error from the shader 
compilation.
I use
viewer->getCamera()->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(true);
 to get the osg_* variables, and also
viewer->getCamera()->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(false);
 
to keep the fixed pipeline possibilities (for other models in my scene).

I saw a strange thing in the log : on Mac gl_MultiTexCoord0 is converted to  
osg_MultiTexCoord0 even if setUseVertexAttributeAliasing is set to false. On 
Linux 
gl_MultiTexCoord0 is not converted and is keeped. 
By the way if I set setUseVertexAttributeAliasing to true and replace 
gl_MultiTexCoord0 by osg_MultiTexCoord0, my model is properly visible (but I 
don't want that because I lose fixed pipeline functions).

Has anybody an idea of where this behavior comes from ?

Thank you!

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66344#66344





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osg_MultiTexCoord0 on OpenGL 2 vs GLES2

2016-02-10 Thread Pierre-Jean Petitprez

Hi Sebastian,

Thank you. It works as expected. I was wondering what this method was 
doing, its name was not really helping me when I saw it while doing some 
research.


Thanks,

cheers,
Pierre-Jean
Le 10/02/2016 10:06, Sebastian Messerschmidt a écrit :

Hi Pierre,

In order to use the osg_XXX replacements outside of GLES/GL3 
etc.-builds you need to inform the viewer to supply them:


...
viewer->getCamera()->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(true); 
//you're doing this already
viewer->getCamera()->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(true); 



cheers
Sebastian

Hi,

I am working on an application that has to work both on regular 
Ubuntu environment and on Android. So I have written a couple of 
shaders in order to comply with GLES2 specs.
The problem is, with regular OpenGL profile on Ubuntu, the same 
shader is not working properly: the osg_MultiTexCoord0 seems to not 
be working, while gl_MultiTexCoord0 works (but obviously noton GLES2 
of course).


Here is my vertex shader:

Code:

attribute vec4 osg_Vertex;
uniform mat4 osg_ModelViewProjectionMatrix;
attribute vec4 osg_MultiTexCoord0;
varying vec4 texCoord;

void main(void) {
gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
texCoord = osg_MultiTexCoord0;
}




The fragment shader is just applying the texture thanks to the 
texCoord variable.


So on GLES2 this vertex shader works properly, but on OpenGL 2 I have 
to replace osg_MultiTexCoord0 by the old gl_MultiTexCoord0 in order 
to make it work.


I have tried with OSG 3.2 (as apt packages on Ubuntu), 3.4 and 3.5 as 
sources, and I always get the same results.
I have applied setUseModelViewAndProjectionUniforms(true) on my 
graphics context state to enable osg_* matrices.  Is there a 
possibility to also enable other osg_* variables ?


Thank you!

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66255#66255





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] osg_MultiTexCoord0 on OpenGL 2 vs GLES2

2016-02-10 Thread Pierre-Jean Petitprez
Hi,

I am working on an application that has to work both on regular Ubuntu 
environment and on Android. So I have written a couple of shaders in order to 
comply with GLES2 specs.
The problem is, with regular OpenGL profile on Ubuntu, the same shader is not 
working properly: the osg_MultiTexCoord0 seems to not be working, while 
gl_MultiTexCoord0 works (but obviously noton GLES2 of course).

Here is my vertex shader:

Code:

attribute vec4 osg_Vertex;
uniform mat4 osg_ModelViewProjectionMatrix;
attribute vec4 osg_MultiTexCoord0;
varying vec4 texCoord;

void main(void) {
gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
texCoord = osg_MultiTexCoord0;
}




The fragment shader is just applying the texture thanks to the texCoord 
variable.

So on GLES2 this vertex shader works properly, but on OpenGL 2  I have to 
replace osg_MultiTexCoord0 by the old gl_MultiTexCoord0 in order to make it 
work.

I have tried with OSG 3.2 (as apt packages on Ubuntu), 3.4 and 3.5 as sources, 
and I always get the same results.
I have applied setUseModelViewAndProjectionUniforms(true) on my graphics 
context state to enable osg_* matrices.  Is there a possibility to also enable 
other osg_* variables ?

Thank you!

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66255#66255





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Compute occluding transparent objects

2015-11-25 Thread Pierre-Jean Petitprez
Hi Jannik,

Thank you very much. This is exactly what I was looking for.
For some reason I thought that only "RenderBin" and "DepthSortedBin" were 
possible, and I didn't find the right lines in the source code.

Thanks for your help !

Cheers,
Pierre-Jean


scrawl wrote:
> Hi Pierre-Jean,
> 
> put your objects in the SORT_FRONT_TO_BACK render bin.
> 
> stateset->setRenderBinDetails(binNumber, "SORT_FRONT_TO_BACK"); 
> 
> Ensure that this particular binNumber is only used for objects you want 
> sorted front to back, so that the render bin can be created correctly.
> 
> The render bin prototypes provided by default in OSG are documented here: 
> https://github.com/openscenegraph/osg/blob/master/src/osgUtil/RenderBin.cpp#L35
> 
> Cheers,
> Jannik


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65766#65766





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Compute occluding transparent objects

2015-11-24 Thread Pierre-Jean Petitprez
Hi,

I need to render transparent objects in my scene. But they need to be sorted 
front-to-back (like if they were not transparent) and not back-to-front like 
it's done when using the depthSortedBin render hint.
The reason I need to do that (I know it sounds stupid) is because I want to 
have my "transparent" objects occlude the other "transparent" objects that are 
behind them. That way, we should only see the closest transparent object and 
not the other objects that are behind it.

Is there a way to force front-to-back rendering on transparent bin ?

Thank you!

Cheers,
Pierre-Jean[/code]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65762#65762





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] osgShadow: shadow is seen on the opposite side of the model too

2015-11-17 Thread Pierre-Jean Petitprez
Hi,

I am using osgShadow for adding soft shadows to my scene. My scene has a big 
cube that receives shadows and some small objects above it that cast shadows. 
My light is placed above all the objects.
The big cube receives correctly the shadows on its top face (perfectly as it 
should be), but also on its bottom face, as if the cube's top face was 
transparent. But in the real world it would never happen, as the top face 
should stop the light rays to reach the bottom face...

Please see the attached file to understand what I mean.

This problem also appears in the osgshadow example (I have added a box in the 
scene with the cessnas and I see the same thing) and with every shadow 
technique, so I guess it is in osgShadow's implementation.

How can I do to avoid the shadows to be seen on the opposite faces of the 
receivers ?
Thank you.

Cheers,
Pierre-Jean

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65654#65654




Attachments: 
http://forum.openscenegraph.org//files/shadows_969.png


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG 3.2.1 and Qt5 Widget integration

2015-08-03 Thread Pierre-Jean Petitprez

Hi Sebastian,

I use Qt 5 and OSG 3.2.1 with no problem passing the key events from Qt 
to OSG.


In your Qt widget subclass you'll have a method which gets the key events:
void keyPressEvent(QKeyEvent* e)
{
const char *keyData = e-text().toLatin1().data();
gw-getEventQueue()-keyPress(osgGA::GUIEventAdapter::KeySymbol(*keyData));
}
provided that gw is your osgViewer::GraphicsWindow.

Note that for the meta keys (like ALT, CTRL, SHIFT), you'll have to 
check something like:

 switch(e-key())
{
case Qt::Key_Shift:
key = osgGA::GUIEventAdapter::KEY_Shift_L; //left key is chosen 
in an arbitrary way since Qt doesn't differ left or right

break;
case Qt::Key_Control :
key = osgGA::GUIEventAdapter::KEY_Control_L;
break;
case Qt::Key_Alt :
key = osgGA::GUIEventAdapter::KEY_Alt_L;
break;
}
since there is no value in e-text().

And the same can be achieved for the keyReleaseEvent, 
mousePress/ReleaseEvent, etc. by creating a new GUIEventAdapter from the 
Qt event and then send it to the event queue.


Hope that helps.

Cheers
Pierre-Jean


Le 03/08/2015 17:01, Sebastian Messerschmidt a écrit :

Am 03.08.2015 um 16:57 schrieb Can Olcek:

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.


Okay, I know how to use EventFilters etc.
The point is, that the qt4 implementation somehow passed the events to 
OSG, while the qt5 seems to fail to pass any keys.


Cheers
Sebastian


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_castQKeyEvent *(event));
   break;
 case QEvent::KeyRelease:
   onKeyRelease(static_castQKeyEvent *(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 



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org