diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-05-15 12:51:13 +0200 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-05-15 14:23:43 +0200 |
commit | 9ba99cbfcf793539f47f34fd637a48f97a249920 (patch) | |
tree | 6782b8debc8bba16e55f59f9cbb22393c098eaad /avmedia | |
parent | OGLWindow: remove event listeners also when window is disposed (diff) | |
download | core-9ba99cbfcf793539f47f34fd637a48f97a249920.tar.gz core-9ba99cbfcf793539f47f34fd637a48f97a249920.zip |
OGLWindow: move camera only when one of the key candidates is pressed
Change-Id: I52b3d100512cad569a53d10c9dc819e4548ba928
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/opengl/oglwindow.cxx | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx index 8f9eefa4eaec..f7987188d30a 100644 --- a/avmedia/source/opengl/oglwindow.cxx +++ b/avmedia/source/opengl/oglwindow.cxx @@ -246,40 +246,45 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent) if(pKeyEvt) { const sal_uInt16 nCode = pKeyEvt->GetKeyCode().GetCode(); - m_pContext->makeCurrent(); - - // Calculate movement - glm::vec3 vMoveBy; + if (nCode == KEY_Q || nCode == KEY_E || + nCode == KEY_A || nCode == KEY_D || + nCode == KEY_W || nCode == KEY_S ) { - glm::vec3 vEye; - glm::vec3 vView; - glm::vec3 vUp; - gltf_get_camera_pos(&vEye,&vView,&vUp); - float fModelSize =(float)gltf_get_model_size(); - - glm::vec3 vMove = vView-vEye; - vMove = glm::normalize(vMove); - vMove *= 25.0f; - glm::vec3 vStrafe = glm::cross(vView-vEye, vUp); - vStrafe = glm::normalize(vStrafe); - vStrafe *= 25.0f; - glm::vec3 vMup = glm::cross(vView-vEye,glm::vec3(1.f,0.f,0.f) ); - vMup = glm::normalize(vMup); - vMup *= 25.0f; - - if(nCode == KEY_Q)vMoveBy += vMove*(0.1f*fModelSize); - if(nCode == KEY_E)vMoveBy -= vMove*(0.1f*fModelSize); - if(nCode == KEY_A)vMoveBy -= vStrafe*(0.1f*fModelSize); - if(nCode == KEY_D)vMoveBy += vStrafe*(0.1f*fModelSize); - if(nCode == KEY_W)vMoveBy -= vMup*(0.1f*fModelSize); - if(nCode == KEY_S)vMoveBy += vMup*(0.1f*fModelSize); - } + m_pContext->makeCurrent(); + + // Calculate movement + glm::vec3 vMoveBy; + { + glm::vec3 vEye; + glm::vec3 vView; + glm::vec3 vUp; + gltf_get_camera_pos(&vEye,&vView,&vUp); + float fModelSize =(float)gltf_get_model_size(); + + glm::vec3 vMove = vView-vEye; + vMove = glm::normalize(vMove); + vMove *= 25.0f; + glm::vec3 vStrafe = glm::cross(vView-vEye, vUp); + vStrafe = glm::normalize(vStrafe); + vStrafe *= 25.0f; + glm::vec3 vMup = glm::cross(vView-vEye,glm::vec3(1.f,0.f,0.f) ); + vMup = glm::normalize(vMup); + vMup *= 25.0f; + + if(nCode == KEY_Q)vMoveBy += vMove*(0.1f*fModelSize); + if(nCode == KEY_E)vMoveBy -= vMove*(0.1f*fModelSize); + if(nCode == KEY_A)vMoveBy -= vStrafe*(0.1f*fModelSize); + if(nCode == KEY_D)vMoveBy += vStrafe*(0.1f*fModelSize); + 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); - gltf_prepare_renderer(m_pHandle); - gltf_renderer(m_pHandle); - gltf_complete_renderer(); - m_pContext->swapBuffers(); + gltf_renderer_move_camera(vMoveBy.x,vMoveBy.y,vMoveBy.z,10.0); + gltf_prepare_renderer(m_pHandle); + gltf_renderer(m_pHandle); + gltf_complete_renderer(); + m_pContext->swapBuffers(); + } } } return 0; |