Ocean
VRImageVisualizer.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_IMAGE_VISUALIZER_H
9 #define META_OCEAN_PLATFORM_META_QUEST_APPLICATION_VR_IMAGE_VISUALIZER_H
10 
13 
14 #include "ocean/rendering/Engine.h"
16 
17 namespace Ocean
18 {
19 
20 namespace Platform
21 {
22 
23 namespace Meta
24 {
25 
26 namespace Quest
27 {
28 
29 namespace Application
30 {
31 
32 /**
33  * This class implements a helper function allowing to visualize images in an Ocean-based VR application (e.g., VRNativeApplication).
34  * The visualize allows to place images at arbitrary locations in the 3D environment, to update them (e.g., a video), or to remove them again.<br>
35  * The `image` coordinate system of the visualization is defined as follows:
36  * <pre>
37  * Coordinate system of image, the origin is in the center of the image, the image is visualized in the local z=0 plane:
38  *
39  * (image top-left)
40  * ---------------------------------------------
41  * | |
42  * | ^ |
43  * | | y-axis |
44  * | | |
45  * | *------> x-axis |
46  * | / |
47  * | / z-axis |
48  * | v |
49  * | |
50  * ---------------------------------------------
51  * (image bottom-right)
52  *
53  * |<-------------- object width --------------->|
54  * </pre>
55  * @see VRNativeApplication.
56  * @ingroup platformmetaquestapplication
57  */
58 class OCEAN_PLATFORM_META_QUEST_APPLICATION_EXPORT VRImageVisualizer : public VRVisualizer
59 {
60  public:
61 
62  /**
63  * Default constructor, creates a new invalid visualizer.
64  */
65  inline VRImageVisualizer();
66 
67  /**
68  * Creates a new image visualizer and initializes the object with a given rendering engine and associated framebuffer.
69  * 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.
70  * @param engine The rendering engine to be used, must be valid
71  * @param framebuffer The framebuffer to be used, must be valid
72  */
73  explicit inline VRImageVisualizer(const Rendering::EngineRef& engine, const Rendering::FramebufferRef framebuffer);
74 
75  /**
76  * Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the world).
77  * A previous visualization can be updated by specifying the old id and a new frame.
78  * Beware: The visualizer must be created with a valid engine and framebuffer before usage.
79  * @param id The unique id of the visualization, the same id can be used to update/change the visualization
80  * @param world_T_image The transformation at which the image will be displayed, transforming image to world, can be invalid to remove the existing visualization
81  * @param frame The frame to visualize, can be invalid to remove the existing visualization
82  * @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
83  * @see visualizeImageInView().
84  */
85  inline void visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, Frame&& frame, const ObjectSize& objectSize);
86 
87  /**
88  * Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the world).
89  * A previous visualization can be updated by specifying the old id and a new frame.
90  * Beware: The visualizer must be created with a valid engine and framebuffer before usage.
91  * @param id The unique id of the visualization, the same id can be used to update/change the visualization
92  * @param world_T_image The transformation at which the image will be displayed, transforming image to world, can be invalid to remove the existing visualization
93  * @param frame The frame to visualize, can be invalid to remove the existing visualization
94  * @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
95  * @see visualizeImageInView().
96  */
97  inline void visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, const Frame& frame, const ObjectSize& objectSize);
98 
99  /**
100  * Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the view).
101  * A previous visualization can be updated by specifying the old id and a new frame.
102  * Beware: The visualizer must be created with a valid engine and framebuffer before usage.
103  * @param id The unique id of the visualization, the same id can be used to update/change the visualization
104  * @param view_T_image The transformation at which the image will be displayed, transforming image to view, can be invalid to remove the existing visualization
105  * @param frame The frame to visualize, can be invalid to remove the existing visualization
106  * @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
107  * @see visualizeImageInWorld().
108  */
109  inline void visualizeImageInView(const unsigned int id, const HomogenousMatrix4& view_T_image, Frame&& frame, const ObjectSize& objectSize);
110 
111  /**
112  * Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the view).
113  * A previous visualization can be updated by specifying the old id and a new frame.
114  * Beware: The visualizer must be created with a valid engine and framebuffer before usage.
115  * @param id The unique id of the visualization, the same id can be used to update/change the visualization
116  * @param view_T_image The transformation at which the image will be displayed, transforming image to view, can be invalid to remove the existing visualization
117  * @param frame The frame to visualize, can be invalid to remove the existing visualization
118  * @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
119  * @see visualizeImageInWorld().
120  */
121  inline void visualizeImageInView(const unsigned int id, const HomogenousMatrix4& view_T_image, const Frame& frame, const ObjectSize& objectSize);
122 
123  /**
124  * Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the world or to the view).
125  * A previous visualization can be updated by specifying the old id and a new frame.
126  * Beware: The visualizer must be created with a valid engine and framebuffer before usage.
127  * @param id The unique id of the visualization, the same id can be used to update/change the visualization
128  * @param reference_T_image The transformation at which the image will be displayed, transforming image to reference (either world or view), can be invalid to remove the existing visualization
129  * @param frame The frame to visualize, can be invalid to remove the existing visualization
130  * @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
131  * @param referenceIsWorld True, if reference is world; False, if reference is view
132  */
133  void visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, Frame&& frame, const ObjectSize& objectSize, const bool referenceIsWorld = true);
134 
135  /**
136  * Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the world or to the view).
137  * A previous visualization can be updated by specifying the old id and a new frame.
138  * Beware: The visualizer must be created with a valid engine and framebuffer before usage.
139  * @param id The unique id of the visualization, the same id can be used to update/change the visualization
140  * @param reference_T_image The transformation at which the image will be displayed, transforming image to reference (either world or view), can be invalid to remove the existing visualization
141  * @param frame The frame to visualize, can be invalid to remove the existing visualization
142  * @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
143  * @param referenceIsWorld True, if reference is world; False, if reference is view
144  */
145  inline void visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, const Frame& frame, const ObjectSize& objectSize, const bool referenceIsWorld = true);
146 };
147 
149 {
150  // nothing to do here
151 }
152 
154  VRVisualizer(engine, framebuffer)
155 {
156  // nothing to do here
157 }
158 
159 inline void VRImageVisualizer::visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, Frame&& frame, const ObjectSize& objectSize)
160 {
161  return visualizeImage(id, world_T_image, std::move(frame), objectSize, true);
162 }
163 
164 inline void VRImageVisualizer::visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, const Frame& frame, const ObjectSize& objectSize)
165 {
166  return visualizeImage(id, world_T_image, frame, objectSize, true);
167 }
168 
169 inline void VRImageVisualizer::visualizeImageInView(const unsigned int id, const HomogenousMatrix4& world_T_image, Frame&& frame, const ObjectSize& objectSize)
170 {
171  return visualizeImage(id, world_T_image, std::move(frame), objectSize, false);
172 }
173 
174 inline void VRImageVisualizer::visualizeImageInView(const unsigned int id, const HomogenousMatrix4& world_T_image, const Frame& frame, const ObjectSize& objectSize)
175 {
176  return visualizeImage(id, world_T_image, frame, objectSize, false);
177 }
178 
179 inline void VRImageVisualizer::visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, const Frame& frame, const ObjectSize& objectSize, const bool referenceIsWorld)
180 {
181  return visualizeImage(id, reference_T_image, Frame(frame, Frame::ACM_COPY_REMOVE_PADDING_LAYOUT), objectSize, referenceIsWorld);
182 }
183 
184 }
185 
186 }
187 
188 }
189 
190 }
191 
192 }
193 
194 #endif // META_OCEAN_PLATFORM_META_QUEST_APPLICATION_VR_IMAGE_VISUALIZER_H
This class implements Ocean's image class.
Definition: Frame.h:1792
@ ACM_COPY_REMOVE_PADDING_LAYOUT
Same as CM_COPY_REMOVE_PADDING_LAYOUT.
Definition: Frame.h:1818
This class implements a helper function allowing to visualize images in an Ocean-based VR application...
Definition: VRImageVisualizer.h:59
VRImageVisualizer()
Default constructor, creates a new invalid visualizer.
Definition: VRImageVisualizer.h:148
void visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4 &world_T_image, Frame &&frame, const ObjectSize &objectSize)
Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment ...
Definition: VRImageVisualizer.h:159
void visualizeImageInView(const unsigned int id, const HomogenousMatrix4 &view_T_image, Frame &&frame, const ObjectSize &objectSize)
Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment ...
Definition: VRImageVisualizer.h:169
void visualizeImage(const unsigned int id, const HomogenousMatrix4 &reference_T_image, Frame &&frame, const ObjectSize &objectSize, const bool referenceIsWorld=true)
Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment ...
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
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15