From a61efc034bc780aa405c6dca6e3fe4f656fc7169 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 11 Jul 2023 16:16:34 -0400 Subject: [PATCH] Make CesiumTilesetPrim derive from Gprim so that it can be assigned a material --- .../schemas/cesium_schemas.usda | 2 +- .../CesiumUsdSchemas/generatedSchema.usda.in | 40 +++++++++++++++++++ src/plugins/CesiumUsdSchemas/plugInfo.json.in | 2 +- .../src/CesiumUsdSchemas/tileset.cpp | 4 +- .../src/CesiumUsdSchemas/tileset.h | 8 ++-- .../src/CesiumUsdSchemas/wrapTileset.cpp | 2 +- 6 files changed, 49 insertions(+), 9 deletions(-) diff --git a/exts/cesium.usd.plugins/schemas/cesium_schemas.usda b/exts/cesium.usd.plugins/schemas/cesium_schemas.usda index f21199ea4..1edf8e2f5 100644 --- a/exts/cesium.usd.plugins/schemas/cesium_schemas.usda +++ b/exts/cesium.usd.plugins/schemas/cesium_schemas.usda @@ -165,7 +165,7 @@ class CesiumGeoreferencePrim "CesiumGeoreferencePrim" ( class CesiumTilesetPrim "CesiumTilesetPrim" ( doc = """A prim representing a tileset.""" - inherits = + inherits = customData = { string className = "Tileset" diff --git a/src/plugins/CesiumUsdSchemas/generatedSchema.usda.in b/src/plugins/CesiumUsdSchemas/generatedSchema.usda.in index be7693b89..9ec24b093 100644 --- a/src/plugins/CesiumUsdSchemas/generatedSchema.usda.in +++ b/src/plugins/CesiumUsdSchemas/generatedSchema.usda.in @@ -166,6 +166,25 @@ class CesiumTilesetPrim "CesiumTilesetPrim" ( displayName = "URL" doc = "The URL of this tileset's tileset.json file. Usually blank if this is an ion asset." ) + uniform bool doubleSided = 0 ( + doc = """Although some renderers treat all parametric or polygonal + surfaces as if they were effectively laminae with outward-facing + normals on both sides, some renderers derive significant optimizations + by considering these surfaces to have only a single outward side, + typically determined by control-point winding order and/or + orientation. By doing so they can perform \"backface culling\" to + avoid drawing the many polygons of most closed surfaces that face away + from the viewer. + + However, it is often advantageous to model thin objects such as paper + and cloth as single, open surfaces that must be viewable from both + sides, always. Setting a gprim's doubleSided attribute to + \\c true instructs all renderers to disable optimizations such as + backface culling for the gprim, and attempt (not all renderers are able + to do so, but the USD reference GL renderer always will) to provide + forward-facing normals on each side of the surface for lighting + calculations.""" + ) float3[] extent ( doc = """Extent is a three dimensional range measuring the geometric extent of the authored gprim in its own local space (i.e. its own @@ -184,6 +203,27 @@ class CesiumTilesetPrim "CesiumTilesetPrim" ( the extent of all children, as they will be pruned from BBox computation during traversal.""" ) + uniform token orientation = "rightHanded" ( + allowedTokens = ["rightHanded", "leftHanded"] + doc = """Orientation specifies whether the gprim's surface normal + should be computed using the right hand rule, or the left hand rule. + Please see for a deeper explanation and + generalization of orientation to composed scenes with transformation + hierarchies.""" + ) + color3f[] primvars:displayColor ( + doc = '''It is useful to have an "official" colorSet that can be used + as a display or modeling color, even in the absence of any specified + shader for a gprim. DisplayColor serves this role; because it is a + UsdGeomPrimvar, it can also be used as a gprim override for any shader + that consumes a displayColor parameter.''' + ) + float[] primvars:displayOpacity ( + doc = """Companion to displayColor that specifies opacity, broken + out as an independent attribute rather than an rgba color, both so that + each can be independently overridden, and because shaders rarely consume + rgba parameters.""" + ) rel proxyPrim ( doc = '''The proxyPrim relationship allows us to link a prim whose purpose is "render" to its (single target) diff --git a/src/plugins/CesiumUsdSchemas/plugInfo.json.in b/src/plugins/CesiumUsdSchemas/plugInfo.json.in index cb824e536..4f0df0d06 100644 --- a/src/plugins/CesiumUsdSchemas/plugInfo.json.in +++ b/src/plugins/CesiumUsdSchemas/plugInfo.json.in @@ -52,7 +52,7 @@ }, "autoGenerated": true, "bases": [ - "UsdGeomBoundable" + "UsdGeomGprim" ], "schemaKind": "concreteTyped" } diff --git a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tileset.cpp b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tileset.cpp index 18c3b6fb9..57718bcdc 100644 --- a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tileset.cpp +++ b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tileset.cpp @@ -11,7 +11,7 @@ PXR_NAMESPACE_OPEN_SCOPE TF_REGISTRY_FUNCTION(TfType) { TfType::Define >(); + TfType::Bases< UsdGeomGprim > >(); // Register the usd prim typename as an alias under UsdSchemaBase. This // enables one to call @@ -455,7 +455,7 @@ CesiumTileset::GetSchemaAttributeNames(bool includeInherited) }; static TfTokenVector allNames = _ConcatenateAttributeNames( - UsdGeomBoundable::GetSchemaAttributeNames(true), + UsdGeomGprim::GetSchemaAttributeNames(true), localNames); if (includeInherited) diff --git a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tileset.h b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tileset.h index d79e7f069..d4851bdee 100644 --- a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tileset.h +++ b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tileset.h @@ -5,7 +5,7 @@ #include "pxr/pxr.h" #include ".//api.h" -#include "pxr/usd/usdGeom/boundable.h" +#include "pxr/usd/usdGeom/gprim.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usd/stage.h" #include ".//tokens.h" @@ -36,7 +36,7 @@ class SdfAssetPath; /// So to set an attribute to the value "rightHanded", use CesiumTokens->rightHanded /// as the value. /// -class CesiumTileset : public UsdGeomBoundable +class CesiumTileset : public UsdGeomGprim { public: /// Compile time constant representing what kind of schema this class is. @@ -49,7 +49,7 @@ class CesiumTileset : public UsdGeomBoundable /// for a \em valid \p prim, but will not immediately throw an error for /// an invalid \p prim explicit CesiumTileset(const UsdPrim& prim=UsdPrim()) - : UsdGeomBoundable(prim) + : UsdGeomGprim(prim) { } @@ -57,7 +57,7 @@ class CesiumTileset : public UsdGeomBoundable /// Should be preferred over CesiumTileset(schemaObj.GetPrim()), /// as it preserves SchemaBase state. explicit CesiumTileset(const UsdSchemaBase& schemaObj) - : UsdGeomBoundable(schemaObj) + : UsdGeomGprim(schemaObj) { } diff --git a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/wrapTileset.cpp b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/wrapTileset.cpp index b8c31fc9d..8ce680fd5 100644 --- a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/wrapTileset.cpp +++ b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/wrapTileset.cpp @@ -174,7 +174,7 @@ void wrapCesiumTileset() { typedef CesiumTileset This; - class_ > + class_ > cls("Tileset"); cls