void set_frustum_axis(float, float);
void set_frustum_rotation(const Geometry::Angle<float> &);
const Geometry::Angle<float> &get_field_of_view() const { return fov; }
+ bool is_orthographic() const { return fov==Geometry::Angle<float>::zero(); }
+ float get_orthographic_width() const { return height*aspect; }
+ float get_orthographic_height() const { return height; }
float get_aspect() const { return aspect; }
float get_near_clip() const { return clip_near; }
float get_far_clip() const { return clip_far; }
culling_matrix = renderer.get_matrix();
- float y = tan(camera->get_field_of_view()/2.0f);
- float s = sqrt(y*y+1);
- frustum_edges[0] = Vector4(0, 1/s, y/s, 0);
- frustum_edges[1] = Vector4(0, -1/s, y/s, 0);
-
- float x = y*camera->get_aspect();
- s = sqrt(x*x+1);
- frustum_edges[2] = Vector4(1/s, 0, x/s, 0);
- frustum_edges[3] = Vector4(-1/s, 0, x/s, 0);
+ if(camera->is_orthographic())
+ {
+ float h = camera->get_orthographic_height();
+ frustum_edges[0] = Vector4(0, 1, 0, -h);
+ frustum_edges[1] = Vector4(0, -1, 0, -h);
+
+ float w = camera->get_orthographic_width();
+ frustum_edges[2] = Vector4(1, 0, 0, -w);
+ frustum_edges[3] = Vector4(-1, 0, 0, -w);
+ }
+ else
+ {
+ float y = tan(camera->get_field_of_view()/2.0f);
+ float s = sqrt(y*y+1);
+ frustum_edges[0] = Vector4(0, 1/s, y/s, 0);
+ frustum_edges[1] = Vector4(0, -1/s, y/s, 0);
+
+ float x = y*camera->get_aspect();
+ s = sqrt(x*x+1);
+ frustum_edges[2] = Vector4(1/s, 0, x/s, 0);
+ frustum_edges[3] = Vector4(-1/s, 0, x/s, 0);
+ }
frustum_edges[4] = Vector4(0, 0, -1, -camera->get_far_clip());
frustum_edges[5] = Vector4(0, 0, 1, camera->get_near_clip());