From 9e8dbd37c4dda5d07c22c66a5a2b08cce4d175f5 Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Thu, 17 Jul 2014 16:21:02 +0200 Subject: glTF: allow to move camera also by keyboard in orbit mode. Change-Id: Ibf16b9651988358c30d649dd937813329d0f64ec --- avmedia/source/opengl/oglwindow.cxx | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'avmedia') diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx index d082aa9d24f4..ce8f46242da0 100644 --- a/avmedia/source/opengl/oglwindow.cxx +++ b/avmedia/source/opengl/oglwindow.cxx @@ -260,15 +260,18 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent) vMup = glm::normalize(vMup); vMup *= 25.0f; - if(nCode == KEY_W)vMoveBy += vMove*(0.0005f*fModelSize); - if(nCode == KEY_S)vMoveBy -= vMove*(0.0005f*fModelSize); if( !m_bIsOrbitMode ) { + if(nCode == KEY_W)vMoveBy += vMove*(0.0005f*fModelSize); + if(nCode == KEY_S)vMoveBy -= vMove*(0.0005f*fModelSize); if(nCode == KEY_A)vMoveBy -= vStrafe*(0.0005f*fModelSize); if(nCode == KEY_D)vMoveBy += vStrafe*(0.0005f*fModelSize); } else { + if(nCode == KEY_E)vMoveBy += vMove*(0.0005f*fModelSize); + if(nCode == KEY_Q)vMoveBy -= vMove*(0.0005f*fModelSize); + // Limit zooming in orbit mode m_fCameraDistance += vMoveBy.z; if ((m_fCameraDistance < 0.5 * fModelSize && vMoveBy.z < 0.0 ) || @@ -280,6 +283,30 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent) } } gltf_renderer_move_camera(&m_rHandle, vMoveBy.x, vMoveBy.y, vMoveBy.z, 0.0); + + if( m_bIsOrbitMode ) + { + long nDeltaX = 0; + long nDeltaY = 0; + if (nCode == KEY_W) + { + nDeltaY -= 1; + } + if (nCode == KEY_S) + { + nDeltaY += 1; + } + if (nCode == KEY_A) + { + nDeltaX -= 1; + } + if (nCode == KEY_D) + { + nDeltaX += 1; + } + float fSensitivity = 50.0; + gltf_renderer_rotate_model(&m_rHandle, nDeltaX*fSensitivity, nDeltaY*fSensitivity, 0.0); + } } else if(nCode == KEY_M) { -- cgit