Small Maya Camera Animator addendum

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Small Maya Camera Animator addendum

Post by Klunk »

a small snippet so the animator defaults to the initial camera setup.

in CSceneNodeAnimatorCameraMaya.h change the constructor to

Code: Select all

CSceneNodeAnimatorCameraMaya(vector3df& campos, vector3df& targpos, ICursorControl* cursor, f32 rotateSpeed = -1500.0f, 
        f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f);
 
and in CSceneNodeAnimatorCameraMaya.cpp change the constructor to
 

Code: Select all

CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(vector3df& campos, vector3df& targpos,
                irr::gui::ICursorControl* cursor, f32 rotate, f32 zoom, f32 translate )
    : CursorControl(cursor), OldCamera(0), MousePos(0.5f, 0.5f),
    ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate),
    Zooming(false), Rotating(false), Moving(false), Translating(false)
{
    #ifdef _DEBUG
    setDebugName("CSceneNodeAnimatorCameraMaya");
    #endif
 
    if (CursorControl)
    {
        CursorControl->grab();
        MousePos = CursorControl->getRelativePosition();
    }
 
// convert the init camera setup into the correct starting point for the animator
 
    vector3df camdir = campos - targpos; 
    vector3df rot = camdir.getSphericalCoordinateAngles();
    RotX = -rot.Y;
    RotY = 90.0f - rot.X;
    CurrentZoom = camdir.getLength();
    allKeysUp();
}
 
then to add to a scene you can use something like....
 

Code: Select all

ICameraSceneNode* cam = smgr->addCameraSceneNode(0,campos,target);
if(cam)
{
    ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraMaya(campos, target, gDevice->getCursorControl(), -1500.0f, 200.0f, 1500.0f);
    cam->addAnimator(anm);
    anm->drop();
}
 
or edit the factory function in source scene files.
Post Reply