aspect(4.0/3.0),
clip_near(0.1),
clip_far(10),
+ frustum_x(0),
+ frustum_y(0),
position(0, 0, 0),
look_dir(0, 0, -1),
up_dir(0, 1, 0)
clip_far = f;
}
+void Camera::set_frustum_axis(float x, float y)
+{
+ frustum_x = x;
+ frustum_y = y;
+}
+
void Camera::set_position(const Vector3 &p)
{
position = p;
void Camera::apply() const
{
- MatrixStack::projection() = Matrix::perspective(fov, aspect, clip_near, clip_far);
+ float frustum_h = tan(fov/2.0f)*clip_near;
+ float frustum_w = frustum_h*aspect;
+ float left = frustum_w*(frustum_x-1.0f);
+ float right = frustum_w*(frustum_x+1.0f);
+ float bottom = frustum_h*(frustum_y-1.0f);
+ float top = frustum_h*(frustum_y+1.0f);
+ MatrixStack::projection() = Matrix::frustum(left, right, bottom, top, clip_near, clip_far);
MatrixStack::modelview() = matrix;
}
// Some compilers have "near" and "far" keywords
float clip_near;
float clip_far;
+ float frustum_x;
+ float frustum_y;
Vector3 position;
Vector3 look_dir;
Vector3 up_dir;
void set_field_of_view(const Geometry::Angle<float> &);
void set_aspect(float);
void set_depth_clip(float, float);
+ void set_frustum_axis(float, float);
const Geometry::Angle<float> &get_field_of_view() const { return fov; }
float get_aspect() const { return aspect; }
float get_near_clip() const { return clip_near; }