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