Ocean
Loading...
Searching...
No Matches
TexturedTrianglesRendererBackup.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_TRACKING_MAPTEXTURING_TEXTURED_TRIANGLES_RENDERER_BACKUP_H
9#define META_OCEAN_TRACKING_MAPTEXTURING_TEXTURED_TRIANGLES_RENDERER_BACKUP_H
10
14
15#include "ocean/base/Frame.h"
16
18
26
27namespace Ocean
28{
29
30namespace Tracking
31{
32
33namespace MapTexturing
34{
35
36/**
37 * This class implements a renderer rendering textured triangles into a texture atlas using a backup approach without a geometry shader.
38 * @ingroup trackingmaptexturing
39 */
40class OCEAN_TRACKING_MAPTEXTURING_EXPORT TexturedTrianglesRendererBackup
41{
42 protected:
43
44 /**
45 * Definition of an unordered map mapping mesh ids to texture framebuffers.
46 */
47 typedef std::unordered_map<Index32, Rendering::TextureFramebufferRef> TextureFramebufferMap;
48
49 public:
50
51 /**
52 * Destructs this renderer and releases all resources.
53 */
55
56 /**
57 * Updates this renderer with a new live frame which will be used as source texture.
58 * @param engine The rendering engine to be used
59 * @param rgbFrame The frame to be used as source texture, invalid to keep the previous frame
60 * @return True, if succeeded
61 */
62 bool update(const Rendering::Engine& engine, Frame&& rgbFrame);
63
64 /**
65 * Renders textured triangles into a texture atlas.
66 * @param engine The rendering engine to be used
67 * @param triangles The triangles to render, must be valid
68 * @param numberTriangles The number of triangles to render, with range [0, infinity)
69 * @param anyCamera The camera profile to be used when rendering, must be valid
70 * @param projectionMatrix The projection matrix to be used, must be valid
71 * @param world_T_camera The transformation between camera and world, must be valid
72 * @param visibleTrianglesFramebuffer The texture framebuffer containing all visible triangles, must be valid
73 * @param textureAtlas The texture atlas defining the layout
74 * @return True, if succeeded
75 */
76 bool render(const Rendering::Engine& engine, const HashableTriangle* triangles, const unsigned int numberTriangles, const AnyCamera& anyCamera, const SquareMatrix4& projectionMatrix, const HomogenousMatrix4& world_T_camera, const Rendering::TextureFramebufferRef& visibleTrianglesFramebuffer, const TextureAtlas& textureAtlas);
77
78 /**
79 * Renders textured triangles into a texture atlas.
80 * @param engine The rendering engine to be used
81 * @param triangles All possible triangles, must be valid
82 * @param numberMeshes The maximal number of meshes, with range [1, infinity)
83 * @param triangleIds The ids of all triangles to be rendered
84 * @param anyCamera The camera profile to be used when rendering, must be valid
85 * @param world_T_camera The transformation between camera and world, must be valid
86 * @param textureFramebufferMap The map of texture framebuffers to which the triangles will be rendered
87 * @param renderedMeshFramebuffer The source texture holding the texture information of the triangles, must be valid
88 * @param textureAtlas The texture atlas defining the layout
89 * @return True, if succeeded
90 */
91 bool render(const Rendering::Engine& engine, const HashableTriangle* triangles, const unsigned int numberMeshes, const Indices32& triangleIds, const AnyCamera& anyCamera, const HomogenousMatrix4& world_T_camera, const TextureFramebufferMap& textureFramebufferMap, const Rendering::TextureFramebufferRef& renderedMeshFramebuffer, const TextureAtlas& textureAtlas);
92
93 /**
94 * Returns the map mapping mesh ids to texture framebuffers.
95 * @return The map of texture framebuffers
96 */
97 inline const TextureFramebufferMap& textureFramebufferMap() const;
98
99 /**
100 * Returns the latest texture atlas image for a specified mesh.
101 * @param meshId The id of the mesh for which the latest atlas image will be returned, must be valid
102 * @param textureFrame The resulting atlas image
103 * @return True, if succeeded
104 */
105 bool latestTexture(const Index32 meshId, Frame& textureFrame) const;
106
107 /**
108 * Returns the ids of all textured meshes.
109 * @return The ids of all meshes
110 */
112
113 /**
114 * Explicitly releases this renderer and releases all resources.
115 */
116 void release();
117
118 /**
119 * Returns whether this renderer has been initialized successfully.
120 * @return True, if succeeded
121 */
122 inline bool isValid() const;
123
124 protected:
125
126 /**
127 * Renders textured triangles into a texture atlas.
128 * @param engine The rendering engine to be used
129 * @param meshId The id of the mesh for which the textured triangles will be rendered, must be valid
130 * @param vertices The vertices of the triangles to render
131 * @param textureCoordinates The texture coordinates of the triangles to render
132 * @param texture The source texture holding the texture information of the triangles, must be valid
133 * @param textureAtlas The texture atlas defining the layout
134 * @return True, if succeeded
135 */
136 bool renderMesh(const Rendering::Engine& engine, const Index32 meshId, const Vectors3& vertices, const Vectors2& textureCoordinates, const Rendering::TextureRef& texture, const TextureAtlas& textureAtlas);
137
138 /**
139 * Renders textured triangles into a texture atlas.
140 * @param engine The rendering engine to be used
141 * @param meshId The id of the mesh for which the textured triangles will be rendered, must be valid
142 * @param vertices The vertices of the triangles to render
143 * @param textureCoordinates The texture coordinates of the triangles to render
144 * @param textureFramebuffer The texture framebuffer in which the triangles will be rendered, must be valid
145 * @param texture The source texture holding the texture information of the triangles, must be valid
146 * @param textureAtlas The texture atlas defining the layout
147 * @return True, if succeeded
148 */
149 bool renderMesh(const Rendering::Engine& engine, const Index32 meshId, const Vectors3& vertices, const Vectors2& textureCoordinates, const Rendering::TextureFramebufferRef& textureFramebuffer, const Rendering::TextureRef& texture, const TextureAtlas& textureAtlas);
150
151 protected:
152
153 /// The shader program rendering individual triangles with individual color ids.
155
156 /// The map of texture framebuffers, one for each mesh id.
158
159 /// The frame texture holding the texture information for the triangles.
161
162 /// The renderer's own vertex set.
164
165 /// The renderer's own triangles.
167
168 /// The internal state frame.
170
171 /// Reusable vertices.
173
174 /// Reusable texture coordinates.
176
177 /// The platform-specific shader part.
178 static const char* partPlatform_;
179
180 /// The vertex shader part.
181 static const char* programVertexShader_;
182
183 /// The fragment shader part.
184 static const char* programFragmentShader_;
185};
186
191
192}
193
194}
195
196}
197
198#endif // META_OCEAN_TRACKING_MAPTEXTURING_TEXTURED_TRIANGLES_RENDERER_BACKUP_H
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
This class implements Ocean's image class.
Definition Frame.h:1808
This class is the base class for all rendering engines like.
Definition Engine.h:46
This class implements a 3D triangle which is hash-able.
Definition HashableTriangle.h:41
This class implements a texture atlas for triangles with regular shape.
Definition TextureAtlas.h:31
This class implements a renderer rendering textured triangles into a texture atlas using a backup app...
Definition TexturedTrianglesRendererBackup.h:41
~TexturedTrianglesRendererBackup()
Destructs this renderer and releases all resources.
bool isValid() const
Returns whether this renderer has been initialized successfully.
bool renderMesh(const Rendering::Engine &engine, const Index32 meshId, const Vectors3 &vertices, const Vectors2 &textureCoordinates, const Rendering::TextureRef &texture, const TextureAtlas &textureAtlas)
Renders textured triangles into a texture atlas.
Rendering::ShaderProgramRef shaderProgram_
The shader program rendering individual triangles with individual color ids.
Definition TexturedTrianglesRendererBackup.h:154
const TextureFramebufferMap & textureFramebufferMap() const
Returns the map mapping mesh ids to texture framebuffers.
Definition TexturedTrianglesRendererBackup.h:187
std::unordered_map< Index32, Rendering::TextureFramebufferRef > TextureFramebufferMap
Definition of an unordered map mapping mesh ids to texture framebuffers.
Definition TexturedTrianglesRendererBackup.h:47
Rendering::FrameTexture2DRef texture_
The frame texture holding the texture information for the triangles.
Definition TexturedTrianglesRendererBackup.h:160
Vectors3 reusableVertices_
Reusable vertices.
Definition TexturedTrianglesRendererBackup.h:172
static const char * programVertexShader_
The vertex shader part.
Definition TexturedTrianglesRendererBackup.h:181
static const char * programFragmentShader_
The fragment shader part.
Definition TexturedTrianglesRendererBackup.h:184
void release()
Explicitly releases this renderer and releases all resources.
bool render(const Rendering::Engine &engine, const HashableTriangle *triangles, const unsigned int numberTriangles, const AnyCamera &anyCamera, const SquareMatrix4 &projectionMatrix, const HomogenousMatrix4 &world_T_camera, const Rendering::TextureFramebufferRef &visibleTrianglesFramebuffer, const TextureAtlas &textureAtlas)
Renders textured triangles into a texture atlas.
Rendering::TrianglesRef triangles_
The renderer's own triangles.
Definition TexturedTrianglesRendererBackup.h:166
Indices32 meshIds() const
Returns the ids of all textured meshes.
bool update(const Rendering::Engine &engine, Frame &&rgbFrame)
Updates this renderer with a new live frame which will be used as source texture.
bool renderMesh(const Rendering::Engine &engine, const Index32 meshId, const Vectors3 &vertices, const Vectors2 &textureCoordinates, const Rendering::TextureFramebufferRef &textureFramebuffer, const Rendering::TextureRef &texture, const TextureAtlas &textureAtlas)
Renders textured triangles into a texture atlas.
bool latestTexture(const Index32 meshId, Frame &textureFrame) const
Returns the latest texture atlas image for a specified mesh.
Frame stateFrame_
The internal state frame.
Definition TexturedTrianglesRendererBackup.h:169
TextureFramebufferMap textureFramebufferMap_
The map of texture framebuffers, one for each mesh id.
Definition TexturedTrianglesRendererBackup.h:157
static const char * partPlatform_
The platform-specific shader part.
Definition TexturedTrianglesRendererBackup.h:178
bool render(const Rendering::Engine &engine, const HashableTriangle *triangles, const unsigned int numberMeshes, const Indices32 &triangleIds, const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_camera, const TextureFramebufferMap &textureFramebufferMap, const Rendering::TextureFramebufferRef &renderedMeshFramebuffer, const TextureAtlas &textureAtlas)
Renders textured triangles into a texture atlas.
Rendering::VertexSetRef vertexSet_
The renderer's own vertex set.
Definition TexturedTrianglesRendererBackup.h:163
Vectors2 reusableTextureCoordinates_
Reusable texture coordinates.
Definition TexturedTrianglesRendererBackup.h:175
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
The namespace covering the entire Ocean framework.
Definition Accessor.h:15