All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
context.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 
25 #ifndef __GUSD_CONTEXT_H__
26 #define __GUSD_CONTEXT_H__
27 
28 #include "pxr/pxr.h"
29 #include "pxr/usd/usd/timeCode.h"
30 #include "pxr/usd/usd/stage.h"
31 #include "pxr/usd/usdGeom/tokens.h"
32 
33 #include <GT/GT_Primitive.h>
34 
35 #include <functional>
36 #include <string>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 class GusdGT_AttrFilter;
41 class UsdGeomXformCache;
42 
45 
46 class GusdContext {
47 public:
48  typedef std::function<UsdStageRefPtr ()> GetStageFunc;
49  enum Granularity { ONE_FILE, PER_FRAME };
50 
52  Granularity g,
53  const GusdGT_AttrFilter& af )
54  : time( t )
55  , granularity( g )
56  , writeOverlay( false )
57  , overlayPoints( false )
58  , overlayTransforms( false )
59  , overlayPrimvars( false )
60  , overlayAll( false )
61  , writeStaticGeo( false )
62  , writeStaticTopology( false )
63  , writeStaticPrimvars( false )
64  , attributeFilter( af )
65  , purpose( UsdGeomTokens->default_ )
66  , makeRefsInstanceable( true )
67  {}
68 
69  // Time of the current frame we are writing
70  UsdTimeCode time;
71 
72  // Are we writing on frame per file or all the frames into a single file?
73  Granularity granularity;
74 
75  bool writeOverlay; // Overlay existing geometry rather than creating new geometry?
76 
77  // Flags indicating what should be overlayed
78  bool overlayPoints; // For point instancers, overlayPoints and overlayTransforms are synonymous.π
79  bool overlayTransforms;
80  bool overlayPrimvars;
81  bool overlayAll; // Completely replace prims, including topology.
82  // For point instancers, if overlayAll is set and
83  // prototypes are specified, replace the prototypes.
84 
85  bool writeStaticGeo;
86  bool writeStaticTopology;
87  bool writeStaticPrimvars;
88 
89  // Filter specifying what primvars to write for each prim.
90  const GusdGT_AttrFilter& attributeFilter;
91 
92  // Name of attribute that specifies usd prim path to write prims to.
93  // a prim.
94  std::string primPathAttribute;
95 
96  // Path to a sop or obj node that contains all the prototypes so we can
97  // write a complete and static relationship array. Will be overridden by
98  // attributes if they exist.
99  std::string usdPrototypesPath;
100 
101  // Identifier (and possibly path to a primitive) to both create an entry
102  // in a point instancer's relationship array and mark which prototype to use
103  // for a point. Will be overridden by attributes if they exist.
104  std::string usdInstancePath;
105 
106  // Offset value to set in a Layer Offset of a USD reference. For retiming
107  // references.
108  double usdTimeOffset;
109 
110  // Scale value to set in a Layer Offset of a USD reference. For retiming
111  // references.
112  double usdTimeScale;
113 
114  // When we write a USD packed prim to a USD file, we write a USD reference.
115  // If the prim path attribute in the USD packed prim contains a variant
116  // selection, write that with the reference.
117  bool authorVariantSelections;
118 
119  // Purpose (render, proxy or guide) to tag prims with.
120  TfToken purpose;
121 
122  // Whether to make references to a USD prims instanceable.
123  bool makeRefsInstanceable;
124 
125 };
126 
127 PXR_NAMESPACE_CLOSE_SCOPE
128 
129 #endif // __GUSD_CONTEXT_H__
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
USDGEOM_API TfStaticData< UsdGeomTokensType > UsdGeomTokens
A global variable with static, efficient TfTokens for use in all public USD API.
A GusdContext structure is created by the ROPs that write USD files and passed to the GusdPrimWrapper...
Definition: context.h:46
A caching mechanism for transform matrices.
Definition: xformCache.h:58