2 This file is part of the graphics core library.
4 Copyright (c) 2004, 2005 John Tsiombikas <nuclear@siggraph.org>
6 the graphics core library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 the graphics core library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the graphics core library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef _BASE_CAM_HPP_
21 #define _BASE_CAM_HPP_
24 #include "animation.hpp"
25 #include "n3dmath2/n3dmath2.hpp"
27 enum ClipPlane {CLIP_NEAR, CLIP_FAR};
29 /* DON'T change the order of these enums!
30 * The frustum plane extraction algorithm depends on it.
32 enum {FRUSTUM_LEFT, FRUSTUM_RIGHT, FRUSTUM_BOTTOM, FRUSTUM_TOP, FRUSTUM_NEAR, FRUSTUM_FAR};
36 scalar_t a, b, c, d; // the plane equation coefficients
39 FrustumPlane(scalar_t a, scalar_t b, scalar_t c, scalar_t d);
40 FrustumPlane(const Matrix4x4 &mat, int plane);
44 class BaseCamera : public XFormNode {
47 scalar_t near_clip, far_clip;
51 mutable FrustumPlane frustum[6];
53 struct {bool x, y, z;} flip_view;
55 virtual void setup_frustum(const Matrix4x4 &m);
58 BaseCamera(const Vector3 &trans = Vector3(0,0,0), const Quaternion &rot = Quaternion());
59 virtual ~BaseCamera();
61 virtual void set_up_vector(const Vector3 &up);
63 virtual void set_fov(scalar_t angle);
64 virtual scalar_t get_fov() const;
66 virtual void set_aspect(scalar_t aspect);
67 virtual scalar_t get_aspect() const;
69 virtual void set_clipping_planes(scalar_t near_clip, scalar_t far_clip);
70 virtual void set_clipping_plane(scalar_t val, ClipPlane which);
71 virtual scalar_t get_clipping_plane(ClipPlane which) const;
73 virtual void zoom(scalar_t zoom_factor, unsigned long msec = XFORM_LOCAL_PRS);
74 virtual void pan(const Vector2 &dir, unsigned long msec = XFORM_LOCAL_PRS);
75 virtual void roll(scalar_t angle, unsigned long msec = XFORM_LOCAL_PRS);
77 virtual void flip(bool x, bool y, bool z);
79 virtual const FrustumPlane *get_frustum() const;
81 virtual Matrix4x4 get_camera_matrix(unsigned long msec = XFORM_LOCAL_PRS) const = 0;
82 virtual Matrix4x4 get_projection_matrix() const;
84 virtual void activate(unsigned long msec = XFORM_LOCAL_PRS) const;
87 #endif // _BASE_CAM_HPP_