All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 USDAPPUTILS_FRAME_RECORDER_H
25 #define USDAPPUTILS_FRAME_RECORDER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usdImaging/usdAppUtils/api.h"
31 
32 #include "pxr/base/tf/diagnostic.h"
33 #include "pxr/base/tf/token.h"
34 #include "pxr/usd/usd/stage.h"
35 #include "pxr/usd/usd/timeCode.h"
36 #include "pxr/usd/usdGeom/camera.h"
37 #include "pxr/usdImaging/usdImagingGL/engine.h"
38 
39 #include <string>
40 
41 
42 PXR_NAMESPACE_OPEN_SCOPE
43 
44 
56 {
57 public:
58  USDAPPUTILS_API
60 
64  return _imagingEngine.GetCurrentRendererId();
65  }
66 
68  bool SetRendererPlugin(const TfToken& id) {
69  return _imagingEngine.SetRendererPlugin(id);
70  }
71 
78  void SetImageWidth(const size_t imageWidth) {
79  if (imageWidth == 0u) {
80  TF_CODING_ERROR("Image width cannot be zero");
81  return;
82  }
83  _imageWidth = imageWidth;
84  }
85 
89  void SetComplexity(const float complexity) {
90  _complexity = complexity;
91  }
92 
96  void SetColorCorrectionMode(const TfToken& colorCorrectionMode) {
97  _colorCorrectionMode = colorCorrectionMode;
98  }
99 
106  USDAPPUTILS_API
107  void SetIncludedPurposes(const TfTokenVector& purposes);
108 
119  USDAPPUTILS_API
120  bool Record(
121  const UsdStagePtr& stage,
122  const UsdGeomCamera& usdCamera,
123  const UsdTimeCode timeCode,
124  const std::string& outputImagePath);
125 
126 private:
127  UsdImagingGLEngine _imagingEngine;
128  size_t _imageWidth;
129  float _complexity;
130  TfToken _colorCorrectionMode;
131  TfTokenVector _purposes;
132 };
133 
134 
135 PXR_NAMESPACE_CLOSE_SCOPE
136 
137 
138 #endif
void SetComplexity(const float complexity)
Sets the level of refinement complexity.
Definition: frameRecorder.h:89
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:87
bool SetRendererPlugin(const TfToken &id)
Sets the Hydra renderer plugin to be used for recording.
Definition: frameRecorder.h:68
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
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.
void SetColorCorrectionMode(const TfToken &colorCorrectionMode)
Sets the color correction mode to be used for recording.
Definition: frameRecorder.h:96
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
A utility class for recording images of USD stages.
Definition: frameRecorder.h:55
USDIMAGINGGL_API TfToken GetCurrentRendererId() const
Return the id of the currently used renderer plugin.
The UsdImagingGLEngine is the main entry point API for rendering USD scenes.
Definition: engine.h:81
void SetImageWidth(const size_t imageWidth)
Sets the width of the recorded image.
Definition: frameRecorder.h:78
Transformable camera.
Definition: camera.h:89
TfToken GetCurrentRendererId() const
Gets the ID of the Hydra renderer plugin that will be used for recording.
Definition: frameRecorder.h:63
USDIMAGINGGL_API bool SetRendererPlugin(TfToken const &id)
Set the current render-graph delegate to id.