Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
seac02developer's avatar
seac02developer
Honored Guest
12 years ago

Body Movement + rotation issue

Hi,
i've implementend body movement with GLUT for my avatar with w,s,a,d keys. When i turn my head or move the body of my avatar separately it works very well, but doing the two actions combined it's easy to notice a huge "shaking" in the camera movement causing a very disturbing motion sickness.

This is how i calculate my modelviewmatrix and how i set up it on my two cameras:

 float HeadPitch, HeadRoll, HeadYaw;
OculusVR->getEyePosition(&HeadYaw,&HeadPitch, &HeadRoll);

ovrFrameTiming hmdFrameTiming = ovrHmd_BeginFrame(OculusVR->HMD, 0);

EyePos.y = ovrHmd_GetFloat(OculusVR->HMD, OVR_KEY_EYE_HEIGHT, EyePos.y);
//Move on Eye pos from controls
OVR::Matrix4f yawRotate = OVR::Matrix4f::RotationY(HeadYaw);

Vector3f orientationVector = yawRotate.Transform(localMoveVector);

orientationVector *= MoveSpeed;
EyePos += orientationVector;


for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++)
{
OculusVR->eye = OculusVR->HMDDesc.EyeRenderOrder[eyeIndex];
OculusVR->eyeRenderPose[OculusVR->eye] = ovrHmd_BeginEyeRender(OculusVR->HMD, OculusVR->eye);
OVR::Quatf culo= OculusVR->eyeRenderPose[OculusVR->eye].Orientation;

OVR::Matrix4f finalRollPitchYaw = OVR::Matrix4f(culo);
OVR::Vector3f finalUp = finalRollPitchYaw.Transform(Vector3f(0,1,0));
OVR::Vector3f finalForward = finalRollPitchYaw.Transform(Vector3f(0,0,-1));
OVR::Vector3f shiftedEyePos = EyePos; //+ OculusVR->eyeRenderPose[OculusVR->eye].Position;

OVR::Matrix4f view = OVR::Matrix4f::LookAtRH(shiftedEyePos,shiftedEyePos + finalForward, finalUp);
OVR::Matrix4f proj = ovrMatrix4f_Projection(OculusVR->EyeRenderDesc[OculusVR->eye].Desc.Fov, 0.01f, 10000.0f, true);

if(eyeIndex == 0)
{
beginEditCP(leftCamera);
leftCamera->setProjectionMatrix(OVRtoOSG(proj));
viewm = OVRtoOSG(OVR::Matrix4f::Translation(OculusVR->EyeRenderDesc[OculusVR->eye].ViewAdjust) * view);
leftCamera->setModelviewMatrix(viewm);
endEditCP(leftCamera);
}
else
{
beginEditCP(rightCamera);
rightCamera->setProjectionMatrix(OVRtoOSG(proj));
viewm = OVRtoOSG(OVR::Matrix4f::Translation(OculusVR->EyeRenderDesc[OculusVR->eye].ViewAdjust) * view);
rightCamera->setModelviewMatrix(viewm);
endEditCP(rightCamera);
}
ovrHmd_EndEyeRender(OculusVR->HMD, OculusVR->eye, OculusVR->eyeRenderPose[ OculusVR->eye], &EyeTexture[ OculusVR->eye].Texture);
}
localMoveVector.x=0;
localMoveVector.y=0;
localMoveVector.z=0;

glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
ovrHmd_EndFrame(OculusVR->HMD);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glUseProgramTROIA(0);
}


And this is the GLUT part of my code, which reacts to key inputs:

void keyboard(unsigned char k, int x, int y)
{
switch(k)
{
case 27:
{
exit(0);
}
break;

case 115:
{
localMoveVector.z=1;
}
break;

case 119:
{
localMoveVector.z=-1;
}
break;
case 97:
{
localMoveVector.x=-1;
}
break;
case 100:
{
localMoveVector.x=1;
}
break;
}
}

1 Reply

  • One thing I would try is smoothing the movement out over several frames. Instead of directly incrementing the player's position when the key is pressed, you could add set his velocity in a given direction. The game could then sample the velocity each render frame and increment the position by the velocity times the change in time since the last frame.