X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcamera.cpp;h=3bba0eaf38e00385e68a077474095a980a10f340;hp=6ae162aeb77909fca84b20fa8bf9b9ed3389dfef;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=7cf5ebbc9d91d09d0664598d3fb88606c3307deb diff --git a/source/camera.cpp b/source/camera.cpp index 6ae162ae..3bba0eaf 100644 --- a/source/camera.cpp +++ b/source/camera.cpp @@ -116,12 +116,6 @@ Vector3 Camera::unproject(const Vector3 &p) const return unproject(Vector4(p.x, p.y, p.z, 1.0f)).slice<3>(0); } -void Camera::apply() const -{ - MatrixStack::projection() = proj_matrix; - MatrixStack::modelview() = view_matrix; -} - void Camera::update_projection_matrix() { float frustum_h = (fov!=Geometry::Angle::zero() ? tan(fov/2.0f)*clip_near : height/2); @@ -149,5 +143,59 @@ void Camera::update_object_matrix() view_matrix = invert(matrix); } + +Camera::Loader::Loader(Camera &c): + DataFile::ObjectLoader(c) +{ + add("aspect_ratio", &Loader::aspect_ratio); + add("depth_clip", &Loader::depth_clip); + add("field_of_view", &Loader::field_of_view); + add("look_at", &Loader::look_at); + add("look_direction", &Loader::look_direction); + add("orthographic", &Loader::orthographic); + add("position", &Loader::position); + add("up_direction", &Loader::up_direction); +} + +void Camera::Loader::aspect_ratio(float a) +{ + obj.set_aspect_ratio(a); +} + +void Camera::Loader::depth_clip(float n, float f) +{ + obj.set_depth_clip(n, f); +} + +void Camera::Loader::field_of_view(float a) +{ + obj.set_field_of_view(Geometry::Angle::from_degrees(a)); +} + +void Camera::Loader::look_at(float x, float y, float z) +{ + obj.look_at(Vector3(x, y, z)); +} + +void Camera::Loader::look_direction(float x, float y, float z) +{ + obj.set_look_direction(Vector3(x, y, z)); +} + +void Camera::Loader::orthographic(float w, float h) +{ + obj.set_orthographic(w, h); +} + +void Camera::Loader::position(float x, float y, float z) +{ + obj.set_position(Vector3(x, y, z)); +} + +void Camera::Loader::up_direction(float x, float y, float z) +{ + obj.set_up_direction(Vector3(x, y, z)); +} + } // namespace GL } // namespace Msp