Ocean
Loading...
Searching...
No Matches
VRTextVisualizer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_PLATFORM_META_QUEST_APPLICATION_VR_TEXT_VISUALIZER_H
9#define META_OCEAN_PLATFORM_META_QUEST_APPLICATION_VR_TEXT_VISUALIZER_H
10
13
16
17namespace Ocean
18{
19
20namespace Platform
21{
22
23namespace Meta
24{
25
26namespace Quest
27{
28
29namespace Application
30{
31
32/**
33 * This class implements a helper function allowing to visualize text in an Ocean-based VR application (e.g., VRNativeApplication).
34 * The visualize allows to place text at arbitrary locations in the 3D environment, to update the text, or to remove the text again.<br>
35 * The `text` coordinate system of the visualization is defined as follows:
36 * <pre>
37 * Coordinate system of text, the origin is in the center of the text, the text is visualized in the local z=0 plane:
38 *
39 * (text field top-left)
40 * ---------------------------------------------
41 * | |
42 * | ^ |
43 * | | y-axis |
44 * | | |
45 * | *------> x-axis |
46 * | / |
47 * | / z-axis |
48 * | v |
49 * | |
50 * ---------------------------------------------
51 * (text field bottom-right)
52 *
53 * |<-------------- object width --------------->|
54 * </pre>
55 * The visualizer uses `CV::Fonts` to rendering the text.
56 * Custom fonts can be registered via `CV::Fonts::FontManager::get().registerFont()`.
57 * @see VRNativeApplication.
58 * @ingroup platformmetaquestapplication
59 */
60class OCEAN_PLATFORM_META_QUEST_APPLICATION_EXPORT VRTextVisualizer : public VRVisualizer
61{
62 public:
63
64 /**
65 * Default constructor, creates a new invalid visualizer.
66 */
67 inline VRTextVisualizer();
68
69 /**
70 * Creates a new text visualizer and initializes the object with a given rendering engine and associated framebuffer.
71 * Rendering engine and framebuffer are necessary so that the rendering objects (like Scene, Transform, Texture2D) can be created and attached to the existing rendering objects.
72 * @param engine The rendering engine to be used, must be valid
73 * @param framebuffer The framebuffer to be used, must be valid
74 */
75 inline VRTextVisualizer(const Rendering::EngineRef& engine, const Rendering::FramebufferRef framebuffer);
76
77 /**
78 * Visualizes a text at a specific location in the virtual environment (defined in relation to the world).
79 * A previous visualization can be updated by specifying the old id and a new text.
80 * Beware: The visualizer must be created with a valid engine and framebuffer before usage.
81 * @param id The unique id of the visualization, the same id can be used to update/change the visualization
82 * @param world_T_text The transformation at which the text will be displayed, transforming text to world, can be invalid to remove the existing visualization
83 * @param text The text to visualize, can contain end-of-line characters for multiple text lines, can be empty to remove the existing visualization
84 * @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
85 * @param workaroundTimestamp Current workaround: Timestamp of the rendering engine
86 * @param fontName The name of the font to be used to render the text
87 * @param backgroundColor The background color with alpha, default is opaque gray (0.25, 0.25, 0.25, 1.0)
88 * @see visualizeTextnView().
89 */
90 inline void visualizeTextInWorld(const unsigned int id, const HomogenousMatrix4& world_T_text, const std::string& text, const ObjectSize& objectSize, const Timestamp& workaroundTimestamp = Timestamp(false), const std::string& fontName = "Roboto", const RGBAColor& backgroundColor = RGBAColor(0.25f, 0.25f, 0.25f, 1.0f));
91
92 /**
93 * Visualizes a text at a specific location in the virtual environment (defined in relation to the view).
94 * A previous visualization can be updated by specifying the old id and a new text.
95 * Beware: The visualizer must be created with a valid engine and framebuffer before usage.
96 * @param id The unique id of the visualization, the same id can be used to update/change the visualization
97 * @param view_T_text The transformation at which the text will be displayed, transforming text to view, can be invalid to remove the existing visualization
98 * @param text The text to visualize, can contain end-of-line characters for multiple text lines, can be empty to remove the existing visualization
99 * @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
100 * @param workaroundTimestamp Current workaround: Timestamp of the rendering engine
101 * @param fontName The name of the font to be used to render the text
102 * @param backgroundColor The background color with alpha, default is opaque gray (0.25, 0.25, 0.25, 1.0)
103 * @see visualizeTextInWorld().
104 */
105 inline void visualizeTextInView(const unsigned int id, const HomogenousMatrix4& view_T_text, const std::string& text, const ObjectSize& objectSize, const Timestamp& workaroundTimestamp = Timestamp(false), const std::string& fontName = "Roboto", const RGBAColor& backgroundColor = RGBAColor(0.25f, 0.25f, 0.25f, 1.0f));
106
107 /**
108 * Visualizes a text at a specific location in the virtual environment (defined in relation to the world or to the view).
109 * A previous visualization can be updated by specifying the old id and a new text.
110 * Beware: The visualizer must be created with a valid engine and framebuffer before usage.
111 * @param id The unique id of the visualization, the same id can be used to update/change the visualization
112 * @param reference_T_text The transformation at which the text will be displayed, transforming text to reference (either world or view), can be invalid to remove the existing visualization
113 * @param text The text to visualize, can contain end-of-line characters for multiple text lines, can be empty to remove the existing visualization
114 * @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
115 * @param workaroundTimestamp Current workaround: Timestamp of the rendering engine
116 * @param referenceIsWorld True, if reference is world; False, if reference is view
117 * @param fontName The name of the font to be used to render the text
118 * @param backgroundColor The background color with alpha, default is opaque gray (0.25, 0.25, 0.25, 1.0)
119 */
120 void visualizeText(const unsigned int id, const HomogenousMatrix4& reference_T_text, const std::string& text, const ObjectSize& objectSize, const Timestamp& workaroundTimestamp = Timestamp(false), const bool referenceIsWorld = true, const std::string& fontName = "Roboto", const RGBAColor& backgroundColor = RGBAColor(0.25f, 0.25f, 0.25f, 1.0f));
121};
122
124{
125 // nothing to do here
126}
127
129 VRVisualizer(engine, framebuffer)
130{
131 // nothing to do here
132}
133
134inline void VRTextVisualizer::visualizeTextInWorld(const unsigned int id, const HomogenousMatrix4& world_T_text, const std::string& text, const ObjectSize& objectSize, const Timestamp& workaroundTimestamp, const std::string& fontName, const RGBAColor& backgroundColor)
135{
136 return visualizeText(id, world_T_text, text, objectSize, workaroundTimestamp, true, fontName, backgroundColor);
137}
138
139inline void VRTextVisualizer::visualizeTextInView(const unsigned int id, const HomogenousMatrix4& world_T_text, const std::string& text, const ObjectSize& objectSize, const Timestamp& workaroundTimestamp, const std::string& fontName, const RGBAColor& backgroundColor)
140{
141 return visualizeText(id, world_T_text, text, objectSize, workaroundTimestamp, false, fontName, backgroundColor);
142}
143
144}
145
146}
147
148}
149
150}
151
152}
153
154#endif // META_OCEAN_PLATFORM_META_QUEST_APPLICATION_VR_TEXT_VISUALIZER_H
This class implements a helper function allowing to visualize text in an Ocean-based VR application (...
Definition VRTextVisualizer.h:61
void visualizeTextInView(const unsigned int id, const HomogenousMatrix4 &view_T_text, const std::string &text, const ObjectSize &objectSize, const Timestamp &workaroundTimestamp=Timestamp(false), const std::string &fontName="Roboto", const RGBAColor &backgroundColor=RGBAColor(0.25f, 0.25f, 0.25f, 1.0f))
Visualizes a text at a specific location in the virtual environment (defined in relation to the view)...
Definition VRTextVisualizer.h:139
void visualizeTextInWorld(const unsigned int id, const HomogenousMatrix4 &world_T_text, const std::string &text, const ObjectSize &objectSize, const Timestamp &workaroundTimestamp=Timestamp(false), const std::string &fontName="Roboto", const RGBAColor &backgroundColor=RGBAColor(0.25f, 0.25f, 0.25f, 1.0f))
Visualizes a text at a specific location in the virtual environment (defined in relation to the world...
Definition VRTextVisualizer.h:134
void visualizeText(const unsigned int id, const HomogenousMatrix4 &reference_T_text, const std::string &text, const ObjectSize &objectSize, const Timestamp &workaroundTimestamp=Timestamp(false), const bool referenceIsWorld=true, const std::string &fontName="Roboto", const RGBAColor &backgroundColor=RGBAColor(0.25f, 0.25f, 0.25f, 1.0f))
Visualizes a text at a specific location in the virtual environment (defined in relation to the world...
VRTextVisualizer()
Default constructor, creates a new invalid visualizer.
Definition VRTextVisualizer.h:123
Definition of a size object allowing to specify either width and height, or only width,...
Definition VRVisualizer.h:50
This class implements the base class for all VR visualizers allowing to visualize e....
Definition VRVisualizer.h:43
This class implements a color defined by red, green, blue and alpha parameters.
Definition RGBAColor.h:41
This class implements a timestamp.
Definition Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition Accessor.h:15