Creating a camera that follows a node

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Creating a camera that follows a node

Post by Browndog »

I'm tring to make a camera that follows a node that is flying so not only does it turn left and right but it goes up and down and rolls etc..

I've been using one of the examples (http://irrlicht.sourceforge.net/phpBB2/ ... c&start=15) in the howtos section of the fourm and it seems to work fairly well except when the node turns or pitches the camera jumps in the opposite direction, once the turn operation is complete the camera fixes its self and ends up in hte correct postition. does anyone know why this happens here is the code for the camera movement:

Code: Select all

 void makeCockpit(irr::scene::ICameraSceneNode *camera,
                irr::scene::ISceneNode *node, 
                irr::core::vector3df offset)
{
    irr::core::matrix4 m;
    m.setRotationDegrees(node->getRotation());

    irr::core::vector3df frv = irr::core::vector3df (0.0f, 0.0f, 1.0f);
    m.transformVect(frv);

    irr::core::vector3df upv = irr::core::vector3df (0.0f, 1.0f, 0.0f);
    m.transformVect(upv);

    m.transformVect(offset);
   
    offset -= node->getPosition(); // I had to change this from += to -=
    camera->setPosition(offset);
   
    camera->setUpVector(upv);
   
    offset += frv;
    camera->setTarget(offset);
} 

Also I dont understand what frv and upv are or do? Maybe if I understood these I would be able fix the problem.
SARIN
Posts: 139
Joined: Fri Oct 29, 2004 3:53 am

Post by SARIN »

upv stands for upvector, its basically the direction up. 1 on the y axis means that up is y. this is also the pivot axis.
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Post by Browndog »

ahh ok, so that basicaly the translation require on the y axis and frv is the translation required on the Z axis?.
Post Reply