[osg-users] VR with OpenSceneGraph

2012-04-03 Thread Chris Blizniak
Hi,

I'm trying to implement VR application where head tracking will be used to 
create the 3D illusion by changing the perspective in 3D scene.

The idea is very similar to the one implemented by Johny Lee in his 'Head 
Tracking for Desktop VR Displays' project using WiiRemote.

The head tracking part works fine, I have got the 3D point corresponding to my 
head's position, the problem is when I move my head in horizontal or vertical 
direction it behaves ok, apart from the fact that objects - in my case cubes, 
are stretched in the z-axis. Secondly when I move my head in the z-axis in 
other words - closer to and further away from the screen I can see the back 
wall of my virtual room moves but the objects seem to be fixed and they do not 
change in size at all when I get closer to the screen.

Below are 3 images:

First one, head is in the original position.

[Image: http://obrazki.elektroda.pl/6286372200_1333477477_thumb.jpg ] 
(http://obrazki.elektroda.pl/6286372200_1333477477.png)

Second one, I moved my head right so I can see more of the left side of the 
room.
[Image: http://obrazki.elektroda.pl/6130984900_1333477478_thumb.jpg ] 
(http://obrazki.elektroda.pl/6130984900_1333477478.png) 

Third one, I moved closer to the screen, but objects did not change their sizes 
but the back wall is closer now.

[Image: http://obrazki.elektroda.pl/1229996500_1333477477_thumb.jpg ] 
(http://obrazki.elektroda.pl/1229996500_1333477477.png)

I'm using the following code to render my scene:

Code:

...
float nearPlane = 0.0f;
float farPlane = 20.0f;
mOsgViewer.getCamera()-setProjectionMatrixAsFrustum(
-0.5 + x,
0.5 + x,
-0.5 + y,
0.5 + y,
nearPlane - z, farPlane);

osg::Matrixd cameraTrans;
cameraTrans.makeTranslate(x, y, z);
mOsgViewer.getCamera()-setViewMatrix(cameraTrans);
mOsgViewer.frame();
...




I've created a widget in Qt which inherits from QGLWidget, to render my OSG 
scene. I added all cubes and room inside the constructor and in paintGL() I'm 
setting up glFrustum using the above code.

I'm not using any camera manipulators.

Is anyone familiar with VR displays. What should be the behaviour of a 3D scene 
rendered in such a way?

I'm not sure if I'm doing this the right way.
There are numerous projects using OpenGL and where glFrustum is set in the same 
way and then the head's movement is compensated with glTranslate.

I will be very happy if someone could give me some hints as I think I'm doing 
something wrong.

Thank you!

Cheers,
Chris
Code:




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





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


Re: [osg-users] Strange results from osgviewer

2012-02-23 Thread Chris Blizniak
Hi,

Robert, thank you for your suggestions. I used the svn version and there is no 
difference. Now, when I can add some images to my post I included a screen-shot 
of 'osgviewerQt', when the two 3D models are not displayed correctly, these are 
'cow' and 'dumptruck', left top and right top windows respectively. 

[Image: http://obrazki.elektroda.pl/2590187500_1329991217_thumb.jpg ] 
(http://obrazki.elektroda.pl/2590187500_1329991217.png)

Secondly, after building OSG last night, I have noticed that now I cannot even 
run the examples showing use of textures, I have problem with
'osgtexture2d.exe' - this one crashes, 'osgtexture3d.exe' is fine but it 
doesn't display the texture, it says only that it could not open files.

What is the difference between 3d model of 'cessna' and 'cow', why only one of 
them is displayed ok.

Thank you!

Cheers,
Chris

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





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


Re: [osg-users] Strange results from osgviewer

2012-02-23 Thread Chris Blizniak
Hi,

I tried to convert cow.osg and cow.osgt to .osgt, .osg, and .osgb all possible 
combinations. Using osgviewer, the results are the same. The 3D model is loaded 
only with few vertices, exactly the same as on the screen-shot above.

In terms of the hardware - I'm using a laptop, not too old, and the only 
problem is the Intel's integrated graphics card. To be honest I had a problem 
with video streaming in Qt when I used openGL to display video frames, it was 
incredibly slow. 

Anyway, I think I will stop here as I need to move on with my work. 
Textures work fine in few cases, I can load some simple objects, therefore it 
should be enough. I am not planning to do anything huge at the moment so the 
current setup should be enough. I have different problem but I will post that 
as a new post as it is not related to this one.

Thank you for your time. 


Cheers,
Chris

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





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


[osg-users] Fishtank VR project

2012-02-23 Thread Chris Blizniak
Hi,

I'm trying to implement something similar to:

http://linuxtoosx.blogspot.com/2010/06/fishtank-vr-project-with-opencv-and_30.html

When I'm doing that using OpenGL only, I'm getting satisfactory results.
The code is exactly the same as the one suggested on the website,

Code:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-0.5 + x, 0.5 + x, -0.5 + y, 0.5 + y, nearPlane - z, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(x, y, z);



But when I try to achieve the same result in OSG, the output is not exactly the 
same, currently I'm using the following code:

Code:
osgViewer.getCamera()-setProjectionMatrixAsFrustum(-0.5 + x, 0.5 + x, -0.5 + 
y, 0.5 + y, nearPlane - z, 100.0);
osg::Matrixd cameraTrans;
cameraTrans.makeTranslate(x, y, z);
osgViewer.getCamera()-setViewMatrix(cameraTrans);




Is that equivalent to the OpenGL implementation? Or am I missing something? 


Thank you!

Cheers,
Chris[/url]

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





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


Re: [osg-users] setViewMatrixAsLookAt in Qt

2012-02-23 Thread Chris Blizniak
Hi,

Thanks for your reply Tom, I changed few things in my code, and I'm no longer 
using osgviewerQt. I tried different approach, much simpler - something similar 
to:
https://gitorious.org/mahjong-night/mahjong-night/blobs/master/mahjong-night/client/tablewidget.cpp

Using slots and signals was pretty straight forward in this case.

Thank you!

Cheers,
Chris

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





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


Re: [osg-users] Fishtank VR project

2012-02-23 Thread Chris Blizniak
Hi,

I derived a widget in Qt from QGLWidget, based on the code presented here:
https://gitorious.org/mahjong-night/mahjong-night/blobs/master/mahjong-night/client/tablewidget.cpp
  

initializeGL(), resizeGL() and paintGL() are exactly the same,
I removed everything else to have just basic functionality where I load a 
'cessna' model. That worked fine, then I replaced 'cessna' model with four 
quads - creating four walls of the room (left, right, top, bottom) and using 
viewer.getCamera()-setViewMatrixAsLookAt() everything was ok.
When I added:

Code:
osgViewer.getCamera()-setProjectionMatrixAsFrustum(-0.5 + x, 0.5 + x, -0.5 + 
y, 0.5 + y, nearPlane - z, 100.0); 
osg::Matrixd cameraTrans; 
cameraTrans.makeTranslate(x, y, z);

 
in paintGL() just before viewer.frame(), I can zoom in and zoom out and move 
the viewpoint left-right, top-bottom but the result is not even close to the 
one I achieved using only openGL.

Thank you!

Cheers,
Chris

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





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


Re: [osg-users] Strange results from osgviewer

2012-02-22 Thread Chris Blizniak
Hi,

The version of OSG I'm currently using is 3.0.1.
I tried both source code and binaries, the same problems in both cases.

Apart from the issue with displaying some of the 3D models I have noticed that 
I cannot see any textures I use them in my program. Even the examples provided 
with OSG do not display any textures. 

Is it required to have dependencies like 'libpng' and 'libz' etc. present in 
the system before building OSG?

Because this is the only thing I missed when I was setting up OSG on my 
computer.


Thank you!

Cheers,
Chris

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





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


[osg-users] Strange results from osgviewer

2012-02-21 Thread Chris Blizniak
Hi,

I've got a strange problem.
By running osgviewer.exe dumptruck.osgt. The 3D model is not displayed 
properly. The problem exists with the following models: cow, dumptruck, 
cessnafire... I haven't tested more. There are no problems with displaying 
cessna.osg or robot.osg. 

I cannot post a screenshot yet, as I need to have at least two posts.
The result from osgviewer is quite strange and it looks like only certain 
number of vertices has been loaded. It simply doesn't display a whole mesh but 
only few lines.

Thank you!

Cheers,
chris

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





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


[osg-users] setViewMatrixAsLookAt in Qt

2012-02-21 Thread Chris Blizniak
Hi,

I would like to ask if there is an easy way of setting position and orientation 
of view matrix.
Currently I've got simple project in VS2010, using 'osgViewerQt.cpp' file, I 
disabled the camera manipulator and I am trying to control the camera using 
setViewMatrixAsLookAt() function, the problem is that I am not sure how to 
update that in real time. 
The idea is simple, I want to add three sliders to my main window where the osg 
widget is present, currently with the cessna.osgt model, and by adjusting 
sliders I want to change, X, Y, Z coordinates corresponding to the position of 
the camera. I tried signals and slots, but that did not work as I would expect. 
Any suggestions are more than welcome.

Thank you in advance!

Chris

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





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