Original Post
Hi Somehow I don't get the camera rotation working correctly :( Normally this should be done in 5min but somehow I don't get it right this time.
__forceinline void addCameraRotationX(type::real rotx)
{
type::real dy= _position.r[Y] - _target.r[Y];
type::real dz= _position.r[Z] - _target.r[Z];
type::real len= sqrt(dy*dy + dz*dz);
type::real angle= atan(dy / dz) + rotx;
_position.r[Y]= _target.r[Y] + len * sin(angle);
_position.r[Z]= _target.r[Z] + len * cos(angle);
_view_matrix_version++;
}
__forceinline void addCameraRotationY(type::real roty)
{
type::real dx= _position.r[X] - _target.r[X];
type::real dz= _position.r[Z] - _target.r[Z];
type::real len= sqrt(dx*dx + dz*dz);
type::real angle= atan(dz / dx) + roty;
_position.r[X]= _target.r[X] + len * cos(angle);
_position.r[Z]= _target.r[Z] + len * sin(angle);
_view_matrix_version++;
} I'm sure my mistake should be quite obvious but I just can't see it. Please help. cheers Daniel