Rerun C++ SDK
Loading...
Searching...
No Matches
mesh3d.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/mesh3d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../component_batch.hpp"
9#include "../components/albedo_factor.hpp"
10#include "../components/class_id.hpp"
11#include "../components/color.hpp"
12#include "../components/image_buffer.hpp"
13#include "../components/image_format.hpp"
14#include "../components/position3d.hpp"
15#include "../components/texcoord2d.hpp"
16#include "../components/triangle_indices.hpp"
17#include "../components/vector3d.hpp"
18#include "../indicator_component.hpp"
19#include "../result.hpp"
20
21#include <cstdint>
22#include <optional>
23#include <utility>
24#include <vector>
25
26namespace rerun::archetypes {
27 /// **Archetype**: A 3D triangle mesh as specified by its per-mesh and per-vertex properties.
28 ///
29 /// See also `archetypes::Asset3D`.
30 ///
31 /// If there are multiple `archetypes::InstancePoses3D` instances logged to the same entity as a mesh,
32 /// an instance of the mesh will be drawn for each transform.
33 ///
34 /// ## Examples
35 ///
36 /// ### Simple indexed 3D mesh
37 /// ![image](https://static.rerun.io/mesh3d_indexed/57c70dc992e6dc0bd9c5222ca084f5b6240cea75/full.png)
38 ///
39 /// ```cpp
40 /// #include <rerun.hpp>
41 ///
42 /// #include <vector>
43 ///
44 /// int main() {
45 /// const auto rec = rerun::RecordingStream("rerun_example_mesh3d_indexed");
46 /// rec.spawn().exit_on_failure();
47 ///
48 /// const rerun::Position3D vertex_positions[3] = {
49 /// {0.0f, 1.0f, 0.0f},
50 /// {1.0f, 0.0f, 0.0f},
51 /// {0.0f, 0.0f, 0.0f},
52 /// };
53 /// const rerun::Color vertex_colors[3] = {
54 /// {0, 0, 255},
55 /// {0, 255, 0},
56 /// {255, 0, 0},
57 /// };
58 ///
59 /// rec.log(
60 /// "triangle",
61 /// rerun::Mesh3D(vertex_positions)
62 /// .with_vertex_normals({{0.0, 0.0, 1.0}})
63 /// .with_vertex_colors(vertex_colors)
64 /// .with_triangle_indices({{2, 1, 0}})
65 /// );
66 /// }
67 /// ```
68 ///
69 /// ### 3D mesh with instancing
70 /// ![image](https://static.rerun.io/mesh3d_leaf_transforms3d/c2d0ee033129da53168f5705625a9b033f3a3d61/full.png)
71 ///
72 /// ```cpp
73 /// #include <rerun.hpp>
74 ///
75 /// int main() {
76 /// const auto rec = rerun::RecordingStream("rerun_example_mesh3d_instancing");
77 /// rec.spawn().exit_on_failure();
78 ///
79 /// rec.set_time_sequence("frame", 0);
80 /// rec.log(
81 /// "shape",
82 /// rerun::Mesh3D(
83 /// {{1.0f, 1.0f, 1.0f}, {-1.0f, -1.0f, 1.0f}, {-1.0f, 1.0f, -1.0f}, {1.0f, -1.0f, -1.0f}}
84 /// )
85 /// .with_triangle_indices({{0, 1, 2}, {0, 1, 3}, {0, 2, 3}, {1, 2, 3}})
86 /// .with_vertex_colors({0xFF0000FF, 0x00FF00FF, 0x00000FFFF, 0xFFFF00FF})
87 /// );
88 /// // This box will not be affected by its parent's instance poses!
89 /// rec.log("shape/box", rerun::Boxes3D::from_half_sizes({{5.0f, 5.0f, 5.0f}}));
90 ///
91 /// for (int i = 0; i <100; ++i) {
92 /// rec.set_time_sequence("frame", i);
93 /// rec.log(
94 /// "shape",
95 /// rerun::InstancePoses3D()
96 /// .with_translations(
97 /// {{2.0f, 0.0f, 0.0f},
98 /// {0.0f, 2.0f, 0.0f},
99 /// {0.0f, -2.0f, 0.0f},
100 /// {-2.0f, 0.0f, 0.0f}}
101 /// )
102 /// .with_rotation_axis_angles({rerun::RotationAxisAngle(
103 /// {0.0f, 0.0f, 1.0f},
104 /// rerun::Angle::degrees(static_cast<float>(i) * 2.0f)
105 /// )})
106 /// );
107 /// }
108 /// }
109 /// ```
110 struct Mesh3D {
111 /// The positions of each vertex.
112 ///
113 /// If no `triangle_indices` are specified, then each triplet of positions is interpreted as a triangle.
115
116 /// Optional indices for the triangles that make up the mesh.
117 std::optional<Collection<rerun::components::TriangleIndices>> triangle_indices;
118
119 /// An optional normal for each vertex.
120 std::optional<Collection<rerun::components::Vector3D>> vertex_normals;
121
122 /// An optional color for each vertex.
123 std::optional<Collection<rerun::components::Color>> vertex_colors;
124
125 /// An optional uv texture coordinate for each vertex.
126 std::optional<Collection<rerun::components::Texcoord2D>> vertex_texcoords;
127
128 /// A color multiplier applied to the whole mesh.
129 std::optional<rerun::components::AlbedoFactor> albedo_factor;
130
131 /// Optional albedo texture.
132 ///
133 /// Used with the `components::Texcoord2D` of the mesh.
134 ///
135 /// Currently supports only sRGB(A) textures, ignoring alpha.
136 /// (meaning that the tensor must have 3 or 4 channels and use the `u8` format)
137 std::optional<rerun::components::ImageBuffer> albedo_texture_buffer;
138
139 /// The format of the `albedo_texture_buffer`, if any.
140 std::optional<rerun::components::ImageFormat> albedo_texture_format;
141
142 /// Optional class Ids for the vertices.
143 ///
144 /// The `components::ClassId` provides colors and labels if not specified explicitly.
145 std::optional<Collection<rerun::components::ClassId>> class_ids;
146
147 public:
148 static constexpr const char IndicatorComponentName[] = "rerun.components.Mesh3DIndicator";
149
150 /// Indicator component, used to identify the archetype when converting to a list of components.
152
153 public:
154 Mesh3D() = default;
155 Mesh3D(Mesh3D&& other) = default;
156
157 explicit Mesh3D(Collection<rerun::components::Position3D> _vertex_positions)
158 : vertex_positions(std::move(_vertex_positions)) {}
159
160 /// Optional indices for the triangles that make up the mesh.
163 ) && {
164 triangle_indices = std::move(_triangle_indices);
165 // See: https://github.com/rerun-io/rerun/issues/4027
166 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
167 }
168
169 /// An optional normal for each vertex.
171 vertex_normals = std::move(_vertex_normals);
172 // See: https://github.com/rerun-io/rerun/issues/4027
173 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
174 }
175
176 /// An optional color for each vertex.
178 vertex_colors = std::move(_vertex_colors);
179 // See: https://github.com/rerun-io/rerun/issues/4027
180 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
181 }
182
183 /// An optional uv texture coordinate for each vertex.
185 ) && {
186 vertex_texcoords = std::move(_vertex_texcoords);
187 // See: https://github.com/rerun-io/rerun/issues/4027
188 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
189 }
190
191 /// A color multiplier applied to the whole mesh.
193 albedo_factor = std::move(_albedo_factor);
194 // See: https://github.com/rerun-io/rerun/issues/4027
195 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
196 }
197
198 /// Optional albedo texture.
199 ///
200 /// Used with the `components::Texcoord2D` of the mesh.
201 ///
202 /// Currently supports only sRGB(A) textures, ignoring alpha.
203 /// (meaning that the tensor must have 3 or 4 channels and use the `u8` format)
205 ) && {
206 albedo_texture_buffer = std::move(_albedo_texture_buffer);
207 // See: https://github.com/rerun-io/rerun/issues/4027
208 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
209 }
210
211 /// The format of the `albedo_texture_buffer`, if any.
213 ) && {
214 albedo_texture_format = std::move(_albedo_texture_format);
215 // See: https://github.com/rerun-io/rerun/issues/4027
216 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
217 }
218
219 /// Optional class Ids for the vertices.
220 ///
221 /// The `components::ClassId` provides colors and labels if not specified explicitly.
223 class_ids = std::move(_class_ids);
224 // See: https://github.com/rerun-io/rerun/issues/4027
225 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
226 }
227 };
228
229} // namespace rerun::archetypes
230
231namespace rerun {
232 /// \private
233 template <typename T>
234 struct AsComponents;
235
236 /// \private
237 template <>
238 struct AsComponents<archetypes::Mesh3D> {
239 /// Serialize all set component batches.
240 static Result<std::vector<ComponentBatch>> serialize(const archetypes::Mesh3D& archetype);
241 };
242} // 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:77
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Archetype: A 3D triangle mesh as specified by its per-mesh and per-vertex properties.
Definition mesh3d.hpp:110
Mesh3D with_albedo_texture_format(rerun::components::ImageFormat _albedo_texture_format) &&
The format of the albedo_texture_buffer, if any.
Definition mesh3d.hpp:212
std::optional< Collection< rerun::components::Texcoord2D > > vertex_texcoords
An optional uv texture coordinate for each vertex.
Definition mesh3d.hpp:126
Collection< rerun::components::Position3D > vertex_positions
The positions of each vertex.
Definition mesh3d.hpp:114
Mesh3D with_albedo_factor(rerun::components::AlbedoFactor _albedo_factor) &&
A color multiplier applied to the whole mesh.
Definition mesh3d.hpp:192
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the vertices.
Definition mesh3d.hpp:145
Mesh3D with_vertex_colors(Collection< rerun::components::Color > _vertex_colors) &&
An optional color for each vertex.
Definition mesh3d.hpp:177
std::optional< rerun::components::ImageBuffer > albedo_texture_buffer
Optional albedo texture.
Definition mesh3d.hpp:137
std::optional< Collection< rerun::components::TriangleIndices > > triangle_indices
Optional indices for the triangles that make up the mesh.
Definition mesh3d.hpp:117
Mesh3D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional class Ids for the vertices.
Definition mesh3d.hpp:222
std::optional< Collection< rerun::components::Color > > vertex_colors
An optional color for each vertex.
Definition mesh3d.hpp:123
Mesh3D with_triangle_indices(Collection< rerun::components::TriangleIndices > _triangle_indices) &&
Optional indices for the triangles that make up the mesh.
Definition mesh3d.hpp:161
std::optional< rerun::components::AlbedoFactor > albedo_factor
A color multiplier applied to the whole mesh.
Definition mesh3d.hpp:129
std::optional< rerun::components::ImageFormat > albedo_texture_format
The format of the albedo_texture_buffer, if any.
Definition mesh3d.hpp:140
Mesh3D with_albedo_texture_buffer(rerun::components::ImageBuffer _albedo_texture_buffer) &&
Optional albedo texture.
Definition mesh3d.hpp:204
Mesh3D with_vertex_texcoords(Collection< rerun::components::Texcoord2D > _vertex_texcoords) &&
An optional uv texture coordinate for each vertex.
Definition mesh3d.hpp:184
std::optional< Collection< rerun::components::Vector3D > > vertex_normals
An optional normal for each vertex.
Definition mesh3d.hpp:120
Mesh3D with_vertex_normals(Collection< rerun::components::Vector3D > _vertex_normals) &&
An optional normal for each vertex.
Definition mesh3d.hpp:170
Component: A color multiplier, usually applied to a whole entity, e.g. a mesh.
Definition albedo_factor.hpp:15
Component: A buffer that is known to store image data.
Definition image_buffer.hpp:19
Component: The metadata describing the contents of a components::ImageBuffer.
Definition image_format.hpp:15
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32