Skip to content

Commit

Permalink
Support all of usdGeom/usdShade/usdLux API tokens.
Browse files Browse the repository at this point in the history
  • Loading branch information
syoyo committed Jul 20, 2024
1 parent 5e91db9 commit 1b46af8
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 3 deletions.
56 changes: 56 additions & 0 deletions src/pprinter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2074,14 +2074,42 @@ std::string to_string(const APISchemas::APIName &name) {
std::string s;

switch (name) {
case APISchemas::APIName::VisibilityAPI: {
s = "VisibilityAPI";
break;
}
case APISchemas::APIName::XformCommonAPI: {
s = "XformCommonAPI";
break;
}
case APISchemas::APIName::SkelBindingAPI: {
s = "SkelBindingAPI";
break;
}
case APISchemas::APIName::MotionAPI: {
s = "MotionAPI";
break;
}
case APISchemas::APIName::PrimvarsAPI: {
s = "PrimvarsAPI";
break;
}
case APISchemas::APIName::CollectionAPI: {
s = "CollectionAPI";
break;
}
case APISchemas::APIName::ConnectableAPI: {
s = "ConnectableAPI";
break;
}
case APISchemas::APIName::CoordSysAPI: {
s = "CoordSysAPI";
break;
}
case APISchemas::APIName::NodeDefAPI: {
s = "NodeDefAPI";
break;
}
case APISchemas::APIName::MaterialBindingAPI: {
s = "MaterialBindingAPI";
break;
Expand All @@ -2090,6 +2118,34 @@ std::string to_string(const APISchemas::APIName &name) {
s = "ShapingAPI";
break;
}
case APISchemas::APIName::ShadowAPI: {
s = "ShadowAPI";
break;
}
case APISchemas::APIName::GeomModelAPI: {
s = "GeomModelAPI";
break;
}
case APISchemas::APIName::ListAPI: {
s = "ListAPI";
break;
}
case APISchemas::APIName::LightAPI: {
s = "LightAPI";
break;
}
case APISchemas::APIName::LightListAPI: {
s = "LightListAPI";
break;
}
case APISchemas::APIName::VolumeLightAPI: {
s = "VolumeLightAPI";
break;
}
case APISchemas::APIName::MeshLightAPI: {
s = "MeshLightAPI";
break;
}
case APISchemas::APIName::Preliminary_AnchoringAPI: {
s = "Preliminary_AnchoringAPI";
break;
Expand Down
26 changes: 24 additions & 2 deletions src/prim-types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,32 @@ struct AssetInfo {
struct APISchemas {
// TinyUSDZ does not allow user-supplied API schema for now
enum class APIName {
// usdShade
MaterialBindingAPI, // "MaterialBindingAPI"
SkelBindingAPI, // "SkelBindingAPI"
ShapingAPI, // "ShapingAPI"(usdLux)
ConnectableAPI, // "ConnectableAPI"
CoordSysAPI, // "CoordSysAPI"
NodeDefAPI, // "NodeDefAPI"

CollectionAPI, // "CollectionAPI"
// usdGeom
GeomModelAPI, // "GeomModelAPI"
MotionAPI, // "MotionAPI"
PrimvarsAPI, // "PrimvarsAPI"
VisibilityAPI, // "VisibilityAPI"
XformCommonAPI, // "XformCommonAPI"

// usdLux
LightAPI, // "LightAPI"
LightListAPI, // "LightListAPI"
ListAPI, // "ListAPI"
MeshLightAPI, // "MeshLightAPI"
ShapingAPI, // "ShapingAPI"
ShadowAPI, // "ShadowAPI"
VolumeLightAPI, // "VolumeLightAPI"

// usdSkel
SkelBindingAPI, // "SkelBindingAPI"

// USDZ AR extensions
Preliminary_AnchoringAPI,
Preliminary_PhysicsColliderAPI,
Expand Down
30 changes: 29 additions & 1 deletion src/usda-reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -728,14 +728,42 @@ class USDAReader::Impl {
"MaterialBindingAPI"),
std::make_pair(APISchemas::APIName::ShapingAPI,
"ShapingAPI"),
std::make_pair(APISchemas::APIName::ShadowAPI,
"ShadowAPI"),
std::make_pair(APISchemas::APIName::VolumeLightAPI,
"VolumeLightAPI"),
std::make_pair(APISchemas::APIName::Preliminary_PhysicsMaterialAPI,
"Preliminary_PhysicsMaterialAPI"),
std::make_pair(APISchemas::APIName::Preliminary_PhysicsRigidBodyAPI,
"Preliminary_PhysicsRigidBodyAPI"),
std::make_pair(APISchemas::APIName::Preliminary_PhysicsColliderAPI,
"Preliminary_PhysicsColliderAPI"),
std::make_pair(APISchemas::APIName::Preliminary_AnchoringAPI,
"Preliminary_AnchoringAPI")
"Preliminary_AnchoringAPI"),
std::make_pair(APISchemas::APIName::LightAPI,
"LightAPI"),
std::make_pair(APISchemas::APIName::MeshLightAPI,
"MeshLightAPI"),
std::make_pair(APISchemas::APIName::LightListAPI,
"LightListAPI"),
std::make_pair(APISchemas::APIName::ListAPI,
"ListAPI"),
std::make_pair(APISchemas::APIName::MotionAPI,
"MotionAPI"),
std::make_pair(APISchemas::APIName::PrimvarsAPI,
"PrimvarsAPI"),
std::make_pair(APISchemas::APIName::GeomModelAPI,
"GeomModelAPI"),
std::make_pair(APISchemas::APIName::VisibilityAPI,
"VisibilityAPI"),
std::make_pair(APISchemas::APIName::XformCommonAPI,
"XformCommonAPI"),
std::make_pair(APISchemas::APIName::NodeDefAPI,
"NodeDefAPI"),
std::make_pair(APISchemas::APIName::CoordSysAPI,
"CoordSysAPI"),
std::make_pair(APISchemas::APIName::ConnectableAPI,
"ConnectableAPI")
};
return EnumHandler<APISchemas::APIName>("apiSchemas", tok, enums);
};
Expand Down
34 changes: 34 additions & 0 deletions src/usdc-reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,42 @@ nonstd::expected<APISchemas, std::string> USDCReader::Impl::ToAPISchemas(
[](const value::token &tok) -> nonstd::optional<APISchemas::APIName> {
if (tok.str() == "MaterialBindingAPI") {
return APISchemas::APIName::MaterialBindingAPI;
} else if (tok.str() == "NodeDefAPI") {
return APISchemas::APIName::NodeDefAPI;
} else if (tok.str() == "CoordSysAPI") {
return APISchemas::APIName::CoordSysAPI;
} else if (tok.str() == "ConnectableAPI") {
return APISchemas::APIName::ConnectableAPI;
} else if (tok.str() == "CollectionAPI") {
return APISchemas::APIName::CollectionAPI;
} else if (tok.str() == "SkelBindingAPI") {
return APISchemas::APIName::SkelBindingAPI;
} else if (tok.str() == "VisibilityAPI") {
return APISchemas::APIName::VisibilityAPI;
} else if (tok.str() == "GeomModelAPI") {
return APISchemas::APIName::GeomModelAPI;
} else if (tok.str() == "MotionAPI") {
return APISchemas::APIName::MotionAPI;
} else if (tok.str() == "PrimvarsAPI") {
return APISchemas::APIName::PrimvarsAPI;
} else if (tok.str() == "XformCommonAPI") {
return APISchemas::APIName::XformCommonAPI;
} else if (tok.str() == "ListAPI") {
return APISchemas::APIName::ListAPI;
} else if (tok.str() == "LightListAPI") {
return APISchemas::APIName::LightListAPI;
} else if (tok.str() == "LightAPI") {
return APISchemas::APIName::LightAPI;
} else if (tok.str() == "MeshLightAPI") {
return APISchemas::APIName::MeshLightAPI;
} else if (tok.str() == "VolumeLightAPI") {
return APISchemas::APIName::VolumeLightAPI;
} else if (tok.str() == "ConnectableAPI") {
return APISchemas::APIName::ConnectableAPI;
} else if (tok.str() == "ShadowAPI") {
return APISchemas::APIName::ShadowAPI;
} else if (tok.str() == "ShapingAPI") {
return APISchemas::APIName::ShapingAPI;
} else if (tok.str() == "Preliminary_AnchoringAPI") {
return APISchemas::APIName::Preliminary_AnchoringAPI;
} else if (tok.str() == "Preliminary_PhysicsColliderAPI") {
Expand Down
15 changes: 15 additions & 0 deletions tests/usda/apishcema-001.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#usda 1.0
(
metersPerUnit = 1
upAxis = "Y"
defaultPrim = "hello"
)

def Cone "hello"
(
prepend apiSchemas = ["GeomModelAPI", "MotionAPI", "ListAPI", "LightListAPI"]
)
{
uniform token axis = "X"
double height = 1.2
}
Binary file added tests/usdc/apischema-001.usdc
Binary file not shown.

0 comments on commit 1b46af8

Please sign in to comment.