All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
camera.h
1 //
2 // Copyright 2017 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef HD_CAMERA_H
25 #define HD_CAMERA_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hd/sprim.h"
31 
32 #include "pxr/imaging/cameraUtil/conformWindow.h"
33 
34 #include "pxr/usd/sdf/path.h"
35 #include "pxr/base/tf/staticTokens.h"
36 #include "pxr/base/gf/matrix4d.h"
37 
38 #include <boost/shared_ptr.hpp>
39 
40 #include <vector>
41 
42 PXR_NAMESPACE_OPEN_SCOPE
43 
48 #define HD_CAMERA_TOKENS \
49  /* basic params */ \
50  (worldToViewMatrix) \
51  (projectionMatrix) \
52  (clipPlanes) \
53  (windowPolicy) \
54  /* additional params (in world units)*/ \
55  (horizontalAperture) \
56  (verticalAperture) \
57  (horizontalApertureOffset) \
58  (verticalApertureOffset) \
59  (focalLength) \
60  (clippingRange) \
61  \
62  (fStop) \
63  (focusDistance) \
64  \
65  (shutterOpen) \
66  (shutterClose)
67 
68 
69 TF_DECLARE_PUBLIC_TOKENS(HdCameraTokens, HD_API, HD_CAMERA_TOKENS);
70 
71 class HdSceneDelegate;
72 
80 class HdCamera : public HdSprim {
81 public:
82  typedef std::vector<GfVec4d> ClipPlanesVector;
83 
84  HD_API
85  HdCamera(SdfPath const & id);
86  HD_API
87  virtual ~HdCamera();
88 
89  // change tracking for HdCamera
90  enum DirtyBits : HdDirtyBits {
91  Clean = 0,
92  DirtyViewMatrix = 1 << 0,
93  DirtyProjMatrix = 1 << 1,
94  DirtyWindowPolicy = 1 << 2,
95  DirtyClipPlanes = 1 << 3,
96  DirtyParams = 1 << 4,
97  AllDirty = (DirtyViewMatrix
98  |DirtyProjMatrix
99  |DirtyWindowPolicy
100  |DirtyClipPlanes
101  |DirtyParams)
102  };
103 
104  // ---------------------------------------------------------------------- //
106  // ---------------------------------------------------------------------- //
107 
109  HD_API
110  virtual void Sync(HdSceneDelegate *sceneDelegate,
111  HdRenderParam *renderParam,
112  HdDirtyBits *dirtyBits) override;
113 
114 
118  HD_API
119  virtual HdDirtyBits GetInitialDirtyBitsMask() const override;
120 
121  // ---------------------------------------------------------------------- //
123  // ---------------------------------------------------------------------- //
124 
126  HD_API
127  GfMatrix4d const& GetViewMatrix() const {
128  return _worldToViewMatrix;
129  }
130 
132  HD_API
134  return _worldToViewInverseMatrix;
135  }
136 
138  HD_API
140  return _projectionMatrix;
141  }
142 
144  HD_API
145  std::vector<GfVec4d> const& GetClipPlanes() const {
146  return _clipPlanes;
147  }
148 
151  HD_API
152  CameraUtilConformWindowPolicy const& GetWindowPolicy() const {
153  return _windowPolicy;
154  }
155 
156 protected:
157  GfMatrix4d _worldToViewMatrix;
158  GfMatrix4d _worldToViewInverseMatrix;
159  GfMatrix4d _projectionMatrix;
160  CameraUtilConformWindowPolicy _windowPolicy;
161  std::vector<GfVec4d> _clipPlanes;
162 };
163 
164 PXR_NAMESPACE_CLOSE_SCOPE
165 
166 #endif // HD_CAMERA_H
HD_API GfMatrix4d const & GetViewInverseMatrix() const
Returns the matrix transformation from camera to world space.
Definition: camera.h:133
virtual HD_API HdDirtyBits GetInitialDirtyBitsMask() const override
Returns the minimal set of dirty bits to place in the change tracker for use in the first sync of thi...
Hydra schema for a camera that pulls the basic params (see above) during Sync.
Definition: camera.h:80
virtual HD_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override
Sprim API.
HD_API std::vector< GfVec4d > const & GetClipPlanes() const
Returns any additional clipping planes defined in camera space.
Definition: camera.h:145
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
HD_API CameraUtilConformWindowPolicy const & GetWindowPolicy() const
Returns the window policy of the camera.
Definition: camera.h:152
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
Adapter class providing data exchange with the client scene graph.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
HD_API GfMatrix4d const & GetViewMatrix() const
Camera parameters accessor API.
Definition: camera.h:127
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e...
Definition: sprim.h:54
HD_API GfMatrix4d const & GetProjectionMatrix() const
Returns the projection matrix for the camera.
Definition: camera.h:139