Loading...
Searching...
No Matches
frameRecorder.h
Go to the documentation of this file.
1//
2// Copyright 2019 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_USD_IMAGING_USD_APP_UTILS_FRAME_RECORDER_H
25#define PXR_USD_IMAGING_USD_APP_UTILS_FRAME_RECORDER_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usdImaging/usdAppUtils/api.h"
31
33#include "pxr/base/tf/token.h"
34#include "pxr/usd/usd/stage.h"
35#include "pxr/usd/usd/timeCode.h"
38
39#include <string>
40
41
42PXR_NAMESPACE_OPEN_SCOPE
43
44
58{
59public:
70 USDAPPUTILS_API
72 const TfToken& rendererPluginId = TfToken(),
73 bool gpuEnabled = true,
74 const SdfPath& renderSettingsPrimPath = SdfPath());
75
79 return _imagingEngine.GetCurrentRendererId();
80 }
81
88 bool SetRendererPlugin(const TfToken& id) {
89 const bool succeeded = _imagingEngine.SetRendererPlugin(id);
90 _imagingEngine.SetEnablePresentation(false);
91
92 return succeeded;
93 }
94
101 void SetImageWidth(const size_t imageWidth) {
102 if (imageWidth == 0u) {
103 TF_CODING_ERROR("Image width cannot be zero");
104 return;
105 }
106 _imageWidth = imageWidth;
107 }
108
112 void SetComplexity(const float complexity) {
113 _complexity = complexity;
114 }
115
119 USDAPPUTILS_API
120 void SetColorCorrectionMode(const TfToken& colorCorrectionMode);
121
126 USDAPPUTILS_API
127 void SetCameraLightEnabled(bool cameraLightEnabled);
128
135 USDAPPUTILS_API
136 void SetIncludedPurposes(const TfTokenVector& purposes);
137
154 USDAPPUTILS_API
155 bool Record(
156 const UsdStagePtr& stage,
157 const UsdGeomCamera& usdCamera,
158 const UsdTimeCode timeCode,
159 const std::string& outputImagePath);
160
161private:
162 UsdImagingGLEngine _imagingEngine;
163 size_t _imageWidth;
164 float _complexity;
165 TfToken _colorCorrectionMode;
166 TfTokenVector _purposes;
167 SdfPath _renderSettingsPrimPath;
168 bool _cameraLightEnabled;
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:290
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
A utility class for recording images of USD stages.
Definition: frameRecorder.h:58
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.
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:88
USDAPPUTILS_API UsdAppUtilsFrameRecorder(const TfToken &rendererPluginId=TfToken(), bool gpuEnabled=true, const SdfPath &renderSettingsPrimPath=SdfPath())
The rendererPluginId argument indicates the renderer plugin that Hyrda should use.
TfToken GetCurrentRendererId() const
Gets the ID of the Hydra renderer plugin that will be used for recording.
Definition: frameRecorder.h:78
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.
Transformable camera.
Definition: camera.h:112
The UsdImagingGLEngine is the main entry point API for rendering USD scenes.
Definition: engine.h:96
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:84
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:85
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:457