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