Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoCamera.h
1 #ifndef COIN_SOCAMERA_H
2 #define COIN_SOCAMERA_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/nodes/SoSubNode.h>
37 #include <Inventor/SbViewportRegion.h>
38 #include <Inventor/SbViewVolume.h>
39 #include <Inventor/fields/SoSFRotation.h>
40 #include <Inventor/fields/SoSFEnum.h>
41 #include <Inventor/fields/SoSFVec3f.h>
42 #include <Inventor/fields/SoSFFloat.h>
43 
44 #include <Inventor/SbVec3f.h>
45 #include <Inventor/SbMatrix.h>
46 #include <Inventor/SbBox3f.h>
47 
48 #define SO_ASPECT_SQUARE 1.0f
49 #define SO_ASPECT_VIDEO (4.0f/3.0f)
50 #define SO_ASPECT_35mm_ACADEMY 1.371
51 #define SO_ASPECT_16mm 1.369
52 #define SO_ASPECT_35mm_FULL 1.33333
53 #define SO_ASPECT_70mm 2.287
54 #define SO_ASPECT_CINEMASCOPE 2.35
55 #define SO_ASPECT_HDTV (16.0f/9.0f)
56 #define SO_ASPECT_PANAVISION 2.361
57 #define SO_ASPECT_35mm (3.0f/2.0f)
58 #define SO_ASPECT_VISTAVISION 2.301
59 
60 class SoPath;
61 
62 class SoCameraP;
63 
64 class COIN_DLL_API SoCamera : public SoNode {
65  typedef SoNode inherited;
66 
68 
69 public:
70  static void initClass(void);
71 
73  CROP_VIEWPORT_FILL_FRAME,
74  CROP_VIEWPORT_LINE_FRAME,
75  CROP_VIEWPORT_NO_FRAME,
76  ADJUST_CAMERA,
77  LEAVE_ALONE
78  };
79 
87 
88  SbViewVolume getViewVolume(const SbViewportRegion & vp,
89  SbViewportRegion & resultvp,
90  const SbMatrix & mm = SbMatrix::identity()) const;
91 
92  void pointAt(const SbVec3f & targetpoint);
93  void pointAt(const SbVec3f & targetpoint, const SbVec3f & upvector);
94  virtual void scaleHeight(float scalefactor) = 0;
95  virtual SbViewVolume getViewVolume(float useaspectratio = 0.0f) const = 0;
96  void viewAll(SoNode * const sceneroot, const SbViewportRegion & vpregion,
97  const float slack = 1.0f);
98  void viewAll(SoPath * const path, const SbViewportRegion & vpregion,
99  const float slack = 1.0f);
100  SbViewportRegion getViewportBounds(const SbViewportRegion & region) const;
101 
102  enum StereoMode {
105  RIGHT_VIEW
106  };
107 
108  void setStereoMode(StereoMode mode);
109  StereoMode getStereoMode(void) const;
110 
111  void setStereoAdjustment(float adjustment);
112  float getStereoAdjustment(void) const;
113  void setBalanceAdjustment(float adjustment);
114  float getBalanceAdjustment(void) const;
115 
116  virtual void doAction(SoAction * action);
117  virtual void callback(SoCallbackAction * action);
118  virtual void GLRender(SoGLRenderAction * action);
119  virtual void audioRender(SoAudioRenderAction *action);
120  virtual void getBoundingBox(SoGetBoundingBoxAction * action);
121  virtual void getMatrix(SoGetMatrixAction * action);
122  virtual void handleEvent(SoHandleEventAction * action);
123  virtual void rayPick(SoRayPickAction * action);
124  virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
125  virtual void viewBoundingBox(const SbBox3f & box, float aspect,
126  float slack) = 0;
127 protected:
128  SoCamera(void);
129  virtual ~SoCamera();
130 
131  virtual void jitter(int numpasses, int curpass,
132  const SbViewportRegion & vpreg,
133  SbVec3f & jitteramount) const;
134 
135 private:
136  void getView(SoAction * action, SbViewVolume & resultvv,
137  SbViewportRegion & resultvp,
138  const SbBool considermodelmatrix = TRUE);
139 
140  void drawCroppedFrame(SoGLRenderAction * action,
141  const int viewportmapping,
142  const SbViewportRegion & oldvp,
143  const SbViewportRegion & newvp);
144 
145  void lookAt(const SbVec3f & dir, const SbVec3f & up);
146 
147  StereoMode stereomode;
148  float stereoadjustment;
149  float balanceadjustment;
150 private:
151  SoCameraP *pimpl;
152  friend class SoCameraP;
153 };
154 
155 #endif // !COIN_SOCAMERA_H
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition: SoBase.h:45
The SoRayPickAction class does ray intersection with scene graphs.
Definition: SoRayPickAction.h:50
Definition: SoCamera.h:103
virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action)
Definition: SoNode.cpp:894
SoSFFloat nearDistance
Definition: SoCamera.h:84
The SoGetMatrixAction class is an action for accumulating the transformation matrix of a subgraph...
Definition: SoGetMatrixAction.h:46
ViewportMapping
Definition: SoCamera.h:72
The SoCamera class is the abstract base class for camera definition nodes.
Definition: SoCamera.h:64
The SoSFRotation class is a container for an SbRotation.
Definition: SoSFRotation.h:40
Definition: SoCamera.h:104
The SbBox3f class is an abstraction for an axis aligned 3 dimensional box.
Definition: SbBox3f.h:46
StereoMode
Definition: SoCamera.h:102
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
SoSFRotation orientation
Definition: SoCamera.h:82
The SoSFEnum class is a container for an enum value.
Definition: SoSFEnum.h:40
SoSFFloat aspectRatio
Definition: SoCamera.h:83
SoSFVec3f position
Definition: SoCamera.h:81
SoSFFloat focalDistance
Definition: SoCamera.h:86
virtual void rayPick(SoRayPickAction *action)
Definition: SoNode.cpp:1139
virtual void audioRender(SoAudioRenderAction *action)
Definition: SoNode.cpp:1307
The SoPath class is a container class for traversal path descriptions.
Definition: SoPath.h:52
virtual void getMatrix(SoGetMatrixAction *action)
Definition: SoNode.cpp:1053
The SoAudioRenderAction class renders the aural parts of the scene graph.
Definition: SoAudioRenderAction.h:42
The SoAction class is the base class for all traversal actions.
Definition: SoAction.h:77
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition: SbVec3f.h:51
SoSFFloat farDistance
Definition: SoCamera.h:85
virtual void doAction(SoAction *action)
Definition: SoNode.cpp:809
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition: SbMatrix.h:47
The SoHandleEventAction class distributes user events to the scene.
Definition: SoHandleEventAction.h:46
The SoGetPrimitiveCountAction class counts the primitives in a scene.
Definition: SoGetPrimitiveCountAction.h:44
The SoGetBoundingBoxAction class calculates bounding boxes for nodes and subgraphs.
Definition: SoGetBoundingBoxAction.h:45
static SbMatrix identity(void)
Definition: SbMatrix.cpp:848
The SbViewVolume class is a viewing volume in 3D space.
Definition: SbViewVolume.h:50
The SoCallbackAction class invokes callbacks at specific nodes.
Definition: SoCallbackAction.h:80
SoSFEnum viewportMapping
Definition: SoCamera.h:80
The SoSFFloat class is a container for a floating point value.
Definition: SoSFFloat.h:39
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
Definition: SoNode.cpp:865
The SoSFVec3f class is a container for an SbVec3f vector.
Definition: SoSFVec3f.h:40
The SbViewportRegion class is a viewport within a full window.
Definition: SbViewportRegion.h:40
virtual void GLRender(SoGLRenderAction *action)
Definition: SoNode.cpp:954
virtual void callback(SoCallbackAction *action)
Definition: SoNode.cpp:1026
virtual void handleEvent(SoHandleEventAction *action)
Definition: SoNode.cpp:1083
#define SO_NODE_ABSTRACT_HEADER(classname)
The SoGLRenderAction class renders the scene graph with OpenGL calls.
Definition: SoGLRenderAction.h:50