Rerun C++ SDK
Loading...
Searching...
No Matches
mesh3d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/archetypes/mesh3d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../components/class_id.hpp"
9#include "../components/color.hpp"
10#include "../components/instance_key.hpp"
11#include "../components/material.hpp"
12#include "../components/mesh_properties.hpp"
13#include "../components/position3d.hpp"
14#include "../components/vector3d.hpp"
15#include "../data_cell.hpp"
16#include "../indicator_component.hpp"
17#include "../result.hpp"
18
19#include <cstdint>
20#include <optional>
21#include <utility>
22#include <vector>
23
24namespace rerun::archetypes {
25 /// **Archetype**: A 3D triangle mesh as specified by its per-mesh and per-vertex properties.
26 ///
27 /// ## Example
28 ///
29 /// ### Simple indexed 3D mesh
30 /// ![image](https://static.rerun.io/mesh3d_simple/e1e5fd97265daf0d0bc7b782d862f19086fd6975/full.png)
31 ///
32 /// ```cpp
33 /// #include <rerun.hpp>
34 ///
35 /// #include <vector>
36 ///
37 /// int main() {
38 /// const auto rec = rerun::RecordingStream("rerun_example_mesh3d_indexed");
39 /// rec.spawn().exit_on_failure();
40 ///
41 /// const rerun::Position3D vertex_positions[3] = {
42 /// {0.0f, 1.0f, 0.0f},
43 /// {1.0f, 0.0f, 0.0f},
44 /// {0.0f, 0.0f, 0.0f},
45 /// };
46 /// const rerun::Color vertex_colors[3] = {
47 /// {0, 0, 255},
48 /// {0, 255, 0},
49 /// {255, 0, 0},
50 /// };
51 /// const std::vector<uint32_t> indices = {2, 1, 0};
52 ///
53 /// rec.log(
54 /// "triangle",
55 /// rerun::Mesh3D(vertex_positions)
56 /// .with_vertex_normals({{0.0, 0.0, 1.0}})
57 /// .with_vertex_colors(vertex_colors)
58 /// .with_mesh_properties(rerun::components::MeshProperties::from_triangle_indices(indices))
59 /// .with_mesh_material(rerun::components::Material::from_albedo_factor(0xCC00CCFF))
60 /// );
61 /// }
62 /// ```
63 struct Mesh3D {
64 /// The positions of each vertex.
65 ///
66 /// If no `indices` are specified, then each triplet of positions is interpreted as a triangle.
68
69 /// Optional properties for the mesh as a whole (including indexed drawing).
70 std::optional<rerun::components::MeshProperties> mesh_properties;
71
72 /// An optional normal for each vertex.
73 ///
74 /// If specified, this must have as many elements as `vertex_positions`.
75 std::optional<Collection<rerun::components::Vector3D>> vertex_normals;
76
77 /// An optional color for each vertex.
78 std::optional<Collection<rerun::components::Color>> vertex_colors;
79
80 /// Optional material properties for the mesh as a whole.
81 std::optional<rerun::components::Material> mesh_material;
82
83 /// Optional class Ids for the vertices.
84 ///
85 /// The class ID provides colors and labels if not specified explicitly.
86 std::optional<Collection<rerun::components::ClassId>> class_ids;
87
88 /// Unique identifiers for each individual vertex in the mesh.
89 std::optional<Collection<rerun::components::InstanceKey>> instance_keys;
90
91 public:
92 static constexpr const char IndicatorComponentName[] = "rerun.components.Mesh3DIndicator";
93
94 /// Indicator component, used to identify the archetype when converting to a list of components.
96
97 public:
98 Mesh3D() = default;
99 Mesh3D(Mesh3D&& other) = default;
100
101 explicit Mesh3D(Collection<rerun::components::Position3D> _vertex_positions)
102 : vertex_positions(std::move(_vertex_positions)) {}
103
104 /// Optional properties for the mesh as a whole (including indexed drawing).
106 mesh_properties = std::move(_mesh_properties);
107 // See: https://github.com/rerun-io/rerun/issues/4027
108 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
109 }
110
111 /// An optional normal for each vertex.
112 ///
113 /// If specified, this must have as many elements as `vertex_positions`.
115 vertex_normals = std::move(_vertex_normals);
116 // See: https://github.com/rerun-io/rerun/issues/4027
117 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
118 }
119
120 /// An optional color for each vertex.
122 vertex_colors = std::move(_vertex_colors);
123 // See: https://github.com/rerun-io/rerun/issues/4027
124 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
125 }
126
127 /// Optional material properties for the mesh as a whole.
129 mesh_material = std::move(_mesh_material);
130 // See: https://github.com/rerun-io/rerun/issues/4027
131 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
132 }
133
134 /// Optional class Ids for the vertices.
135 ///
136 /// The class ID provides colors and labels if not specified explicitly.
138 class_ids = std::move(_class_ids);
139 // See: https://github.com/rerun-io/rerun/issues/4027
140 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
141 }
142
143 /// Unique identifiers for each individual vertex in the mesh.
145 instance_keys = std::move(_instance_keys);
146 // See: https://github.com/rerun-io/rerun/issues/4027
147 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
148 }
149
150 /// Returns the number of primary instances of this archetype.
151 size_t num_instances() const {
152 return vertex_positions.size();
153 }
154 };
155
156} // namespace rerun::archetypes
157
158namespace rerun {
159 /// \private
160 template <typename T>
161 struct AsComponents;
162
163 /// \private
164 template <>
165 struct AsComponents<archetypes::Mesh3D> {
166 /// Serialize all set component batches.
167 static Result<std::vector<DataCell>> serialize(const archetypes::Mesh3D& archetype);
168 };
169} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:47
size_t size() const
Returns the number of instances in this collection.
Definition collection.hpp:254
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:66
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Archetype: A 3D triangle mesh as specified by its per-mesh and per-vertex properties.
Definition mesh3d.hpp:63
Collection< rerun::components::Position3D > vertex_positions
The positions of each vertex.
Definition mesh3d.hpp:67
size_t num_instances() const
Returns the number of primary instances of this archetype.
Definition mesh3d.hpp:151
Mesh3D with_mesh_material(rerun::components::Material _mesh_material) &&
Optional material properties for the mesh as a whole.
Definition mesh3d.hpp:128
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the vertices.
Definition mesh3d.hpp:86
Mesh3D with_vertex_colors(Collection< rerun::components::Color > _vertex_colors) &&
An optional color for each vertex.
Definition mesh3d.hpp:121
std::optional< rerun::components::Material > mesh_material
Optional material properties for the mesh as a whole.
Definition mesh3d.hpp:81
Mesh3D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional class Ids for the vertices.
Definition mesh3d.hpp:137
std::optional< rerun::components::MeshProperties > mesh_properties
Optional properties for the mesh as a whole (including indexed drawing).
Definition mesh3d.hpp:70
std::optional< Collection< rerun::components::Color > > vertex_colors
An optional color for each vertex.
Definition mesh3d.hpp:78
std::optional< Collection< rerun::components::InstanceKey > > instance_keys
Unique identifiers for each individual vertex in the mesh.
Definition mesh3d.hpp:89
Mesh3D with_mesh_properties(rerun::components::MeshProperties _mesh_properties) &&
Optional properties for the mesh as a whole (including indexed drawing).
Definition mesh3d.hpp:105
Mesh3D with_instance_keys(Collection< rerun::components::InstanceKey > _instance_keys) &&
Unique identifiers for each individual vertex in the mesh.
Definition mesh3d.hpp:144
std::optional< Collection< rerun::components::Vector3D > > vertex_normals
An optional normal for each vertex.
Definition mesh3d.hpp:75
Mesh3D with_vertex_normals(Collection< rerun::components::Vector3D > _vertex_normals) &&
An optional normal for each vertex.
Definition mesh3d.hpp:114
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23
Component: Material properties of a mesh.
Definition material.hpp:22
Component: Optional triangle indices for a mesh.
Definition mesh_properties.hpp:23