summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--avmedia/source/opengl/oglwindow.cxx18
-rw-r--r--avmedia/source/opengl/oglwindow.hxx2
2 files changed, 20 insertions, 0 deletions
diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx
index ffb0855806f4..c748ca15605e 100644
--- a/avmedia/source/opengl/oglwindow.cxx
+++ b/avmedia/source/opengl/oglwindow.cxx
@@ -22,6 +22,7 @@ OGLWindow::OGLWindow( glTFHandle& rHandle, OpenGLContext& rContext, Window& rEve
, meZoomLevel( media::ZoomLevel_ORIGINAL )
, m_aLastMousePos(Point())
, m_bIsOrbitMode( false )
+ , m_fCameraDistance(0.0)
{
}
@@ -274,6 +275,17 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent)
if(nCode == KEY_A)vMoveBy -= vStrafe*(0.0005f*fModelSize);
if(nCode == KEY_D)vMoveBy += vStrafe*(0.0005f*fModelSize);
}
+ else
+ {
+ // Limit zooming in orbit mode
+ m_fCameraDistance += vMoveBy.z;
+ if ((m_fCameraDistance < 0.5 * fModelSize && vMoveBy.z < 0.0 ) ||
+ (m_fCameraDistance > 2 * fModelSize && vMoveBy.z > 0.0 ))
+ {
+ m_fCameraDistance -= vMoveBy.z;
+ vMoveBy = glm::vec3(0.0);
+ }
+ }
}
gltf_renderer_move_camera(&m_rHandle, vMoveBy.x, vMoveBy.y, vMoveBy.z, 0.0);
}
@@ -288,6 +300,12 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent)
{
gltf_orbit_mode_start(&m_rHandle);
m_bIsOrbitMode = true;
+ // Set default camera distance
+ glm::vec3 vEye;
+ glm::vec3 vView;
+ glm::vec3 vUp;
+ gltf_get_camera_pos(&m_rHandle, &vEye,&vView,&vUp);
+ m_fCameraDistance = vEye.z - gltf_get_model_center_pos(&m_rHandle)->z - (gltf_get_model_size(&m_rHandle)/2.0);
}
}
else if(nCode == KEY_F)
diff --git a/avmedia/source/opengl/oglwindow.hxx b/avmedia/source/opengl/oglwindow.hxx
index 5a52cca9e3e6..35c54c8cbd2f 100644
--- a/avmedia/source/opengl/oglwindow.hxx
+++ b/avmedia/source/opengl/oglwindow.hxx
@@ -68,10 +68,12 @@ private:
glTFHandle& m_rHandle;
OpenGLContext& m_rContext;
Window& m_rEventHandler;
+
bool m_bVisible;
com::sun::star::media::ZoomLevel meZoomLevel;
Point m_aLastMousePos;
bool m_bIsOrbitMode;
+ double m_fCameraDistance;
};
} // namespace ogl