VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Signals | Public Member Functions | Protected Member Functions | Properties | List of all members

QQuickItem which represents the Camera into the game world. More...

Inheritance diagram for Camera:
QQuickItem QObject QQmlParserStatus

Signals

void fovChanged ()
 Emitted when fov changes. More...
 
void lookAtChanged ()
 Emitted when lookAt changes. More...
 
void transformApplied ()
 Signals the current frame's update is complete and that the camera's transform now points at its new location, in response to applyTransform(). More...
 

Public Member Functions

 Camera (QQuickItem *parent=0)
 Construct a Camera. More...
 
float getFov () const
 Returns fov. More...
 
void setFov (float fov)
 Sets fov. More...
 
QPointF getLookAt () const
 Returns lookAt. More...
 
void setLookAt (const QPointF &lookAt)
 Sets lookAt. More...
 
float getAspectRatio () const
 Returns aspectRatio. More...
 
QPointF getParallaxOrigin () const
 Returns the current parallax origin. More...
 
void setParallaxOrigin (const QPointF &value)
 Sets the current parallax origin. More...
 
QPointF getParallaxOffset () const
 Returns the Camera's offset from the parallax origin. More...
 
const QMatrix4x4getOpenGLViewMatrix () const
 Returns the matrix transform used to project world coordinates into normalized device coordinates. More...
 
const QRectFgetViewportWorldBounds () const
 Get the viewport rectangle in world space coordinates. More...
 
const QRectFgetWorldCullBounds () const
 Gets the world space rectangle encompassing the viewport, outside of which objects should be culled. More...
 
void updateTransform ()
 Computes new transforms, but does not move Items visually, or update the GL transform. More...
 
void applyTransform ()
 Copies the computed transforms, updating Items visually and updates the GL transform. More...
 
- Public Member Functions inherited from QQuickItem
 QQuickItem (QQuickItem *parent)
 
QQuickWindowwindow () const
 
QQuickItemparentItem () const
 
void setParentItem (QQuickItem *parent)
 
void stackBefore (const QQuickItem *sibling)
 
void stackAfter (const QQuickItem *sibling)
 
QRectF childrenRect ()
 
QList< QQuickItem * > childItems () const
 
bool clip () const
 
void setClip (bool)
 
QString state () const
 
void setState (const QString &)
 
qreal baselineOffset () const
 
void setBaselineOffset (qreal)
 
qreal x () const
 
qreal y () const
 
void setX (qreal)
 
void setY (qreal)
 
qreal width () const
 
void setWidth (qreal)
 
void resetWidth ()
 
void setImplicitWidth (qreal)
 
qreal implicitWidth () const
 
qreal height () const
 
void setHeight (qreal)
 
void resetHeight ()
 
void setImplicitHeight (qreal)
 
qreal implicitHeight () const
 
TransformOrigin transformOrigin () const
 
void setTransformOrigin (TransformOrigin)
 
qreal z () const
 
void setZ (qreal)
 
qreal rotation () const
 
void setRotation (qreal)
 
qreal scale () const
 
void setScale (qreal)
 
qreal opacity () const
 
void setOpacity (qreal)
 
bool isVisible () const
 
void setVisible (bool)
 
bool isEnabled () const
 
void setEnabled (bool)
 
bool smooth () const
 
void setSmooth (bool)
 
bool activeFocusOnTab () const
 
void setActiveFocusOnTab (bool)
 
bool antialiasing () const
 
void setAntialiasing (bool)
 
void resetAntialiasing ()
 
Flags flags () const
 
void setFlag (Flag flag, bool enabled)
 
void setFlags (QFlags< QQuickItem::Flag > flags)
 
bool hasActiveFocus () const
 
bool hasFocus () const
 
void setFocus (bool)
 
void setFocus (bool focus, Qt::FocusReason reason)
 
bool isFocusScope () const
 
QQuickItemscopedFocusItem () const
 
Qt::MouseButtons acceptedMouseButtons () const
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 
bool acceptHoverEvents () const
 
void setAcceptHoverEvents (bool enabled)
 
QCursor cursor () const
 
void setCursor (const QCursor &cursor)
 
void unsetCursor ()
 
void grabMouse ()
 
void ungrabMouse ()
 
bool keepMouseGrab () const
 
void setKeepMouseGrab (bool keep)
 
bool filtersChildMouseEvents () const
 
void setFiltersChildMouseEvents (bool filter)
 
void grabTouchPoints (const QVector< int > &ids)
 
void ungrabTouchPoints ()
 
bool keepTouchGrab () const
 
void setKeepTouchGrab (bool keep)
 
virtual bool contains (const QPointF &point) const
 
QPointF mapToItem (const QQuickItem *item, const QPointF &point) const
 
QPointF mapToScene (const QPointF &point) const
 
QRectF mapRectToItem (const QQuickItem *item, const QRectF &rect) const
 
QRectF mapRectToScene (const QRectF &rect) const
 
QPointF mapFromItem (const QQuickItem *item, const QPointF &point) const
 
QPointF mapFromScene (const QPointF &point) const
 
QRectF mapRectFromItem (const QQuickItem *item, const QRectF &rect) const
 
QRectF mapRectFromScene (const QRectF &rect) const
 
void polish ()
 
void forceActiveFocus ()
 
void forceActiveFocus (Qt::FocusReason reason)
 
QQuickItemnextItemInFocusChain (bool forward)
 
QQuickItemchildAt (qreal x, qreal y) const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
virtual bool isTextureProvider () const
 
virtual QSGTextureProvidertextureProvider () const
 
void update ()
 
void windowChanged (QQuickWindow *window)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegExp &regExp, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegularExpression &re, QFlags< Qt::FindChildOption > options) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 
- Public Member Functions inherited from QQmlParserStatus
virtual void classBegin ()=0
 
virtual void componentComplete ()=0
 

Protected Member Functions

virtual QSGNodeupdatePaintNode (QSGNode *oldNode, UpdatePaintNodeData *data) override
 Override of QQuickItem::updatePaintNode() which forces Qt's renderer to continue rendering. More...
 
- Protected Member Functions inherited from QQuickItem
virtual bool event (QEvent *ev)
 
bool isComponentComplete () const
 
virtual void itemChange (ItemChange change, const ItemChangeData &value)
 
void updateInputMethod (Qt::InputMethodQueries queries)
 
bool widthValid () const
 
bool heightValid () const
 
virtual void classBegin ()
 
virtual void componentComplete ()
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void focusInEvent (QFocusEvent *event)
 
virtual void focusOutEvent (QFocusEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseUngrabEvent ()
 
virtual void touchUngrabEvent ()
 
virtual void wheelEvent (QWheelEvent *event)
 
virtual void touchEvent (QTouchEvent *event)
 
virtual void hoverEnterEvent (QHoverEvent *event)
 
virtual void hoverMoveEvent (QHoverEvent *event)
 
virtual void hoverLeaveEvent (QHoverEvent *event)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual bool childMouseEventFilter (QQuickItem *item, QEvent *event)
 
virtual void geometryChanged (const QRectF &newGeometry, const QRectF &oldGeometry)
 
virtual void releaseResources ()
 
virtual void updatePolish ()
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Properties

float fov
 Zoom level of the Camera, as a field of view. More...
 
QPointF lookAt
 Point in world coordinates that the Camera is centered around. More...
 
float aspectRatio
 Read only property containing the aspect ratio of the viewport. More...
 
- Properties inherited from QQuickItem
 parent
 
 x
 
 y
 
 z
 
 width
 
 height
 
 opacity
 
 enabled
 
 visible
 
 state
 
 childrenRect
 
 baselineOffset
 
 clip
 
 focus
 
 activeFocus
 
 activeFocusOnTab
 
 rotation
 
 scale
 
 transformOrigin
 
 smooth
 
 antialiasing
 
 implicitWidth
 
 implicitHeight
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Public Attributes inherited from QQuickItem
typedef Flags
 

Detailed Description

QQuickItem which represents the Camera into the game world.

The game camera is a 2D orthographic projection, with special mechanisms to perform parallax scrolling (ParallaxTransformItem). The viewport is centered around a world position (lookAt), and has a certain zoom level (fov).

In a game's Item hierarchy, you will find all of the game's graphical items under the Camera node. This is because this node is actually providing the transform from the "world" in which the game items live onto the screen.

Updates to these properties are applied to the transform in updateTransform() and applyTransform().

Constructor & Destructor Documentation

Camera::Camera ( QQuickItem parent = 0)
explicit

Construct a Camera.

Parameters
parentParent item

Member Function Documentation

void Camera::applyTransform ( )

Copies the computed transforms, updating Items visually and updates the GL transform.

void Camera::fovChanged ( )
signal

Emitted when fov changes.

float Camera::getAspectRatio ( ) const

Returns aspectRatio.

float Camera::getFov ( ) const
inline

Returns fov.

QPointF Camera::getLookAt ( ) const
inline

Returns lookAt.

const QMatrix4x4& Camera::getOpenGLViewMatrix ( ) const
inline

Returns the matrix transform used to project world coordinates into normalized device coordinates.

QPointF Camera::getParallaxOffset ( ) const
inline

Returns the Camera's offset from the parallax origin.

Note
This is used to compute parallax scrolling offsets.
See also
ParallaxTransformItem
QPointF Camera::getParallaxOrigin ( ) const
inline

Returns the current parallax origin.

Note
This is set by Level.
See also
ParallaxTransformItem
const QRectF& Camera::getViewportWorldBounds ( ) const
inline

Get the viewport rectangle in world space coordinates.

Points within the rectangle are visible to the Camera.

const QRectF& Camera::getWorldCullBounds ( ) const
inline

Gets the world space rectangle encompassing the viewport, outside of which objects should be culled.

This rectangle is the viewport rectangle expanded by a padding margin.

void Camera::lookAtChanged ( )
signal

Emitted when lookAt changes.

void Camera::setFov ( float  fov)

Sets fov.

Parameters
fovFloat to set fov to
void Camera::setLookAt ( const QPointF lookAt)

Sets lookAt.

Parameters
lookAtQPointF to set lookAt to
void Camera::setParallaxOrigin ( const QPointF value)

Sets the current parallax origin.

Note
This is set by Level.
Parameters
valuePoint in world coordinates to set as the parallax origin
See also
ParallaxTransformItem
void Camera::transformApplied ( )
signal

Signals the current frame's update is complete and that the camera's transform now points at its new location, in response to applyTransform().

virtual QSGNode* Camera::updatePaintNode ( QSGNode oldNode,
UpdatePaintNodeData data 
)
overrideprotectedvirtual

Override of QQuickItem::updatePaintNode() which forces Qt's renderer to continue rendering.

This is necessary because otherwise Qt can sometimes detect that no QQuickItems require updating, causing the renderer to pause. Because we have visual elements moving outside of Qt's QML item tree (i.e. objects in the game world, rendered through our game-specific renderer), we need to force Qt to repaint.

Parameters
oldNodePrevious QSGNode for this QQuickItem
dataData describing update
Returns
Updated QSGNode

Reimplemented from QQuickItem.

void Camera::updateTransform ( )

Computes new transforms, but does not move Items visually, or update the GL transform.

Property Documentation

float Camera::aspectRatio
read

Read only property containing the aspect ratio of the viewport.

float Camera::fov
readwrite

Zoom level of the Camera, as a field of view.

The field of view is set to the width of the viewport in world coordinates. For example, a value of 1.0f means the Camera can see exactly 1.0f unit (in world coordinates) across. A value of 5.0f means the Camera can see 5.0f units across. The amount that can be seen vertically is determined by the viewport's aspect ratio (aspectRatio).

QPointF Camera::lookAt
readwrite

Point in world coordinates that the Camera is centered around.

Changes to this property get applied in updateTransform() and applyTransform().