[Development] StereoViewport for Qt3D

Svenn-Arne Dragly s at dragly.com
Wed Nov 20 20:52:36 CET 2013


On ma. 18. nov. 2013 kl. 15.59 +0100, Sean Harmer wrote:
> On Sunday 17 November 2013 23:11:32 Svenn-Arne Dragly wrote:
>> On Wed 06 Nov 2013 12:54:07 PM CET, Rutledge Shawn wrote:
>>> On 28 Oct 2013, at 10:35 PM, Svenn-Arne Dragly wrote:
>>>> Secondly, I was missing a stereo option for the default QML Viewport
>>>> element, and decided to have a look at the implementation in QGLView to
>>>> see if I could port that to the QML Viewport element. Luckily this was
>>>> quite easy (thanks to Qt3D being well designed) and I have uploaded the
>>>> resulting StereoViewport element to a GitHub repository:
>>>>
>>>> https://github.com/dragly/stereoviewport
>>>>
>>>> This should compile with Qt5.1.1 and the latest master branch of Qt3D.
>>>
>>> Cool. Are you using it with an Oculus Rift, 3D TV or something else?
>>
>> Both and Oculus Rift and a 3D TV, actually. I have tested the stereo
>> mode where the viewport is split in two thoroughly, with one half of the
>> screen for the left eye and the other for the right. It works quite well
>> and seems to be stable.
>>
>>>> Now, I'm wondering if this feature should be a part of the original
>>>> Viewport element. Should I contribute this into the main Qt3D
>>>> repository? If so, what steps should I take before doing this, apart
>>>> from those listed in the Qt Contributing Guidelines? I'm for instance
>>>> not sure if I might have introduced some bugs or damaged any features of
>>>> the original Viewport element. How should I verify that I haven't
>>>> done so?
>>>
>>> I don't know much about that but I'm sure you will get a reply from
>>> someone who does. But it sounds like a good feature to have.
>>
>> I hope so too, but if I don't hear anything I'll just try pushing it to
>> gerrit and see how it goes.
>
> Apologies, I missed this thread. Yes, please submit the patch to gerrit. We're
> not allowed to accept patches any other way.

No worries - thanks for getting back to me.

I pushed the changes now, hopefully in the right way: 
https://codereview.qt-project.org/#change,71869

I added you (Sean) as a reviewer. I saw that you had been reviewing 
earlier contributions to Qt3D, so I hope that's okay.

Before committing, I realized that I had to update the implementation 
of "picking" in the Viewport class to handle the new stereo mode. I've 
had some issues with picking earlier, and realized, while working on 
this, that the temporary frame buffer used for picking had a size set 
to 8x8 pixels(!). This seems way too little to actually work. So I 
decided to change this to an implementation that renders to a buffer of 
the same size as the current viewport and that uses the same camera, 
which is the way it's done in QGLView. This solved the reliability 
issue and now works for the new stereo mode. If I in any way did 
something bad here, feel free to let me know and I'll try to find a way 
to support picking without changing the frame buffer size.

I also needed some classes from the same directory as qglview.cpp, 
namely QGLDrawBufferSurface and QGLMaskedSurface. These are private, so 
I copied the files into the same directory as viewport.cpp for now, but 
perhaps there is a way I could use them without code duplication?

> I don't have any 3D stereoscopic
> devices to try it on yet so I'll have to take your word for that part.

Setting the eyeSeparation property on the camera to something other 
than 0.0 and the stereoMode property to Viewport.RightLeft on the 
viewport, will let you check that the rendering and picking works even 
though you don't have any 3D stereoscopic devices.

There's also the option of crossing your eyes to get the 3D effect, but 
that can be a quite uncomfortable for longer periods of time.


Best regards,
Svenn-Arne




More information about the Development mailing list