root/OpenSceneGraph/trunk/include/osg/CameraView @ 13041

Revision 13041, 3.8 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
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.
7 *
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.
12*/
13
14#ifndef OSG_CAMERAVIEW
15#define OSG_CAMERAVIEW 1
16
17#include <osg/Group>
18#include <osg/Transform>
19#include <osg/AnimationPath>
20#include <osg/Vec3d>
21#include <osg/Quat>
22
23namespace osg {
24
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.
28*/
29class OSG_EXPORT CameraView : public Transform
30{
31    public :
32        CameraView();
33
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) {}
41
42
43        META_Node(osg, CameraView);
44
45        /** Set the position of the camera view.*/
46        inline void setPosition(const Vec3d& pos) { _position = pos; dirtyBound(); }
47
48        /** Get the position of the camera view.*/
49        inline const Vec3d& getPosition() const { return _position; }
50
51        /** Set the attitude of the camera view.*/
52        inline void setAttitude(const Quat& quat) { _attitude = quat; dirtyBound(); }
53
54        /** Get the attitude of the camera view.*/
55        inline const Quat& getAttitude() const { return _attitude; }
56
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; }
62
63        /** Get the field of view.*/
64        inline double getFieldOfView() const { return _fieldOfView; }
65
66        enum FieldOfViewMode
67        {
68            UNCONSTRAINED,
69            HORIZONTAL,
70            VERTICAL
71        };
72
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; }
75
76        /** Get the field of view mode.*/
77        inline FieldOfViewMode getFieldOfViewMode() const { return _fieldOfViewMode; }
78
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; }
83
84        /** Get the focal length of the camera.*/
85        inline double getFocalLength() const { return _focalLength; }
86
87
88        virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
89        virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
90
91
92    protected :
93
94        virtual ~CameraView() {}
95
96        Vec3d           _position;
97        Quat            _attitude;
98        double          _fieldOfView;
99        FieldOfViewMode _fieldOfViewMode;
100        double          _focalLength;
101};
102
103}
104
105#endif
Note: See TracBrowser for help on using the browser.