DriveWorks SDK Reference
3.5.78 Release
For Test and Development only

/dvs/git/dirty/gitlab-master_av/dw/sdk/src/dwvisualization/maps/mapsrenderer/docs/usecase1.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
2 
3 @page renderer_usecase3 Maps Renderer
4 
5 @note SW Release Applicability: This tutorial is applicable to modules in **NVIDIA DRIVE Software** releases.
6 
7 The Maps Renderer
8 - renders map data contained in the NVIDIA<sup>&reg;</sup> DriveWorks Maps module
9 - renders objects defined in WGS84 coordinates on top of the map
10 
11 It uses the Render Engine to render the data.
12 
13 
14 ## General Usage
15 
16 ```{.cpp}
17  // init map
18 
19  // init maps renderer module
20  dwMapsRenderer_initialize(...);
21 
22  while (...)
23  {
24  //
25  // orthographic top down rendering
26  //
27 
28  // select render engine tile
29  dwRenderEngine_setTile(...)
30 
31  // setup camera for top down view onto map data
32  dwMapsRenderer_setTopDownProjection(...); // camera zoom
33  dwMapsRenderer_setTopDownModelView(...); // camera position
34 
35  // render
36  dwMapsRenderer_renderMap(...)
37  dwMapsRenderer_renderLanePlan(...)
38  dwMapsRenderer_renderPolylines(...)
39  dwMapsRenderer_renderOrientedBox(...)
40  dwMapsRenderer_renderBox(...)
41 
42 
43 
44  //
45  // perspective rendering
46  //
47 
48  // select render engine tile
49  dwRenderEngine_setTile(...)
50 
51  // set camera zoom
52  dwRenderEngine_setPerspectiveProjection(...)
53 
54  // set camera position and orientation
55  dwMapsRenderer_setLookAt(...)
56 
57  // render
58  dwMapsRenderer_renderMap(...)
59  dwMapsRenderer_renderLanePlan(...)
60  dwMapsRenderer_renderPolylines(...)
61  dwMapsRenderer_renderOrientedBox(...)
62  dwMapsRenderer_renderBox(...)
63  }
64 
65  // release module
66  dwMapsRenderer_release(...);
67 ```
68 
69 
70 ## Initialization
71 
72 The Maps Renderer is initialized with a map handle of the DriveWorks Maps module and initializes a render buffer using the Render Engine. That render buffer gets filled with lines for all lane dividers in the map. Additionally, a buffer gets allocated for additional renderings during runtime. The user has to specify the maximum number of lines that will be needed during one of the render calls that render additional data (all render calls other than dwMapsRenderer_renderMap()).
73 Also, it can be chosen whether the line directions of the map should be visible, so that it can be seen where lines start and end. When setting `showMapLineDirections` to true, the lines will be shaded (darker to brighter) to show the line directions.
74 
75 ```{.cpp}
76 dwStatus dwMapsRenderer_initialize(dwMapsRendererHandle_t* mapsRenderer,
77  uint32_t maxRenderBufferLineCount,
78  uint32_t maxRenderBufferPointCount,
79  bool showMapLineDirections,
80  dwRenderEngineHandle_t renderEngine,
81  dwConstMapHandle_t map);
82 ```
83 
84 
85 ## dwRenderEngine
86 
87 The Maps Renderer uses the Render Engine. It renders any lines with the current setting of the Render Engine. That means, it renders into the active tile, using its projection and modelView matrix and with line width settings. Color handling is different depending on the render call. There are helper functions to set up the projection and modelView matrices for the Maps Renderer.
88 
89 
90 
91 ## Render Functions
92 
93 The Maps Renderer provides the following render functions:
94 
95 ```{.cpp}
96 dwMapsRenderer_renderMap
97 ```
98 
99 Renders all map lane dividers.
100 
101 
102 ```{.cpp}
103 dwMapsRenderer_renderLanePlan
104 ```
105 
106 Render the lines of a lane plan from the DriveWorks Lane Planner module.
107 
108 
109 ```{.cpp}
110 dwMapsRenderer_renderGeoPolylines
111 ```
112 
113 Render a list of polylines of WGS84 points.
114 
115 
116 ```{.cpp}
117 dwMapsRenderer_renderOrientedGeoBox
118 ```
119 
120 Render an oriented box, defined by a WGS84 point, a bearing (clockwise angle to north) in radian, length and width in meters, optionally with a center cross and/or an arrow towards the bearing direction.
121 
122 
123 ```{.cpp}
124 dwMapsRenderer_renderGeoBox
125 ```
126 
127 Render an axis-aligned square box defined by a WGS84 point and a size in meters, optionally with a center cross.
128 
129 
130 ## Camera setup
131 
132 There are helper functions to set up projection and modelview matrices.
133 
134 ```{.cpp}
135 dwMapsRenderer_setTopDownProjection
136 ```
137 
138 Set the projection matrix in the renderEngine tile such that the active tile height covers a given distance of map data in meters.
139 
140 
141 ```{.cpp}
142 dwMapsRenderer_setTopDownModelView
143 ```
144 
145 Set the modelView matrix in the renderEngine tile such that the given WGS84 coordinate is in the tile center.
146 
147 
148 ```{.cpp}
149 dwMapsRenderer_moveTopDownModelView
150 ```
151 
152 Move the modelView matrix by a given delta in meters. This assumes the current modelView matrix is already set up for top-down orthographic view.
153 
154 
155 ```{.cpp}
156 dwMapsRenderer_setLookAt
157 ```
158 
159 Set up the modelView matrix such that the camera is at a given WGS84 point, looking towards another WGS84 point.
160 
161 
162 ## Pixel Queries
163 
164 There are helper functions to check whether a screen pixel is within a box that is defined by WGS84 coordinates:
165 
166 ```{.cpp}
167 dwMapsRenderer_isPixelCoordInOrientedBox
168 dwMapsRenderer_isPixelCoordInBox
169 ```
170 
171 
172 ## Coordinate Queries
173 
174 There are helper functions to transform between different coordinates.
175 
176 ```{.cpp}
177 dwMapsRenderer_getRenderCoord
178 ```
179 
180 Returns the internally used render coordinate of a WGS84 point. This can be used to externally render lines into the same coordinate system.
181 
182 
183 ```{.cpp}
184 dwMapsRenderer_getWGS84CoordFromRenderCoord
185 ```
186 
187 Returns the WGS84 coordinate for a point given in the internal render coordinate system.
188 
189 
190 ```{.cpp}
191 dwMapsRenderer_getWGS84Coord
192 ```
193 
194 Returns the WGS84 coordinate that corresponds to a screen pixel. This can be used to localize mouse clicks on the screen, for example.
195 
196 
197 ```{.cpp}
198 dwMapsRenderer_getWGS84CoordNDC
199 ```
200 
201 Returns the WGS84 coordinate that corresponds to a Normalized Display Coordinate system, with (0,0) in the center of the screen, going from (-1,-1) to (1,1). This can be helpful when selecting a point at a given position on the screen, e.g. screen center.
202 
203 For more information see @ref dwx_hd_map_access_sample .