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 "../indicator_component.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 between the current entity and its parent. Unlike `archetypes::Transform3D`, it is *not* propagated in the transform hierarchy.
24 ///
25 /// If both `archetypes::InstancePoses3D` and `archetypes::Transform3D` are present,
26 /// first the tree propagating `archetypes::Transform3D` is applied, then `archetypes::InstancePoses3D`.
27 ///
28 /// From the point of view of the entity's coordinate system,
29 /// all components are applied in the inverse order they are listed here.
30 /// E.g. if both a translation and a max3x3 transform are present,
31 /// the 3x3 matrix is applied first, followed by the translation.
32 ///
33 /// Currently, many visualizers support only a single instance transform per entity.
34 /// Check archetype documentations for details - if not otherwise specified, only the first instance transform is applied.
35 /// Some visualizers like the mesh visualizer used for `archetypes::Mesh3D`,
36 /// will draw an object for every pose, a behavior also known as "instancing".
37 ///
38 /// ## Example
39 ///
40 /// ### Regular & instance transforms in tandem
41 /// ![image](https://static.rerun.io/leaf_transform3d/41674f0082d6de489f8a1cd1583f60f6b5820ddf/full.png)
42 ///
43 /// ```cpp
44 /// #include <rerun.hpp>
45 /// #include <rerun/demo_utils.hpp>
46 ///
47 /// int main() {
48 /// const auto rec = rerun::RecordingStream("rerun_example_instance_pose3d_combined");
49 /// rec.set_time_sequence("frame", 0);
50 ///
51 /// // Log a box and points further down in the hierarchy.
52 /// rec.log("world/box", rerun::Boxes3D::from_half_sizes({{1.0, 1.0, 1.0}}));
53 /// rec.log(
54 /// "world/box/points",
55 /// rerun::Points3D(rerun::demo::grid3d<rerun::Position3D, float>(-10.0f, 10.0f, 10))
56 /// );
57 ///
58 /// for (int i = 0; i <180; ++i) {
59 /// rec.set_time_sequence("frame", i);
60 ///
61 /// // Log a regular transform which affects both the box and the points.
62 /// rec.log(
63 /// "world/box",
64 /// rerun::Transform3D::from_rotation(rerun::RotationAxisAngle{
65 /// {0.0f, 0.0f, 1.0f},
66 /// rerun::Angle::degrees(static_cast<float>(i) * 2.0f)})
67 /// );
68 ///
69 /// // Log an instance pose which affects only the box.
70 /// rec.log(
71 /// "world/box",
72 /// rerun::InstancePoses3D().with_translations(
73 /// {{0.0f, 0.0f, std::abs(static_cast<float>(i) * 0.1f - 5.0f) - 5.0f}}
74 /// )
75 /// );
76 /// }
77 /// }
78 /// ```
80 /// Translation vectors.
81 std::optional<ComponentBatch> translations;
82
83 /// Rotations via axis + angle.
84 std::optional<ComponentBatch> rotation_axis_angles;
85
86 /// Rotations via quaternion.
87 std::optional<ComponentBatch> quaternions;
88
89 /// Scaling factors.
90 std::optional<ComponentBatch> scales;
91
92 /// 3x3 transformation matrices.
93 std::optional<ComponentBatch> mat3x3;
94
95 public:
96 static constexpr const char IndicatorComponentName[] =
97 "rerun.components.InstancePoses3DIndicator";
98
99 /// Indicator component, used to identify the archetype when converting to a list of components.
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, "translations",
108 );
109 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
111 ArchetypeName, "rotation_axis_angles",
113 );
114 /// `ComponentDescriptor` for the `quaternions` field.
116 ArchetypeName, "quaternions",
118 );
119 /// `ComponentDescriptor` for the `scales` field.
120 static constexpr auto Descriptor_scales = ComponentDescriptor(
121 ArchetypeName, "scales",
123 );
124 /// `ComponentDescriptor` for the `mat3x3` field.
125 static constexpr auto Descriptor_mat3x3 = ComponentDescriptor(
126 ArchetypeName, "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.
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.
184 ) && {
185 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
186 return std::move(*this);
187 }
188
189 /// Partitions the component data into multiple sub-batches.
190 ///
191 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
192 /// instead, via `ComponentBatch::partitioned`.
193 ///
194 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
195 ///
196 /// The specified `lengths` must sum to the total length of the component batch.
198
199 /// Partitions the component data into unit-length sub-batches.
200 ///
201 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
202 /// where `n` is automatically guessed.
204 };
205
206} // namespace rerun::archetypes
207
208namespace rerun {
209 /// \private
210 template <typename T>
211 struct AsComponents;
212
213 /// \private
214 template <>
215 struct AsComponents<archetypes::InstancePoses3D> {
216 /// Serialize all set component batches.
217 static Result<Collection<ComponentBatch>> as_batches(
218 const archetypes::InstancePoses3D& archetype
219 );
220 };
221} // 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=rerun::Loggable< T >::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:14
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:79
InstancePoses3D with_scales(const Collection< rerun::components::PoseScale3D > &_scales) &&
Scaling factors.
Definition instance_poses3d.hpp:176
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:87
std::optional< ComponentBatch > scales
Scaling factors.
Definition instance_poses3d.hpp:90
InstancePoses3D with_mat3x3(const Collection< rerun::components::PoseTransformMat3x3 > &_mat3x3) &&
3x3 transformation matrices.
Definition instance_poses3d.hpp:182
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:81
InstancePoses3D with_quaternions(const Collection< rerun::components::PoseRotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition instance_poses3d.hpp:167
InstancePoses3D with_rotation_axis_angles(const Collection< rerun::components::PoseRotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition instance_poses3d.hpp:155
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.
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.
std::optional< ComponentBatch > mat3x3
3x3 transformation matrices.
Definition instance_poses3d.hpp:93
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition instance_poses3d.hpp:84
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
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition instance_poses3d.hpp:110
InstancePoses3D with_translations(const Collection< rerun::components::PoseTranslation3D > &_translations) &&
Translation vectors.
Definition instance_poses3d.hpp:146
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32