Rerun C++ SDK
Loading...
Searching...
No Matches
texcoord2d.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/components/texcoord2d.fbs".
3
4#pragma once
5
6#include "../datatypes/vec2d.hpp"
7#include "../result.hpp"
8
9#include <array>
10#include <cstdint>
11#include <memory>
12
13namespace rerun::components {
14 /// **Component**: A 2D texture UV coordinate.
15 ///
16 /// Texture coordinates specify a position on a 2D texture.
17 /// A range from 0-1 covers the entire texture in the respective dimension.
18 /// Unless configured otherwise, the texture repeats outside of this range.
19 /// Rerun uses top-left as the origin for UV coordinates.
20 ///
21 /// 0 U 1
22 /// 0 + --------- →
23 /// | .
24 /// V | .
25 /// | .
26 /// 1 ↓ . . . . . .
27 ///
28 /// This is the same convention as in Vulkan/Metal/DX12/WebGPU, but (!) unlike OpenGL,
29 /// which places the origin at the bottom-left.
30 struct Texcoord2D {
32
33 public: // START of extensions from texcoord2d_ext.cpp:
34 /// Construct Texcoord2D from u/v values.
35 Texcoord2D(float u, float v) : uv{u, v} {}
36
37 float u() const {
38 return uv.x();
39 }
40
41 float v() const {
42 return uv.y();
43 }
44
45 // END of extensions from texcoord2d_ext.cpp, start of generated code:
46
47 public:
48 Texcoord2D() = default;
49
50 Texcoord2D(rerun::datatypes::Vec2D uv_) : uv(uv_) {}
51
52 Texcoord2D& operator=(rerun::datatypes::Vec2D uv_) {
53 uv = uv_;
54 return *this;
55 }
56
57 Texcoord2D(std::array<float, 2> xy_) : uv(xy_) {}
58
59 Texcoord2D& operator=(std::array<float, 2> xy_) {
60 uv = xy_;
61 return *this;
62 }
63
64 /// Cast to the underlying Vec2D datatype
65 operator rerun::datatypes::Vec2D() const {
66 return uv;
67 }
68 };
69} // namespace rerun::components
70
71namespace rerun {
72 static_assert(sizeof(rerun::datatypes::Vec2D) == sizeof(components::Texcoord2D));
73
74 /// \private
75 template <>
76 struct Loggable<components::Texcoord2D> {
77 static constexpr const char Name[] = "rerun.components.Texcoord2D";
78
79 /// Returns the arrow data type this type corresponds to.
80 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
81 return Loggable<rerun::datatypes::Vec2D>::arrow_datatype();
82 }
83
84 /// Serializes an array of `rerun::components::Texcoord2D` into an arrow array.
85 static Result<std::shared_ptr<arrow::Array>> to_arrow(
86 const components::Texcoord2D* instances, size_t num_instances
87 ) {
88 if (num_instances == 0) {
89 return Loggable<rerun::datatypes::Vec2D>::to_arrow(nullptr, 0);
90 } else if (instances == nullptr) {
91 return rerun::Error(
92 ErrorCode::UnexpectedNullArgument,
93 "Passed array instances is null when num_elements> 0."
94 );
95 } else {
96 return Loggable<rerun::datatypes::Vec2D>::to_arrow(&instances->uv, num_instances);
97 }
98 }
99 };
100} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
Component: A 2D texture UV coordinate.
Definition texcoord2d.hpp:30
Texcoord2D(float u, float v)
Construct Texcoord2D from u/v values.
Definition texcoord2d.hpp:35
Datatype: A vector in 2D space.
Definition vec2d.hpp:20