[Interest] Qt3D - Setting the Camera's ViewMatrix Directly

Sean Harmer sh at theharmers.co.uk
Mon Dec 5 19:55:24 CET 2016


Hi,

On 05/12/2016 17:59, Juan Jose Casafranca wrote:
> Just for curiosity, why it is not typed as QCameraLens as that it is the
> "real" camera?

Because QCameraLens is only responsible for the projection matrix part 
of the overall transformation. It only cares about field of view, aspect 
ratio etc.

The other part, the view matrix, comes from the camera's position and 
orientation. That is conveniently provided by the Qt3DCore::QTransform 
component.

QCamera needs both those things and so aggregates both types of component.

Hope this helps,

Sean

>
>
> El 5 dic. 2016 6:34 PM, "Philip Schuchardt" <vpicaver at gmail.com
> <mailto:vpicaver at gmail.com>> escribió:
>
>     Awesome, thanks!
>     On Mon, Dec 5, 2016 at 12:32 PM Sean Harmer <sean.harmer at kdab.com
>     <mailto:sean.harmer at kdab.com>> wrote:
>
>
>
>         On 05/12/2016 16:37, Philip Schuchardt wrote:
>         > Awesome! Thanks! I really like the entity and component system
>         in qt3d!
>         > It just takes time to understand all the components and how
>         they play
>         > together with each other.
>
>         Yeah, it's a little bit of a mental shift from traditional OOP
>         but means
>         we can keep adding more components and aspects without baking many
>         assumptions into the core framework of Qt 3D.
>
>         > If I aggregate the QTransform and QCameraLens
>         > into my own camera code, do I need to subclass framegraph node
>         to select
>         > my custom camera?
>
>         Nope, no need to subclass. The QCameraSelector framegraph node's
>         camera
>         property is intentionally typed as QEntity* for this reason.
>
>         Cheers,
>
>         Sean
>
>         >
>         >
>         > On Mon, Dec 5, 2016 at 3:52 AM Sean Harmer
>         <sean.harmer at kdab.com <mailto:sean.harmer at kdab.com>
>         > <mailto:sean.harmer at kdab.com <mailto:sean.harmer at kdab.com>>>
>         wrote:
>         >
>         >     Hi,
>         >
>         >     I see you found it already but I'll explain for posterity.
>         All Qt 3D
>         >     wants from a "camera" is a view matrix and a projection
>         matrix. These
>         >     come from the QTransform and QCameraLens components
>         respectively, which
>         >     are aggregated by QCamera. QCamera itself is not special,
>         it is just an
>         >     entity with these components and provides some API for common
>         >     operations. If QCamera doesn't suit your needs you can
>         subclass QEntity,
>         >     aggregate these components, plus any others you want
>         (perhaps a light
>         >     source), and add whatever API you like.
>         >
>         >     Cheers,
>         >
>         >     Sean
>         >
>         >     On 04/12/2016 20:49, Philip Schuchardt wrote:
>         >     > Nevermind, I figured it out. The QCamera can be accessed
>         changed
>         >     > directly through QCamera::transform()->setMatrix().
>         >     >
>         >     >
>         >     >
>         >     > On Sun, Dec 4, 2016 at 9:54 AM Philip Schuchardt
>         >     <vpicaver at gmail.com <mailto:vpicaver at gmail.com>
>         <mailto:vpicaver at gmail.com <mailto:vpicaver at gmail.com>>
>         >     > <mailto:vpicaver at gmail.com <mailto:vpicaver at gmail.com>
>         <mailto:vpicaver at gmail.com <mailto:vpicaver at gmail.com>>>> wrote:
>         >     >
>         >     >     In the next step of porting my OpenGL application to
>         Qt3D, I
>         >     trying
>         >     >     to use my existing camera and interaction code. My
>         interaction
>         >     code
>         >     >     creates and manipulates QMatrix4x4's for projection
>         and view
>         >     >     matrixes. It seems like Qt3D's camera doesn't
>         provide direct
>         >     access
>         >     >     of ViewMatrix. My question is how do I set this
>         directly? Can I
>         >     >     subclass QCamera and control it directly? Could I
>         make my code
>         >     >     Camera an entry and not use QCamera? How would Qt3D
>         interpret my
>         >     >     camera as a QCamera and set the necessary uniforms
>         in the shaders.
>         >     >     Also, how would this play with CameraSelector nodes
>         in the
>         >     >     framegraph? Would I have to make a custom CameraSelector
>         >     framegraph
>         >     >     node?  The nice thing about direct control of the
>         ViewMatrix is
>         >     >     there's no mystery about how the math works. Without
>         direct access
>         >     >     to the ViewMatrix, it'll take me a decedent amount
>         to port my
>         >     camera
>         >     >     code...
>         >     >
>         >     >     Also, how do you unproject a point on the screen
>         using the QCamera
>         >     >     and the viewport in Q3D? This is necessary for my
>         interactions to
>         >     >     work correctly.
>         >     >
>         >     >     Thanks,
>         >     >     Phi|ip
>         >     >     --
>         >     >     Phi|ip
>         >     >
>         >     > --
>         >     > Phi|ip
>         >     >
>         >     >
>         >     > _______________________________________________
>         >     > Interest mailing list
>         >     > Interest at qt-project.org <mailto:Interest at qt-project.org>
>         <mailto:Interest at qt-project.org <mailto:Interest at qt-project.org>>
>         >     > http://lists.qt-project.org/mailman/listinfo/interest
>         <http://lists.qt-project.org/mailman/listinfo/interest>
>         >     >
>         >
>         >     --
>         >     Dr Sean Harmer | sean.harmer at kdab.com
>         <mailto:sean.harmer at kdab.com> <mailto:sean.harmer at kdab.com
>         <mailto:sean.harmer at kdab.com>>
>         >     | Managing Director UK
>         >     KDAB (UK) Ltd, a KDAB Group company
>         >     Tel. +44 (0)1625 809908 <tel:+44%201625%20809908>
>         <tel:+44%201625%20809908>; Sweden (HQ)
>         >     +46-563-540090 <tel:+46%20563%2054%2000%2090>
>         <tel:+46%20563%2054%2000%2090>
>         >     Mobile: +44 (0)7545 140604 <tel:+44%207545%20140604>
>         <tel:+44%207545%20140604>
>         >     KDAB - Qt Experts
>         >     _______________________________________________
>         >     Interest mailing list
>         >     Interest at qt-project.org <mailto:Interest at qt-project.org>
>         <mailto:Interest at qt-project.org <mailto:Interest at qt-project.org>>
>         >     http://lists.qt-project.org/mailman/listinfo/interest
>         <http://lists.qt-project.org/mailman/listinfo/interest>
>         >
>         > --
>         > Phi|ip
>
>         --
>         Dr Sean Harmer | sean.harmer at kdab.com
>         <mailto:sean.harmer at kdab.com> | Managing Director UK
>         KDAB (UK) Ltd, a KDAB Group company
>         Tel. +44 (0)1625 809908 <tel:+44%201625%20809908>; Sweden (HQ)
>         +46-563-540090 <tel:+46%20563%2054%2000%2090>
>         Mobile: +44 (0)7545 140604 <tel:+44%207545%20140604>
>         KDAB - Qt Experts
>
>     --
>     Phi|ip
>
>     _______________________________________________
>     Interest mailing list
>     Interest at qt-project.org <mailto:Interest at qt-project.org>
>     http://lists.qt-project.org/mailman/listinfo/interest
>     <http://lists.qt-project.org/mailman/listinfo/interest>
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



More information about the Interest mailing list