summaryrefslogtreecommitdiffstats
path: root/src/runtime/q3dsuippresentation.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-09-07 13:26:44 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-09-12 13:24:36 +0000
commitfe1c72687bc52072b3f1695859bcebce2392fdb6 (patch)
treefd8ef7898605d9724a5bd49aaba3a9c7ed2e0b31 /src/runtime/q3dsuippresentation.cpp
parentf9fe63833282f1fd08d5d76232862b15dc1a1b39 (diff)
Add fovhorizontal property to cameras
This is a boolean property. If it is true, the fov value will be interpreted as horizontal angle. Since there were change to MetaData.xml, it was was updated to match editor version. Task-number: QT3DS-708 Change-Id: I68ac43c497a344a1f7bfcf25505f0dc4eb4cd6b5 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/runtime/q3dsuippresentation.cpp')
-rw-r--r--src/runtime/q3dsuippresentation.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/runtime/q3dsuippresentation.cpp b/src/runtime/q3dsuippresentation.cpp
index 3888ebe..1de9ad5 100644
--- a/src/runtime/q3dsuippresentation.cpp
+++ b/src/runtime/q3dsuippresentation.cpp
@@ -2999,6 +2999,7 @@ void Q3DSCameraNode::setProps(const V &attrs, PropSetFlags flags)
parseProperty(attrs, flags, typeName, QStringLiteral("orthographic"), &m_orthographic);
parseProperty(attrs, flags, typeName, QStringLiteral("fov"), &m_fov);
+ parseProperty(attrs, flags, typeName, QStringLiteral("fovhorizontal"), &m_fovHorizontal);
parseProperty(attrs, flags, typeName, QStringLiteral("clipnear"), &m_clipNear);
parseProperty(attrs, flags, typeName, QStringLiteral("clipfar"), &m_clipFar);
parseProperty(attrs, flags, typeName, QStringLiteral("scalemode"), &m_scaleMode);
@@ -3031,6 +3032,11 @@ Q3DSPropertyChange Q3DSCameraNode::setFov(float v)
return createPropSetter(m_fov, v, "fov");
}
+Q3DSPropertyChange Q3DSCameraNode::setFovHorizontal(bool v)
+{
+ return createPropSetter(m_fovHorizontal, v, "fovhorizontal");
+}
+
Q3DSPropertyChange Q3DSCameraNode::setClipNear(float v)
{
return createPropSetter(m_clipNear, v, "clipnear");
@@ -3051,6 +3057,16 @@ Q3DSPropertyChange Q3DSCameraNode::setScaleAnchor(ScaleAnchor v)
return createPropSetter(m_scaleAnchor, v, "scaleanchor");
}
+float Q3DSCameraNode::verticalFov(float aspectRatio) const
+{
+ if (m_fovHorizontal) {
+ return 2.0f * qRadiansToDegrees(qAtan(qTan(qDegreesToRadians(m_fov) / 2.0)
+ / qreal(aspectRatio)));
+ } else {
+ return m_fov;
+ }
+}
+
Q3DSLightNode::Q3DSLightNode()
: Q3DSNode(Q3DSGraphObject::Light)
{