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() {
53 /// const auto rec = rerun::RecordingStream("rerun_example_instance_pose3d_combined");
54 /// rec.set_time_sequence("frame", 0);
55 ///
56 /// // Log a box and points further down in the hierarchy.
57 /// rec.log("world/box", rerun::Boxes3D::from_half_sizes({{1.0, 1.0, 1.0}}));
58 /// rec.log(
59 /// "world/box/points",
60 /// rerun::Points3D(rerun::demo::grid3d<rerun::Position3D, float>(-10.0f, 10.0f, 10))
61 /// );
62 ///
63 /// for (int i = 0; i <180; ++i) {
64 /// rec.set_time_sequence("frame", i);
65 ///
66 /// // Log a regular transform which affects both the box and the points.
67 /// rec.log(
68 /// "world/box",
69 /// rerun::Transform3D::from_rotation(rerun::RotationAxisAngle{
70 /// {0.0f, 0.0f, 1.0f},
71 /// rerun::Angle::degrees(static_cast<float>(i) * 2.0f)})
72 /// );
73 ///
74 /// // Log an instance pose which affects only the box.
75 /// rec.log(
76 /// "world/box",
77 /// rerun::InstancePoses3D().with_translations(
78 /// {{0.0f, 0.0f, std::abs(static_cast<float>(i) * 0.1f - 5.0f) - 5.0f}}
79 /// )
80 /// );
81 /// }
82 /// }
83 /// ```
85 /// Translation vectors.
86 std::optional<ComponentBatch> translations;
87
88 /// Rotations via axis + angle.
89 std::optional<ComponentBatch> rotation_axis_angles;
90
91 /// Rotations via quaternion.
92 std::optional<ComponentBatch> quaternions;
93
94 /// Scaling factors.
95 std::optional<ComponentBatch> scales;
96
97 /// 3x3 transformation matrices.
98 std::optional<ComponentBatch> mat3x3;
99
100 public:
101 /// The name of the archetype as used in `ComponentDescriptor`s.
102 static constexpr const char ArchetypeName[] = "rerun.archetypes.InstancePoses3D";
103
104 /// `ComponentDescriptor` for the `translations` field.
106 ArchetypeName, "InstancePoses3D:translations",
108 );
109 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
111 ArchetypeName, "InstancePoses3D:rotation_axis_angles",
113 );
114 /// `ComponentDescriptor` for the `quaternions` field.
116 ArchetypeName, "InstancePoses3D:quaternions",
118 );
119 /// `ComponentDescriptor` for the `scales` field.
120 static constexpr auto Descriptor_scales = ComponentDescriptor(
121 ArchetypeName, "InstancePoses3D:scales",
123 );
124 /// `ComponentDescriptor` for the `mat3x3` field.
125 static constexpr auto Descriptor_mat3x3 = ComponentDescriptor(
126 ArchetypeName, "InstancePoses3D:mat3x3",
128 );
129
130 public:
131 InstancePoses3D() = default;
132 InstancePoses3D(InstancePoses3D&& other) = default;
133 InstancePoses3D(const InstancePoses3D& other) = default;
134 InstancePoses3D& operator=(const InstancePoses3D& other) = default;
135 InstancePoses3D& operator=(InstancePoses3D&& other) = default;
136
137 /// Update only some specific fields of a `InstancePoses3D`.
139 return InstancePoses3D();
140 }
141
142 /// Clear all the fields of a `InstancePoses3D`.
144
145 /// Translation vectors.
148 ) && {
150 .value_or_throw();
151 return std::move(*this);
152 }
153
154 /// Rotations via axis + angle.
156 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angles
157 ) && {
159 _rotation_axis_angles,
161 )
162 .value_or_throw();
163 return std::move(*this);
164 }
165
166 /// Rotations via quaternion.
169 ) && {
171 .value_or_throw();
172 return std::move(*this);
173 }
174
175 /// Scaling factors.
177 scales = ComponentBatch::from_loggable(_scales, Descriptor_scales).value_or_throw();
178 return std::move(*this);
179 }
180
181 /// 3x3 transformation matrices.
183 ) && {
184 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
185 return std::move(*this);
186 }
187
188 /// Partitions the component data into multiple sub-batches.
189 ///
190 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
191 /// instead, via `ComponentBatch::partitioned`.
192 ///
193 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
194 ///
195 /// The specified `lengths` must sum to the total length of the component batch.
197
198 /// Partitions the component data into unit-length sub-batches.
199 ///
200 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
201 /// where `n` is automatically guessed.
203 };
204
205} // namespace rerun::archetypes
206
207namespace rerun {
208 /// \private
209 template <typename T>
210 struct AsComponents;
211
212 /// \private
213 template <>
214 struct AsComponents<archetypes::InstancePoses3D> {
215 /// Serialize all set component batches.
216 static Result<Collection<ComponentBatch>> as_batches(
217 const archetypes::InstancePoses3D& archetype
218 );
219 };
220} // 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 applied on the current entity's transform frame.
Definition instance_poses3d.hpp:84
static constexpr auto Descriptor_scales
ComponentDescriptor for the scales field.
Definition instance_poses3d.hpp:120
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition instance_poses3d.hpp:92
std::optional< ComponentBatch > scales
Scaling factors.
Definition instance_poses3d.hpp:95
static InstancePoses3D update_fields()
Update only some specific fields of a InstancePoses3D.
Definition instance_poses3d.hpp:138
std::optional< ComponentBatch > translations
Translation vectors.
Definition instance_poses3d.hpp:86
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:102
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:167
InstancePoses3D with_translations(const Collection< rerun::components::Translation3D > &_translations) &&
Translation vectors.
Definition instance_poses3d.hpp:146
static constexpr auto Descriptor_mat3x3
ComponentDescriptor for the mat3x3 field.
Definition instance_poses3d.hpp:125
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:176
InstancePoses3D with_mat3x3(const Collection< rerun::components::TransformMat3x3 > &_mat3x3) &&
3x3 transformation matrices.
Definition instance_poses3d.hpp:182
std::optional< ComponentBatch > mat3x3
3x3 transformation matrices.
Definition instance_poses3d.hpp:98
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition instance_poses3d.hpp:89
static constexpr auto Descriptor_translations
ComponentDescriptor for the translations field.
Definition instance_poses3d.hpp:105
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition instance_poses3d.hpp:115
InstancePoses3D with_rotation_axis_angles(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition instance_poses3d.hpp:155
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition instance_poses3d.hpp:110