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/build/re_type_definitions/rerun/archetypes/instance_poses3d.def.rs".
3
4#pragma once
5
6#include "../archetype_utils.hpp"
7#include "../collection.hpp"
8#include "../component_batch.hpp"
9#include "../component_column.hpp"
10#include "../components/rotation_axis_angle.hpp"
11#include "../components/rotation_quat.hpp"
12#include "../components/scale3d.hpp"
13#include "../components/transform_mat3x3.hpp"
14#include "../components/translation3d.hpp"
15#include "../result.hpp"
16
17#include <cstdint>
18#include <optional>
19#include <utility>
20#include <vector>
21
22namespace rerun::archetypes {
23 /// **Archetype**: One or more transforms applied on the current entity's transform frame.
24 ///
25 /// Unlike `archetypes::Transform3D`, it is *not* propagated in the transform hierarchy.
26 /// If `archetypes::CoordinateFrame` is specified, it acts relative to that coordinate frame,
27 /// otherwise it is relative to the entity's implicit coordinate frame.
28 ///
29 /// Whenever you log this archetype, the state of the resulting overall pose is fully reset to the new archetype.
30 /// This means that if you first log a pose with only a translation, and then log one with only a rotation,
31 /// it will be resolved to a pose with only a rotation.
32 /// (This is unlike how we usually apply latest-at semantics on an archetype where we take the latest state of any component independently)
33 ///
34 /// From the point of view of the entity's coordinate system,
35 /// all components are applied in the inverse order they are listed here.
36 /// E.g. if both a translation and a mat3x3 transform are present,
37 /// the 3x3 matrix is applied first, followed by the translation.
38 ///
39 /// Currently, many visualizers support only a single instance transform per entity.
40 /// Check archetype documentations for details - if not otherwise specified, only the first instance transform is applied.
41 /// Some visualizers like the mesh visualizer used for `archetypes::Mesh3D`,
42 /// will draw an object for every pose, a behavior also known as "instancing".
43 ///
44 /// ## Example
45 ///
46 /// ### Regular & instance transforms in tandem
47 /// ![image](https://static.rerun.io/leaf_transform3d/41674f0082d6de489f8a1cd1583f60f6b5820ddf/full.png)
48 ///
49 /// ```cpp
50 /// #include <rerun.hpp>
51 /// #include <rerun/demo_utils.hpp>
52 ///
53 /// int main(int argc, char* argv[]) {
54 /// const auto rec =
55 /// rerun::RecordingStream("rerun_example_instance_pose3d_combined");
56 /// rec.set_time_sequence("frame", 0);
57 ///
58 /// // Log a box and points further down in the hierarchy.
59 /// rec.log("world/box", rerun::Boxes3D::from_half_sizes({{1.0, 1.0, 1.0}}));
60 /// rec.log(
61 /// "world/box/points",
62 /// rerun::Points3D(
63 /// rerun::demo::grid3d<rerun::Position3D, float>(-10.0f, 10.0f, 10)
64 /// )
65 /// );
66 ///
67 /// for (int i = 0; i <180; ++i) {
68 /// rec.set_time_sequence("frame", i);
69 ///
70 /// // Log a regular transform which affects both the box and the points.
71 /// rec.log(
72 /// "world/box",
73 /// rerun::Transform3D::from_rotation(rerun::RotationAxisAngle{
74 /// {0.0f, 0.0f, 1.0f},
75 /// rerun::Angle::degrees(static_cast<float>(i) * 2.0f)
76 /// })
77 /// );
78 ///
79 /// // Log an instance pose which affects only the box.
80 /// rec.log(
81 /// "world/box",
82 /// rerun::InstancePoses3D().with_translations(
83 /// {{0.0f,
84 /// 0.0f,
85 /// std::abs(static_cast<float>(i) * 0.1f - 5.0f) - 5.0f}}
86 /// )
87 /// );
88 /// }
89 /// }
90 /// ```
92 /// Translation vectors.
93 std::optional<ComponentBatch> translations;
94
95 /// Rotations via axis + angle.
96 std::optional<ComponentBatch> rotation_axis_angles;
97
98 /// Rotations via quaternion.
99 std::optional<ComponentBatch> quaternions;
100
101 /// Scaling factors.
102 std::optional<ComponentBatch> scales;
103
104 /// 3x3 transformation matrices.
105 std::optional<ComponentBatch> mat3x3;
106
107 public:
108 /// The name of the archetype as used in `ComponentDescriptor`s.
109 static constexpr const char ArchetypeName[] = "rerun.archetypes.InstancePoses3D";
110
111 /// `ComponentDescriptor` for the `translations` field.
113 ArchetypeName, "InstancePoses3D:translations",
115 );
116 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
118 ArchetypeName, "InstancePoses3D:rotation_axis_angles",
120 );
121 /// `ComponentDescriptor` for the `quaternions` field.
123 ArchetypeName, "InstancePoses3D:quaternions",
125 );
126 /// `ComponentDescriptor` for the `scales` field.
127 static constexpr auto Descriptor_scales = ComponentDescriptor(
128 ArchetypeName, "InstancePoses3D:scales",
130 );
131 /// `ComponentDescriptor` for the `mat3x3` field.
132 static constexpr auto Descriptor_mat3x3 = ComponentDescriptor(
133 ArchetypeName, "InstancePoses3D:mat3x3",
135 );
136
137 public:
138 InstancePoses3D() = default;
139 InstancePoses3D(InstancePoses3D&& other) = default;
140 InstancePoses3D(const InstancePoses3D& other) = default;
141 InstancePoses3D& operator=(const InstancePoses3D& other) = default;
142 InstancePoses3D& operator=(InstancePoses3D&& other) = default;
143
144 /// Update only some specific fields of a `InstancePoses3D`.
146 return InstancePoses3D();
147 }
148
149 /// Clear all the fields of a `InstancePoses3D`.
151
152 /// Translation vectors.
155 ) && {
157 .value_or_throw();
158 return std::move(*this);
159 }
160
161 /// Rotations via axis + angle.
163 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angles
164 ) && {
166 _rotation_axis_angles,
168 )
169 .value_or_throw();
170 return std::move(*this);
171 }
172
173 /// Rotations via quaternion.
176 ) && {
178 .value_or_throw();
179 return std::move(*this);
180 }
181
182 /// Scaling factors.
184 scales = ComponentBatch::from_loggable(_scales, Descriptor_scales).value_or_throw();
185 return std::move(*this);
186 }
187
188 /// 3x3 transformation matrices.
190 ) && {
191 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
192 return std::move(*this);
193 }
194
195 /// Partitions the component data into multiple sub-batches.
196 ///
197 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
198 /// instead, via `ComponentBatch::partitioned`.
199 ///
200 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
201 ///
202 /// The specified `lengths` must sum to the total length of the component batch.
204 return detail::partition_batches(
206 lengths_
207 )
208 .value_or_throw();
209 }
210
211 /// Partitions the component data into unit-length sub-batches.
212 ///
213 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
214 /// where `n` is automatically guessed.
216 return detail::partition_batches_of_unit_length(
218 )
219 .value_or_throw();
220 }
221 };
222
223} // namespace rerun::archetypes
224
225namespace rerun {
226 /// \private
227 template <typename T>
228 struct AsComponents;
229
230 /// \private
231 template <>
232 struct AsComponents<archetypes::InstancePoses3D> {
233 /// Serialize all set component batches.
234 static Result<Collection<ComponentBatch>> as_batches(
235 const archetypes::InstancePoses3D& archetype
236 ) {
237 return detail::collect_batches(
238 {&archetype.translations,
239 &archetype.rotation_axis_angles,
240 &archetype.quaternions,
241 &archetype.scales,
242 &archetype.mat3x3}
243 );
244 }
245 };
246} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:90
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
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 applied on the current entity's transform frame.
Definition instance_poses3d.hpp:91
static constexpr auto Descriptor_scales
ComponentDescriptor for the scales field.
Definition instance_poses3d.hpp:127
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition instance_poses3d.hpp:99
std::optional< ComponentBatch > scales
Scaling factors.
Definition instance_poses3d.hpp:102
static InstancePoses3D update_fields()
Update only some specific fields of a InstancePoses3D.
Definition instance_poses3d.hpp:145
std::optional< ComponentBatch > translations
Translation vectors.
Definition instance_poses3d.hpp:93
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition instance_poses3d.hpp:203
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition instance_poses3d.hpp:109
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition instance_poses3d.hpp:215
InstancePoses3D with_quaternions(const Collection< rerun::components::RotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition instance_poses3d.hpp:174
InstancePoses3D with_translations(const Collection< rerun::components::Translation3D > &_translations) &&
Translation vectors.
Definition instance_poses3d.hpp:153
static constexpr auto Descriptor_mat3x3
ComponentDescriptor for the mat3x3 field.
Definition instance_poses3d.hpp:132
static InstancePoses3D clear_fields()
Clear all the fields of a InstancePoses3D.
InstancePoses3D with_scales(const Collection< rerun::components::Scale3D > &_scales) &&
Scaling factors.
Definition instance_poses3d.hpp:183
InstancePoses3D with_mat3x3(const Collection< rerun::components::TransformMat3x3 > &_mat3x3) &&
3x3 transformation matrices.
Definition instance_poses3d.hpp:189
std::optional< ComponentBatch > mat3x3
3x3 transformation matrices.
Definition instance_poses3d.hpp:105
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition instance_poses3d.hpp:96
static constexpr auto Descriptor_translations
ComponentDescriptor for the translations field.
Definition instance_poses3d.hpp:112
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition instance_poses3d.hpp:122
InstancePoses3D with_rotation_axis_angles(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition instance_poses3d.hpp:162
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition instance_poses3d.hpp:117