Kuesa Runtime

TransformTracker Class

class Kuesa::TransformTracker

TransformTracker allows watching a transform for change and computing a projected screen position given a window size and a camera. More...

Header: #include <TransformTracker>
Since: Kuesa 1.3
Instantiated By: TransformTracker
Inherits: Kuesa::KuesaNode

This class was introduced in Kuesa 1.3.

Properties

Public Functions

Qt3DCore::QEntity *camera() const
QMatrix4x4 matrix() const
QString name() const
QQuaternion rotation() const
float rotationX() const
float rotationY() const
float rotationZ() const
float scale() const
QVector3D scale3D() const
QPointF screenPosition() const
QSize screenSize() const
QVector3D translation() const
QRectF viewportRect() const
QMatrix4x4 worldMatrix() const

Public Slots

void setCamera(Qt3DCore::QEntity *camera)
void setMatrix(const QMatrix4x4 &matrix)
void setName(const QString &name)
void setRotation(const QQuaternion &rotation)
void setRotationX(float rotationX)
void setRotationY(float rotationY)
void setRotationZ(float rotationZ)
void setScale(float scale)
void setScale3D(const QVector3D &scale3D)
void setScreenSize(const QSize &screenSize)
void setTranslation(const QVector3D &translation)
void setViewportRect(qreal x, qreal y, qreal width, qreal height)
void setViewportRect(const QRectF &viewportRect)

Signals

void cameraChanged(Qt3DCore::QEntity *camera)
void matrixChanged(const QMatrix4x4 &matrix)
void nameChanged(const QString &name)
void rotationChanged(const QQuaternion &rotation)
void rotationXChanged(float rotationX)
void rotationYChanged(float rotationY)
void rotationZChanged(float rotationZ)
void scale3DChanged(const QVector3D &scale)
void scaleChanged(float scale)
void screenPositionChanged(const QPointF &screenPosition)
void screenSizeChanged(const QSize &screenSize)
void translationChanged(const QVector3D &translation)
void viewportRectChanged(QRectF viewportRect)
void worldMatrixChanged(const QMatrix4x4 &worldMatrix)

Detailed Description

TransformTracker allows watching a transform for change and computing a projected screen position given a window size and a camera.

This is especially useful to place 2D content based on a 3D position.

 Kuesa::SceneEntity *sceneEntity = new Kuesa::SceneEntity();
 Kuesa::TransformTracker *tracker = new Kuesa::TransformTracker();
 Qt3DRender::QCamera *camera = new Qt3DRender::Camera();


 tracker->setSceneEntity(sceneEntity);
 tracker->setName(QStringLiteral("MyTransform");
 tracker->setCamera(camera);
 tracker->setScreenSize({512, 512});

 QObject::connect(tracker, &Kuesa::TransformTracker::screenPositionChanged,
                  this, [this] (const QPointF &screenPosition) {
                     // Reacts to new position
                     ....
                  });

Property Documentation

camera : Qt3DCore::QEntity*

Holds the camera entity from which we should compute the screen position.

Access functions:

Qt3DCore::QEntity *camera() const
void setCamera(Qt3DCore::QEntity *camera)

Notifier signal:

void cameraChanged(Qt3DCore::QEntity *camera)

matrix : QMatrix4x4

Holds the local transformation matrix associated to the tracker's referenced QTransform instance.

Access functions:

QMatrix4x4 matrix() const
void setMatrix(const QMatrix4x4 &matrix)

Notifier signal:

void matrixChanged(const QMatrix4x4 &matrix)

name : QString

Holds the name of the Qt3DCore::QTransform instance to retrieve from the Kuesa::SceneEntity.

Access functions:

QString name() const
void setName(const QString &name)

Notifier signal:

void nameChanged(const QString &name)

rotation : QQuaternion

Holds the local rotation associated to the tracker's referenced QTransform instance.

Access functions:

QQuaternion rotation() const
void setRotation(const QQuaternion &rotation)

Notifier signal:

void rotationChanged(const QQuaternion &rotation)

rotationX : float

Holds the local x rotation (euler angle) associated to the tracker's referenced QTransform instance.

Access functions:

float rotationX() const
void setRotationX(float rotationX)

Notifier signal:

void rotationXChanged(float rotationX)

rotationY : float

Holds the local y rotation (euler angle) associated to the tracker's referenced QTransform instance.

Access functions:

float rotationY() const
void setRotationY(float rotationY)

Notifier signal:

void rotationYChanged(float rotationY)

rotationZ : float

Holds the local z rotation (euler angle) associated to the tracker's referenced QTransform instance.

Access functions:

float rotationZ() const
void setRotationZ(float rotationZ)

Notifier signal:

void rotationZChanged(float rotationZ)

scale : float

Holds the local uniform scale associated to the tracker's referenced QTransform instance.

Access functions:

float scale() const
void setScale(float scale)

Notifier signal:

void scaleChanged(float scale)

scale3D : QVector3D

Holds the local 3D scale associated to the tracker's referenced QTransform instance.

Access functions:

QVector3D scale3D() const
void setScale3D(const QVector3D &scale3D)

Notifier signal:

void scale3DChanged(const QVector3D &scale)

screenPosition : const QPointF

Holds the 2D screen position computed from the transformation in world space obtained from the tracker's referenced Transform, the camera, the sceneSize and viewportRect.

Access functions:

QPointF screenPosition() const

Notifier signal:

void screenPositionChanged(const QPointF &screenPosition)

screenSize : QSize

Holds the size of the area within which we should compute screen positions. This would usually be the size of the window or the size of the sub view within the window.

Access functions:

QSize screenSize() const
void setScreenSize(const QSize &screenSize)

Notifier signal:

void screenSizeChanged(const QSize &screenSize)

translation : QVector3D

Holds the local translation associated to the tracker's referenced QTransform instance.

Access functions:

QVector3D translation() const
void setTranslation(const QVector3D &translation)

Notifier signal:

void translationChanged(const QVector3D &translation)

viewportRect : QRectF

Holds the normalized viewport rectangle defining the area into which screen positions should be computed. If unspecified QRectF(0.0f, 0.0f, 1.0f, 1.0f) will be used.

Access functions:

QRectF viewportRect() const
void setViewportRect(const QRectF &viewportRect)
void setViewportRect(qreal x, qreal y, qreal width, qreal height)

Notifier signal:

void viewportRectChanged(QRectF viewportRect)

worldMatrix : const QMatrix4x4

Holds the world transformation matrix associated to the tracker's referenced QTransform instance.

This property is readonly.

Access functions:

QMatrix4x4 worldMatrix() const

Notifier signal:

void worldMatrixChanged(const QMatrix4x4 &worldMatrix)