I'm trying to implement a sort of chase cam, that stays sticky to it's target (effect: the target looks still, only the world rotates). I use the following code to calculate the camera position:
Now in my app, the position and target get updated correctly, but there seem to be problems with the up vector - camera rotation doesn't match the rotation of the target./* fix main cam stuff */
matrix4 mat = getSceneNode()->getRelativeTransformation();
matrix4 fixmat;
fixmat.setRotationDegrees(mat.getRotationDegrees());
// calculate cam position and target
vector3df lookat(0,0,(getSceneNode()->getBoundingBox().getExtent().Z + 1));
mat.transformVect(lookat);
// calculate cameras up vector
vector3df up(0,1,0);
fixmat.transformVect(up);
up.normalize();
vector3df campos(0,2,-3);
mat.transformVect(campos);
cams[E_CAMERA_FRONT]->setUpVector(up);
cams[E_CAMERA_FRONT]->setPosition(campos);
cams[E_CAMERA_FRONT]->setTarget(lookat);
What's strange, I use the same code in my other test app and it works like it should.
The main difference between both apps is that the first (not working) updates the camera from within a class method, the second one (working) updates the cam from within irrlicht main loop, without use of class methods - can it have any influence?
Any ideas what am I doing wrong?