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 "../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 ///
78 /// // Log an instance pose which affects only the box.
79 /// rec.log(
80 /// "world/box",
81 /// rerun::InstancePoses3D().with_translations(
82 /// {{0.0f,
83 /// 0.0f,
84 /// std::abs(static_cast<float>(i) * 0.1f - 5.0f) - 5.0f}}
85 /// )
86 /// );
87 /// }
88 /// }
89 /// ```
91 /// Translation vectors.
92 std::optional<ComponentBatch> translations;
93
94 /// Rotations via axis + angle.
95 std::optional<ComponentBatch> rotation_axis_angles;
96
97 /// Rotations via quaternion.
98 std::optional<ComponentBatch> quaternions;
99
100 /// Scaling factors.
101 std::optional<ComponentBatch> scales;
102
103 /// 3x3 transformation matrices.
104 std::optional<ComponentBatch> mat3x3;
105
106 public:
107 /// The name of the archetype as used in `ComponentDescriptor`s.
108 static constexpr const char ArchetypeName[] = "rerun.archetypes.InstancePoses3D";
109
110 /// `ComponentDescriptor` for the `translations` field.
112 ArchetypeName, "InstancePoses3D:translations",
114 );
115 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
117 ArchetypeName, "InstancePoses3D:rotation_axis_angles",
119 );
120 /// `ComponentDescriptor` for the `quaternions` field.
122 ArchetypeName, "InstancePoses3D:quaternions",
124 );
125 /// `ComponentDescriptor` for the `scales` field.
126 static constexpr auto Descriptor_scales = ComponentDescriptor(
127 ArchetypeName, "InstancePoses3D:scales",
129 );
130 /// `ComponentDescriptor` for the `mat3x3` field.
131 static constexpr auto Descriptor_mat3x3 = ComponentDescriptor(
132 ArchetypeName, "InstancePoses3D:mat3x3",
134 );
135
136 public:
137 InstancePoses3D() = default;
138 InstancePoses3D(InstancePoses3D&& other) = default;
139 InstancePoses3D(const InstancePoses3D& other) = default;
140 InstancePoses3D& operator=(const InstancePoses3D& other) = default;
141 InstancePoses3D& operator=(InstancePoses3D&& other) = default;
142
143 /// Update only some specific fields of a `InstancePoses3D`.
145 return InstancePoses3D();
146 }
147
148 /// Clear all the fields of a `InstancePoses3D`.
150
151 /// Translation vectors.
154 ) && {
156 .value_or_throw();
157 return std::move(*this);
158 }
159
160 /// Rotations via axis + angle.
162 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angles
163 ) && {
165 _rotation_axis_angles,
167 )
168 .value_or_throw();
169 return std::move(*this);
170 }
171
172 /// Rotations via quaternion.
175 ) && {
177 .value_or_throw();
178 return std::move(*this);
179 }
180
181 /// Scaling factors.
183 scales = ComponentBatch::from_loggable(_scales, Descriptor_scales).value_or_throw();
184 return std::move(*this);
185 }
186
187 /// 3x3 transformation matrices.
189 ) && {
190 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
191 return std::move(*this);
192 }
193
194 /// Partitions the component data into multiple sub-batches.
195 ///
196 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
197 /// instead, via `ComponentBatch::partitioned`.
198 ///
199 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
200 ///
201 /// The specified `lengths` must sum to the total length of the component batch.
203
204 /// Partitions the component data into unit-length sub-batches.
205 ///
206 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
207 /// where `n` is automatically guessed.
209 };
210
211} // namespace rerun::archetypes
212
213namespace rerun {
214 /// \private
215 template <typename T>
216 struct AsComponents;
217
218 /// \private
219 template <>
220 struct AsComponents<archetypes::InstancePoses3D> {
221 /// Serialize all set component batches.
222 static Result<Collection<ComponentBatch>> as_batches(
223 const archetypes::InstancePoses3D& archetype
224 );
225 };
226} // 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:90
static constexpr auto Descriptor_scales
ComponentDescriptor for the scales field.
Definition instance_poses3d.hpp:126
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition instance_poses3d.hpp:98
std::optional< ComponentBatch > scales
Scaling factors.
Definition instance_poses3d.hpp:101
static InstancePoses3D update_fields()
Update only some specific fields of a InstancePoses3D.
Definition instance_poses3d.hpp:144
std::optional< ComponentBatch > translations
Translation vectors.
Definition instance_poses3d.hpp:92
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:108
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:173
InstancePoses3D with_translations(const Collection< rerun::components::Translation3D > &_translations) &&
Translation vectors.
Definition instance_poses3d.hpp:152
static constexpr auto Descriptor_mat3x3
ComponentDescriptor for the mat3x3 field.
Definition instance_poses3d.hpp:131
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:182
InstancePoses3D with_mat3x3(const Collection< rerun::components::TransformMat3x3 > &_mat3x3) &&
3x3 transformation matrices.
Definition instance_poses3d.hpp:188
std::optional< ComponentBatch > mat3x3
3x3 transformation matrices.
Definition instance_poses3d.hpp:104
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition instance_poses3d.hpp:95
static constexpr auto Descriptor_translations
ComponentDescriptor for the translations field.
Definition instance_poses3d.hpp:111
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition instance_poses3d.hpp:121
InstancePoses3D with_rotation_axis_angles(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition instance_poses3d.hpp:161
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition instance_poses3d.hpp:116