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 PXR_IMAGING_HD_CAMERA_H
25 #define PXR_IMAGING_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 <vector>
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
46 #define HD_CAMERA_TOKENS \
47  /* basic params */ \
48  (worldToViewMatrix) \
49  (projectionMatrix) \
50  (clipPlanes) \
51  (windowPolicy) \
52  /* additional params (in world units)*/ \
53  (horizontalAperture) \
54  (verticalAperture) \
55  (horizontalApertureOffset) \
56  (verticalApertureOffset) \
57  (focalLength) \
58  (clippingRange) \
59  \
60  (fStop) \
61  (focusDistance) \
62  \
63  (shutterOpen) \
64  (shutterClose)
65 
66 
67 TF_DECLARE_PUBLIC_TOKENS(HdCameraTokens, HD_API, HD_CAMERA_TOKENS);
68 
69 class HdSceneDelegate;
70 
78 class HdCamera : public HdSprim {
79 public:
80  typedef std::vector<GfVec4d> ClipPlanesVector;
81 
82  HD_API
83  HdCamera(SdfPath const & id);
84  HD_API
85  virtual ~HdCamera();
86 
87  // change tracking for HdCamera
88  enum DirtyBits : HdDirtyBits {
89  Clean = 0,
90  DirtyViewMatrix = 1 << 0,
91  DirtyProjMatrix = 1 << 1,
92  DirtyWindowPolicy = 1 << 2,
93  DirtyClipPlanes = 1 << 3,
94  DirtyParams = 1 << 4,
95  AllDirty = (DirtyViewMatrix
96  |DirtyProjMatrix
97  |DirtyWindowPolicy
98  |DirtyClipPlanes
99  |DirtyParams)
100  };
101 
102  // ---------------------------------------------------------------------- //
104  // ---------------------------------------------------------------------- //
105 
107  HD_API
108  virtual void Sync(HdSceneDelegate *sceneDelegate,
109  HdRenderParam *renderParam,
110  HdDirtyBits *dirtyBits) override;
111 
112 
116  HD_API
117  virtual HdDirtyBits GetInitialDirtyBitsMask() const override;
118 
119  // ---------------------------------------------------------------------- //
121  // ---------------------------------------------------------------------- //
122 
124  HD_API
125  GfMatrix4d const& GetViewMatrix() const {
126  return _worldToViewMatrix;
127  }
128 
130  HD_API
132  return _worldToViewInverseMatrix;
133  }
134 
136  HD_API
138  return _projectionMatrix;
139  }
140 
142  HD_API
143  std::vector<GfVec4d> const& GetClipPlanes() const {
144  return _clipPlanes;
145  }
146 
149  HD_API
150  CameraUtilConformWindowPolicy const& GetWindowPolicy() const {
151  return _windowPolicy;
152  }
153 
154 protected:
155  GfMatrix4d _worldToViewMatrix;
156  GfMatrix4d _worldToViewInverseMatrix;
157  GfMatrix4d _projectionMatrix;
158  CameraUtilConformWindowPolicy _windowPolicy;
159  std::vector<GfVec4d> _clipPlanes;
160 };
161 
162 PXR_NAMESPACE_CLOSE_SCOPE
163 
164 #endif // PXR_IMAGING_HD_CAMERA_H
HD_API GfMatrix4d const & GetViewInverseMatrix() const
Returns the matrix transformation from camera to world space.
Definition: camera.h:131
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:78
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:143
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:150
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:125
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e...
Definition: sprim.h:52
HD_API GfMatrix4d const & GetProjectionMatrix() const
Returns the projection matrix for the camera.
Definition: camera.h:137