1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3 @page renderer_usecase3 Maps Renderer
5 @note SW Release Applicability: This tutorial is applicable to modules in **NVIDIA DRIVE Software** releases.
8 - renders map data contained in the NVIDIA<sup>®</sup> DriveWorks Maps module
9 - renders objects defined in WGS84 coordinates on top of the map
11 It uses the Render Engine to render the data.
19 // init maps renderer module
20 dwMapsRenderer_initialize(...);
25 // orthographic top down rendering
28 // select render engine tile
29 dwRenderEngine_setTile(...)
31 // setup camera for top down view onto map data
32 dwMapsRenderer_setTopDownProjection(...); // camera zoom
33 dwMapsRenderer_setTopDownModelView(...); // camera position
36 dwMapsRenderer_renderMap(...)
37 dwMapsRenderer_renderLanePlan(...)
38 dwMapsRenderer_renderPolylines(...)
39 dwMapsRenderer_renderOrientedBox(...)
40 dwMapsRenderer_renderBox(...)
45 // perspective rendering
48 // select render engine tile
49 dwRenderEngine_setTile(...)
52 dwRenderEngine_setPerspectiveProjection(...)
54 // set camera position and orientation
55 dwMapsRenderer_setLookAt(...)
58 dwMapsRenderer_renderMap(...)
59 dwMapsRenderer_renderLanePlan(...)
60 dwMapsRenderer_renderPolylines(...)
61 dwMapsRenderer_renderOrientedBox(...)
62 dwMapsRenderer_renderBox(...)
66 dwMapsRenderer_release(...);
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.
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);
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.
93 The Maps Renderer provides the following render functions:
96 dwMapsRenderer_renderMap
99 Renders all map lane dividers.
103 dwMapsRenderer_renderLanePlan
106 Render the lines of a lane plan from the DriveWorks Lane Planner module.
110 dwMapsRenderer_renderGeoPolylines
113 Render a list of polylines of WGS84 points.
117 dwMapsRenderer_renderOrientedGeoBox
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.
124 dwMapsRenderer_renderGeoBox
127 Render an axis-aligned square box defined by a WGS84 point and a size in meters, optionally with a center cross.
132 There are helper functions to set up projection and modelview matrices.
135 dwMapsRenderer_setTopDownProjection
138 Set the projection matrix in the renderEngine tile such that the active tile height covers a given distance of map data in meters.
142 dwMapsRenderer_setTopDownModelView
145 Set the modelView matrix in the renderEngine tile such that the given WGS84 coordinate is in the tile center.
149 dwMapsRenderer_moveTopDownModelView
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.
156 dwMapsRenderer_setLookAt
159 Set up the modelView matrix such that the camera is at a given WGS84 point, looking towards another WGS84 point.
164 There are helper functions to check whether a screen pixel is within a box that is defined by WGS84 coordinates:
167 dwMapsRenderer_isPixelCoordInOrientedBox
168 dwMapsRenderer_isPixelCoordInBox
172 ## Coordinate Queries
174 There are helper functions to transform between different coordinates.
177 dwMapsRenderer_getRenderCoord
180 Returns the internally used render coordinate of a WGS84 point. This can be used to externally render lines into the same coordinate system.
184 dwMapsRenderer_getWGS84CoordFromRenderCoord
187 Returns the WGS84 coordinate for a point given in the internal render coordinate system.
191 dwMapsRenderer_getWGS84Coord
194 Returns the WGS84 coordinate that corresponds to a screen pixel. This can be used to localize mouse clicks on the screen, for example.
198 dwMapsRenderer_getWGS84CoordNDC
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.
203 For more information see @ref dwx_hd_map_access_sample .