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