Skip to content

Kuesa::Qt3D::PlaceholderTracker

Module: Kuesa Qt 3D API

PlaceholderTracker allows watching a placeholder for changes and computing a screen position changes given a window size and a camera. More...

#include <placeholdertracker.h>

Inherits from Kuesa::Qt3D::KuesaNode, Qt3DCore::QNode

Public Slots

Name
void setName(const QString & name)
void setCamera(Qt3DCore::QEntity * camera)
void setScreenSize(const QSize & screenSize)
void setViewportRect(const QRectF & viewportRect)
void setViewportRect(qreal x, qreal y, qreal width, qreal height)
void setTarget(QObject * target)

Public Signals

Name
void nameChanged(const QString & name)
void cameraChanged(Qt3DCore::QEntity * camera)
void screenSizeChanged(const QSize & screenSize)
void viewportRectChanged(QRectF viewportRect)
void targetChanged(QObject * target)
void xChanged(int x)
void yChanged(int y)
void widthChanged(int width)
void heightChanged(int height)
void screenPositionChanged(const QPointF & screenPosition)

Public Functions

Name
PlaceholderTracker(Qt3DCore::QNode * parent =nullptr)
~PlaceholderTracker()
QString name() const
Qt3DCore::QEntity * camera() const
QSize screenSize() const
QRectF viewportRect() const
QObject * target() const
int x() const
int y() const
int width() const
int height() const
QPointF screenPosition() const

Public Properties

Name
QString name
Qt3DCore::QEntity * camera
QSize screenSize
QRectF viewportRect
QObject * target
int x
int y
int width
int height
QPointF screenPosition

Additional inherited members

Public Slots inherited from Kuesa::Qt3D::KuesaNode

Name
void setSceneEntity(Kuesa::Qt3D::SceneEntity * sceneEntity)

Public Signals inherited from Kuesa::Qt3D::KuesaNode

Name
void sceneEntityChanged(Kuesa::Qt3D::SceneEntity * sceneEntity)

Public Functions inherited from Kuesa::Qt3D::KuesaNode

Name
KuesaNode(Qt3DCore::QNode * parent =nullptr)
SceneEntity * sceneEntity() const

Public Properties inherited from Kuesa::Qt3D::KuesaNode

Name
Kuesa::Qt3D::SceneEntity * sceneEntity

Protected Attributes inherited from Kuesa::Qt3D::KuesaNode

Name
SceneEntity * m_sceneEntity

Detailed Description

1
class Kuesa::Qt3D::PlaceholderTracker;

PlaceholderTracker allows watching a placeholder for changes and computing a screen position changes given a window size and a camera.

See: Kuesa::Qt3D::Placeholder

Since: Kuesa 2.0

PlaceholderTracker allows watching a placeholder for changes and computing a screen position changes given a window size and a camera.

This is especially useful to easily map 2D content based on a 3D placeholder. It does so by projecting a plane defined by the

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Kuesa::Qt3D::SceneEntity *sceneEntity = new Kuesa::Qt3D::SceneEntity();
Kuesa::Qt3D::PlaceholderTracker *tracker = new Kuesa::Qt3D::PlaceholderTracker();
Qt3DRender::QCamera *camera = new Qt3DRender::Camera();
QObject *target = new QObject(); // Our UI target

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

Read more about

Public Slots Documentation

slot setName

1
2
3
void setName(
    const QString & name
)

slot setCamera

1
2
3
void setCamera(
    Qt3DCore::QEntity * camera
)

slot setScreenSize

1
2
3
void setScreenSize(
    const QSize & screenSize
)

slot setViewportRect

1
2
3
void setViewportRect(
    const QRectF & viewportRect
)

slot setViewportRect

1
2
3
4
5
6
void setViewportRect(
    qreal x,
    qreal y,
    qreal width,
    qreal height
)

slot setTarget

1
2
3
void setTarget(
    QObject * target
)

Public Signals Documentation

signal nameChanged

1
2
3
void nameChanged(
    const QString & name
)

signal cameraChanged

1
2
3
void cameraChanged(
    Qt3DCore::QEntity * camera
)

signal screenSizeChanged

1
2
3
void screenSizeChanged(
    const QSize & screenSize
)

signal viewportRectChanged

1
2
3
void viewportRectChanged(
    QRectF viewportRect
)

signal targetChanged

1
2
3
void targetChanged(
    QObject * target
)

signal xChanged

1
2
3
void xChanged(
    int x
)

signal yChanged

1
2
3
void yChanged(
    int y
)

signal widthChanged

1
2
3
void widthChanged(
    int width
)

signal heightChanged

1
2
3
void heightChanged(
    int height
)

signal screenPositionChanged

1
2
3
void screenPositionChanged(
    const QPointF & screenPosition
)

Public Functions Documentation

function PlaceholderTracker

1
2
3
explicit PlaceholderTracker(
    Qt3DCore::QNode * parent =nullptr
)

function ~PlaceholderTracker

1
~PlaceholderTracker()

function name

1
QString name() const

function camera

1
Qt3DCore::QEntity * camera() const

function screenSize

1
QSize screenSize() const

function viewportRect

1
QRectF viewportRect() const

function target

1
QObject * target() const

function x

1
int x() const

function y

1
int y() const

function width

1
int width() const

function height

1
int height() const

function screenPosition

1
QPointF screenPosition() const

Public Property Documentation

property name

1
QString name;

Holds the name of the Placeholder instance to retrieve from the Kuesa::Qt3D::SceneEntity.

property camera

1
Qt3DCore::QEntity * camera;

Note: using a Qt3DRender::QCamera for the placeholderTracker different than the one being used for the render might give unexpected results.

Holds the camera the placeholder is facing and which is used to project the plane to screen space.

1
2
3
4
5
6
7
QQuickItem *target = view->rootItem();
Kuesa::Qt3D::PlaceholderTracker *placeholderTracker = new Kuesa::Qt3D::PlaceholderTracker();
placeholderTracker->setName(QStringLiteral("placeholder"));
Qt3DRender::QCamera *camera = sceneEntity->camera(QStringLiteral("Camera_Orientation"));
placeholderTracker->setSceneSize({view.width(), view.height()});
placeholderTracker->setTarget(target);
placeholderTracker->setCamera(camera);

property screenSize

1
QSize screenSize;

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.

property viewportRect

1
QRectF viewportRect;

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.

property target

1
QObject * target;

Holds the target object on which to set x, y, width and height properties computed from the Placeholder and Camera transformations.

Commonly it would be a QtQuick element and should be used as

1
2
3
4
5
QQuickItem *target = view->rootItem();
Kuesa::Qt3D::PlaceholderTracker *placeholderTracker = new Kuesa::Qt3D::PlaceholderTracker();
placeholder->setName(QStringLiteral("placeholder"));
placeholder->setScreenSize({view.width(), view.height()});
placeholder->setTarget(target);

property x

1
int x;

Holds the top left x screen position coordinate computed from the placeholder.

property y

1
int y;

Holds the top left y screen position coordinate computed from the placeholder.

property width

1
int width;

Holds the width in screen coordinates computed from the placeholder.

property height

1
int height;

Holds the height in screen coordinates computed from the placeholder.

property screenPosition

1
QPointF screenPosition;

Holds the screenPosition computed from the placeholder.


Updated on 2023-07-03 at 11:02:09 +0000