All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ROP_usdoutput.h
1 //
2 // Copyright 2017 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 __GUSD_ROP_USDOUTPUT_H__
25 #define __GUSD_ROP_USDOUTPUT_H__
26 
27 #include <pxr/pxr.h>
28 #include "pxr/base/tf/refPtr.h"
29 
30 #include "pxr/usd/usd/stage.h"
31 
32 #include <GA/GA_OffsetList.h>
33 #include <GA/GA_Types.h>
34 #include <GU/GU_Detail.h>
35 #include <ROP/ROP_Node.h>
36 #include <UT/UT_Map.h>
37 
38 #include "gusd/GT_Utils.h"
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
42 class GusdROP_usdoutput : public ROP_Node
43 {
44  typedef UT_Map<SdfPath, GT_PrimitiveHandle> GprimMap;
45 
46  typedef std::pair<std::string, std::string> UsdRefShader;
47  typedef UT_Map<UsdRefShader, std::vector<SdfPath> > UsdRefShaderMap;
48  typedef UT_Map<std::string, std::vector<SdfPath> > HouMaterialMap;
49 
50  enum Granularity { ONE_FILE, PER_FRAME };
51 
52 public:
53 
54  static void Register(OP_OperatorTable* table);
55 
56  GusdROP_usdoutput(OP_Network* network,
57  const char* name,
58  OP_Operator* op);
59 
60  virtual ~GusdROP_usdoutput();
61 
62  virtual bool updateParmsFlags() override;
63 
64  virtual int startRender(int frameCount,
65  fpreal tstart,
66  fpreal tend) override;
67 
68  virtual ROP_RENDER_CODE renderFrame(fpreal time,
69  UT_Interrupt* interrupt) override;
70 
71  virtual ROP_RENDER_CODE endRender() override;
72 
73 private:
74 
75  ROP_RENDER_CODE openStage(fpreal tstart, int startTimeCode, int endTimeCode);
76  ROP_RENDER_CODE closeStage(fpreal tend);
77 
78  ROP_RENDER_CODE bindAndWriteShaders(UsdRefShaderMap& usdRefShaderMap,
79  HouMaterialMap& houMaterialMap);
80  void resetState();
81 
82  ROP_RENDER_CODE abort(const std::string& errorMessage);
83 
84 private:
85 
86  double m_startFrame;
87  double m_endFrame;
88  std::string m_pathPrefix;
89  bool m_hasPartitionAttr;
90  std::string m_partitionAttrName;
91  OP_Context m_houdiniContext;
92 
93  SOP_Node* m_renderNode;
94 
95  UsdStageRefPtr m_usdStage;
96  int m_fdTmpFile;
97  GusdGT_AttrFilter m_primvarFilter;
98  GprimMap m_gprimMap;
99  std::string m_defaultPrimPath;
100  UsdPrim m_modelPrim;
101  std::string m_assetName;
102 
103  Granularity m_granularity;
104 };
105 
106 PXR_NAMESPACE_CLOSE_SCOPE
107 
108 #endif /* __GUSD_ROP_USDOUTPUT_H__ */
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131