omni/connect/core/XformAlgo.h

File members: omni/connect/core/XformAlgo.h

// SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.

#pragma once

#include "Api.h"

#include <carb/cpp/Optional.h>

#include <pxr/base/gf/matrix4d.h>
#include <pxr/base/gf/transform.h>
#include <pxr/usd/sdf/path.h>
#include <pxr/usd/usd/prim.h>
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usd/timeCode.h>
#include <pxr/usd/usdGeom/xform.h>

#include <string>

namespace omni::connect::core
{

enum class RotationOrder
{
    eXyz,
    eXzy,
    eYxz,
    eYzx,
    eZxy,
    eZyx
};

OMNICONNECTCORE_API bool setLocalTransform(pxr::UsdPrim prim, const pxr::GfTransform& transform, pxr::UsdTimeCode time = pxr::UsdTimeCode::Default());

OMNICONNECTCORE_API bool setLocalTransform(pxr::UsdPrim prim, const pxr::GfMatrix4d& matrix, pxr::UsdTimeCode time = pxr::UsdTimeCode::Default());

OMNICONNECTCORE_API bool setLocalTransform(
    pxr::UsdPrim prim,
    const pxr::GfVec3d& translation,
    const pxr::GfVec3d& pivot,
    const pxr::GfVec3f& rotation,
    const RotationOrder rotationOrder,
    const pxr::GfVec3f& scale,
    pxr::UsdTimeCode time = pxr::UsdTimeCode::Default()
);

OMNICONNECTCORE_API pxr::GfTransform getLocalTransform(const pxr::UsdPrim& prim, pxr::UsdTimeCode time = pxr::UsdTimeCode::Default());

OMNICONNECTCORE_API pxr::GfMatrix4d getLocalTransformMatrix(const pxr::UsdPrim& prim, pxr::UsdTimeCode time = pxr::UsdTimeCode::Default());

OMNICONNECTCORE_API void getLocalTransformComponents(
    const pxr::UsdPrim& prim,
    pxr::GfVec3d& translation,
    pxr::GfVec3d& pivot,
    pxr::GfVec3f& rotation,
    RotationOrder& rotationOrder,
    pxr::GfVec3f& scale,
    pxr::UsdTimeCode time = pxr::UsdTimeCode::Default()
);

OMNICONNECTCORE_API pxr::UsdGeomXform defineXform(
    pxr::UsdStagePtr stage,
    const pxr::SdfPath& path,
    carb::cpp::optional<const pxr::GfTransform> transform = carb::cpp::nullopt
);

OMNICONNECTCORE_API pxr::UsdGeomXform defineXform(
    pxr::UsdPrim parent,
    const std::string& name,
    carb::cpp::optional<const pxr::GfTransform> transform = carb::cpp::nullopt
);

} // namespace omni::connect::core