frameRecorder.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_IMAGING_USD_APP_UTILS_FRAME_RECORDER_H
8 #define PXR_USD_IMAGING_USD_APP_UTILS_FRAME_RECORDER_H
9 
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usdImaging/usdAppUtils/api.h"
14 
15 #include "pxr/base/tf/diagnostic.h"
16 #include "pxr/base/tf/token.h"
17 #include "pxr/usd/usd/stage.h"
18 #include "pxr/usd/usd/timeCode.h"
19 #include "pxr/usd/usdGeom/camera.h"
21 
22 #include <string>
23 
24 
25 PXR_NAMESPACE_OPEN_SCOPE
26 
27 
41 {
42 public:
51  USDAPPUTILS_API
53  const TfToken& rendererPluginId = TfToken(),
54  bool gpuEnabled = true,
55  bool enableUsdDrawModes = true);
56 
60  return _imagingEngine.GetCurrentRendererId();
61  }
62 
69  bool SetRendererPlugin(const TfToken& id) {
70  const bool succeeded = _imagingEngine.SetRendererPlugin(id);
71  _imagingEngine.SetEnablePresentation(false);
72 
73  return succeeded;
74  }
75 
81  USDAPPUTILS_API
82  void SetActiveRenderPassPrimPath(SdfPath const& path);
83 
87  USDAPPUTILS_API
88  void SetActiveRenderSettingsPrimPath(SdfPath const& path);
89 
96  void SetImageWidth(const size_t imageWidth) {
97  if (imageWidth == 0u) {
98  TF_CODING_ERROR("Image width cannot be zero");
99  return;
100  }
101  _imageWidth = imageWidth;
102  }
103 
107  void SetComplexity(const float complexity) {
108  _complexity = complexity;
109  }
110 
114  USDAPPUTILS_API
115  void SetColorCorrectionMode(const TfToken& colorCorrectionMode);
116 
121  USDAPPUTILS_API
122  void SetCameraLightEnabled(bool cameraLightEnabled);
123 
128  USDAPPUTILS_API
129  void SetDomeLightVisibility(bool domeLightsVisible);
130 
137  USDAPPUTILS_API
138  void SetIncludedPurposes(const TfTokenVector& purposes);
139 
141  USDAPPUTILS_API
142  void SetPrimaryCameraPrimPath(const SdfPath& cameraPath);
143 
160  USDAPPUTILS_API
161  bool Record(
162  const UsdStagePtr& stage,
163  const UsdGeomCamera& usdCamera,
164  const UsdTimeCode timeCode,
165  const std::string& outputImagePath);
166 
167 private:
168  UsdImagingGLEngine _imagingEngine;
169  size_t _imageWidth;
170  float _complexity;
171  TfToken _colorCorrectionMode;
172  TfTokenVector _purposes;
173  SdfPath _renderPassPrimPath;
174  SdfPath _renderSettingsPrimPath;
175  bool _cameraLightEnabled;
176  bool _domeLightsVisible;
177 };
178 
179 
180 PXR_NAMESPACE_CLOSE_SCOPE
181 
182 
183 #endif
USDAPPUTILS_API void SetPrimaryCameraPrimPath(const SdfPath &cameraPath)
Sets the primary camera prim path.
USDAPPUTILS_API void SetActiveRenderSettingsPrimPath(SdfPath const &path)
Sets the path to the render settings prim to use.
USDAPPUTILS_API void SetActiveRenderPassPrimPath(SdfPath const &path)
Sets the path to the render pass prim to use.
void SetComplexity(const float complexity)
Sets the level of refinement complexity.
USDAPPUTILS_API void SetIncludedPurposes(const TfTokenVector &purposes)
Sets the UsdGeomImageable purposes to be used for rendering.
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:69
USDIMAGINGGL_API TfToken GetCurrentRendererId() const
Return the id of the currently used renderer plugin.
Low-level utilities for informing users of various internal and external diagnostic conditions.
bool SetRendererPlugin(const TfToken &id)
Sets the Hydra renderer plugin to be used for recording.
Definition: frameRecorder.h:69
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:80
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:73
USDAPPUTILS_API bool Record(const UsdStagePtr &stage, const UsdGeomCamera &usdCamera, const UsdTimeCode timeCode, const std::string &outputImagePath)
Records an image and writes the result to outputImagePath.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:489
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
TfToken GetCurrentRendererId() const
Gets the ID of the Hydra renderer plugin that will be used for recording.
Definition: frameRecorder.h:59
A utility class for recording images of USD stages.
Definition: frameRecorder.h:40
USDAPPUTILS_API void SetColorCorrectionMode(const TfToken &colorCorrectionMode)
Sets the color correction mode to be used for recording.
USDAPPUTILS_API void SetCameraLightEnabled(bool cameraLightEnabled)
Turns the built-in camera light on or off.
USDIMAGINGGL_API void SetEnablePresentation(bool enabled)
Enable / disable presenting the render to bound framebuffer.
The UsdImagingGLEngine is the main entry point API for rendering USD scenes.
Definition: engine.h:83
USDAPPUTILS_API void SetDomeLightVisibility(bool domeLightsVisible)
Sets the camera visibility of dome lights.
void SetImageWidth(const size_t imageWidth)
Sets the width of the recorded image.
Definition: frameRecorder.h:96
USDAPPUTILS_API UsdAppUtilsFrameRecorder(const TfToken &rendererPluginId=TfToken(), bool gpuEnabled=true, bool enableUsdDrawModes=true)
The rendererPluginId argument indicates the renderer plugin that Hyrda should use.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
Transformable camera.
Definition: camera.h:129
USDIMAGINGGL_API bool SetRendererPlugin(TfToken const &id)
Set the current render-graph delegate to id.