18 #include <Qt3DRender/QCamera>
20 #include <QDomDocument>
24 QDomElement elemCamera = doc.createElement( QStringLiteral(
"camera-pose" ) );
25 elemCamera.setAttribute( QStringLiteral(
"x" ), mCenterPoint.
x() );
26 elemCamera.setAttribute( QStringLiteral(
"y" ), mCenterPoint.
y() );
27 elemCamera.setAttribute( QStringLiteral(
"z" ), mCenterPoint.
z() );
28 elemCamera.setAttribute( QStringLiteral(
"dist" ), mDistanceFromCenterPoint );
29 elemCamera.setAttribute( QStringLiteral(
"pitch" ), mPitchAngle );
30 elemCamera.setAttribute( QStringLiteral(
"heading" ), mHeadingAngle );
36 double x = elem.attribute( QStringLiteral(
"x" ) ).toDouble();
37 double y = elem.attribute( QStringLiteral(
"y" ) ).toDouble();
38 double z = elem.attribute( QStringLiteral(
"z" ) ).toDouble();
41 mDistanceFromCenterPoint = elem.attribute( QStringLiteral(
"dist" ) ).toFloat();
42 mPitchAngle = elem.attribute( QStringLiteral(
"pitch" ) ).toFloat();
43 mHeadingAngle = elem.attribute( QStringLiteral(
"heading" ) ).toFloat();
53 camera->setUpVector( QVector3D( 0, 0, -1 ) );
54 camera->setPosition( QVector3D( mCenterPoint.
x(), mDistanceFromCenterPoint + mCenterPoint.
y(), mCenterPoint.
z() ) );
55 camera->setViewCenter( QVector3D( mCenterPoint.
x(), mCenterPoint.
y(), mCenterPoint.
z() ) );
56 camera->rotateAboutViewCenter( QQuaternion::fromEulerAngles( mPitchAngle, mHeadingAngle, 0 ) );
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element and returns it.
void readXml(const QDomElement &elem)
Reads configuration from a DOM element previously written using writeXml()
void updateCamera(Qt3DRender::QCamera *camera)
Update Qt3D camera view matrix based on the pose.
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.