glTF rendering: workaround for camera movements

If the glTF contains camera movement in it moving camera
by keyboard didn't work very well.

Change-Id: I9300a257858d4f35c2d622654a0c2fd85eedc5ed
(cherry picked from commit 968b7f807561339d0083fe0aa6e893983ca60456)
This commit is contained in:
Zolnai Tamás 2014-05-28 15:33:39 +02:00
parent 16a6207901
commit 6773029347

View file

@ -270,18 +270,33 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent)
vMup = glm::normalize(vMup);
vMup *= 25.0f;
if(nCode == KEY_Q)vMoveBy += vMove*(0.001f*fModelSize);
if(nCode == KEY_E)vMoveBy -= vMove*(0.001f*fModelSize);
if(nCode == KEY_A)vMoveBy -= vStrafe*(0.001f*fModelSize);
if(nCode == KEY_D)vMoveBy += vStrafe*(0.001f*fModelSize);
if(nCode == KEY_W)vMoveBy -= vMup*(0.001f*fModelSize);
if(nCode == KEY_S)vMoveBy += vMup*(0.001f*fModelSize);
if(nCode == KEY_Q)vMoveBy += vMove*(0.0005f*fModelSize);
if(nCode == KEY_E)vMoveBy -= vMove*(0.0005f*fModelSize);
if(nCode == KEY_A)vMoveBy -= vStrafe*(0.0005f*fModelSize);
if(nCode == KEY_D)vMoveBy += vStrafe*(0.0005f*fModelSize);
if(nCode == KEY_W)vMoveBy -= vMup*(0.0005f*fModelSize);
if(nCode == KEY_S)vMoveBy += vMup*(0.0005f*fModelSize);
}
gltf_renderer_move_camera(m_pHandle, vMoveBy.x, vMoveBy.y, vMoveBy.z, 0.0);
update();
}
}
}
// TODO: Clean this mess up after libgltf gets a working camera handling
else if( pEvent->GetId() == VCLEVENT_WINDOW_KEYUP )
{
KeyEvent* pKeyEvt = (KeyEvent*)pEvent->GetData();
if(pKeyEvt)
{
const sal_uInt16 nCode = pKeyEvt->GetKeyCode().GetCode();
if (nCode == KEY_Q || nCode == KEY_E ||
nCode == KEY_A || nCode == KEY_D ||
nCode == KEY_W || nCode == KEY_S )
{
gltf_renderer_move_camera(m_pHandle, 0.0, 0.0, 0.0, 0.0);
}
}
}
else if( pEvent->GetId() == VCLEVENT_WINDOW_MOUSEBUTTONDOWN )
{
MouseEvent* pMouseEvt = (MouseEvent*)pEvent->GetData();