diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-05-15 12:54:57 +0200 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-05-15 14:23:43 +0200 |
commit | 3efddb093e72c100bc609ec691effb4563af2c20 (patch) | |
tree | 83359ccc06eb8669c24487250f79bc828df66fcc /avmedia | |
parent | OGLWindow: use update function for redrawing. (diff) | |
download | core-3efddb093e72c100bc609ec691effb4563af2c20.tar.gz core-3efddb093e72c100bc609ec691effb4563af2c20.zip |
OGLWindow: First try to rotate camera
For now its too slow to render by mousemove so
use mousebuttonup instead.
It seems gltf_renderer_rotate_camera() method does not rotate
the camera but set the new position of it.
Change-Id: I0fe7895720dbf95acb0963a5ba6dd2a5840d8f6b
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/opengl/oglwindow.cxx | 25 | ||||
-rw-r--r-- | avmedia/source/opengl/oglwindow.hxx | 1 |
2 files changed, 25 insertions, 1 deletions
diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx index f32070af4366..ca2ffbf41a1f 100644 --- a/avmedia/source/opengl/oglwindow.cxx +++ b/avmedia/source/opengl/oglwindow.cxx @@ -20,6 +20,7 @@ OGLWindow::OGLWindow( glTFHandle* pHandle, OpenGLContext* pContext, SystemChildW , m_pEventHandler( pChildWindow->GetParent() ) , m_bVisible ( false ) , meZoomLevel( media::ZoomLevel_ORIGINAL ) + , m_aLastMousePos(Point()) { } @@ -276,12 +277,34 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent) if(nCode == KEY_W)vMoveBy -= vMup*(0.1f*fModelSize); if(nCode == KEY_S)vMoveBy += vMup*(0.1f*fModelSize); } - gltf_renderer_move_camera(vMoveBy.x,vMoveBy.y,vMoveBy.z,10.0); update(); } } } + else if( pEvent->GetId() == VCLEVENT_WINDOW_MOUSEBUTTONDOWN ) + { + MouseEvent* pMouseEvt = (MouseEvent*)pEvent->GetData(); + if(pMouseEvt && pMouseEvt->IsLeft() && pMouseEvt->GetClicks() == 1) + { + m_aLastMousePos = pMouseEvt->GetPosPixel(); + } + } + else if( pEvent->GetId() == VCLEVENT_WINDOW_MOUSEBUTTONUP ) + { + MouseEvent* pMouseEvt = (MouseEvent*)pEvent->GetData(); + if(pMouseEvt && pMouseEvt->IsLeft()) + { + const Point& aCurPos = pMouseEvt->GetPosPixel(); + + long nDeltaX = m_aLastMousePos.X()-aCurPos.X(); + long nDeltaY = aCurPos.Y()-m_aLastMousePos.Y(); + static const float fSensitivity = 4.0; + // TODO: It seems this method just moves the camera but not rotate it. + gltf_renderer_rotate_camera((float)nDeltaX*fSensitivity,(float)nDeltaY*fSensitivity,0.0,10.0); + update(); + } + } return 0; } diff --git a/avmedia/source/opengl/oglwindow.hxx b/avmedia/source/opengl/oglwindow.hxx index e7b0d3ab57d3..ba510e46f31c 100644 --- a/avmedia/source/opengl/oglwindow.hxx +++ b/avmedia/source/opengl/oglwindow.hxx @@ -70,6 +70,7 @@ private: Window* m_pEventHandler; bool m_bVisible; com::sun::star::media::ZoomLevel meZoomLevel; + Point m_aLastMousePos; }; } // namespace ogl |