Camera::Camera():
fov(Geometry::Angle<float>::from_turns(0.125)),
+ height(0),
aspect(4.0/3.0),
clip_near(0.1),
clip_far(10),
position(0, 0, 0),
look_dir(0, 0, -1),
up_dir(0, 1, 0)
-{ }
+{
+ update_projection_matrix();
+ update_object_matrix();
+}
void Camera::set_field_of_view(const Geometry::Angle<float> &f)
{
update_projection_matrix();
}
+void Camera::set_orthographic(float w, float h)
+{
+ fov = Geometry::Angle<float>::zero();
+ height = h;
+ if(w)
+ aspect = w/h;
+ update_projection_matrix();
+}
+
void Camera::set_aspect(float a)
{
aspect = a;
float right = frustum_w*(frustum_x+1.0f);
float bottom = frustum_h*(frustum_y-1.0f);
float top = frustum_h*(frustum_y+1.0f);
- proj_matrix = Matrix::frustum(left, right, bottom, top, clip_near, clip_far);
+ if(fov>Geometry::Angle<float>::zero())
+ proj_matrix = Matrix::frustum(left, right, bottom, top, clip_near, clip_far);
+ else
+ proj_matrix = Matrix::ortho(left, right, bottom, top, clip_near, clip_far);
}
void Camera::update_object_matrix()