Qt World Summit: Register Today!

Qt3D - How does a camera provide its view matrix

  • Hi everyone,

    I have a question on cameras in Qt3D:

    While Qt3D provides its own QCamera class, it is stated in the documentation of the QForwardRenderer class that

    Note: A camera is a QEntity that has a QCameraLens as one of its components.

    (The fact that the camera property of the QForwardRenderer is of type Qt3DCore::QEntity* backs this up.)

    So if I write a custom camera (by subclassing QEntity), what do I need to do to provide a view matrix? While the projection matrix is given by the QCameraLens, the view matrix needs to be provided by the camera entity itself somehow. Or am I misunderstanding this?

    Thanks in advance for any help!

  • Ok, I toyed around a little and figured it out myself:

    A QEntity element that is used as a camera can, just like other (visible) QEntity elements, be positioned by attaching a QTransform component, and the view matrix is automatically induced by the camera entity's global transform (just like a visible QEntity's model matrix is induced by its transform).

    So the functionality of a QTransform object seems to be much more genral than its - optimistically named - Detailed description in the doc suggests:

    "Used to perform transforms on meshes"

    Big thanks to the Qt and KDAB team for Qt3D, which seems to be an awesome 3D module. Waiting patiently for more documentation...

  • Hi,
    the latest QT3D documentation, so far, is here: http://doc-snapshots.qt.io/qt5-dev/qt3d-cpp.html
    But e.g. QTransform did not change much yet.

  • @m.sue That's good to know, thanks for the link!