| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef MUJOCO_SRC_EXPERIMENTAL_USD_PLUGINS_MJCF_UTILS_H_ |
| | #define MUJOCO_SRC_EXPERIMENTAL_USD_PLUGINS_MJCF_UTILS_H_ |
| |
|
| | #include <type_traits> |
| |
|
| | #include <pxr/base/tf/token.h> |
| | #include <pxr/imaging/hd/primTypeIndex.h> |
| | #include <pxr/usd/sdf/abstractData.h> |
| | #include <pxr/usd/sdf/path.h> |
| | #include <pxr/usd/sdf/schema.h> |
| | #include <pxr/usd/sdf/types.h> |
| | #include <pxr/usd/sdf/valueTypeName.h> |
| |
|
| | namespace mujoco { |
| | namespace usd { |
| |
|
| | |
| | pxr::SdfPath CreatePrimSpec( |
| | pxr::SdfAbstractDataRefPtr& data, const pxr::SdfPath& parent_path, |
| | const pxr::TfToken& name, const pxr::TfToken& type = pxr::TfToken(), |
| | pxr::SdfSpecifier specifier = pxr::SdfSpecifier::SdfSpecifierDef); |
| |
|
| | |
| | |
| | pxr::SdfPath CreateAttributeSpec( |
| | pxr::SdfAbstractDataRefPtr& data, const pxr::SdfPath& prim_path, |
| | const pxr::TfToken& name, const pxr::SdfValueTypeName& type_name, |
| | pxr::SdfVariability variability = pxr::SdfVariabilityVarying); |
| |
|
| | |
| | pxr::SdfPath CreateRelationshipSpec( |
| | pxr::SdfAbstractDataRefPtr& data, const pxr::SdfPath& prim_path, |
| | const pxr::TfToken& relationship_name, |
| | const pxr::SdfPath& relationship_path, |
| | pxr::SdfVariability variability = pxr::SdfVariabilityVarying); |
| |
|
| | pxr::SdfPath CreateClassSpec(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& prim_path, |
| | const pxr::TfToken& class_name); |
| |
|
| | void AddAttributeConnection(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& attribute_path, |
| | const pxr::SdfPath& target_attribute_path); |
| |
|
| | void AddPrimReference(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& prim_path, |
| | const pxr::SdfPath& referenced_prim_path); |
| |
|
| | void AddPrimInherit(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& prim_path, |
| | const pxr::SdfPath& class_path); |
| |
|
| | void ApplyApiSchema(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& prim_path, |
| | const pxr::TfToken& schema_name); |
| |
|
| | void SetPrimKind(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& prim_path, pxr::TfToken kind); |
| |
|
| | void SetPrimPurpose(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& prim_path, pxr::TfToken purpose); |
| |
|
| | |
| | template <typename T> |
| | void SetField(pxr::SdfAbstractDataRefPtr& data, const pxr::SdfPath& field_path, |
| | const pxr::TfToken key, T&& value) { |
| | using Deduced = typename std::remove_reference_t<T>; |
| | const auto typed_val = pxr::SdfAbstractDataConstTypedValue<Deduced>(&value); |
| | const pxr::SdfAbstractDataConstValue& untyped_val = typed_val; |
| |
|
| | data->Set(field_path, key, untyped_val); |
| | } |
| |
|
| | |
| | template <typename T> |
| | void SetFieldTimeSample(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& field_path, double time, |
| | T&& value) { |
| | using Deduced = typename std::remove_reference_t<T>; |
| | const auto typed_val = pxr::SdfAbstractDataConstTypedValue<Deduced>(&value); |
| | const pxr::SdfAbstractDataConstValue& untyped_val = typed_val; |
| |
|
| | pxr::VtValue vt_value; |
| | untyped_val.GetValue(&vt_value); |
| | |
| | data->SetTimeSample(field_path, time, vt_value); |
| | } |
| |
|
| | |
| | template <typename T> |
| | void SetAttribute(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& attribute_path, const pxr::TfToken key, |
| | T&& value) { |
| | SetField(data, attribute_path, key, value); |
| | } |
| |
|
| | |
| | template <typename T> |
| | void SetPrimMetadata(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& prim_path, const pxr::TfToken key, |
| | T&& value) { |
| | SetAttribute(data, prim_path, key, value); |
| | } |
| |
|
| | |
| | template <typename T> |
| | void SetAttributeMetadata(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& attribute_path, |
| | const pxr::TfToken key, T&& value) { |
| | SetAttribute(data, attribute_path, key, value); |
| | } |
| |
|
| | |
| | template <typename T> |
| | void SetAttributeDefault(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& attribute_path, |
| | T&& default_value) { |
| | SetAttribute(data, attribute_path, pxr::SdfFieldKeys->Default, default_value); |
| | } |
| |
|
| | |
| | template <typename T> |
| | void SetAttributeTimeSample(pxr::SdfAbstractDataRefPtr& data, |
| | const pxr::SdfPath& attribute_path, |
| | double time, |
| | T&& default_value) { |
| | SetFieldTimeSample(data, attribute_path, time, default_value); |
| | } |
| |
|
| | |
| | template <typename T> |
| | void SetLayerMetadata(pxr::SdfAbstractDataRefPtr& data, const pxr::TfToken& key, |
| | T&& value) { |
| | SetAttribute(data, pxr::SdfPath::AbsoluteRootPath(), key, value); |
| | } |
| |
|
| | } |
| | } |
| |
|
| | #endif |
| |
|