QtCraft API C++ classes QML types Handbook

QcCamera Struct

First-person camera. More...

Header: #include <clientcore/camera/QcCamera.h>

Public Functions

QVector3D forward() const
QMatrix4x4 projectionMatrix(float aspect, float farPlane) const
QVector3D relative(const QcVec3 &world) const
QMatrix4x4 viewRotation() const

Public Variables

float fieldOfView
float pitch
QcVec3 position
float roll
float yaw

Static Public Members

const float defaultFieldOfView
const float farPlaneMargin
const float nearPlane

Detailed Description

Yaw 0 looks along -Z, positive yaw turns right; angles in degrees.

The position is in double: far from the origin a float holds a block coordinate only to metres (decision E-883). Everything drawn is placed relative to the camera (relative()), and the view matrix is the camera's rotation alone, so the floats the GPU sees stay small.

Member Function Documentation

QVector3D QcCamera::forward() const

Returns the unit vector the camera looks along.

QMatrix4x4 QcCamera::projectionMatrix(float aspect, float farPlane) const

Returns the perspective projection for the width-to-height ratio aspect and the far plane at farPlane metres.

QVector3D QcCamera::relative(const QcVec3 &world) const

Returns world relative to the camera, subtracted in double before it becomes a float.

QMatrix4x4 QcCamera::viewRotation() const

Returns the view of a camera at the origin with this camera's direction and roll: maps positions relative to the camera (relative()) into view space.

Member Variable Documentation

const float QcCamera::defaultFieldOfView

Vertical field of view of a new camera, in degrees.

const float QcCamera::farPlaneMargin

Metres the far plane lies beyond the end of the fog.

float QcCamera::fieldOfView

Vertical field of view in degrees.

const float QcCamera::nearPlane

Distance of the near plane in metres.

float QcCamera::pitch

Pitch in degrees, positive looks up.

QcVec3 QcCamera::position

The camera's position.

float QcCamera::roll

Roll in degrees about the view direction, positive clockwise (the head leaning to the right): the tilt of a hurt (QcHurtTilt, decision E-971).

float QcCamera::yaw

Yaw in degrees.