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

Stephan Maximilian Huber ratzfatz at digitalmind.de
Tue Sep 30 09:25:45 PDT 2008


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 animation
> 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 
matrix,

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

Stephan








More information about the osg-users mailing list