[osg-users] Smoothing camera movements from HMD's input.

Brian R Hill bhill22 at csc.com
Tue Sep 30 09:35:07 PDT 2008

You don't want to interpolate euler angles. You'll have issues with zero
crossings and gimbal lock, unless you add a bunch of checks and


-----osg-users-bounces at lists.openscenegraph.org wrote: -----

To: OpenSceneGraph Users <osg-users at lists.openscenegraph.org>
From: Stephan Maximilian Huber <ratzfatz at digitalmind.de>
Sent by: osg-users-bounces at lists.openscenegraph.org
Date: 09/30/2008 12:25PM
Subject: Re: [osg-users] Smoothing camera movements from HMD's input.

Hi Alessandro,

alessandro terenzi schrieb:
> I'm integrating a head mounted display (HMD) in my OSG application, the
> HMD's APIs give me Euler's angles (yaw, pitch and roll) and I use them to
> adjust my scene's camera view using an update callback.
> But I noticed that, changing camera view from frame to frame, results in
> jerky movements, even when I try to rotate my head very slowly.
> In order to solve this problem, I was thinking about creating an
> path (on the fly) from a previously stored orientation to current head
> orientation. Is this the correct way to proceed? Or there is some other
> technique to smooth the resulting camera movements?

you can just interpolate the euler-angles:

const float scalar(0.9f);
currentYaw  = currentYaw   * scalar + newYaw   * (1-scalar);
curentPitch = currentPitch * scalar + newPitch * (1-scalar);
currentRoll = currentRoll  * scalar * newRoll  * (1-scalar);

current(Yaw|Pitch|Roll) are stord between successive frames and are used
to construct the matrices. Depending on the scalar jerky movement gets
flattened, you'll have to tweak the parameter to your needs.

You can even interpolate between quads:

osg::Quad newQuad = .. // construct the quad out of your euler angles
currentQuad = currentQuad.slerp(currentQuad, newQuad, scalar);

store currentquad for the next frame and use it to construct the view

this is code out of my head, the chance is high, that it doesn't compile.


osg-users mailing list
osg-users at lists.openscenegraph.org

More information about the osg-users mailing list