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 const double x = elem.attribute( QStringLiteral(
"x" ) ).toDouble();
37 const double y = elem.attribute( QStringLiteral(
"y" ) ).toDouble();
38 const 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();
49 if ( std::isnan( point.
x() ) || std::isnan( point.
y() ) || std::isnan( point.
z() ) )
50 qWarning() <<
"Not updating camera position: it cannot be NaN!";
57 mDistanceFromCenterPoint = std::max( distance, 10.0f );
67 mPitchAngle = std::clamp( pitch, 0.2f, 179.8f );
77 camera->setUpVector( QVector3D( 0, 0, -1 ) );
78 camera->setPosition( QVector3D( mCenterPoint.
x(), mDistanceFromCenterPoint + mCenterPoint.
y(), mCenterPoint.
z() ) );
79 camera->setViewCenter( QVector3D( mCenterPoint.
x(), mCenterPoint.
y(), mCenterPoint.
z() ) );
80 camera->rotateAboutViewCenter( QQuaternion::fromEulerAngles( mPitchAngle, mHeadingAngle, 0 ) );