fhRenderMatrix fhRenderMatrix::CreateLookAtMatrix( const idVec3& viewOrigin, const idVec3& at, const idVec3& up ) { fhRenderMatrix rot = CreateLookAtMatrix( at - viewOrigin, up ); fhRenderMatrix translate; translate[12] = -viewOrigin.x; translate[13] = -viewOrigin.y; translate[14] = -viewOrigin.z; return rot * translate; }
void Camera::compute( const vec3 target, const float x_view_angle, const float y_view_angle) { const vec3 y = _smooth_banshee_y; const vec3 z = _smooth_banshee_z; const vec3 x = cross(y, z); // camera position offset in banshee coord system const vec3 offset( sin(x_view_angle), -cos(x_view_angle) * cos(y_view_angle), cos(x_view_angle) * sin(y_view_angle) ); // set camera position _position = _smooth_banshee_position + x * offset.x * _back_range + y * offset.y * _back_range + z * offset.z * _back_range; _view_mat = CreateLookAtMatrix(_position, target, z); }
Camera::Camera( const mat4x4 start_position, const float half_life, const float back_range) : _half_life(half_life), _back_range(back_range) { const vec3 banshee_position( start_position(0, 3), start_position(1, 3), start_position(2, 3)); const vec3 banshee_y( start_position(0, 1), start_position(1, 1), start_position(2, 1)); const vec3 banshee_z( start_position(0, 2), start_position(1, 2), start_position(2, 2)); _view_mat = CreateLookAtMatrix( _position, _position + banshee_y, banshee_z); _smooth_banshee_position = banshee_position; _smooth_banshee_y = banshee_y; _smooth_banshee_z = banshee_z; compute( banshee_position + banshee_y * infinity, 0, 0); }