add usd-21-05-win64_py37
This commit is contained in:
1 parent
41d23e71ba
commit
66bc054336
15675 files changed
+3061008
No files matched your search
@@ -0,0 +1,182 @@
|
||||
#!C:/Users/sebastien/AppData/Local/Programs/Python/Python37/python.exe
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
'''
|
||||
Creates a top-level, referenceable asset USD file from one or more
|
||||
'variant' files, each of which can contain arbitrary scene description.
|
||||
When supplying multiple files, one must also provide the name for a
|
||||
variantSet that will be constructed to switch between the files.
|
||||
|
||||
The asset file will place the variant files behind a "payload", which will
|
||||
enable consumers to defer loading and processing of the data when composed
|
||||
onto a UsdStage.
|
||||
|
||||
The names of the created variations will be taken directly from the basename
|
||||
of their corresponding input file.
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from pxr import Tf, Kind, Sdf, Usd
|
||||
|
||||
# ToDo:
|
||||
# - handle multiple variantSets
|
||||
# - layer multiple kinds of files (e.g. shading.usd over geom.usd)
|
||||
# - allow output filename to be independently specifiable? (Breaks with Pixar
|
||||
# convention)
|
||||
# - allow variant names to be specified independently of variant file names
|
||||
# - Compute and present (per-variant) UsdGeomModelAPI.extentsHint
|
||||
# - Compute and author UsdModelAPI::SetPayloadAssetDependencies()
|
||||
def CreateModelStage(assetName,
|
||||
assetIdentifier=None,
|
||||
kind=Kind.Tokens.component,
|
||||
filesToReference=None,
|
||||
variantSetName=None,
|
||||
defaultVariantSelection=None):
|
||||
# Preconditions....
|
||||
if not Tf.IsValidIdentifier(assetName):
|
||||
print("assetName '%s' must be a valid identifier. Aborting." %
|
||||
assetName)
|
||||
return None
|
||||
if variantSetName and not Tf.IsValidIdentifier(variantSetName):
|
||||
print("variantSetName '%s' must be a valid identifier. Aborting." %
|
||||
variantSetName)
|
||||
return None
|
||||
if filesToReference and len(filesToReference) > 1 and not variantSetName:
|
||||
# For now, we only allow multiple files to reference if we're switching
|
||||
# them with a variantSet. We can relax this restriction when we can
|
||||
# make internal payload arcs (bug #119960)
|
||||
print("Cannot create multiple-file-reference without a variantSet. Aborting")
|
||||
return None
|
||||
if not Kind.Registry.IsA(kind, Kind.Tokens.model):
|
||||
print("kind '%s' is not a valid model kind, which must be one of:" %
|
||||
kind)
|
||||
print(Kind.Registry.GetAllKinds())
|
||||
return None
|
||||
|
||||
# Create the root file for the stage, and make it ASCII text.
|
||||
# We need some nicer sugar for this.
|
||||
fileName = assetName + ".usd"
|
||||
rootLayer = Sdf.Layer.CreateNew(fileName, args = {'format':'usda'})
|
||||
stage = Usd.Stage.Open(rootLayer)
|
||||
|
||||
# Name the root prim after the asset. Don't give it a type, since we
|
||||
# want that to come from referenced files. Make it be the "default prim"
|
||||
# so that we can reference the resulting file without specifiying a
|
||||
# prim path
|
||||
rootPath = Sdf.Path.absoluteRootPath
|
||||
modelRootPrim = stage.DefinePrim(rootPath.AppendChild(assetName))
|
||||
stage.SetDefaultPrim(modelRootPrim)
|
||||
modelAPI = Usd.ModelAPI(modelRootPrim)
|
||||
modelAPI.SetKind(kind)
|
||||
# See http://openusd.org/docs/api/class_usd_model_a_p_i.html#details
|
||||
# for more on assetInfo
|
||||
modelAPI.SetAssetName(assetName)
|
||||
modelAPI.SetAssetIdentifier(assetIdentifier or fileName)
|
||||
|
||||
# Add a class named after the asset, and make the asset inherit from it.
|
||||
# This is not necessary for a valid asset, and the class-naming is a Pixar
|
||||
# convention. But always having a class associated with each asset is
|
||||
# extremely useful for non-destructively editing many referenced or
|
||||
# instanced assets of the same type.
|
||||
classPrim = stage.CreateClassPrim(rootPath.AppendChild("_class_"+assetName))
|
||||
modelRootPrim.GetInherits().AddInherit(classPrim.GetPath())
|
||||
|
||||
if not filesToReference:
|
||||
# weird edge case... we're done
|
||||
return stage
|
||||
elif len(filesToReference) == 1 and not variantSetName:
|
||||
# The other, more plausible edge case: we're just wrapping
|
||||
# some other file (e.g. alembic) in order to give it a payload
|
||||
# and other proper USD trappings - no variants
|
||||
modelRootPrim.GetPayloads().AddPayload(Sdf.Payload(filesToReference[0]))
|
||||
return stage
|
||||
|
||||
# OK, we're making a variantSet, and we are going to vary the payload
|
||||
# in each variant
|
||||
varSet = modelRootPrim.GetVariantSet(variantSetName)
|
||||
for variantFile in filesToReference:
|
||||
import os
|
||||
variantName = os.path.splitext(os.path.basename(variantFile))[0]
|
||||
# If we didn't specify a default selection, choose the first one
|
||||
if not defaultVariantSelection:
|
||||
defaultVariantSelection = variantName
|
||||
varSet.AddVariant(variantName)
|
||||
varSet.SetVariantSelection(variantName)
|
||||
# The context object makes all edits "go inside" the variant we
|
||||
# just created.
|
||||
with varSet.GetVariantEditContext():
|
||||
modelRootPrim.GetPayloads().AddPayload(Sdf.Payload(variantFile))
|
||||
# Now put the variantSet into the state we want it to be in by default
|
||||
varSet.SetVariantSelection(defaultVariantSelection)
|
||||
|
||||
return stage
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse, os, sys
|
||||
descr = __doc__.strip()
|
||||
parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),
|
||||
description=descr)
|
||||
parser.add_argument('assetName')
|
||||
parser.add_argument('variantFiles', nargs='+')
|
||||
parser.add_argument(
|
||||
'-k', '--kind', default='component', action='store', metavar='kind',
|
||||
help="Model kind, one of: component, group, or assembly")
|
||||
parser.add_argument(
|
||||
'-v', '--variantSet', default='', action='store', metavar='variantSet',
|
||||
help="Variantset to create to modulate variantFiles. Can be elided "
|
||||
"if only one file is supplied")
|
||||
parser.add_argument(
|
||||
'-i', '--identifier', default='', action='store', metavar='identifier',
|
||||
help="The identifier you would expect your Ar asset-resolver plugin "
|
||||
"to resolve to the (installed) assetName.usd file this script creates. "
|
||||
" If unspecified, defaults to assetName.usd")
|
||||
parser.add_argument(
|
||||
'-d', '--defaultVariantSelection', default='', action='store',
|
||||
metavar='defaultVariantSelection',
|
||||
help="This variant will be selected by default when the asset is "
|
||||
"added to a composition. If unspecified, will be the variant for "
|
||||
"'variantFile1'")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.assetName or args.assetName == '':
|
||||
parser.error("No assetName specified")
|
||||
|
||||
stage = CreateModelStage(args.assetName,
|
||||
assetIdentifier=args.identifier,
|
||||
kind=args.kind,
|
||||
filesToReference=args.variantFiles,
|
||||
variantSetName=args.variantSet,
|
||||
defaultVariantSelection=args.defaultVariantSelection)
|
||||
|
||||
if stage:
|
||||
stage.GetRootLayer().Save()
|
||||
exit(0)
|
||||
else:
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
@python "%~dp0usdMakeFileVariantModelAsset" %*
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright 2017 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDSCHEMAEXAMPLES_API_H
|
||||
#define USDSCHEMAEXAMPLES_API_H
|
||||
|
||||
#include "pxr/base/arch/export.h"
|
||||
|
||||
#if defined(PXR_STATIC)
|
||||
# define USDSCHEMAEXAMPLES_API
|
||||
# define USDSCHEMAEXAMPLES_API_TEMPLATE_CLASS(...)
|
||||
# define USDSCHEMAEXAMPLES_API_TEMPLATE_STRUCT(...)
|
||||
# define USDSCHEMAEXAMPLES_LOCAL
|
||||
#else
|
||||
# if defined(USDSCHEMAEXAMPLES_EXPORTS)
|
||||
# define USDSCHEMAEXAMPLES_API ARCH_EXPORT
|
||||
# define USDSCHEMAEXAMPLES_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define USDSCHEMAEXAMPLES_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# else
|
||||
# define USDSCHEMAEXAMPLES_API ARCH_IMPORT
|
||||
# define USDSCHEMAEXAMPLES_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define USDSCHEMAEXAMPLES_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# endif
|
||||
# define USDSCHEMAEXAMPLES_LOCAL ARCH_HIDDEN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,199 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDSCHEMAEXAMPLES_GENERATED_COMPLEX_H
|
||||
#define USDSCHEMAEXAMPLES_GENERATED_COMPLEX_H
|
||||
|
||||
/// \file usdSchemaExamples/complex.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "./api.h"
|
||||
#include "./simple.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "./tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// COMPLEXPRIM //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdSchemaExamplesComplex
|
||||
///
|
||||
/// An example of a untyped IsA schema prim
|
||||
///
|
||||
class UsdSchemaExamplesComplex : public UsdSchemaExamplesSimple
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// \deprecated
|
||||
/// Same as schemaKind, provided to maintain temporary backward
|
||||
/// compatibility with older generated schemas.
|
||||
static const UsdSchemaKind schemaType = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdSchemaExamplesComplex on UsdPrim \p prim .
|
||||
/// Equivalent to UsdSchemaExamplesComplex::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdSchemaExamplesComplex(const UsdPrim& prim=UsdPrim())
|
||||
: UsdSchemaExamplesSimple(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdSchemaExamplesComplex on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdSchemaExamplesComplex(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdSchemaExamplesComplex(const UsdSchemaBase& schemaObj)
|
||||
: UsdSchemaExamplesSimple(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
virtual ~UsdSchemaExamplesComplex();
|
||||
|
||||
/// Return a vector of names of all pre-declared attributes for this schema
|
||||
/// class and all its ancestor classes. Does not include attributes that
|
||||
/// may be authored by custom/extended methods of the schemas involved.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdSchemaExamplesComplex holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p stage, or if the prim at that path does not adhere to this schema,
|
||||
/// return an invalid schema object. This is shorthand for the following:
|
||||
///
|
||||
/// \code
|
||||
/// UsdSchemaExamplesComplex(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static UsdSchemaExamplesComplex
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a path must be an absolute prim path that does not contain
|
||||
/// any variant selections.
|
||||
///
|
||||
/// If it is impossible to author any of the necessary PrimSpecs, (for
|
||||
/// example, in case \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a UsdPrim.
|
||||
///
|
||||
/// Note that this method may return a defined prim whose typeName does not
|
||||
/// specify this schema class, in case a stronger typeName opinion overrides
|
||||
/// the opinion at the current EditTarget.
|
||||
///
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static UsdSchemaExamplesComplex
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
/// \deprecated
|
||||
/// Same as _GetSchemaKind, provided to maintain temporary backward
|
||||
/// compatibility with older generated schemas.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdSchemaKind _GetSchemaType() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// COMPLEXSTRING
|
||||
// --------------------------------------------------------------------- //
|
||||
///
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `string complexString = "somethingComplex"` |
|
||||
/// | C++ Type | std::string |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->String |
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute GetComplexStringAttr() const;
|
||||
|
||||
/// See GetComplexStringAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute CreateComplexStringAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,235 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDSCHEMAEXAMPLES_GENERATED_PARAMSAPI_H
|
||||
#define USDSCHEMAEXAMPLES_GENERATED_PARAMSAPI_H
|
||||
|
||||
/// \file usdSchemaExamples/paramsAPI.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "./api.h"
|
||||
#include "pxr/usd/usd/apiSchemaBase.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "./tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// PARAMSAPI //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdSchemaExamplesParamsAPI
|
||||
///
|
||||
///
|
||||
class UsdSchemaExamplesParamsAPI : public UsdAPISchemaBase
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
|
||||
|
||||
/// \deprecated
|
||||
/// Same as schemaKind, provided to maintain temporary backward
|
||||
/// compatibility with older generated schemas.
|
||||
static const UsdSchemaKind schemaType = UsdSchemaKind::SingleApplyAPI;
|
||||
|
||||
/// Construct a UsdSchemaExamplesParamsAPI on UsdPrim \p prim .
|
||||
/// Equivalent to UsdSchemaExamplesParamsAPI::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdSchemaExamplesParamsAPI(const UsdPrim& prim=UsdPrim())
|
||||
: UsdAPISchemaBase(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdSchemaExamplesParamsAPI on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdSchemaExamplesParamsAPI(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdSchemaExamplesParamsAPI(const UsdSchemaBase& schemaObj)
|
||||
: UsdAPISchemaBase(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
virtual ~UsdSchemaExamplesParamsAPI();
|
||||
|
||||
/// Return a vector of names of all pre-declared attributes for this schema
|
||||
/// class and all its ancestor classes. Does not include attributes that
|
||||
/// may be authored by custom/extended methods of the schemas involved.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdSchemaExamplesParamsAPI holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p stage, or if the prim at that path does not adhere to this schema,
|
||||
/// return an invalid schema object. This is shorthand for the following:
|
||||
///
|
||||
/// \code
|
||||
/// UsdSchemaExamplesParamsAPI(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static UsdSchemaExamplesParamsAPI
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
/// Applies this <b>single-apply</b> API schema to the given \p prim.
|
||||
/// This information is stored by adding "ParamsAPI" to the
|
||||
/// token-valued, listOp metadata \em apiSchemas on the prim.
|
||||
///
|
||||
/// \return A valid UsdSchemaExamplesParamsAPI object is returned upon success.
|
||||
/// An invalid (or empty) UsdSchemaExamplesParamsAPI object is returned upon
|
||||
/// failure. See \ref UsdPrim::ApplyAPI() for conditions
|
||||
/// resulting in failure.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static UsdSchemaExamplesParamsAPI
|
||||
Apply(const UsdPrim &prim);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
/// \deprecated
|
||||
/// Same as _GetSchemaKind, provided to maintain temporary backward
|
||||
/// compatibility with older generated schemas.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdSchemaKind _GetSchemaType() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MASS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Double value denoting mass
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double params:mass` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute GetMassAttr() const;
|
||||
|
||||
/// See GetMassAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute CreateMassAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VELOCITY
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Double value denoting velocity
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double params:velocity` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute GetVelocityAttr() const;
|
||||
|
||||
/// See GetVelocityAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute CreateVelocityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VOLUME
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Double value denoting volume
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double params:volume` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute GetVolumeAttr() const;
|
||||
|
||||
/// See GetVolumeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,190 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDSCHEMAEXAMPLES_GENERATED_SIMPLE_H
|
||||
#define USDSCHEMAEXAMPLES_GENERATED_SIMPLE_H
|
||||
|
||||
/// \file usdSchemaExamples/simple.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "./api.h"
|
||||
#include "pxr/usd/usd/typed.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "./tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// SIMPLEPRIM //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdSchemaExamplesSimple
|
||||
///
|
||||
/// An example of an untyped schema prim. Note that it does not
|
||||
/// specify a typeName
|
||||
///
|
||||
class UsdSchemaExamplesSimple : public UsdTyped
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractTyped;
|
||||
|
||||
/// \deprecated
|
||||
/// Same as schemaKind, provided to maintain temporary backward
|
||||
/// compatibility with older generated schemas.
|
||||
static const UsdSchemaKind schemaType = UsdSchemaKind::AbstractTyped;
|
||||
|
||||
/// Construct a UsdSchemaExamplesSimple on UsdPrim \p prim .
|
||||
/// Equivalent to UsdSchemaExamplesSimple::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdSchemaExamplesSimple(const UsdPrim& prim=UsdPrim())
|
||||
: UsdTyped(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdSchemaExamplesSimple on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdSchemaExamplesSimple(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdSchemaExamplesSimple(const UsdSchemaBase& schemaObj)
|
||||
: UsdTyped(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
virtual ~UsdSchemaExamplesSimple();
|
||||
|
||||
/// Return a vector of names of all pre-declared attributes for this schema
|
||||
/// class and all its ancestor classes. Does not include attributes that
|
||||
/// may be authored by custom/extended methods of the schemas involved.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdSchemaExamplesSimple holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p stage, or if the prim at that path does not adhere to this schema,
|
||||
/// return an invalid schema object. This is shorthand for the following:
|
||||
///
|
||||
/// \code
|
||||
/// UsdSchemaExamplesSimple(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static UsdSchemaExamplesSimple
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
/// \deprecated
|
||||
/// Same as _GetSchemaKind, provided to maintain temporary backward
|
||||
/// compatibility with older generated schemas.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdSchemaKind _GetSchemaType() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDSCHEMAEXAMPLES_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// INTATTR
|
||||
// --------------------------------------------------------------------- //
|
||||
/// An integer attribute with fallback value of 0.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int intAttr = 0` |
|
||||
/// | C++ Type | int |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute GetIntAttrAttr() const;
|
||||
|
||||
/// See GetIntAttrAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdAttribute CreateIntAttrAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TARGET
|
||||
// --------------------------------------------------------------------- //
|
||||
/// A relationship called target that could point to another prim
|
||||
/// or a property
|
||||
///
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdRelationship GetTargetRel() const;
|
||||
|
||||
/// See GetTargetRel(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
|
||||
USDSCHEMAEXAMPLES_API
|
||||
UsdRelationship CreateTargetRel() const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDSCHEMAEXAMPLES_TOKENS_H
|
||||
#define USDSCHEMAEXAMPLES_TOKENS_H
|
||||
|
||||
/// \file usdSchemaExamples/tokens.h
|
||||
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
//
|
||||
// This is an automatically generated file (by usdGenSchema.py).
|
||||
// Do not hand-edit!
|
||||
//
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "./api.h"
|
||||
#include "pxr/base/tf/staticData.h"
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
/// \class UsdSchemaExamplesTokensType
|
||||
///
|
||||
/// \link UsdSchemaExamplesTokens \endlink provides static, efficient
|
||||
/// \link TfToken TfTokens\endlink for use in all public USD API.
|
||||
///
|
||||
/// These tokens are auto-generated from the module's schema, representing
|
||||
/// property names, for when you need to fetch an attribute or relationship
|
||||
/// directly by name, e.g. UsdPrim::GetAttribute(), in the most efficient
|
||||
/// manner, and allow the compiler to verify that you spelled the name
|
||||
/// correctly.
|
||||
///
|
||||
/// UsdSchemaExamplesTokens also contains all of the \em allowedTokens values
|
||||
/// declared for schema builtin attributes of 'token' scene description type.
|
||||
/// Use UsdSchemaExamplesTokens like so:
|
||||
///
|
||||
/// \code
|
||||
/// gprim.GetMyTokenValuedAttr().Set(UsdSchemaExamplesTokens->complexString);
|
||||
/// \endcode
|
||||
struct UsdSchemaExamplesTokensType {
|
||||
USDSCHEMAEXAMPLES_API UsdSchemaExamplesTokensType();
|
||||
/// \brief "complexString"
|
||||
///
|
||||
/// UsdSchemaExamplesComplex
|
||||
const TfToken complexString;
|
||||
/// \brief "intAttr"
|
||||
///
|
||||
/// UsdSchemaExamplesSimple
|
||||
const TfToken intAttr;
|
||||
/// \brief "params:mass"
|
||||
///
|
||||
/// UsdSchemaExamplesParamsAPI
|
||||
const TfToken paramsMass;
|
||||
/// \brief "params:velocity"
|
||||
///
|
||||
/// UsdSchemaExamplesParamsAPI
|
||||
const TfToken paramsVelocity;
|
||||
/// \brief "params:volume"
|
||||
///
|
||||
/// UsdSchemaExamplesParamsAPI
|
||||
const TfToken paramsVolume;
|
||||
/// \brief "target"
|
||||
///
|
||||
/// UsdSchemaExamplesSimple
|
||||
const TfToken target;
|
||||
/// A vector of all of the tokens listed above.
|
||||
const std::vector<TfToken> allTokens;
|
||||
};
|
||||
|
||||
/// \var UsdSchemaExamplesTokens
|
||||
///
|
||||
/// A global variable with static, efficient \link TfToken TfTokens\endlink
|
||||
/// for use in all public USD API. \sa UsdSchemaExamplesTokensType
|
||||
extern USDSCHEMAEXAMPLES_API TfStaticData<UsdSchemaExamplesTokensType> UsdSchemaExamplesTokens;
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef EXTRAS_IMAGING_EXAMPLES_HD_TINY_MESH_H
|
||||
#define EXTRAS_IMAGING_EXAMPLES_HD_TINY_MESH_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hd/mesh.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
/// \class HdTinyMesh
|
||||
///
|
||||
/// This class is an example of a Hydra Rprim, or renderable object, and it
|
||||
/// gets created on a call to HdRenderIndex::InsertRprim() with a type of
|
||||
/// HdPrimTypeTokens->mesh.
|
||||
///
|
||||
/// The prim object's main function is to bridge the scene description and the
|
||||
/// renderable representation. The Hydra image generation algorithm will call
|
||||
/// HdRenderIndex::SyncAll() before any drawing; this, in turn, will call
|
||||
/// Sync() for each mesh with new data.
|
||||
///
|
||||
/// Sync() is passed a set of dirtyBits, indicating which scene buffers are
|
||||
/// dirty. It uses these to pull all of the new scene data and constructs
|
||||
/// updated geometry objects.
|
||||
///
|
||||
/// An rprim's state is lazily populated in Sync(); matching this, Finalize()
|
||||
/// can do the heavy work of releasing state (such as handles into the top-level
|
||||
/// scene), so that object population and existence aren't tied to each other.
|
||||
///
|
||||
class HdTinyMesh final : public HdMesh
|
||||
{
|
||||
public:
|
||||
HF_MALLOC_TAG_NEW("new HdTinyMesh");
|
||||
|
||||
/// HdTinyMesh constructor.
|
||||
/// \param id The scene-graph path to this mesh.
|
||||
HdTinyMesh(SdfPath const& id);
|
||||
|
||||
/// HdTinyMesh destructor.
|
||||
~HdTinyMesh() override = default;
|
||||
|
||||
/// Inform the scene graph which state needs to be downloaded in the
|
||||
/// first Sync() call: in this case, topology and points data to build
|
||||
/// the geometry object in the scene graph.
|
||||
/// \return The initial dirty state this mesh wants to query.
|
||||
HdDirtyBits GetInitialDirtyBitsMask() const override;
|
||||
|
||||
/// Pull invalidated scene data and prepare/update the renderable
|
||||
/// representation.
|
||||
///
|
||||
/// This function is told which scene data to pull through the
|
||||
/// dirtyBits parameter. The first time it's called, dirtyBits comes
|
||||
/// from _GetInitialDirtyBits(), which provides initial dirty state,
|
||||
/// but after that it's driven by invalidation tracking in the scene
|
||||
/// delegate.
|
||||
///
|
||||
/// The contract for this function is that the prim can only pull on scene
|
||||
/// delegate buffers that are marked dirty. Scene delegates can and do
|
||||
/// implement just-in-time data schemes that mean that pulling on clean
|
||||
/// data will be at best incorrect, and at worst a crash.
|
||||
///
|
||||
/// This function is called in parallel from worker threads, so it needs
|
||||
/// to be threadsafe; calls into HdSceneDelegate are ok.
|
||||
///
|
||||
/// Reprs are used by hydra for controlling per-item draw settings like
|
||||
/// flat/smooth shaded, wireframe, refined, etc.
|
||||
/// \param sceneDelegate The data source for this geometry item.
|
||||
/// \param renderParam State.
|
||||
/// \param dirtyBits A specifier for which scene data has changed.
|
||||
/// \param reprToken A specifier for which representation to draw with.
|
||||
///
|
||||
void Sync(
|
||||
HdSceneDelegate* sceneDelegate,
|
||||
HdRenderParam* renderParam,
|
||||
HdDirtyBits* dirtyBits,
|
||||
TfToken const &reprToken) override;
|
||||
|
||||
protected:
|
||||
// Initialize the given representation of this Rprim.
|
||||
// This is called prior to syncing the prim, the first time the repr
|
||||
// is used.
|
||||
//
|
||||
// reprToken is the name of the repr to initalize.
|
||||
//
|
||||
// dirtyBits is an in/out value. It is initialized to the dirty bits
|
||||
// from the change tracker. InitRepr can then set additional dirty bits
|
||||
// if additional data is required from the scene delegate when this
|
||||
// repr is synced. InitRepr occurs before dirty bit propagation.
|
||||
//
|
||||
// See HdRprim::InitRepr()
|
||||
void _InitRepr(
|
||||
TfToken const &reprToken,
|
||||
HdDirtyBits *dirtyBits) override;
|
||||
|
||||
// This callback from Rprim gives the prim an opportunity to set
|
||||
// additional dirty bits based on those already set. This is done
|
||||
// before the dirty bits are passed to the scene delegate, so can be
|
||||
// used to communicate that extra information is needed by the prim to
|
||||
// process the changes.
|
||||
//
|
||||
// The return value is the new set of dirty bits, which replaces the bits
|
||||
// passed in.
|
||||
//
|
||||
// See HdRprim::PropagateRprimDirtyBits()
|
||||
HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override;
|
||||
|
||||
// This class does not support copying.
|
||||
HdTinyMesh(const HdTinyMesh&) = delete;
|
||||
HdTinyMesh &operator =(const HdTinyMesh&) = delete;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // EXTRAS_IMAGING_EXAMPLES_HD_TINY_MESH_H
|
||||
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef EXTRAS_IMAGING_EXAMPLES_HD_TINY_RENDER_DELEGATE_H
|
||||
#define EXTRAS_IMAGING_EXAMPLES_HD_TINY_RENDER_DELEGATE_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hd/renderDelegate.h"
|
||||
#include "pxr/imaging/hd/resourceRegistry.h"
|
||||
#include "pxr/base/tf/staticTokens.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
///
|
||||
/// \class HdTinyRenderDelegate
|
||||
///
|
||||
/// Render delegates provide renderer-specific functionality to the render
|
||||
/// index, the main hydra state management structure. The render index uses
|
||||
/// the render delegate to create and delete scene primitives, which include
|
||||
/// geometry and also non-drawable objects. The render delegate is also
|
||||
/// responsible for creating renderpasses, which know how to draw this
|
||||
/// renderer's scene primitives.
|
||||
///
|
||||
class HdTinyRenderDelegate final : public HdRenderDelegate
|
||||
{
|
||||
public:
|
||||
/// Render delegate constructor.
|
||||
HdTinyRenderDelegate();
|
||||
/// Render delegate constructor.
|
||||
HdTinyRenderDelegate(HdRenderSettingsMap const& settingsMap);
|
||||
/// Render delegate destructor.
|
||||
virtual ~HdTinyRenderDelegate();
|
||||
|
||||
/// Supported types
|
||||
const TfTokenVector &GetSupportedRprimTypes() const override;
|
||||
const TfTokenVector &GetSupportedSprimTypes() const override;
|
||||
const TfTokenVector &GetSupportedBprimTypes() const override;
|
||||
|
||||
// Basic value to return from the RD
|
||||
HdResourceRegistrySharedPtr GetResourceRegistry() const override;
|
||||
|
||||
// Prims
|
||||
HdRenderPassSharedPtr CreateRenderPass(
|
||||
HdRenderIndex *index,
|
||||
HdRprimCollection const& collection) override;
|
||||
|
||||
HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
|
||||
SdfPath const& id) override;
|
||||
void DestroyInstancer(HdInstancer *instancer) override;
|
||||
|
||||
HdRprim *CreateRprim(TfToken const& typeId,
|
||||
SdfPath const& rprimId) override;
|
||||
void DestroyRprim(HdRprim *rPrim) override;
|
||||
|
||||
HdSprim *CreateSprim(TfToken const& typeId,
|
||||
SdfPath const& sprimId) override;
|
||||
HdSprim *CreateFallbackSprim(TfToken const& typeId) override;
|
||||
void DestroySprim(HdSprim *sprim) override;
|
||||
|
||||
HdBprim *CreateBprim(TfToken const& typeId,
|
||||
SdfPath const& bprimId) override;
|
||||
HdBprim *CreateFallbackBprim(TfToken const& typeId) override;
|
||||
void DestroyBprim(HdBprim *bprim) override;
|
||||
|
||||
void CommitResources(HdChangeTracker *tracker) override;
|
||||
|
||||
HdRenderParam *GetRenderParam() const override;
|
||||
|
||||
private:
|
||||
static const TfTokenVector SUPPORTED_RPRIM_TYPES;
|
||||
static const TfTokenVector SUPPORTED_SPRIM_TYPES;
|
||||
static const TfTokenVector SUPPORTED_BPRIM_TYPES;
|
||||
|
||||
void _Initialize();
|
||||
|
||||
HdResourceRegistrySharedPtr _resourceRegistry;
|
||||
|
||||
// This class does not support copying.
|
||||
HdTinyRenderDelegate(const HdTinyRenderDelegate &) = delete;
|
||||
HdTinyRenderDelegate &operator =(const HdTinyRenderDelegate &) = delete;
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // EXTRAS_IMAGING_EXAMPLES_HD_TINY_RENDER_DELEGATE_H
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef EXTRAS_IMAGING_EXAMPLES_HD_TINY_RENDER_PASS_H
|
||||
#define EXTRAS_IMAGING_EXAMPLES_HD_TINY_RENDER_PASS_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hd/renderPass.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
/// \class HdTinyRenderPass
|
||||
///
|
||||
/// HdRenderPass represents a single render iteration, rendering a view of the
|
||||
/// scene (the HdRprimCollection) for a specific viewer (the camera/viewport
|
||||
/// parameters in HdRenderPassState) to the current draw target.
|
||||
///
|
||||
class HdTinyRenderPass final : public HdRenderPass
|
||||
{
|
||||
public:
|
||||
/// Renderpass constructor.
|
||||
/// \param index The render index containing scene data to render.
|
||||
/// \param collection The initial rprim collection for this renderpass.
|
||||
HdTinyRenderPass(HdRenderIndex *index,
|
||||
HdRprimCollection const &collection);
|
||||
|
||||
/// Renderpass destructor.
|
||||
virtual ~HdTinyRenderPass();
|
||||
|
||||
protected:
|
||||
|
||||
/// Draw the scene with the bound renderpass state.
|
||||
/// \param renderPassState Input parameters (including viewer parameters)
|
||||
/// for this renderpass.
|
||||
/// \param renderTags Which rendertags should be drawn this pass.
|
||||
void _Execute(
|
||||
HdRenderPassStateSharedPtr const& renderPassState,
|
||||
TfTokenVector const &renderTags) override;
|
||||
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // EXTRAS_IMAGING_EXAMPLES_HD_TINY_RENDER_PASS_H
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef EXTRAS_IMAGING_EXAMPLES_HD_TINY_RENDERER_PLUGIN_H
|
||||
#define EXTRAS_IMAGING_EXAMPLES_HD_TINY_RENDERER_PLUGIN_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hd/rendererPlugin.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
///
|
||||
/// \class HdTinyRendererPlugin
|
||||
///
|
||||
/// A registered child of HdRendererPlugin, this is the class that gets
|
||||
/// loaded when a Hydra application asks to draw with a certain renderer.
|
||||
/// It supports rendering via creation/destruction of renderer-specific
|
||||
/// classes. The render delegate is the Hydra-facing entrypoint into the
|
||||
/// renderer; it's responsible for creating specialized implementations of Hydra
|
||||
/// prims (which translate scene data into drawable representations) and Hydra
|
||||
/// renderpasses (which draw the scene to the framebuffer).
|
||||
///
|
||||
class HdTinyRendererPlugin final : public HdRendererPlugin
|
||||
{
|
||||
public:
|
||||
HdTinyRendererPlugin() = default;
|
||||
virtual ~HdTinyRendererPlugin() = default;
|
||||
|
||||
/// Construct a new render delegate of type HdTinyRenderDelegate.
|
||||
virtual HdRenderDelegate *CreateRenderDelegate() override;
|
||||
|
||||
/// Construct a new render delegate of type HdTinyRenderDelegate.
|
||||
virtual HdRenderDelegate *CreateRenderDelegate(
|
||||
HdRenderSettingsMap const& settingsMap) override;
|
||||
|
||||
/// Destroy a render delegate created by this class's CreateRenderDelegate.
|
||||
/// \param renderDelegate The render delegate to delete.
|
||||
virtual void DeleteRenderDelegate(
|
||||
HdRenderDelegate *renderDelegate) override;
|
||||
|
||||
/// Checks to see if the plugin is supported on the running system.
|
||||
virtual bool IsSupported() const override;
|
||||
|
||||
private:
|
||||
// This class does not support copying.
|
||||
HdTinyRendererPlugin(const HdTinyRendererPlugin&) = delete;
|
||||
HdTinyRendererPlugin &operator =(const HdTinyRendererPlugin&) = delete;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // EXTRAS_IMAGING_EXAMPLES_HD_TINY_RENDERER_PLUGIN_H
|
||||
@@ -0,0 +1,130 @@
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_EXTRAS_USD_EXAMPLES_USD_DANCING_CUBES_EXAMPLE_FILE_FORMAT_H
|
||||
#define PXR_EXTRAS_USD_EXAMPLES_USD_DANCING_CUBES_EXAMPLE_FILE_FORMAT_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/sdf/fileFormat.h"
|
||||
#include "pxr/usd/pcp/dynamicFileFormatInterface.h"
|
||||
#include "pxr/base/tf/staticTokens.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
#define USD_DANCING_CUBES_EXAMPLE_FILE_FORMAT_TOKENS \
|
||||
((Id, "usdDancingCubesExample")) \
|
||||
((Version, "1.0")) \
|
||||
((Target, "usd")) \
|
||||
((Extension, "usddancingcubesexample")) \
|
||||
((Params, "Usd_DCE_Params"))
|
||||
|
||||
TF_DECLARE_PUBLIC_TOKENS(UsdDancingCubesExampleFileFormatTokens,
|
||||
USD_DANCING_CUBES_EXAMPLE_FILE_FORMAT_TOKENS);
|
||||
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(UsdDancingCubesExampleFileFormat);
|
||||
|
||||
/// \class UsdDancingCubesExampleFileFormat
|
||||
///
|
||||
/// Example of a dynamic file format plugin implementation that is entirely
|
||||
/// procedurally generated from the layer's file format arguments.
|
||||
///
|
||||
/// It employs its own custom SdfAbstractData subclass,
|
||||
/// UsdDancingCubesExample_Data, which is used to generate multiple animated
|
||||
/// prims entirely from a small set of parameters. Since layers of this file
|
||||
/// format have their contents solely generated from the file format arguments,
|
||||
/// they do not need to read or parse the contents of the file at all. The file
|
||||
/// format arguments provided by the layer's identifier are converted to a
|
||||
/// params object defined with UsdDancingCubesExample_Data which the layer's
|
||||
/// data uses to generate its specs when requested. See data.h and dataImpl.h
|
||||
/// more details on the params and how the data generates its content.
|
||||
///
|
||||
/// This being a PcpDynamicFileFormatInterface subclass, if a file of this
|
||||
/// format is a payload for a prim spec, the file format arguments can be
|
||||
/// generated through the composed fields on the prim. There is a single custom
|
||||
/// metadata field defined in plugInfo.json called "Usd_DCE_Params" that can be
|
||||
/// used to customize the payload's file format arguments. This field needs to
|
||||
/// hold a dictionary value which can provide overrides to the individual param
|
||||
/// value arguments defined in UsdDancingCubesExample_Data.
|
||||
///
|
||||
class UsdDancingCubesExampleFileFormat : public SdfFileFormat,
|
||||
public PcpDynamicFileFormatInterface
|
||||
{
|
||||
public:
|
||||
/// Override this function from SdfFileFormat to provide our own procedural
|
||||
/// SdfAbstractData class.
|
||||
SdfAbstractDataRefPtr InitData(
|
||||
const FileFormatArguments &args) const override;
|
||||
|
||||
/// Must implement SdfFileFormat's CanRead function. Returns true for all
|
||||
/// files as the contents of the file aren't used.
|
||||
bool CanRead(const std::string &filePath) const override;
|
||||
|
||||
/// Must implement SdfFileFormat's Read function, though this implemenation
|
||||
/// doesn't do anything. There is nothing from the file that needs to be
|
||||
/// read as data will have already been initialized from file format
|
||||
/// arguments.
|
||||
bool Read(SdfLayer *layer,
|
||||
const std::string &resolvedPath,
|
||||
bool metadataOnly) const override;
|
||||
|
||||
/// We override WriteToString and WriteToStream methods so
|
||||
/// SdfLayer::ExportToString() etc, work. Writing this layer will write out
|
||||
/// the generated layer contents.
|
||||
/// We do NOT implement WriteToFile as it doesn't make sense to write to
|
||||
/// files of this format when the contents are completely generated from the
|
||||
/// file format arguments.
|
||||
bool WriteToString(const SdfLayer & layer,
|
||||
std::string *str,
|
||||
const std::string &comment=std::string()) const override;
|
||||
bool WriteToStream(const SdfSpecHandle &spec,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
/// A required PcpDynamicFileFormatInterface override for generating
|
||||
/// the file format arguments in context.
|
||||
void ComposeFieldsForFileFormatArguments(
|
||||
const std::string &assetPath,
|
||||
const PcpDynamicFileFormatContext &context,
|
||||
FileFormatArguments *args,
|
||||
VtValue *contextDependencyData) const override;
|
||||
|
||||
/// A required PcpDynamicFileFormatInterface override for processing whether
|
||||
/// a field change may affect the file format arguments within a given
|
||||
/// context.
|
||||
bool CanFieldChangeAffectFileFormatArguments(
|
||||
const TfToken &field,
|
||||
const VtValue &oldValue,
|
||||
const VtValue &newValue,
|
||||
const VtValue &contextDependencyData) const override;
|
||||
|
||||
protected:
|
||||
SDF_FILE_FORMAT_FACTORY_ACCESS;
|
||||
|
||||
virtual ~UsdDancingCubesExampleFileFormat();
|
||||
UsdDancingCubesExampleFileFormat();
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_EXTRAS_USD_EXAMPLES_USD_DANCING_CUBES_EXAMPLE_FILE_FORMAT_H
|
||||
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"HdTinyRendererPlugin": {
|
||||
"bases": [
|
||||
"HdRendererPlugin"
|
||||
],
|
||||
"displayName": "Tiny",
|
||||
"priority": 99
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../hdTiny.dll",
|
||||
"Name": "HdTiny",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"Usd_DCE_Params": {
|
||||
"type": "dictionary",
|
||||
"displayGroup": "Core",
|
||||
"appliesTo": ["prims"],
|
||||
"documentation:": "Used to set number of copies."
|
||||
}
|
||||
},
|
||||
|
||||
"Types": {
|
||||
"UsdDancingCubesExampleFileFormat": {
|
||||
"bases": [
|
||||
"SdfFileFormat"
|
||||
],
|
||||
"displayName": "USD Dancing Cubes Example Format",
|
||||
"extensions": [
|
||||
"usddancingcubesexample"
|
||||
],
|
||||
"formatId": "usdDancingCubesExample",
|
||||
"primary": true,
|
||||
"target": "usd"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../usdDancingCubesExample.dll",
|
||||
"Name": "usdDancingCubesExample",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#usda 1.0
|
||||
(
|
||||
endTimeCode = 200
|
||||
startTimeCode = 0
|
||||
)
|
||||
|
||||
def "Root" (
|
||||
# Dictionary value metadata field that provides all the parameters to
|
||||
# generate the layer in the payload. Change these values to change the
|
||||
# contents of the file.
|
||||
Usd_DCE_Params = {
|
||||
int perSide = 15
|
||||
int framesPerCycle = 36
|
||||
int numFrames = 200
|
||||
double distance = 6.0
|
||||
double moveScale = 1.5
|
||||
token geomType = "Cube"
|
||||
}
|
||||
# Payload to the dynamic file. The file must exist but its contents are
|
||||
# irrelevant as everything is generated from parameters above.
|
||||
payload = @./empty.usddancingcubesexample@
|
||||
)
|
||||
{
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
# This file is intentionally empty. The file must exist to be referenced but the
|
||||
# contents are completely irrelevant for this file format.
|
||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"UsdObjFileFormat": {
|
||||
"bases": [
|
||||
"SdfFileFormat"
|
||||
],
|
||||
"displayName": "USD Tutorial Rudimentary OBJ",
|
||||
"extensions": [
|
||||
"obj"
|
||||
],
|
||||
"formatId": "obj",
|
||||
"primary": true,
|
||||
"target": "usd"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../usdObj.dll",
|
||||
"Name": "usdObj",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"UsdExample_depth": {
|
||||
"type": "int",
|
||||
"default": 1,
|
||||
"displayGroup": "Core",
|
||||
"appliesTo": ["prims"],
|
||||
"documentation:": "Used to set total number of recursions."
|
||||
},
|
||||
"UsdExample_num": {
|
||||
"type": "int",
|
||||
"default": 1,
|
||||
"displayGroup": "Core",
|
||||
"appliesTo": ["prims"],
|
||||
"documentation:": "Used to set the number of prims added at each recursion."
|
||||
},
|
||||
"UsdExample_radius": {
|
||||
"type": "double",
|
||||
"default": 3.0,
|
||||
"displayGroup": "Core",
|
||||
"appliesTo": ["prims"],
|
||||
"documentation:": "Radius of ring used to layout generated prims at each recursion."
|
||||
},
|
||||
"UsdExample_height": {
|
||||
"type": "double",
|
||||
"default": 3.0,
|
||||
"displayGroup": "Core",
|
||||
"appliesTo": ["prims"],
|
||||
"documentation:": "Height above the previous level to place generated prims."
|
||||
},
|
||||
"UsdExample_argDict": {
|
||||
"type": "dictionary",
|
||||
"displayGroup": "Core",
|
||||
"appliesTo": ["prims"],
|
||||
"documentation:": "Dictionary of parameters that can be specified for individually IDed payloads."
|
||||
}
|
||||
},
|
||||
|
||||
"Types": {
|
||||
"UsdRecursivePayloadsExampleFileFormat": {
|
||||
"bases": [
|
||||
"SdfFileFormat"
|
||||
],
|
||||
"displayName": "USD Dynamic File Format Example",
|
||||
"extensions": [
|
||||
"usdrecursivepayloadsexample"
|
||||
],
|
||||
"formatId": "usdRecursivePayloadsExample",
|
||||
"primary": true,
|
||||
"target": "usd"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../usdRecursivePayloadsExample.dll",
|
||||
"Name": "usdRecursivePayloadsExample",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
#usda 1.0
|
||||
(
|
||||
defaultPrim = "cone"
|
||||
)
|
||||
|
||||
def Cone "cone"
|
||||
{
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#usda 1.0
|
||||
|
||||
# Example parameters metadata
|
||||
def "Params" (
|
||||
# These are the parameters that affect any payload that composes them.
|
||||
UsdExample_depth = 5
|
||||
UsdExample_num = 3
|
||||
UsdExample_radius = 50.0
|
||||
# This is an example of the dictionary value for overriding particular
|
||||
# parameters on a payload with a matching payloadId in its file format
|
||||
# arguments.
|
||||
UsdExample_argDict = {
|
||||
# Overrides for the specifically named Foo payload
|
||||
dictionary "Foo" = {
|
||||
int UsdExample_depth = 5
|
||||
int UsdExample_num = 4
|
||||
}
|
||||
# Overrides for the specifically named Bar payload
|
||||
dictionary "Bar" = {
|
||||
double UsdExample_height = 5
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
#usda 1.0
|
||||
|
||||
# Demonstrates a prim with a list of payloads that used a specified file format argument of
|
||||
# UsdExample_payloadId to allow the argDict metadata field to specify different parameters
|
||||
# for each in the same prim.
|
||||
def "PayloadRoot" (
|
||||
payload = [@cone.usdrecursivepayloadsexample:SDF_FORMAT_ARGS:UsdExample_payloadId=Foo@,
|
||||
@sphere.usdrecursivepayloadsexample:SDF_FORMAT_ARGS:UsdExample_payloadId=Bar@]
|
||||
)
|
||||
{
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#usda 1.0
|
||||
|
||||
# Prim that demonstrates how dynamic file formate arguments can be composed from fields
|
||||
# that have been composed. The params reference brings in opinions about the metadata fields
|
||||
# the affect our dynamic payloads. The payload refence brings in a list of payloads that
|
||||
# refer to dynamic file format types. The fields composed from the params reference will
|
||||
# affect the layer content in the payloads.
|
||||
def "RootMulti" (
|
||||
references = [@./params.usda@</Params>,
|
||||
@./payload.usda@</PayloadRoot>]
|
||||
)
|
||||
{
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#usda 1.0
|
||||
(
|
||||
defaultPrim = "hello"
|
||||
)
|
||||
|
||||
def Xform "hello"
|
||||
{
|
||||
def Sphere "sphere"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0, 0, 1)]
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,46 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"WARNING: THIS FILE IS GENERATED BY usdGenSchema. DO NOT EDIT."
|
||||
)
|
||||
|
||||
class "SimplePrim" (
|
||||
doc = """An example of an untyped schema prim. Note that it does not
|
||||
specify a typeName"""
|
||||
)
|
||||
{
|
||||
int intAttr = 0 (
|
||||
doc = "An integer attribute with fallback value of 0."
|
||||
)
|
||||
rel target (
|
||||
doc = """A relationship called target that could point to another prim
|
||||
or a property"""
|
||||
)
|
||||
}
|
||||
|
||||
class ComplexPrim "ComplexPrim" (
|
||||
doc = "An example of a untyped IsA schema prim"
|
||||
)
|
||||
{
|
||||
string complexString = "somethingComplex"
|
||||
int intAttr = 0 (
|
||||
doc = "An integer attribute with fallback value of 0."
|
||||
)
|
||||
rel target (
|
||||
doc = """A relationship called target that could point to another prim
|
||||
or a property"""
|
||||
)
|
||||
}
|
||||
|
||||
class "ParamsAPI"
|
||||
{
|
||||
double params:mass (
|
||||
doc = "Double value denoting mass"
|
||||
)
|
||||
double params:velocity (
|
||||
doc = "Double value denoting velocity"
|
||||
)
|
||||
double params:volume (
|
||||
doc = "Double value denoting volume"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"UsdSchemaExamplesComplex": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "ComplexPrim"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdSchemaExamplesSimple"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdSchemaExamplesParamsAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "ParamsAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdSchemaExamplesSimple": {
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "abstractTyped"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../usdSchemaExamples.dll",
|
||||
"Name": "usdSchemaExamples",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
#usda 1.0
|
||||
(
|
||||
""" This file contains an example schemata for code generation using
|
||||
usdGenSchema.
|
||||
"""
|
||||
subLayers = [
|
||||
@usd/schema.usda@
|
||||
]
|
||||
)
|
||||
|
||||
over "GLOBAL" (
|
||||
customData = {
|
||||
string libraryName = "usdSchemaExamples"
|
||||
string libraryPath = "."
|
||||
string libraryPrefix = "UsdSchemaExamples"
|
||||
}
|
||||
) {
|
||||
}
|
||||
|
||||
class "SimplePrim" (
|
||||
doc = """An example of an untyped schema prim. Note that it does not
|
||||
specify a typeName"""
|
||||
# IsA schemas should derive from </Typed>, which is defined in the sublayer
|
||||
# usd/lib/usd/schema.usda.
|
||||
inherits = </Typed>
|
||||
customData = {
|
||||
# Provide a different class name for the C++ and python schema classes.
|
||||
# This will be prefixed with libraryPrefix.
|
||||
# In this case, the class name becomes UsdSchemaExamplesSimple.
|
||||
string className = "Simple"
|
||||
}
|
||||
)
|
||||
{
|
||||
int intAttr = 0 (
|
||||
doc = "An integer attribute with fallback value of 0."
|
||||
)
|
||||
rel target (
|
||||
doc = """A relationship called target that could point to another prim
|
||||
or a property"""
|
||||
)
|
||||
}
|
||||
|
||||
# Note that it does not specify a typeName.
|
||||
class ComplexPrim "ComplexPrim" (
|
||||
doc = """An example of a untyped IsA schema prim"""
|
||||
# Inherits from </SimplePrim> defined in simple.usda.
|
||||
inherits = </SimplePrim>
|
||||
customData = {
|
||||
string className = "Complex"
|
||||
}
|
||||
)
|
||||
{
|
||||
string complexString = "somethingComplex"
|
||||
}
|
||||
|
||||
class "ParamsAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
)
|
||||
{
|
||||
double params:mass (
|
||||
# Informs schema generator to create GetMassAttr() method
|
||||
# instead of GetParamsMassAttr() method
|
||||
customData = {
|
||||
string apiName = "mass"
|
||||
}
|
||||
doc = "Double value denoting mass"
|
||||
)
|
||||
double params:velocity (
|
||||
customData = {
|
||||
string apiName = "velocity"
|
||||
}
|
||||
doc = "Double value denoting velocity"
|
||||
)
|
||||
double params:volume (
|
||||
customData = {
|
||||
string apiName = "volume"
|
||||
}
|
||||
doc = "Double value denoting volume"
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#usda 1.0
|
||||
|
||||
def Xform "hello"
|
||||
{
|
||||
def Sphere "world"
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# section 1
|
||||
from pxr import Usd, UsdGeom, Vt
|
||||
|
||||
stage = Usd.Stage.Open('HelloWorld.usda')
|
||||
xform = stage.GetPrimAtPath('/hello')
|
||||
sphere = stage.GetPrimAtPath('/hello/world')
|
||||
|
||||
# section 2
|
||||
expected = ['proxyPrim', 'purpose', 'visibility', 'xformOpOrder']
|
||||
assert xform.GetPropertyNames() == expected
|
||||
|
||||
expected = ['doubleSided', 'extent', 'orientation',
|
||||
'primvars:displayColor', 'primvars:displayOpacity',
|
||||
'proxyPrim', 'purpose', 'radius', 'visibility', 'xformOpOrder']
|
||||
assert sphere.GetPropertyNames() == expected
|
||||
|
||||
|
||||
# section 3
|
||||
extentAttr = sphere.GetAttribute('extent')
|
||||
expected = Vt.Vec3fArray([(-1, -1, -1), (1, 1, 1)])
|
||||
assert extentAttr.Get() == expected
|
||||
|
||||
# section 4
|
||||
radiusAttr = sphere.GetAttribute('radius')
|
||||
radiusAttr.Set(2)
|
||||
extentAttr.Set(extentAttr.Get() * 2)
|
||||
print(stage.GetRootLayer().ExportToString())
|
||||
|
||||
# section 5
|
||||
from pxr import UsdGeom
|
||||
sphereSchema = UsdGeom.Sphere(sphere)
|
||||
color = sphereSchema.GetDisplayColorAttr()
|
||||
color.Set([(0,0,1)])
|
||||
print(stage.GetRootLayer().ExportToString())
|
||||
stage.GetRootLayer().Save()
|
||||
@@ -0,0 +1,17 @@
|
||||
#usda 1.0
|
||||
(
|
||||
defaultPrim = "hello"
|
||||
)
|
||||
|
||||
def Xform "hello"
|
||||
{
|
||||
custom double3 xformOp:translate = (4, 5, 6)
|
||||
uniform token[] xformOpOrder = ["xformOp:translate"]
|
||||
|
||||
def Sphere "world"
|
||||
{
|
||||
float3[] extent = [(-2, -2, -2), (2, 2, 2)]
|
||||
color3f[] primvars:displayColor = [(0, 0, 1)]
|
||||
double radius = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# Assumes that $USD_INSTALL_ROOT/lib/python is in sys.path
|
||||
|
||||
from pxr import Usd, UsdGeom
|
||||
|
||||
stage = Usd.Stage.Open('HelloWorld.usda')
|
||||
|
||||
# Clear local opinion, which alwauys wins over variants.
|
||||
colorAttr = UsdGeom.Gprim.Get(stage, '/hello/world').GetDisplayColorAttr()
|
||||
colorAttr.Clear()
|
||||
print(stage.GetRootLayer().ExportToString())
|
||||
|
||||
# Create variant set.
|
||||
rootPrim = stage.GetPrimAtPath('/hello')
|
||||
vset = rootPrim.GetVariantSets().AddVariantSet('shadingVariant')
|
||||
print(stage.GetRootLayer().ExportToString())
|
||||
|
||||
# Create variant options.
|
||||
vset.AddVariant('red')
|
||||
vset.AddVariant('blue')
|
||||
vset.AddVariant('green')
|
||||
print(stage.GetRootLayer().ExportToString())
|
||||
|
||||
# Author red color behind red variant.
|
||||
vset.SetVariantSelection('red')
|
||||
with vset.GetVariantEditContext():
|
||||
colorAttr.Set([(1,0,0)])
|
||||
print(stage.GetRootLayer().ExportToString())
|
||||
|
||||
vset.SetVariantSelection('blue')
|
||||
with vset.GetVariantEditContext():
|
||||
colorAttr.Set([(0,0,1)])
|
||||
vset.SetVariantSelection('green')
|
||||
with vset.GetVariantEditContext():
|
||||
colorAttr.Set([(0,1,0)])
|
||||
print(stage.GetRootLayer().ExportToString())
|
||||
|
||||
stage.GetRootLayer().Export('HelloWorldWithVariants.usda')
|
||||
|
||||
# Print composed results-- note that variants get flattened away.
|
||||
print(stage.ExportToString(False))
|
||||
@@ -0,0 +1,5 @@
|
||||
#usda 1.0
|
||||
|
||||
def Sphere "sphere"
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#usda 1.0
|
||||
|
||||
def Sphere "sphere"
|
||||
{
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Binary file not shown.
@@ -0,0 +1,317 @@
|
||||
#usda 1.0
|
||||
(
|
||||
defaultPrim = "Ball"
|
||||
)
|
||||
|
||||
over "Ball" (
|
||||
variants = {
|
||||
string shadingVariant = "Cue"
|
||||
}
|
||||
add variantSets = "shadingVariant"
|
||||
)
|
||||
{
|
||||
over "mesh"
|
||||
{
|
||||
}
|
||||
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
variantSet "shadingVariant" = {
|
||||
"Ball_1" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball1.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(1, 0.850422, 0.0241323)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_10" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball10.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.0170208, 0.0444973, 0.363132)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_11" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball11.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.947959, 0.0329563, 0.0134364)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_12" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball12.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.0473661, 0.0167832, 0.133209)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_13" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball13.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.956527, 0.215727, 0.0241323)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_14" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball14.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.0013732, 0.0494753, 0.0429018)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_15" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball15.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.333438, 0.0019764, 0.00550657)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_2" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball2.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.0170208, 0.0444973, 0.363132)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_3" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball3.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.947959, 0.0329563, 0.0134364)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_4" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball4.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.0473661, 0.0167832, 0.133209)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_5" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball5.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.956527, 0.215727, 0.0241323)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_6" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball6.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.0013732, 0.0494753, 0.0429018)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_7" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball7.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.333438, 0.0019764, 0.00550657)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_8" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball8.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.00977218, 0.00908114, 0.00778151)]
|
||||
}
|
||||
|
||||
}
|
||||
"Ball_9" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ball9.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(1, 0.850422, 0.0241323)]
|
||||
}
|
||||
|
||||
}
|
||||
"Cue" {
|
||||
over "Looks"
|
||||
{
|
||||
over "BallMaterial"
|
||||
{
|
||||
over "BallTexture"
|
||||
{
|
||||
string filename = "./tex/ballCue.tex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
over "mesh"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(0.991221, 0.982484, 0.743576)]
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#usda 1.0
|
||||
(
|
||||
defaultPrim = "Ball"
|
||||
upAxis = "Y"
|
||||
)
|
||||
|
||||
def Xform "Ball" (
|
||||
assetInfo = {
|
||||
asset identifier = @Ball/Ball.usd@
|
||||
string name = "Ball"
|
||||
}
|
||||
kind = "component"
|
||||
prepend references = [
|
||||
@./Ball.shadingVariants.usda@,
|
||||
@./Ball.maya.usd@
|
||||
]
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash -e
|
||||
txmake=/opt/pixar/RenderManProServer-20.3/bin/txmake
|
||||
$txmake ballCue.jpg ballCue.tex
|
||||
$txmake ball1.jpg ball1.tex
|
||||
$txmake ball9.jpg ball9.tex
|
||||
$txmake ball8.jpg ball8.tex
|
||||
$txmake ball4.jpg ball4.tex
|
||||
File diff suppressed because it is too large.
Load diff
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
#usda 1.0
|
||||
(
|
||||
defaultPrim = "Table"
|
||||
upAxis = "Y"
|
||||
)
|
||||
|
||||
def Xform "Table" (
|
||||
assetInfo = {
|
||||
asset identifier = @Table/Table.usd@
|
||||
string name = "Table"
|
||||
}
|
||||
kind = "component"
|
||||
prepend references = @./Table.maya.usd@
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#usda 1.0
|
||||
(
|
||||
defaultPrim = "main_cam"
|
||||
endTimeCode = 0
|
||||
startTimeCode = 0
|
||||
)
|
||||
|
||||
def Camera "main_cam" (
|
||||
kind = "component"
|
||||
)
|
||||
{
|
||||
float circleOfConfusionSize = 0.0125
|
||||
float4[] clippingPlanes = []
|
||||
float2 clippingRange = (10, 500000)
|
||||
matrix4d constraintTargets:HeadXf = ( (1, 0, 0, 0), (0, 0.999999999997669, 0, 0), (0, 0, 0.999999999997669, 0), (0, 15, 15, 1) ) (
|
||||
constraintTargetIdentifier = "HeadXf"
|
||||
customData = {
|
||||
bool hasPropertyDefinition = 0
|
||||
}
|
||||
)
|
||||
float3[] extentsHint = [(3.40282e+38, 3.40282e+38, 3.40282e+38), (-3.40282e+38, -3.40282e+38, -3.40282e+38)]
|
||||
float focalLength = 25.047468
|
||||
float focusDistance = 200
|
||||
float fStop = 5.6
|
||||
float horizontalAperture = 24
|
||||
float lensSqueezeRatio = 1
|
||||
token projection = "perspective"
|
||||
uniform bool stereoscopic = 0
|
||||
float verticalAperture = 13.5
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
#usda 1.0
|
||||
|
||||
def Xform "World"
|
||||
{
|
||||
def Xform "sets"
|
||||
{
|
||||
}
|
||||
|
||||
def Xform "anim"
|
||||
{
|
||||
}
|
||||
|
||||
def "main_cam" (
|
||||
prepend references = @./main_cam.usd@
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,121 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
'''
|
||||
Creates an asset file that consists of a top level layer and sublayers for
|
||||
shading and geometry.
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
from pxr import Kind, Sdf, Usd, UsdGeom
|
||||
|
||||
def main():
|
||||
import optparse
|
||||
|
||||
descr = __doc__.strip()
|
||||
usage = 'usage: %prog [options] asset'
|
||||
parser = optparse.OptionParser(description=descr, usage=usage)
|
||||
parser.add_option('-k', '--kind', default=Kind.Tokens.component,
|
||||
help="sets asset's model kind")
|
||||
parser.add_option('-o', '--outputDir',
|
||||
help='directory to create assets. if none specified, will use modelName.')
|
||||
parser.add_option('-s', '--shadingVariantLayer',
|
||||
help='add <asset>.shadingVariants.usda to model references.', default=False,
|
||||
action='store_true')
|
||||
parser.add_option('-f', '--force', default=False, action='store_true',
|
||||
help='if False, this will error if [outputDir] exists')
|
||||
options, args = parser.parse_args()
|
||||
|
||||
if len(args) != 1:
|
||||
parser.error("No asset specified")
|
||||
|
||||
asset = args[0]
|
||||
force = options.force
|
||||
|
||||
outputDir = options.outputDir
|
||||
if not outputDir:
|
||||
outputDir = asset
|
||||
|
||||
if os.path.exists(outputDir):
|
||||
if not force:
|
||||
parser.error('outputDir "%s" exists. Use -f to override' % outputDir)
|
||||
else:
|
||||
os.makedirs(outputDir)
|
||||
|
||||
_CreateAsset(asset, outputDir, options.kind, options.shadingVariantLayer)
|
||||
|
||||
def _CreateAsset(assetName, assetDir, assetKind, addShadingVariantLayer):
|
||||
assetFilePath = os.path.join(assetDir, '%s.usd' % assetName)
|
||||
|
||||
print("Creating asset at %s" % assetFilePath)
|
||||
# Make the layer ascii - good for readability, plus the file is small
|
||||
rootLayer = Sdf.Layer.CreateNew(assetFilePath, args = {'format':'usda'})
|
||||
assetStage = Usd.Stage.Open(rootLayer)
|
||||
|
||||
# Define a prim for the asset and make it the default for the stage.
|
||||
assetPrim = UsdGeom.Xform.Define(assetStage, '/%s' % assetName).GetPrim()
|
||||
assetStage.SetDefaultPrim(assetPrim)
|
||||
# Lets viewing applications know how to orient a free camera properly
|
||||
UsdGeom.SetStageUpAxis(assetStage, UsdGeom.Tokens.y)
|
||||
|
||||
# Usually we will "loft up" the kind authored into the exported geometry
|
||||
# layer rather than re-stamping here; we'll leave that for a later
|
||||
# tutorial, and just be explicit here.
|
||||
model = Usd.ModelAPI(assetPrim)
|
||||
if assetKind:
|
||||
model.SetKind(assetKind)
|
||||
|
||||
model.SetAssetName(assetName)
|
||||
model.SetAssetIdentifier('%s/%s.usd' % (assetName, assetName))
|
||||
|
||||
refs = []
|
||||
if addShadingVariantLayer:
|
||||
# if we're going to add it, then shading is stronger than geom and needs
|
||||
# to be added first
|
||||
refs.append('./%s.shadingVariants.usda' % assetName)
|
||||
|
||||
refs.append('./%s.maya.usd' % assetName)
|
||||
|
||||
_CreateAndReferenceLayers(assetPrim, assetDir, refs)
|
||||
|
||||
assetStage.GetRootLayer().Save()
|
||||
|
||||
def _CreateAndReferenceLayers(assetPrim, assetDir, refs):
|
||||
from pxr import Usd
|
||||
for refLayerPath in refs:
|
||||
referencedStage = Usd.Stage.CreateNew(os.path.join(assetDir, refLayerPath))
|
||||
referencedAssetPrim = referencedStage.DefinePrim(assetPrim.GetPath())
|
||||
referencedStage.SetDefaultPrim(referencedAssetPrim)
|
||||
referencedStage.GetRootLayer().Save()
|
||||
|
||||
assetPrim.GetReferences().AddReference(refLayerPath)
|
||||
|
||||
# If you want to print things out, you can do:
|
||||
#print(rootLayer.ExportToString())
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,103 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
'''
|
||||
Creates a shot with separate layers for departments.
|
||||
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
def main():
|
||||
import optparse
|
||||
|
||||
descr = __doc__.strip()
|
||||
usage = 'usage: %prog [options] shot'
|
||||
parser = optparse.OptionParser(description=descr, usage=usage)
|
||||
parser.add_option('-b', '--baseLayer',
|
||||
help='this will be added verbatim in the subLayerPaths.')
|
||||
parser.add_option('-o', '--outputDir',
|
||||
help='directory to create shot. if none specified, will use shotName.')
|
||||
|
||||
parser.add_option('-f', '--force', default=False, action='store_true',
|
||||
help='if False, this will error if [outputDir] exists')
|
||||
options, args = parser.parse_args()
|
||||
|
||||
if len(args) != 1:
|
||||
parser.error("No shot specified")
|
||||
|
||||
shot = args[0]
|
||||
force = options.force
|
||||
|
||||
outputDir = options.outputDir
|
||||
if not outputDir:
|
||||
outputDir = shot
|
||||
|
||||
if os.path.exists(outputDir):
|
||||
if not force:
|
||||
parser.error('outputDir "%s" exists. Use -f to override' % outputDir)
|
||||
else:
|
||||
os.makedirs(outputDir)
|
||||
|
||||
_CreateShot(shot, outputDir, options.baseLayer)
|
||||
|
||||
def _CreateShot(shotName, shotDir, baseLayer):
|
||||
shotFilePath = os.path.join(shotDir, '%s.usd' % shotName)
|
||||
|
||||
from pxr import Usd, UsdGeom
|
||||
shotStage = Usd.Stage.CreateNew(shotFilePath)
|
||||
print("Creating shot at %s" % shotFilePath)
|
||||
|
||||
_CreateAndAddSubLayers(shotStage, shotName, shotDir, [
|
||||
'./%s_sim.usd' % shotName,
|
||||
'./%s_anim.usd' % shotName,
|
||||
'./%s_layout.usd' % shotName,
|
||||
'./%s_sets.usd' % shotName,
|
||||
])
|
||||
|
||||
if baseLayer:
|
||||
shotStage.GetRootLayer().subLayerPaths.append(baseLayer)
|
||||
|
||||
# Lets viewing applications know how to orient a free camera properly
|
||||
UsdGeom.SetStageUpAxis(shotStage, UsdGeom.Tokens.y)
|
||||
shotStage.GetRootLayer().Save()
|
||||
|
||||
def _CreateAndAddSubLayers(stage, shotName, shotDir, subLayers):
|
||||
# We use the Sdf API here to quickly create layers. Also, we're using it
|
||||
# as a way to author the subLayerPaths as there is no way to do that
|
||||
# directly in the Usd API.
|
||||
|
||||
from pxr import Sdf
|
||||
rootLayer = stage.GetRootLayer()
|
||||
for subLayerPath in subLayers:
|
||||
Sdf.Layer.CreateNew(os.path.join(shotDir, subLayerPath))
|
||||
rootLayer.subLayerPaths.append(subLayerPath)
|
||||
|
||||
# If you want to print things out, you can do:
|
||||
#print(rootLayer.ExportToString())
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
ASSET_BASE = os.path.join('../../', 'models')
|
||||
|
||||
def main():
|
||||
sequenceFilePath = 'shots/s00/s00.usd'
|
||||
setsLayoutLayerFilePath = 'shots/s00/s00_sets.usd'
|
||||
|
||||
from pxr import Kind, Usd, UsdGeom, Sdf
|
||||
stage = Usd.Stage.Open(sequenceFilePath)
|
||||
|
||||
# we use Sdf, a lower level library, to obtain the 'sets' layer.
|
||||
workingLayer = Sdf.Layer.FindOrOpen(setsLayoutLayerFilePath)
|
||||
assert stage.HasLocalLayer(workingLayer)
|
||||
|
||||
# this makes the workingLayer the target for authoring operations by the
|
||||
# stage.
|
||||
stage.SetEditTarget(workingLayer)
|
||||
|
||||
# Make sure the model-parents we need are well-specified
|
||||
Usd.ModelAPI(UsdGeom.Xform.Define(stage, '/World')).SetKind(Kind.Tokens.group)
|
||||
Usd.ModelAPI(UsdGeom.Xform.Define(stage, '/World/sets')).SetKind(Kind.Tokens.group)
|
||||
|
||||
# in previous examples, we've been using GetReferences().AddReference(...). The
|
||||
# following uses .SetItems() instead which lets us explicitly set (replace)
|
||||
# the references at once instead of adding.
|
||||
stage.DefinePrim('/World/sets/Room_set').GetReferences().SetReferences([
|
||||
Sdf.Reference(os.path.join(ASSET_BASE, 'Room_set/Room_set.usd'))])
|
||||
|
||||
stage.GetEditTarget().GetLayer().Save()
|
||||
|
||||
print('===')
|
||||
print('usdview %s' % sequenceFilePath)
|
||||
print('usdcat %s' % setsLayoutLayerFilePath)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
'''
|
||||
This script adds shading to the models at:
|
||||
|
||||
models/
|
||||
Ball/
|
||||
|
||||
This script will change the texture path to point to different textures (though
|
||||
we only ship textures for '1', '9', '8', '4'). We also set the displayColor in
|
||||
the shadingVariants.
|
||||
|
||||
'''
|
||||
import os
|
||||
ASSET_BASE = os.path.join(os.getcwd(), 'models')
|
||||
|
||||
def main():
|
||||
from pxr import Usd
|
||||
stage = Usd.Stage.CreateNew(os.path.join(
|
||||
ASSET_BASE,
|
||||
'Ball/Ball.shadingVariants.usda'))
|
||||
stage.GetRootLayer().defaultPrim = 'Ball'
|
||||
_AddShadingToBall(stage)
|
||||
stage.GetRootLayer().Save()
|
||||
|
||||
def _AddShadingToBall(stage):
|
||||
from pxr import Sdf, UsdShade
|
||||
model = stage.OverridePrim('/Ball')
|
||||
texDir = os.path.join(ASSET_BASE, 'Ball/tex')
|
||||
mesh = stage.OverridePrim('/Ball/mesh')
|
||||
|
||||
ballTexture = UsdShade.Shader(stage.OverridePrim(
|
||||
model.GetPath().AppendPath('Looks/BallMaterial/BallTexture')))
|
||||
|
||||
# now we'll show adding some shading variants to the ball as well.
|
||||
shadingVariantsInfo = [
|
||||
('Cue', '', _Color(0.996, 0.992, 0.874)), # white
|
||||
|
||||
('Ball_1', '', _Color(1.000, 0.929, 0.184)), # yellow
|
||||
('Ball_2', '', _Color(0.157, 0.243, 0.631)), # blue
|
||||
('Ball_3', '', _Color(0.976, 0.212, 0.141)), # red
|
||||
('Ball_4', '', _Color(0.250, 0.156, 0.400)), # purple
|
||||
('Ball_5', '', _Color(0.980, 0.498, 0.184)), # orange
|
||||
('Ball_6', '', _Color(0.050, 0.255, 0.239)), # green
|
||||
('Ball_7', '', _Color(0.607, 0.059, 0.094)), # darkred
|
||||
|
||||
('Ball_8', '', _Color(0.122, 0.118, 0.110)), # black
|
||||
|
||||
('Ball_9', 'striped', _Color(1.000, 0.929, 0.184)), # yellow
|
||||
('Ball_10', 'striped', _Color(0.157, 0.243, 0.631)), # blue
|
||||
('Ball_11', 'striped', _Color(0.976, 0.212, 0.141)), # red
|
||||
('Ball_12', 'striped', _Color(0.250, 0.156, 0.400)), # purple
|
||||
('Ball_13', 'striped', _Color(0.980, 0.498, 0.184)), # orange
|
||||
('Ball_14', 'striped', _Color(0.050, 0.255, 0.239)), # green
|
||||
('Ball_15', 'striped', _Color(0.607, 0.059, 0.094)), # darkred
|
||||
]
|
||||
|
||||
|
||||
# create the shadingVariant variantSet
|
||||
shadingVariant = model.GetVariantSets().AddVariantSet('shadingVariant')
|
||||
for variantName, decoration, color in shadingVariantsInfo:
|
||||
# creates a variant inside 'shadingVariant'
|
||||
shadingVariant.AddVariant(variantName)
|
||||
|
||||
# switch to that variant
|
||||
shadingVariant.SetVariantSelection(variantName)
|
||||
|
||||
# this 'with' construct here tells Usd that authoring operations should
|
||||
# write to the shadingVariant.
|
||||
with shadingVariant.GetVariantEditContext():
|
||||
whichBall = variantName.split('_')[-1]
|
||||
texPath = os.path.join(texDir, 'ball%s.tex' % whichBall)
|
||||
# in the current variant, modify the color
|
||||
_SetParameters(ballTexture, [
|
||||
('filename', Sdf.ValueTypeNames.String, texPath),
|
||||
])
|
||||
|
||||
# set the display color for hydra
|
||||
_SetDisplayColor(mesh, color)
|
||||
|
||||
# currently not doing anything with decoration, but we could maybe
|
||||
# use this to make the solid vs. stripes.
|
||||
|
||||
# now make the variant selection 'Cue' instead of the last variant that we
|
||||
# created above.
|
||||
shadingVariant.SetVariantSelection('Cue')
|
||||
|
||||
def _SetParameters(shadingNode, params):
|
||||
'''
|
||||
shadingNode is a UsdShadeShader
|
||||
params are (paramName, paramType, value) tuples
|
||||
'''
|
||||
|
||||
for paramName, paramType, value in params:
|
||||
shadingNode.CreateInput(paramName, paramType).Set(value)
|
||||
|
||||
def _Color(r, g, b):
|
||||
# for this tutorial, the colors i got are not in linear space.
|
||||
from pxr import Gf
|
||||
return Gf.ConvertDisplayToLinear(Gf.Vec3f(r, g, b))
|
||||
|
||||
def _SetDisplayColor(mesh, color):
|
||||
from pxr import UsdGeom
|
||||
|
||||
# DisplayColor is actually an array. Here, we just author one color which
|
||||
# applies to the whole mesh.
|
||||
UsdGeom.Gprim(mesh).CreateDisplayColorAttr([color])
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,84 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
def main():
|
||||
shotFilePath = 'shots/s00_01/s00_01.usd'
|
||||
animLayerFilePath = 'shots/s00_01/s00_01_anim.usd'
|
||||
|
||||
from pxr import Usd, Sdf
|
||||
stage = Usd.Stage.Open(shotFilePath)
|
||||
|
||||
# set the timeCode range for the shot that other applications can use.
|
||||
stage.SetStartTimeCode(1)
|
||||
stage.SetEndTimeCode(10)
|
||||
|
||||
stage.GetRootLayer().Save()
|
||||
|
||||
# we use Sdf, a lower level library, to obtain the 'anim' layer.
|
||||
workingLayer = Sdf.Layer.FindOrOpen(animLayerFilePath)
|
||||
assert stage.HasLocalLayer(workingLayer)
|
||||
|
||||
# this makes the workingLayer the target for authoring operations by the
|
||||
# stage.
|
||||
stage.SetEditTarget(workingLayer)
|
||||
|
||||
_AnimateBilliards(stage)
|
||||
|
||||
stage.GetEditTarget().GetLayer().Save()
|
||||
|
||||
print('===')
|
||||
print('usdview %s' % shotFilePath)
|
||||
print('usdcat %s' % animLayerFilePath)
|
||||
|
||||
def _AnimateBilliards(stage):
|
||||
_MoveBall(stage.GetPrimAtPath('/World/anim/CueBall'), (1, 0), 40)
|
||||
#_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_2'), (0, 0), 0.0)
|
||||
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_10'), (0, -1), 20)
|
||||
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_1'), (1, -1), 5)
|
||||
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_4'), (1, -0.5), 3.6)
|
||||
|
||||
def _MoveBall(ball, direction, speed):
|
||||
|
||||
from pxr import Usd, UsdGeom, Gf
|
||||
v = Gf.Vec2d(*direction).GetNormalized() * speed
|
||||
xformAPI = UsdGeom.XformCommonAPI(ball)
|
||||
# Here we make use of GfVec3d rather than plain tuples so we can
|
||||
# add vectors, and demonstrate the API (all Usd API's) will accept either.
|
||||
# GetXformVectors() returns a tuple of
|
||||
# (translation, rotation, scale, pivot, rotationOrder), from which we
|
||||
# extract the first element, the translation
|
||||
start = xformAPI.GetXformVectors(Usd.TimeCode.Default())[0]
|
||||
end = start + Gf.Vec3d(v[0], 0, v[1])
|
||||
|
||||
# set keyframe for frame 1 and frame 10.
|
||||
xformAPI.SetTranslate(start, 1)
|
||||
xformAPI.SetTranslate(end, 10)
|
||||
xformAPI.SetRotate(speed * Gf.Vec3f(3.7, 13.9, 91.34))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
'''
|
||||
This script assumes you have models at
|
||||
|
||||
models/
|
||||
Ball/
|
||||
Table/
|
||||
|
||||
It will create a new "set" (aggregate) model, Room_set at
|
||||
|
||||
models/Room_set
|
||||
|
||||
'''
|
||||
|
||||
import os
|
||||
ASSET_BASE = os.path.join(os.getcwd(), 'models')
|
||||
TABLE_HEIGHT = 74.5
|
||||
BALL_RADIUS = 5.715 * 0.5
|
||||
|
||||
def main():
|
||||
from pxr import Kind, Usd, UsdGeom
|
||||
|
||||
setFilePath = os.path.join(ASSET_BASE, 'Room_set/Room_set.usd')
|
||||
|
||||
# Create the model stage, the model prim, and also make the modelPrim the
|
||||
# default prim so that the layer can be referenced without specifying a
|
||||
# root path.
|
||||
stage = Usd.Stage.CreateNew(setFilePath)
|
||||
setModelPrim = UsdGeom.Xform.Define(stage, '/Room_set').GetPrim()
|
||||
stage.SetDefaultPrim(setModelPrim)
|
||||
|
||||
# Lets viewing applications know how to orient a free camera properly
|
||||
UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.y)
|
||||
|
||||
# Models can have a "kind" which can be used to categorize models into
|
||||
# different types. This is useful for other applications to reason about
|
||||
# the model hierarchy.
|
||||
Usd.ModelAPI(setModelPrim).SetKind(Kind.Tokens.assembly)
|
||||
|
||||
# add child models to our set.
|
||||
_AddModel(stage, '/Room_set/Furniture/Table', 'Table/Table.usd')
|
||||
|
||||
ballNumber = 0
|
||||
|
||||
import math
|
||||
for row in range(5):
|
||||
|
||||
tableX = 10 + row * 2 * BALL_RADIUS * math.cos(math.pi/6)
|
||||
tableRowZ = -row * BALL_RADIUS
|
||||
numBallsInRow = row + 1
|
||||
|
||||
for i in range(numBallsInRow):
|
||||
ballNumber += 1
|
||||
|
||||
b = _AddModel(
|
||||
stage,
|
||||
'/Room_set/Props/Ball_%d' % ballNumber,
|
||||
'Ball/Ball.usd')
|
||||
|
||||
# tableX and tableZ will arrange the balls into a triangle.
|
||||
tableZ = tableRowZ + i * 2 * BALL_RADIUS
|
||||
ballXlate = (tableX, TABLE_HEIGHT + BALL_RADIUS, tableZ)
|
||||
|
||||
# Apply the UsdGeom.Xformable schema to the model, and then set the
|
||||
# transformation.
|
||||
# We are only going to translate the balls, but we still use
|
||||
# the helper XformCommonAPI schema to instantiate a translate op.
|
||||
# XformCommonAPI helps ensure transform ops are interchangeable
|
||||
# between applications, when you can make do with SRT + pivot
|
||||
UsdGeom.XformCommonAPI(b).SetTranslate(ballXlate)
|
||||
|
||||
# we conveniently named the shadingVariant the same as the name of
|
||||
# the ball.
|
||||
shadingVariantName = b.GetName()
|
||||
|
||||
# get the variantSet "shadingVariant" and then set it accordingly.
|
||||
vs = b.GetVariantSets().GetVariantSet('shadingVariant')
|
||||
vs.SetVariantSelection(shadingVariantName)
|
||||
|
||||
stage.GetRootLayer().Save()
|
||||
|
||||
def _AddModel(stage, path, refPath):
|
||||
'''
|
||||
Adds a reference to refPath at the given path in the stage. This will make
|
||||
sure the model hierarchy is maintained by ensuring that all ancestors of
|
||||
the path have "kind" set to "group".
|
||||
|
||||
returns the referenced model.
|
||||
'''
|
||||
|
||||
from pxr import Kind, Sdf, Usd, UsdGeom
|
||||
|
||||
# convert path to an Sdf.Path which has several methods that are useful
|
||||
# when working with paths. We use GetPrefixes() here which returns a list
|
||||
# of all the prim prefixes for a given path.
|
||||
path = Sdf.Path(path)
|
||||
for prefixPath in path.GetPrefixes()[1:-1]:
|
||||
parentPrim = stage.GetPrimAtPath(prefixPath)
|
||||
if not parentPrim:
|
||||
parentPrim = UsdGeom.Xform.Define(stage, prefixPath).GetPrim()
|
||||
Usd.ModelAPI(parentPrim).SetKind(Kind.Tokens.group)
|
||||
|
||||
# typeless def here because we'll be getting the type from the prim that
|
||||
# we're referencing.
|
||||
m = stage.DefinePrim(path)
|
||||
m.GetReferences().AddReference(os.path.join(ASSET_BASE, refPath))
|
||||
return m
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
ASSET_BASE = os.path.join(os.getcwd(), 'models')
|
||||
TABLE_HEIGHT = 74.5
|
||||
BALL_RADIUS = 5.715 * 0.5
|
||||
|
||||
def main():
|
||||
shotFilePath = 'shots/s00_01/s00_01.usd'
|
||||
layoutLayerFilePath = 'shots/s00_01/s00_01_layout.usd'
|
||||
|
||||
from pxr import Usd, Sdf
|
||||
stage = Usd.Stage.Open(shotFilePath)
|
||||
|
||||
# set the timeCode range for the shot that other applications can use.
|
||||
stage.SetStartTimeCode(1)
|
||||
stage.SetEndTimeCode(10)
|
||||
|
||||
# we use Sdf, a lower level library, to obtain the 'layout' layer.
|
||||
workingLayer = Sdf.Layer.FindOrOpen(layoutLayerFilePath)
|
||||
assert stage.HasLocalLayer(workingLayer)
|
||||
|
||||
# this makes the workingLayer the target for authoring operations by the
|
||||
# stage.
|
||||
stage.SetEditTarget(workingLayer)
|
||||
|
||||
_SetupBilliards(stage)
|
||||
_MoveCamera(stage)
|
||||
|
||||
stage.GetEditTarget().GetLayer().Save()
|
||||
|
||||
print('===')
|
||||
print('usdview %s' % shotFilePath)
|
||||
print('usdcat %s' % layoutLayerFilePath)
|
||||
|
||||
def _SetupBilliards(stage):
|
||||
from pxr import Kind, Sdf, Usd, UsdGeom
|
||||
|
||||
# Make sure the model-parents we need are well-specified
|
||||
Usd.ModelAPI(UsdGeom.Xform.Define(stage, '/World')).SetKind(Kind.Tokens.group)
|
||||
Usd.ModelAPI(UsdGeom.Xform.Define(stage, '/World/anim')).SetKind(Kind.Tokens.group)
|
||||
# in previous examples, we've been using GetReferences().AddReference(...). The
|
||||
# following uses .SetItems() instead which lets us explicitly set (replace)
|
||||
# the references at once instead of adding.
|
||||
cueBall = stage.DefinePrim('/World/anim/CueBall')
|
||||
cueBall.GetReferences().SetReferences([
|
||||
Sdf.Reference(os.path.join(ASSET_BASE, 'Ball/Ball.usd'))])
|
||||
|
||||
# deactivate everything that isn't 8, 9, 1, 4. We accumulate the prims we
|
||||
# want to deactivate so that we don't delete while iterating.
|
||||
roomProps = stage.GetPrimAtPath('/World/sets/Room_set/Props')
|
||||
keepers = set(['Ball_%d' % i for i in [1, 9, 8, 4] ])
|
||||
toDeactivate = []
|
||||
for child in roomProps.GetChildren():
|
||||
if child.GetName() not in keepers:
|
||||
toDeactivate.append(child)
|
||||
for prim in toDeactivate:
|
||||
prim.SetActive(False)
|
||||
|
||||
# the offset values are relative to the radius of the ball
|
||||
def _MoveBall(ballPrim, offset):
|
||||
translation = (offset[0] * BALL_RADIUS,
|
||||
TABLE_HEIGHT + BALL_RADIUS,
|
||||
offset[1] * BALL_RADIUS)
|
||||
|
||||
# Apply the UsdGeom.Xformable schema to the model, and then set the
|
||||
# transformation. Note we can use ordinary python tuples
|
||||
from pxr import UsdGeom
|
||||
UsdGeom.XformCommonAPI(ballPrim).SetTranslate(translation)
|
||||
|
||||
# all these values are just eye-balled and are relative to Ball_1.
|
||||
_MoveBall(cueBall, (1.831, 4.331))
|
||||
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_2'), (0.000, 0.000))
|
||||
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_10'), (2.221, 1.119))
|
||||
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_1'), (3.776, 0.089))
|
||||
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_4'), (5.453, -0.543))
|
||||
|
||||
def _MoveCamera(stage):
|
||||
from pxr import UsdGeom, Gf
|
||||
cam = UsdGeom.Camera.Get(stage, '/World/main_cam')
|
||||
|
||||
# the camera derives from UsdGeom.Xformable so we can
|
||||
# use the XformCommonAPI on it, too, and see how rotations are handled
|
||||
xformAPI = UsdGeom.XformCommonAPI(cam)
|
||||
xformAPI.SetTranslate( (8, 120, 8) )
|
||||
# -86 degree rotation around X axis. Can specify rotation order as
|
||||
# optional parameter
|
||||
xformAPI.SetRotate( (-86, 0, 0 ) )
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
from pxr import Usd, UsdGeom
|
||||
|
||||
stage = Usd.Stage.CreateNew('HelloWorld.usda')
|
||||
xformPrim = UsdGeom.Xform.Define(stage, '/hello')
|
||||
spherePrim = UsdGeom.Sphere.Define(stage, '/hello/world')
|
||||
stage.GetRootLayer().Save()
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
from pxr import Usd
|
||||
|
||||
stage = Usd.Stage.CreateNew('HelloWorldRedux.usda')
|
||||
xform = stage.DefinePrim('/hello', 'Xform')
|
||||
sphere = stage.DefinePrim('/hello/world', 'Sphere')
|
||||
stage.GetRootLayer().Save()
|
||||
@@ -0,0 +1,11 @@
|
||||
#usda 1.0
|
||||
|
||||
def Xform "hello"
|
||||
{
|
||||
def Sphere "world"
|
||||
{
|
||||
float3[] extent = [(-2, -2, -2), (2, 2, 2)]
|
||||
color3f[] primvars:displayColor = [(0, 0, 1)]
|
||||
double radius = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
# Assumes that $USD_INSTALL_ROOT/lib/python is in sys.path
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from pxr import Usd, UsdGeom
|
||||
|
||||
stage = Usd.Stage.Open('HelloWorld.usda')
|
||||
# XXX: save the usd file to the local directory where the test
|
||||
# is being administered so RefExample will have access to it
|
||||
stage.Export('HelloWorld.usda')
|
||||
hello = stage.GetPrimAtPath('/hello')
|
||||
stage.SetDefaultPrim(hello)
|
||||
UsdGeom.XformCommonAPI(hello).SetTranslate((4, 5, 6))
|
||||
print(stage.GetRootLayer().ExportToString())
|
||||
stage.GetRootLayer().Save()
|
||||
|
||||
# Create an over on which to create our reference.
|
||||
refStage = Usd.Stage.CreateNew('RefExample.usda')
|
||||
refSphere = refStage.OverridePrim('/refSphere')
|
||||
print(refStage.GetRootLayer().ExportToString())
|
||||
|
||||
# Reference in the layer.
|
||||
refSphere.GetReferences().AddReference('./HelloWorld.usda')
|
||||
print(refStage.GetRootLayer().ExportToString())
|
||||
refStage.GetRootLayer().Save()
|
||||
|
||||
# Clear out any authored transformation over the reference.
|
||||
refXform = UsdGeom.Xformable(refSphere)
|
||||
refXform.SetXformOpOrder([])
|
||||
print(refStage.GetRootLayer().ExportToString())
|
||||
|
||||
# Reference in the layer again, on another over.
|
||||
refSphere2 = refStage.OverridePrim('/refSphere2')
|
||||
refSphere2.GetReferences().AddReference('./HelloWorld.usda')
|
||||
print(refStage.GetRootLayer().ExportToString())
|
||||
refStage.GetRootLayer().Save()
|
||||
|
||||
# Author displayColor on a namespace descendant of the referenced prim.
|
||||
overSphere = UsdGeom.Sphere.Get(refStage, '/refSphere2/world' )
|
||||
overSphere.GetDisplayColorAttr().Set( [(1, 0, 0)] )
|
||||
print(refStage.GetRootLayer().ExportToString())
|
||||
refStage.GetRootLayer().Save()
|
||||
|
||||
# Print the final composed results.
|
||||
print(refStage.ExportToString())
|
||||
@@ -0,0 +1,17 @@
|
||||
#usda 1.0
|
||||
(
|
||||
defaultPrim = "hello"
|
||||
)
|
||||
|
||||
def Xform "hello"
|
||||
{
|
||||
custom double3 xformOp:translate = (4, 5, 6)
|
||||
uniform token[] xformOpOrder = ["xformOp:translate"]
|
||||
|
||||
def Sphere "world"
|
||||
{
|
||||
float3[] extent = [(-2, -2, -2), (2, 2, 2)]
|
||||
color3f[] primvars:displayColor = [(0, 0, 1)]
|
||||
double radius = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#usda 1.0
|
||||
|
||||
over "refSphere" (
|
||||
prepend references = @HelloWorld.usda@
|
||||
)
|
||||
{
|
||||
uniform token[] xformOpOrder = []
|
||||
}
|
||||
|
||||
over "refSphere2" (
|
||||
prepend references = @HelloWorld.usda@
|
||||
)
|
||||
{
|
||||
over "world"
|
||||
{
|
||||
color3f[] primvars:displayColor = [(1, 0, 0)]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2016 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
from pxr import Usd, UsdGeom
|
||||
|
||||
# section 1
|
||||
stage = Usd.Stage.Open("RefExample.usda")
|
||||
assert([x for x in stage.Traverse()] == [stage.GetPrimAtPath("/refSphere"),
|
||||
stage.GetPrimAtPath("/refSphere/world"), stage.GetPrimAtPath("/refSphere2"),
|
||||
stage.GetPrimAtPath("/refSphere2/world")])
|
||||
|
||||
# section 2
|
||||
assert([x for x in stage.Traverse() if UsdGeom.Sphere(x)] ==
|
||||
[stage.GetPrimAtPath("/refSphere/world"),
|
||||
stage.GetPrimAtPath("/refSphere2/world")])
|
||||
|
||||
# section 3
|
||||
treeIter = iter(Usd.PrimRange.PreAndPostVisit(stage.GetPseudoRoot()))
|
||||
|
||||
treeIterExpectedResults = [(stage.GetPrimAtPath("/"), False),
|
||||
(stage.GetPrimAtPath("/refSphere"), False),
|
||||
(stage.GetPrimAtPath("/refSphere/world"), False),
|
||||
(stage.GetPrimAtPath("/refSphere/world"), True),
|
||||
(stage.GetPrimAtPath("/refSphere"), True),
|
||||
(stage.GetPrimAtPath("/refSphere2"), False),
|
||||
(stage.GetPrimAtPath("/refSphere2/world"), False),
|
||||
(stage.GetPrimAtPath("/refSphere2/world"), True),
|
||||
(stage.GetPrimAtPath("/refSphere2"), True),
|
||||
(stage.GetPrimAtPath("/"), True)]
|
||||
|
||||
treeIterActualResults = [(x, treeIter.IsPostVisit()) for x in treeIter]
|
||||
assert treeIterExpectedResults == treeIterActualResults
|
||||
|
||||
# section 4
|
||||
# Deactivate the prim as we would in usdview
|
||||
ref2Prim = stage.GetPrimAtPath('/refSphere2')
|
||||
stage.SetEditTarget(stage.GetSessionLayer())
|
||||
Usd.Prim.SetActive(ref2Prim, False)
|
||||
|
||||
assert ([x for x in stage.Traverse()] == [stage.GetPrimAtPath("/refSphere"),
|
||||
stage.GetPrimAtPath("/refSphere/world")])
|
||||
Reference in new issue
Block a user