Loading...
Searching...
No Matches
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
16#include "pxr/base/tf/token.h"
17#include "pxr/usd/usd/stage.h"
18#include "pxr/usd/usd/timeCode.h"
21
22#include <string>
23
24
25PXR_NAMESPACE_OPEN_SCOPE
26
27
41{
42public:
48 USDAPPUTILS_API
50 const TfToken& rendererPluginId = TfToken(),
51 bool gpuEnabled = true);
52
56 return _imagingEngine.GetCurrentRendererId();
57 }
58
65 bool SetRendererPlugin(const TfToken& id) {
66 const bool succeeded = _imagingEngine.SetRendererPlugin(id);
67 _imagingEngine.SetEnablePresentation(false);
68
69 return succeeded;
70 }
71
77 USDAPPUTILS_API
79
83 USDAPPUTILS_API
85
92 void SetImageWidth(const size_t imageWidth) {
93 if (imageWidth == 0u) {
94 TF_CODING_ERROR("Image width cannot be zero");
95 return;
96 }
97 _imageWidth = imageWidth;
98 }
99
103 void SetComplexity(const float complexity) {
104 _complexity = complexity;
105 }
106
110 USDAPPUTILS_API
111 void SetColorCorrectionMode(const TfToken& colorCorrectionMode);
112
117 USDAPPUTILS_API
118 void SetCameraLightEnabled(bool cameraLightEnabled);
119
124 USDAPPUTILS_API
125 void SetDomeLightVisibility(bool domeLightsVisible);
126
133 USDAPPUTILS_API
134 void SetIncludedPurposes(const TfTokenVector& purposes);
135
152 USDAPPUTILS_API
153 bool Record(
154 const UsdStagePtr& stage,
155 const UsdGeomCamera& usdCamera,
156 const UsdTimeCode timeCode,
157 const std::string& outputImagePath);
158
159private:
160 UsdImagingGLEngine _imagingEngine;
161 size_t _imageWidth;
162 float _complexity;
163 TfToken _colorCorrectionMode;
164 TfTokenVector _purposes;
165 SdfPath _renderPassPrimPath;
166 SdfPath _renderSettingsPrimPath;
167 bool _cameraLightEnabled;
168 bool _domeLightsVisible;
169};
170
171
172PXR_NAMESPACE_CLOSE_SCOPE
173
174
175#endif
Low-level utilities for informing users of various internal and external diagnostic conditions.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
A utility class for recording images of USD stages.
Definition: frameRecorder.h:41
USDAPPUTILS_API UsdAppUtilsFrameRecorder(const TfToken &rendererPluginId=TfToken(), bool gpuEnabled=true)
The rendererPluginId argument indicates the renderer plugin that Hyrda should use.
USDAPPUTILS_API void SetColorCorrectionMode(const TfToken &colorCorrectionMode)
Sets the color correction mode to be used for recording.
void SetImageWidth(const size_t imageWidth)
Sets the width of the recorded image.
Definition: frameRecorder.h:92
USDAPPUTILS_API void SetCameraLightEnabled(bool cameraLightEnabled)
Turns the built-in camera light on or off.
bool SetRendererPlugin(const TfToken &id)
Sets the Hydra renderer plugin to be used for recording.
Definition: frameRecorder.h:65
TfToken GetCurrentRendererId() const
Gets the ID of the Hydra renderer plugin that will be used for recording.
Definition: frameRecorder.h:55
USDAPPUTILS_API void SetDomeLightVisibility(bool domeLightsVisible)
Sets the camera visibility of dome lights.
USDAPPUTILS_API void SetActiveRenderSettingsPrimPath(SdfPath const &path)
Sets the path to the render settings 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.
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.
USDAPPUTILS_API void SetActiveRenderPassPrimPath(SdfPath const &path)
Sets the path to the render pass prim to use.
Transformable camera.
Definition: camera.h:95
The UsdImagingGLEngine is the main entry point API for rendering USD scenes.
Definition: engine.h:79
USDIMAGINGGL_API void SetEnablePresentation(bool enabled)
Enable / disable presenting the render to bound framebuffer.
USDIMAGINGGL_API bool SetRendererPlugin(TfToken const &id)
Set the current render-graph delegate to id.
USDIMAGINGGL_API TfToken GetCurrentRendererId() const
Return the id of the currently used renderer plugin.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:67
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:68
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440