scene/schema/instancer.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | /// @file instancer.h | ||
| 3 | /// @brief UsdGeomPointInstancer: prototypes placed at many instances. | ||
| 4 | /// | ||
| 5 | /// References: | ||
| 6 | /// - Pixar, UsdGeomPointInstancer, | ||
| 7 | /// https://openusd.org/release/api/class_usd_geom_point_instancer.html | ||
| 8 | #pragma once | ||
| 9 | |||
| 10 | #include "ernie/scene/schema/geom.h" | ||
| 11 | |||
| 12 | #include <array> | ||
| 13 | #include <string_view> | ||
| 14 | |||
| 15 | // clang-format off | ||
| 16 | #define ERNIE_INSTANCE_VECTORS(X, Name, usdName, text) \ | ||
| 17 | X(Tensor, Name, usdName, Tensor(), text, .group = "Instances", .components = 3, \ | ||
| 18 | .dirty = Dirty::Points) | ||
| 19 | |||
| 20 | #define ERNIE_POINT_INSTANCER_ATTRIBUTES(X) \ | ||
| 21 | X(std::vector<Path>, Prototypes, "prototypes", std::vector<Path>{}, \ | ||
| 22 | "The prims instanced, indexed by the proto indices.", .group = "Instances", \ | ||
| 23 | .dirty = Dirty::Topology) \ | ||
| 24 | X(Tensor, ProtoIndices, "protoIndices", Tensor(), "The prototype of each instance.", \ | ||
| 25 | .group = "Instances", .integer = true, .dirty = Dirty::Topology) \ | ||
| 26 | ERNIE_INSTANCE_VECTORS(X, Positions, "positions", \ | ||
| 27 | "(n, 3) positions in the instancer's space; the number of instances.") \ | ||
| 28 | X(Tensor, Orientations, "orientations", Tensor(), "(n, 4) rotations as quaternions.", \ | ||
| 29 | .group = "Instances", .components = 4, .dirty = Dirty::Points) \ | ||
| 30 | ERNIE_INSTANCE_VECTORS(X, Scales, "scales", "(n, 3) scales.") \ | ||
| 31 | ERNIE_INSTANCE_VECTORS(X, Velocities, "velocities", "(n, 3) metres per second.") \ | ||
| 32 | ERNIE_INSTANCE_VECTORS(X, Accelerations, "accelerations", "(n, 3) metres per second squared.") \ | ||
| 33 | ERNIE_INSTANCE_VECTORS(X, AngularVelocities, "angularVelocities", "(n, 3) degrees per second.") \ | ||
| 34 | X(Tensor, Ids, "ids", Tensor(), "int64 ids that follow instances across time samples.", \ | ||
| 35 | .group = "Instances", .integer = true, .dirty = Dirty::Topology) \ | ||
| 36 | X(Tensor, InvisibleIds, "invisibleIds", Tensor(), "The ids of instances to hide.", \ | ||
| 37 | .group = "Instances", .integer = true, .dirty = Dirty::Visibility) \ | ||
| 38 | X(Choice<QuaternionOrder>, QuaternionOrder, "ernie:quaternionOrder", QuaternionOrder::Xyzw, \ | ||
| 39 | "The component order of the orientations: xyzw (USD, Warp, PhysX) or wxyz (Isaac Lab, " \ | ||
| 40 | "MuJoCo).", \ | ||
| 41 | .group = "Instances", .dirty = Dirty::Points) \ | ||
| 42 | X(Tensor, Worlds, "ernie:worlds", Tensor(), "int (n,): each instance's world.", \ | ||
| 43 | .group = "Instances", .integer = true) | ||
| 44 | // clang-format on | ||
| 45 | |||
| 46 | namespace ernie { | ||
| 47 | |||
| 48 | /// The component order of quaternions in arrays. | ||
| 49 | enum class QuaternionOrder { Xyzw, Wxyz }; | ||
| 50 | |||
| 51 | template <> struct ChoiceTokens<QuaternionOrder> { | ||
| 52 | static constexpr std::array<std::string_view, 2> kTokens{"xyzw", "wxyz"}; | ||
| 53 | }; | ||
| 54 | |||
| 55 | 24 | ERNIE_CONCRETE_SCHEMA(PointInstancer, Boundable, ERNIE_POINT_INSTANCER_ATTRIBUTES, | |
| 56 | "Prototypes placed at instances, bounded by their bounds at each instance."); | ||
| 57 | |||
| 58 | } // namespace ernie | ||
| 59 |