Camcorder         A simple camcorder class for recording & playing back camera paths
Print


I use this class to help me record demos without having the jerky movement of a manually moved camera; the animation smooths out my motion making a more professional looking video. --Sinbad

To use this class, just include it in your project, and call init(viewport, camera) and setEnabled(true) to turn it on. You will need to call processUnbufferedKeyboard and update every frame. When enabled, you can start & stop recording the camera by pressing Insert, and toggle playback using Return. The brackets change the interval between the keyframes that are created in record mode, and the playback speed in playback mode. You can also place keyframes manually with the Space key.

It's currently limited to just one animation and there are no editing features built in, it's purely one-shot recording & playback. Feel free to extend it to full Final Cut Pro status if you want :-)

Prerequisites

This class was made using the 'old' overlays, so you need to grab OgreCore.zip from here:
http://ogre.svn.sourceforge.net/viewvc/ogre/branches/v1-6/Samples/Media/packs/OgreCore.zip(external link)

Add this to resources[_d].cfg:

Zip=../../media/packs/OgreCore.zip

 

Usage

Initialisation
camCorder = new CamcorderHelper();
camCorder->init(vp, mCamera);
camCorder->setEnabled(true);
frameRenderingQueued
camCorder->processUnbufferedKeyboard(mKeyboard, evt.timeSinceLastFrame);
camCorder->update(evt.timeSinceLastFrame);

 

Code

 

Loading and Saving animations using the AnimationSerializer

The AnimationSerializer was made to be able to save and load recorded camera animations, and it requires only two small changes to the CamcorderHelper class.

Camcorder modifications

Add these two lines to Camcorder.h:

const Animation* getAnimation() const {return mCurrentAnimation; }
void setAnimation(Animation* anim);

 
The definition of CamcorderHelper::setAnimation (in Camcorder.cpp):

void CamcorderHelper::setAnimation(Animation* anim)
{
    if(mCurrentAnimation)
        mCurrentAnimation->destroyAllTracks();
    mCurrentAnimation = anim;
    mCurrentTrack = anim->getNodeTrack(0);
    mCurrentAnimation->setInterpolationMode(mInterpolationMode);
    mCurrentAnimation->setRotationInterpolationMode(mRotationInterpolationMode);
    mCurrentTrack->setUseShortestRotationPath(false);
}

 

Loading and saving animations

Add ../../Media/animations to resources[_d].cfg, or choose an existing resource directory to save the animation in:

Save animation
AnimationSerializer animSerializer;
animSerializer.exportAnimation(camCorder->getAnimation(), "../../media/animations/cam.anim");

When loading an animation, you don't need to specify the full path to the resource location:

Load animation
AnimationSerializer animSerializer;
camCorder->setAnimation(animSerializer.importAnimation("cam.anim"));

 
To get a more accurate recording you can lower the frame frequency:

camCorder->setKeyFrameFrequency(0.1f);

 

Tip_icon.png Warning!
When saving a file, the serializer doesn't check if it's a valid resource location.


Contributors to this page: jacmoe111451 points  and OgreWikiBot .
Page last modified on Saturday 31 of July, 2010 22:43:15 GMT by jacmoe111451 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.