Rerun C++ SDK
Loading...
Searching...
No Matches
instance_poses3d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/archetypes/instance_poses3d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/pose_rotation_axis_angle.hpp"
10#include "../components/pose_rotation_quat.hpp"
11#include "../components/pose_scale3d.hpp"
12#include "../components/pose_transform_mat3x3.hpp"
13#include "../components/pose_translation3d.hpp"
14#include "../result.hpp"
15
16#include <cstdint>
17#include <optional>
18#include <utility>
19#include <vector>
20
21namespace rerun::archetypes {
22 /// **Archetype**: One or more transforms between the current entity and its parent. Unlike `archetypes::Transform3D`, it is *not* propagated in the transform hierarchy.
23 ///
24 /// If both `archetypes::InstancePoses3D` and `archetypes::Transform3D` are present,
25 /// first the tree propagating `archetypes::Transform3D` is applied, then `archetypes::InstancePoses3D`.
26 ///
27 /// From the point of view of the entity's coordinate system,
28 /// all components are applied in the inverse order they are listed here.
29 /// E.g. if both a translation and a max3x3 transform are present,
30 /// the 3x3 matrix is applied first, followed by the translation.
31 ///
32 /// Currently, many visualizers support only a single instance transform per entity.
33 /// Check archetype documentations for details - if not otherwise specified, only the first instance transform is applied.
34 /// Some visualizers like the mesh visualizer used for `archetypes::Mesh3D`,
35 /// will draw an object for every pose, a behavior also known as "instancing".
36 ///
37 /// ## Example
38 ///
39 /// ### Regular & instance transforms in tandem
40 /// ![image](https://static.rerun.io/leaf_transform3d/41674f0082d6de489f8a1cd1583f60f6b5820ddf/full.png)
41 ///
42 /// ```cpp
43 /// #include <rerun.hpp>
44 /// #include <rerun/demo_utils.hpp>
45 ///
46 /// int main() {
47 /// const auto rec = rerun::RecordingStream("rerun_example_instance_pose3d_combined");
48 /// rec.set_time_sequence("frame", 0);
49 ///
50 /// // Log a box and points further down in the hierarchy.
51 /// rec.log("world/box", rerun::Boxes3D::from_half_sizes({{1.0, 1.0, 1.0}}));
52 /// rec.log(
53 /// "world/box/points",
54 /// rerun::Points3D(rerun::demo::grid3d<rerun::Position3D, float>(-10.0f, 10.0f, 10))
55 /// );
56 ///
57 /// for (int i = 0; i <180; ++i) {
58 /// rec.set_time_sequence("frame", i);
59 ///
60 /// // Log a regular transform which affects both the box and the points.
61 /// rec.log(
62 /// "world/box",
63 /// rerun::Transform3D::from_rotation(rerun::RotationAxisAngle{
64 /// {0.0f, 0.0f, 1.0f},
65 /// rerun::Angle::degrees(static_cast<float>(i) * 2.0f)})
66 /// );
67 ///
68 /// // Log an instance pose which affects only the box.
69 /// rec.log(
70 /// "world/box",
71 /// rerun::InstancePoses3D().with_translations(
72 /// {{0.0f, 0.0f, std::abs(static_cast<float>(i) * 0.1f - 5.0f) - 5.0f}}
73 /// )
74 /// );
75 /// }
76 /// }
77 /// ```
79 /// Translation vectors.
80 std::optional<ComponentBatch> translations;
81
82 /// Rotations via axis + angle.
83 std::optional<ComponentBatch> rotation_axis_angles;
84
85 /// Rotations via quaternion.
86 std::optional<ComponentBatch> quaternions;
87
88 /// Scaling factors.
89 std::optional<ComponentBatch> scales;
90
91 /// 3x3 transformation matrices.
92 std::optional<ComponentBatch> mat3x3;
93
94 public:
95 /// The name of the archetype as used in `ComponentDescriptor`s.
96 static constexpr const char ArchetypeName[] = "rerun.archetypes.InstancePoses3D";
97
98 /// `ComponentDescriptor` for the `translations` field.
100 ArchetypeName, "InstancePoses3D:translations",
102 );
103 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
105 ArchetypeName, "InstancePoses3D:rotation_axis_angles",
107 );
108 /// `ComponentDescriptor` for the `quaternions` field.
110 ArchetypeName, "InstancePoses3D:quaternions",
112 );
113 /// `ComponentDescriptor` for the `scales` field.
114 static constexpr auto Descriptor_scales = ComponentDescriptor(
115 ArchetypeName, "InstancePoses3D:scales",
117 );
118 /// `ComponentDescriptor` for the `mat3x3` field.
119 static constexpr auto Descriptor_mat3x3 = ComponentDescriptor(
120 ArchetypeName, "InstancePoses3D:mat3x3",
122 );
123
124 public:
125 InstancePoses3D() = default;
126 InstancePoses3D(InstancePoses3D&& other) = default;
127 InstancePoses3D(const InstancePoses3D& other) = default;
128 InstancePoses3D& operator=(const InstancePoses3D& other) = default;
129 InstancePoses3D& operator=(InstancePoses3D&& other) = default;
130
131 /// Update only some specific fields of a `InstancePoses3D`.
133 return InstancePoses3D();
134 }
135
136 /// Clear all the fields of a `InstancePoses3D`.
138
139 /// Translation vectors.
142 ) && {
144 .value_or_throw();
145 return std::move(*this);
146 }
147
148 /// Rotations via axis + angle.
151 ) && {
153 _rotation_axis_angles,
155 )
156 .value_or_throw();
157 return std::move(*this);
158 }
159
160 /// Rotations via quaternion.
163 ) && {
165 .value_or_throw();
166 return std::move(*this);
167 }
168
169 /// Scaling factors.
171 scales = ComponentBatch::from_loggable(_scales, Descriptor_scales).value_or_throw();
172 return std::move(*this);
173 }
174
175 /// 3x3 transformation matrices.
178 ) && {
179 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
180 return std::move(*this);
181 }
182
183 /// Partitions the component data into multiple sub-batches.
184 ///
185 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
186 /// instead, via `ComponentBatch::partitioned`.
187 ///
188 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
189 ///
190 /// The specified `lengths` must sum to the total length of the component batch.
192
193 /// Partitions the component data into unit-length sub-batches.
194 ///
195 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
196 /// where `n` is automatically guessed.
198 };
199
200} // namespace rerun::archetypes
201
202namespace rerun {
203 /// \private
204 template <typename T>
205 struct AsComponents;
206
207 /// \private
208 template <>
209 struct AsComponents<archetypes::InstancePoses3D> {
210 /// Serialize all set component batches.
211 static Result<Collection<ComponentBatch>> as_batches(
212 const archetypes::InstancePoses3D& archetype
213 );
214 };
215} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: One or more transforms between the current entity and its parent.
Definition instance_poses3d.hpp:78
InstancePoses3D with_scales(const Collection< rerun::components::PoseScale3D > &_scales) &&
Scaling factors.
Definition instance_poses3d.hpp:170
static constexpr auto Descriptor_scales
ComponentDescriptor for the scales field.
Definition instance_poses3d.hpp:114
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition instance_poses3d.hpp:86
std::optional< ComponentBatch > scales
Scaling factors.
Definition instance_poses3d.hpp:89
InstancePoses3D with_mat3x3(const Collection< rerun::components::PoseTransformMat3x3 > &_mat3x3) &&
3x3 transformation matrices.
Definition instance_poses3d.hpp:176
static InstancePoses3D update_fields()
Update only some specific fields of a InstancePoses3D.
Definition instance_poses3d.hpp:132
std::optional< ComponentBatch > translations
Translation vectors.
Definition instance_poses3d.hpp:80
InstancePoses3D with_quaternions(const Collection< rerun::components::PoseRotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition instance_poses3d.hpp:161
InstancePoses3D with_rotation_axis_angles(const Collection< rerun::components::PoseRotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition instance_poses3d.hpp:149
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition instance_poses3d.hpp:96
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static constexpr auto Descriptor_mat3x3
ComponentDescriptor for the mat3x3 field.
Definition instance_poses3d.hpp:119
static InstancePoses3D clear_fields()
Clear all the fields of a InstancePoses3D.
std::optional< ComponentBatch > mat3x3
3x3 transformation matrices.
Definition instance_poses3d.hpp:92
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition instance_poses3d.hpp:83
static constexpr auto Descriptor_translations
ComponentDescriptor for the translations field.
Definition instance_poses3d.hpp:99
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition instance_poses3d.hpp:109
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition instance_poses3d.hpp:104
InstancePoses3D with_translations(const Collection< rerun::components::PoseTranslation3D > &_translations) &&
Translation vectors.
Definition instance_poses3d.hpp:140