Game Development Community

dev|Pro Game Development Curriculum

Interpolation Controller

by Phillip O'Shea · 11/09/2009 (12:56 am) · 2 comments

I got pretty sick of rewriting interpolation methods for objects I was creating, so I made a nice little class to deal with it for me!

Download the code

It handles different methods of rotation so you don't need to do any of the crazy math yourself. Some of it hasn't been tested very thoroughly so let me know if there are any issues.

Here is the basic implementation:
class MyClass
{
    // ...

    VInterpController mInterpController;

    // ...
}

bool MyClass::onAdd()
{
   //...

   mInterpController.resetDelta( getTransform() );

   //...
}

void MyClass::processTick( const Move *pMove )
{
    // Pop Delta.
    mInterpController.popDelta();

    // Move Object.
    // ...

    // Push Delta.
    mInterpController.pushDelta( getTransform() );
}

void MyClass::interpolateTick( F32 pDelta )
{
    // Get Interpolated Transform.
    const MatrixF transform = mInterpController.getTransform( pDelta );
    // Set Render Transform.
    setRenderTransform( transform );
}

About the author

Head of Violent Tulip, a small independent software development company working in Wollongong, Australia. Go to http://www.violent-tulip.com/ to see our latest offerings.


#1
11/09/2009 (5:10 am)
Thanks Phillip, very useful!
#2
11/09/2009 (7:33 pm)
Hey, that's really handy!