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:
67 USDAPPUTILS_API
69 const TfToken& rendererPluginId = TfToken(),
70 bool gpuEnabled = true,
71 const SdfPath& renderSettingsPrimPath = SdfPath());
72
76 return _imagingEngine.GetCurrentRendererId();
77 }
78
85 bool SetRendererPlugin(const TfToken& id) {
86 const bool succeeded = _imagingEngine.SetRendererPlugin(id);
87 _imagingEngine.SetEnablePresentation(false);
88
89 return succeeded;
90 }
91
98 void SetImageWidth(const size_t imageWidth) {
99 if (imageWidth == 0u) {
100 TF_CODING_ERROR("Image width cannot be zero");
101 return;
102 }
103 _imageWidth = imageWidth;
104 }
105
109 void SetComplexity(const float complexity) {
110 _complexity = complexity;
111 }
112
116 USDAPPUTILS_API
117 void SetColorCorrectionMode(const TfToken& colorCorrectionMode);
118
125 USDAPPUTILS_API
126 void SetIncludedPurposes(const TfTokenVector& purposes);
127
144 USDAPPUTILS_API
145 bool Record(
146 const UsdStagePtr& stage,
147 const UsdGeomCamera& usdCamera,
148 const UsdTimeCode timeCode,
149 const std::string& outputImagePath);
150
151private:
152 UsdImagingGLEngine _imagingEngine;
153 size_t _imageWidth;
154 float _complexity;
155 TfToken _colorCorrectionMode;
156 TfTokenVector _purposes;
157 SdfPath _renderSettingsPrimPath;
158};
159
160
161PXR_NAMESPACE_CLOSE_SCOPE
162
163
164#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:291
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.
Definition: frameRecorder.h:98
bool SetRendererPlugin(const TfToken &id)
Sets the Hydra renderer plugin to be used for recording.
Definition: frameRecorder.h:85
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:75
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