Camera QML Type

Defines an abstract base for Cameras. More...

Import Statement: import QtQuick3D 1.15
Inherits:

Node

Inherited By:

CustomCamera, OrthographicCamera, and PerspectiveCamera

Properties

Methods

Detailed Description

A Camera is always necessary to view the content of a 3D scene. A camera defines how to project the content of a 3D scene into a 2D coordinate space, which can then be used on a 2D surface. When a camera is present in the scene it can be used to direct what is displayed in a View3D.

To determine the projection of this camera a high level API is provided. First it is possible to position this Camera like any other spatial Node in the scene. This determines where the Camera is in the scene, and what direction it is facing. The default direction of the camera is such that the forward vector is looking up the -Z axis, and the up direction vector is up the +Y axis. With this in mind any transformation applied to the camera as well as the transformations inherited from it's parent Nodes you can define exactly where and in what direction your camera is facing.

The second part of determining the projection of the camera is defining the frustum that defines the what parts of the scenes are visible, as well as how they are visible. The Camera subtypes provide multiple options to determine the shape of the Camera's frustum.

See also PerspectiveCamera, OrthographicCamera, FrustumCamera, and CustomCamera.

Property Documentation

FieldOfViewOrientation : enumeration

This enum type specifies the orientation in which camera field of view is given:

ConstantDescription
Camera.VerticalCamera field of view is vertical, i.e. aspect ratio is adjusted vertically. This is the default orientation.
Camera.HorizontalCamera field of view is horizontal, i.e. aspect ratio is adjusted horizontally.

frustumCullingEnabled : bool

When this property is true object outside the frustum will be culled, meaning they will not be rendered. By default this property is set to false, but for complex scene where a lot of the objects are outside the camera frustum it might be beneficial to enable frustum culling.


Method Documentation

vector3d lookAt(QtQuick3D::Node node)

Sets the rotation value of a camera to be directed at node.

This method was introduced in Qt 5.15.


vector3d lookAt(vector3d scenePos)

Sets the rotation value of a camera to be directed at scenePos.

This method was introduced in Qt 5.15.


vector3d mapFromViewport(vector3d viewportPos)

Transforms viewportPos from viewport space (2D) into global scene space (3D). The x- and y-values of viewportPos must be normalized, with the top-left of the viewport being [0,0] and the bottom-right being [1,1]. The z-value should be the distance from the near side of the frustum (clipNear) into the scene in scene coordinates. If viewportPos cannot be mapped to a position in the scene, a position of [0, 0, 0] is returned.

See also mapToViewport and View3D.mapTo3DScene().


vector3d mapToViewport(vector3d scenePos)

Transforms scenePos from global scene space (3D) into viewport space (2D). The returned position is normalized, with the top-left of the viewport being [0,0] and the bottom-right being [1,1]. The returned z-value will contain the distance from the near side of the frustum (clipNear) to scenePos in view coordinates. If the distance is negative, the point is behind camera. If scenePos cannot be mapped to a position in the viewport, a position of [0, 0, 0] is returned.

See also mapFromViewport() and View3D.mapFrom3DScene().


© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.