HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
usdzPackage.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_USD_UTILS_USDZ_PACKAGE_H
8 #define PXR_USD_USD_UTILS_USDZ_PACKAGE_H
9 
10 /// \file usdUtils/usdzPackage.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/sdf/layer.h"
14 #include "pxr/usd/usdUtils/api.h"
15 
16 #include <string>
17 #include <vector>
18 
20 
21 class SdfAssetPath;
22 
23 /// Creates a USDZ package containing the specified asset, identified by its
24 /// \p assetPath. The created package will include a localized version of the
25 /// asset itself and all of its external dependencies. Any anonymous layers that
26 /// are encountered during dependency discovery will be serialized into the
27 /// resulting package. Due to localization, the packaged layers might be
28 /// modified to have different asset paths.
29 ///
30 /// You can optionally specify a different package-internal name for the first
31 /// layer of the asset by specifying \p firstLayerName. By default,
32 /// \p firstLayerName is empty, meaning that the original name is preserved.
33 ///
34 /// The \p editLayersInPlace parameter controls the strategy used for managing
35 /// changes to layers (including the root layer and all transitive layer
36 /// dependencies) that occur during the package creation process. When
37 /// \p editLayersInPlace is false, a temporary, anonymous copy of each
38 /// modified layer is created and written into the package. This has the
39 /// advantage of leaving source layers untouched at the expense of creating a
40 /// copy of each modified layer in memory for the duration of this function.
41 ///
42 /// When \p editLayersInPlace is set to true, layers are modified in-place and
43 /// not reverted or persisted once the package has been created. In this case,
44 /// there is no overhead of creating copies of each modified layer. If you have
45 /// UsdStages open during the function call that reference the layers being
46 /// modified, you may receive warnings or composition errors. While these
47 /// errors will not affect the resulting package adversely, it is strongly
48 /// recommended that this function is run in isolation after any source
49 /// UsdStages have been closed.
50 ///
51 /// Returns true if the package was created successfully.
52 ///
53 /// \note Clients of this function must take care of configuring the asset
54 /// resolver context before invoking the function. To create a default
55 /// resolver context, use \ref CreateDefaultContextForAsset() with the
56 /// asset path.
57 ///
58 /// \note If the given asset has a dependency on a directory (i.e. an external
59 /// reference to a directory path), the dependency is ignored and the contents
60 /// of the directory are not included in the created package.
61 ///
62 /// \sa UsdUtilsCreateNewARKitUsdzPackage()
64 bool
66  const SdfAssetPath& assetPath,
67  const std::string& usdzFilePath,
68  const std::string& firstLayerName=std::string(),
69  bool editLayersInPlace = false);
70 
71 /// Similar to UsdUtilsCreateNewUsdzPackage, this function packages all of the
72 /// dependencies of the given asset. Assets targeted at the initial usdz
73 /// implementation in ARKit operate under greater constraints than usdz files
74 /// for more general 'in house' uses, and this option attempts to ensure that
75 /// these constraints are honored; this may involve more transformations to the
76 /// data, which may cause loss of features such as VariantSets. Any anonymous
77 /// layers that are encountered during dependency discovery will be serialized
78 /// into the resulting package.
79 ///
80 /// If \p firstLayerName is specified, it is modified to have the ".usdc"
81 /// extension, as required by the initial usdz implementation in ARKit.
82 ///
83 /// The \p editLayersInPlace parameter controls the strategy used for managing
84 /// changes to layers (including the root layer and all transitive layer
85 /// dependencies) that occur during the package creation process. When
86 /// \p editLayersInPlace is false, a temporary, anonymous copy of each
87 /// modified layer is created and written into the package. This has the
88 /// advantage of leaving source layers untouched at the expense of creating a
89 /// copy of each modified layer in memory for the duration of this function.
90 ///
91 /// When \p editLayersInPlace is set to true, layers are modified in-place and
92 /// not reverted or persisted once the package has been created. In this case,
93 /// there is no overhead of creating copies of each modified layer. If you have
94 /// UsdStages open during the function call that reference the layers being
95 /// modified, you may receive warnings or composition errors. While these
96 /// errors will not affect the resulting package adversely, it is strongly
97 /// recommended that this function is run in isolation after any source
98 /// UsdStages have been closed.
99 ///
100 /// Returns true if the package was created successfully.
101 ///
102 /// \note Clients of this function must take care of configuring the asset
103 /// resolver context before invoking the function. To create a default
104 /// resolver context, use \ref CreateDefaultContextForAsset() with the
105 /// asset path.
106 ///
107 /// \note If the given asset has a dependency on a directory (i.e. an external
108 /// reference to a directory path), the dependency is ignored and the contents
109 /// of the directory are not included in the created package.
110 ///
111 /// \sa UsdUtilsCreateNewUsdzPackage()
113 bool
115  const SdfAssetPath &assetPath,
116  const std::string &usdzFilePath,
117  const std::string &firstLayerName=std::string(),
118  bool editLayersInplace = false);
119 
121 
122 #endif // PXR_USD_USD_UTILS_USDZ_PACKAGE_H
USDUTILS_API bool UsdUtilsCreateNewUsdzPackage(const SdfAssetPath &assetPath, const std::string &usdzFilePath, const std::string &firstLayerName=std::string(), bool editLayersInPlace=false)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDUTILS_API bool UsdUtilsCreateNewARKitUsdzPackage(const SdfAssetPath &assetPath, const std::string &usdzFilePath, const std::string &firstLayerName=std::string(), bool editLayersInplace=false)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
#define USDUTILS_API
Definition: api.h:23