1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
15#define OSG_CAMERAVIEW 1
18#include <osg/Transform>
19#include <osg/AnimationPath>
25/** CameraView - is a Transform that is used to specify camera views from within the scene graph.
26 * The application must attach a camera to a CameraView via the NodePath from the top of the scene graph
27 * to the CameraView node itself, and accumulate the view matrix from this NodePath.
29class OSG_EXPORT CameraView : public Transform
34 CameraView(const CameraView& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
35 Transform(pat,copyop),
36 _position(pat._position),
37 _attitude(pat._attitude),
38 _fieldOfView(pat._fieldOfView),
39 _fieldOfViewMode(pat._fieldOfViewMode),
40 _focalLength(pat._focalLength) {}
43 META_Node(osg, CameraView);
45 /** Set the position of the camera view.*/
46 inline void setPosition(const Vec3d& pos) { _position = pos; dirtyBound(); }
48 /** Get the position of the camera view.*/
49 inline const Vec3d& getPosition() const { return _position; }
51 /** Set the attitude of the camera view.*/
52 inline void setAttitude(const Quat& quat) { _attitude = quat; dirtyBound(); }
54 /** Get the attitude of the camera view.*/
55 inline const Quat& getAttitude() const { return _attitude; }
57 /** Set the field of view.
58 * The camera's field of view can be constrained to either the horizontal or vertical axis of the camera, or unconstrained
59 * in which case the camera/application are left to choose an appropriate field of view.
60 * The default value if 60 degrees. */
61 inline void setFieldOfView(double fieldOfView) { _fieldOfView = fieldOfView; }
63 /** Get the field of view.*/
64 inline double getFieldOfView() const { return _fieldOfView; }
73 /** Set the field of view mode - controlling how the field of view of the camera is constrained by the CameraView settings.*/
74 inline void setFieldOfViewMode(FieldOfViewMode mode) { _fieldOfViewMode = mode; }
76 /** Get the field of view mode.*/
77 inline FieldOfViewMode getFieldOfViewMode() const { return _fieldOfViewMode; }
79 /** Set the focal length of the camera.
80 * A focal length of 0.0 indicates that the camera/application should determine the focal length.
81 * The default value is 0.0. */
82 inline void setFocalLength(double focalLength) { _focalLength = focalLength; }
84 /** Get the focal length of the camera.*/
85 inline double getFocalLength() const { return _focalLength; }
88 virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
89 virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
94 virtual ~CameraView() {}
99 FieldOfViewMode _fieldOfViewMode;