QgsCameraController class
3 Object that controls camera movement based on user input
Contents
Constructors, destructors, conversion operators
- QgsCameraController(Qt3DCore::QNode* parent = nullptr)
- Constructs the camera controller with optional parent node that will take ownership.
Public functions
- auto camera() const -> Qt3DRender::QCamera*
- Returns camera that is being controlled.
- auto cameraPose() const -> QgsCameraPose
- Returns camera pose.
- auto distance() const -> float
- Returns distance of the camera from the point it is looking at.
- void frameTriggered(float dt)
- Called internally from 3D scene when a new frame is generated. Updates camera according to keyboard/mouse input.
- auto lookingAtPoint() const -> QgsVector3D
- Returns the point in the world coordinates towards which the camera is looking.
- auto pitch() const -> float
- Returns pitch angle in degrees (0 = looking from the top, 90 = looking from the side).
- void readXml(const QDomElement& elem)
- Reads camera configuration from the given DOM element.
- void resetView(float distance)
- Move camera back to the initial position (looking down towards origin of world's coordinates)
- void setCamera(Qt3DRender::QCamera* camera)
- Assigns camera that should be controlled by this class. Called internally from 3D scene.
- void setCameraPose(const QgsCameraPose& camPose)
- Sets camera pose.
- void setLookingAtPoint(const QgsVector3D& point, float distance, float pitch, float yaw)
- Sets the complete camera configuration: the point towards it is looking (in 3D world coordinates), the distance of the camera from the point, pitch angle in degrees (0 = looking from the top, 90 = looking from the side) and yaw angle in degrees.
- void setTerrainEntity(QgsTerrainEntity* te)
- Connects to object picker attached to terrain entity.
- void setViewFromTop(float worldX, float worldY, float distance, float yaw = 0)
- Sets camera to look down towards given point in world coordinate, in given distance from plane with zero elevation.
- void setViewport(QRect viewport)
- Sets viewport rectangle. Called internally from 3D canvas. Allows conversion of mouse coordinates.
- auto viewport() const -> QRect
- Returns viewport rectangle.
- auto writeXml(QDomDocument& doc) const -> QDomElement
- Writes camera configuration to the given DOM element.
- auto yaw() const -> float
- Returns yaw angle in degrees.
Signals
- void cameraChanged()
- Emitted when camera has been updated.
- void viewportChanged()
- Emitted when viewport rectangle has been updated.
Function documentation
QgsCameraPose QgsCameraController:: cameraPose() const
Returns camera pose.
float QgsCameraController:: distance() const
Returns distance of the camera from the point it is looking at.
float QgsCameraController:: pitch() const
Returns pitch angle in degrees (0 = looking from the top, 90 = looking from the side).
The angle should range from 0 to 180.
void QgsCameraController:: setCameraPose(const QgsCameraPose& camPose)
Sets camera pose.
void QgsCameraController:: setLookingAtPoint(const QgsVector3D& point,
float distance,
float pitch,
float yaw)
Sets the complete camera configuration: the point towards it is looking (in 3D world coordinates), the distance of the camera from the point, pitch angle in degrees (0 = looking from the top, 90 = looking from the side) and yaw angle in degrees.
void QgsCameraController:: setTerrainEntity(QgsTerrainEntity* te)
Connects to object picker attached to terrain entity.
Called internally from 3D scene. This allows camera controller understand how far from the camera is the terrain under mouse cursor. Also it allows adjustment of camera's view center to a point on terrain.
float QgsCameraController:: yaw() const
Returns yaw angle in degrees.
Yaw value of zero means the camera is pointing towards north. The angle should range from 0 to 360.