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 /// Whenever you log this archetype, the state of the resulting overall pose is fully reset to the new archetype.
28 /// This means that if you first log a pose with only a translation, and then log one with only a rotation,
29 /// it will be resolved to a pose with only a rotation.
30 /// (This is unlike how we usually apply latest-at semantics on an archetype where we take the latest state of any component independently)
31 ///
32 /// From the point of view of the entity's coordinate system,
33 /// all components are applied in the inverse order they are listed here.
34 /// E.g. if both a translation and a max3x3 transform are present,
35 /// the 3x3 matrix is applied first, followed by the translation.
36 ///
37 /// Currently, many visualizers support only a single instance transform per entity.
38 /// Check archetype documentations for details - if not otherwise specified, only the first instance transform is applied.
39 /// Some visualizers like the mesh visualizer used for `archetypes::Mesh3D`,
40 /// will draw an object for every pose, a behavior also known as "instancing".
41 ///
42 /// ## Example
43 ///
44 /// ### Regular & instance transforms in tandem
45 /// ![image](https://static.rerun.io/leaf_transform3d/41674f0082d6de489f8a1cd1583f60f6b5820ddf/full.png)
46 ///
47 /// ```cpp
48 /// #include <rerun.hpp>
49 /// #include <rerun/demo_utils.hpp>
50 ///
51 /// int main() {
52 /// const auto rec = rerun::RecordingStream("rerun_example_instance_pose3d_combined");
53 /// rec.set_time_sequence("frame", 0);
54 ///
55 /// // Log a box and points further down in the hierarchy.
56 /// rec.log("world/box", rerun::Boxes3D::from_half_sizes({{1.0, 1.0, 1.0}}));
57 /// rec.log(
58 /// "world/box/points",
59 /// rerun::Points3D(rerun::demo::grid3d<rerun::Position3D, float>(-10.0f, 10.0f, 10))
60 /// );
61 ///
62 /// for (int i = 0; i <180; ++i) {
63 /// rec.set_time_sequence("frame", i);
64 ///
65 /// // Log a regular transform which affects both the box and the points.
66 /// rec.log(
67 /// "world/box",
68 /// rerun::Transform3D::from_rotation(rerun::RotationAxisAngle{
69 /// {0.0f, 0.0f, 1.0f},
70 /// rerun::Angle::degrees(static_cast<float>(i) * 2.0f)})
71 /// );
72 ///
73 /// // Log an instance pose which affects only the box.
74 /// rec.log(
75 /// "world/box",
76 /// rerun::InstancePoses3D().with_translations(
77 /// {{0.0f, 0.0f, std::abs(static_cast<float>(i) * 0.1f - 5.0f) - 5.0f}}
78 /// )
79 /// );
80 /// }
81 /// }
82 /// ```
84 /// Translation vectors.
85 ///
86 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
87 std::optional<ComponentBatch> translations;
88
89 /// Rotations via axis + angle.
90 ///
91 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
92 std::optional<ComponentBatch> rotation_axis_angles;
93
94 /// Rotations via quaternion.
95 ///
96 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
97 std::optional<ComponentBatch> quaternions;
98
99 /// Scaling factors.
100 ///
101 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
102 std::optional<ComponentBatch> scales;
103
104 /// 3x3 transformation matrices.
105 ///
106 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
107 std::optional<ComponentBatch> mat3x3;
108
109 public:
110 /// The name of the archetype as used in `ComponentDescriptor`s.
111 static constexpr const char ArchetypeName[] = "rerun.archetypes.InstancePoses3D";
112
113 /// `ComponentDescriptor` for the `translations` field.
115 ArchetypeName, "InstancePoses3D:translations",
117 );
118 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
120 ArchetypeName, "InstancePoses3D:rotation_axis_angles",
122 );
123 /// `ComponentDescriptor` for the `quaternions` field.
125 ArchetypeName, "InstancePoses3D:quaternions",
127 );
128 /// `ComponentDescriptor` for the `scales` field.
129 static constexpr auto Descriptor_scales = ComponentDescriptor(
130 ArchetypeName, "InstancePoses3D:scales",
132 );
133 /// `ComponentDescriptor` for the `mat3x3` field.
134 static constexpr auto Descriptor_mat3x3 = ComponentDescriptor(
135 ArchetypeName, "InstancePoses3D:mat3x3",
137 );
138
139 public:
140 InstancePoses3D() = default;
141 InstancePoses3D(InstancePoses3D&& other) = default;
142 InstancePoses3D(const InstancePoses3D& other) = default;
143 InstancePoses3D& operator=(const InstancePoses3D& other) = default;
144 InstancePoses3D& operator=(InstancePoses3D&& other) = default;
145
146 /// Update only some specific fields of a `InstancePoses3D`.
148 return InstancePoses3D();
149 }
150
151 /// Clear all the fields of a `InstancePoses3D`.
153
154 /// Translation vectors.
155 ///
156 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
159 ) && {
161 .value_or_throw();
162 return std::move(*this);
163 }
164
165 /// Rotations via axis + angle.
166 ///
167 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
170 ) && {
172 _rotation_axis_angles,
174 )
175 .value_or_throw();
176 return std::move(*this);
177 }
178
179 /// Rotations via quaternion.
180 ///
181 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
184 ) && {
186 .value_or_throw();
187 return std::move(*this);
188 }
189
190 /// Scaling factors.
191 ///
192 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
194 scales = ComponentBatch::from_loggable(_scales, Descriptor_scales).value_or_throw();
195 return std::move(*this);
196 }
197
198 /// 3x3 transformation matrices.
199 ///
200 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
203 ) && {
204 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
205 return std::move(*this);
206 }
207
208 /// Partitions the component data into multiple sub-batches.
209 ///
210 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
211 /// instead, via `ComponentBatch::partitioned`.
212 ///
213 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
214 ///
215 /// The specified `lengths` must sum to the total length of the component batch.
217
218 /// Partitions the component data into unit-length sub-batches.
219 ///
220 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
221 /// where `n` is automatically guessed.
223 };
224
225} // namespace rerun::archetypes
226
227namespace rerun {
228 /// \private
229 template <typename T>
230 struct AsComponents;
231
232 /// \private
233 template <>
234 struct AsComponents<archetypes::InstancePoses3D> {
235 /// Serialize all set component batches.
236 static Result<Collection<ComponentBatch>> as_batches(
237 const archetypes::InstancePoses3D& archetype
238 );
239 };
240} // 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:83
InstancePoses3D with_scales(const Collection< rerun::components::PoseScale3D > &_scales) &&
Scaling factors.
Definition instance_poses3d.hpp:193
static constexpr auto Descriptor_scales
ComponentDescriptor for the scales field.
Definition instance_poses3d.hpp:129
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition instance_poses3d.hpp:97
std::optional< ComponentBatch > scales
Scaling factors.
Definition instance_poses3d.hpp:102
InstancePoses3D with_mat3x3(const Collection< rerun::components::PoseTransformMat3x3 > &_mat3x3) &&
3x3 transformation matrices.
Definition instance_poses3d.hpp:201
static InstancePoses3D update_fields()
Update only some specific fields of a InstancePoses3D.
Definition instance_poses3d.hpp:147
std::optional< ComponentBatch > translations
Translation vectors.
Definition instance_poses3d.hpp:87
InstancePoses3D with_quaternions(const Collection< rerun::components::PoseRotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition instance_poses3d.hpp:182
InstancePoses3D with_rotation_axis_angles(const Collection< rerun::components::PoseRotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition instance_poses3d.hpp:168
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:111
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:134
static InstancePoses3D clear_fields()
Clear all the fields of a InstancePoses3D.
std::optional< ComponentBatch > mat3x3
3x3 transformation matrices.
Definition instance_poses3d.hpp:107
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition instance_poses3d.hpp:92
static constexpr auto Descriptor_translations
ComponentDescriptor for the translations field.
Definition instance_poses3d.hpp:114
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition instance_poses3d.hpp:124
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition instance_poses3d.hpp:119
InstancePoses3D with_translations(const Collection< rerun::components::PoseTranslation3D > &_translations) &&
Translation vectors.
Definition instance_poses3d.hpp:157