Geometric primitives#
OpenUSD supports various basic geometric primitives, known collectively as UsdGeomGprims, which are considered more performant for both rendering & simulation.
While generally trivial to author, it is important to remember to compute correct extents when deviating from the schema fallback values & to check that the prim target location is writeable. The utility functions in this module expose the usual schema parameters of each Gprim, and perform these extra checks.
The set of available Gprims may not directly match the requirements of other data sources. In some cases, it is possible to “shape” a Gprim to match the input data. For example:
A rectangular prism can be authored using
usdex::core::defineCubefollowed byusdex::core::setLocalTransformwith a non-uniform scale.An ellipsoid approximation can be authored using
usdex::core::defineSphereandusdex::core::setLocalTransformwith a non-uniform scale.Several Gprims provide an
axisattribute to orient alongX,Y, orZindependantly of any XformOps.
Note
If the source data cannot be trivially shaped using these mechanisms, it may be necessary to tesselate the input data model and author a mesh using usdex::core::definePolyMesh.
Functions#
- pxr::UsdGeomCapsule usdex::core::defineCapsule(pxr::UsdStagePtr stage, const pxr::SdfPath &path, const double radius=1.0, const double height=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a capsule primitive.
- pxr::UsdGeomCapsule usdex::core::defineCapsule(pxr::UsdPrim parent, const std::string &name, const double radius=1.0, const double height=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a capsule primitive as a child of the
parentprim.- pxr::UsdGeomCapsule usdex::core::defineCapsule(pxr::UsdPrim prim, const double radius=1.0, const double height=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a capsule primitive from an existing prim.
- pxr::UsdGeomCone usdex::core::defineCone(pxr::UsdPrim parent, const std::string &name, const double radius=1.0, const double height=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a cone primitive as a child of the
parentprim.- pxr::UsdGeomCone usdex::core::defineCone(pxr::UsdPrim prim, const double radius=1.0, const double height=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a cone primitive from an existing prim.
- pxr::UsdGeomCone usdex::core::defineCone(pxr::UsdStagePtr stage, const pxr::SdfPath &path, const double radius=1.0, const double height=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a cone primitive.
- pxr::UsdGeomCube usdex::core::defineCube(pxr::UsdPrim prim, const double size=2.0, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a cube primitive from an existing prim.
- pxr::UsdGeomCube usdex::core::defineCube(pxr::UsdPrim parent, const std::string &name, const double size=2.0, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a cube primitive as a child of the
parentprim.- pxr::UsdGeomCube usdex::core::defineCube(pxr::UsdStagePtr stage, const pxr::SdfPath &path, const double size=2.0, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a cube primitive.
- pxr::UsdGeomCylinder usdex::core::defineCylinder(pxr::UsdStagePtr stage, const pxr::SdfPath &path, const double radius=1.0, const double height=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a cylinder primitive.
- pxr::UsdGeomCylinder usdex::core::defineCylinder(pxr::UsdPrim prim, const double radius=1.0, const double height=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a cylinder primitive from an existing prim.
- pxr::UsdGeomCylinder usdex::core::defineCylinder(pxr::UsdPrim parent, const std::string &name, const double radius=1.0, const double height=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a cylinder primitive as a child of the
parentprim.- pxr::UsdGeomPlane usdex::core::definePlane(pxr::UsdPrim prim, const double width=2.0, const double length=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a plane primitive from an existing prim.
- pxr::UsdGeomPlane usdex::core::definePlane(pxr::UsdStagePtr stage, const pxr::SdfPath &path, const double width=2.0, const double length=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a plane primitive.
- pxr::UsdGeomPlane usdex::core::definePlane(pxr::UsdPrim parent, const std::string &name, const double width=2.0, const double length=2.0, const pxr::TfToken axis=pxr::UsdGeomTokens->z, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a plane primitive as a child of the
parentprim.- pxr::UsdGeomSphere usdex::core::defineSphere(pxr::UsdStagePtr stage, const pxr::SdfPath &path, const double radius=1.0, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a sphere primitive.
- pxr::UsdGeomSphere usdex::core::defineSphere(pxr::UsdPrim parent, const std::string &name, const double radius=1.0, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a sphere primitive as a child of the
parentprim.- pxr::UsdGeomSphere usdex::core::defineSphere(pxr::UsdPrim prim, const double radius=1.0, const std::optional< pxr::GfVec3f > displayColor=std::nullopt, const std::optional< float > displayOpacity=std::nullopt)
Defines a sphere primitive from an existing prim.