Maria GDK 5.0.0.738
Documentation of native code in develop branch
Loading...
Searching...
No Matches
Maria3D::Globe Class Reference

#include <M3DGlobe.h>

Inheritance diagram for Maria3D::Globe:
STK::GraphicsModel

Classes

struct  TerrainShader
 

Public Member Functions

 Globe (std::shared_ptr< STK::ShaderProgramManager > shaderManager, const std::shared_ptr< STK::FontManager > &fontManager, std::shared_ptr< LocalOrigin > origin, std::shared_ptr< Maria::SystemTicker >systemTicker, std::shared_ptr< Maria::TileCacheManager > tile_cache_mgr, const Maria3D::Configuration &config)
 
bool initShaders ()
 
void setMapTemplateXml (const std::string &xml)
 
bool setMapTemplate (const Maria::MapTemplate &tpl)
 
bool setElevationTemplateXml (const std::string &xml)
 
bool setElevationTemplate (const Maria::MapTemplate &tpl)
 
bool updateAndCull (const STK::Camera &cam, const STK::Viewport &vp)
 
void drawRenderTiles (const STK::Camera &cam, const std::vector< std::shared_ptr< STK::Uniform > > *uniforms)
 
void redraw (const STK::Camera &cam, const STK::Viewport &vp, int render_mask=STK::OpaqueMask, const std::vector< std::shared_ptr< STK::Uniform > > *uniforms=nullptr)
 
virtual void drawShadowMap (const STK::Camera &cam, const STK::Viewport &vp, const STK::Camera &shd_cam, const STK::Viewport &shd_vp, STK::ShaderProgram *shader, STK::ShaderProgram *tex_shader)
 
virtual void calcBoundingSphere (STK::Vector3f &center, double &radius)
 
bool needsRedraw () const
 
virtual void calcBoundingBox (STK::Vector3f &min, STK::Vector3f &max)
 
void clearRenderData (bool keepCurrentFrame=false)
 
void clearRenderLists ()
 
const QuadTilegetRenderRoot () const
 
QuadTilefindRenderTileLatLon (double lat, double lon, int level)
 
void setTileErrorScale (float scale)
 
float getTileErrorScale () const
 
std::shared_ptr< MapTextureDatagetTextureData (QuadTile *tile)
 
std::shared_ptr< TextureDatagetNormalMapData (QuadTile *tile)
 
std::shared_ptr< GeometryDatagetGeometryData (QuadTile *tile)
 
std::shared_ptr< GeometryDatagetReadyGeometryData (QuadTile *tile)
 
std::shared_ptr< GeometryDatageometryLoadSync (const QuadTile *tile, long timeout_ms=0)
 
std::shared_ptr< GeometryDatageometryLoadAsync (const QuadTile *tile)
 
std::shared_ptr< TextureDatanormalMapLoadSync (const QuadTile *tile, long timeout_ms=0)
 
std::shared_ptr< TextureDatanormalMapLoadAsync (const QuadTile *tile)
 
double calcVisualElevation (double lat, double lon, double pixelSize)
 
std::shared_ptr< const LocalOrigingetLocalOrigin () const
 
std::shared_ptr< LocalOrigingetLocalOrigin ()
 
int getMaxTreeLevel (const QuadCoo &quad) const
 
int getMaxTreeLevelXY (M3DIntCoord x, M3DIntCoord y) const
 
int getMaxTextureLevel (const QuadCoo &quad) const
 
int getMaxNormalMapLevel (const QuadCoo &quad) const
 
void clearTextureLayer ()
 
const std::vector< std::shared_ptr< TileRender > > & GetCurrentRenderTiles () const
 
std::shared_ptr< MapTextureDatacreateTextureData (QuadTile *tile)
 
void getIndexBuffers (unsigned short renderMask, GLuint *indexBuffers, int *numIndexes) const
 
GLuint getIndexBuffer (int childId) const
 Get index buffer ID for child index.
 
int getIndexBufferSize (int childId) const
 Get size of index buffer for child index.
 
const std::vector< uint16_t > & getCollisionIndexArray () const
 
void setOverlay (const Maria::MapContentQuery &mcq)
 
void removeOverlay ()
 
bool hasOverlay () const
 
std::shared_ptr< Maria::ElevationDatagetElevationData () const
 
void generateTextures (QuadTile *root, int numChildLevels, long maxTimeMs)
 
void setMapLabelTemplateXml (const std::string &xml)
 
void setMapLabelTemplate (const Maria::MapTemplate &tpl)
 
void drawLabels (const STK::Camera &cam, const STK::Viewport &vp)
 
std::shared_ptr< LabelRenderergetLabelRenderer () const
 
bool calcRayIntersection (const STK::Vector3d &pos, const STK::Vector3d &dir, STK::Vector3d &intersection)
 
void calcFootprintTextures (const std::shared_ptr< ISceneryModels > &models, std::shared_ptr< FootprintTextureManager > &footprintTextureManager, bool forceFootprintMasking)
 
std::shared_ptr< Maria::SystemTickergetSystemTicker () const
 
void calcIntersectingGeometry (const STK::Vector3d &pos, const STK::Vector3d &dir, std::vector< std::shared_ptr< GeometryData > > &tiles)
 
std::shared_ptr< GeometryDatacalcFinestGeometryTile (double lat, double lon, int maxlevel, bool load_data=true)
 Get the finest available tile with geometry data in the given location.
 
bool useHeightAboveEllipsoid () const
 
void setHeightAboveEllipsoid (bool geoidCorrection)
 
void setForestData (const Configuration &config, const std::shared_ptr< STK::TextureManager > &texManager)
 
- Public Member Functions inherited from STK::GraphicsModel
 GraphicsModel (const std::string &name="")
 
void setName (const std::string &name)
 
const std::string & getName () const
 
virtual void filterChildren (const filter_fn &fn, std::vector< std::shared_ptr< GraphicsModel > > &matched)
 
void setTransform (const STK::Matrix4x4f &transform)
 
const STK::Matrix4x4fgetTransform () const
 
void setEnvironmentMap (const std::shared_ptr< STK::CubeMap > &env_map)
 
std::shared_ptr< STK::CubeMapgetEnvironmentMap ()
 
std::shared_ptr< const STK::CubeMapgetEnvironmentMap () const
 
void setWireframe (bool wireframe)
 
bool getWireframe () const
 
void setInvisible (bool invisible)
 
bool getInvisible () const
 
void setCastShadows (bool cast_shadows)
 
bool getCastShadows () const
 
void setDebugGraphics (bool debug_gfx)
 
bool getDebugGraphics () const
 
virtual void redraw (const STK::Camera &cam, const STK::Viewport &vp, int render_mask=STK::OpaqueMask, const std::vector< std::shared_ptr< STK::Uniform > > *uniforms=nullptr)=0
 
virtual void drawShadowMap (const STK::Camera &cam, const STK::Viewport &vp, const STK::Camera &shd_cam, const STK::Viewport &shd_vp, STK::ShaderProgram *shader, STK::ShaderProgram *tex_shader)=0
 
virtual void calcBoundingSphere (STK::Vector3f &center, double &radius)=0
 
virtual void calcBoundingBox (STK::Vector3f &min, STK::Vector3f &max)=0
 

Protected Member Functions

QuadTilefindTileXY (QuadTile *root_tile, M3DIntCoord x, M3DIntCoord y, int level)
 
void findFinestGeometryTileXY (QuadTile *tile, M3DIntCoord x, M3DIntCoord y, int level, QuadTile *&best_tile, bool load_data=true)
 
double calcTileError (const QuadCoo &quad)
 
int checkTileVisibility (QuadTile *tile, const STK::Camera &cam, int parent_vis)
 
bool isRenderQuadTreeDirty () const
 
void setRenderQuadTreeDirty (bool dirty)
 
bool refineTile (QuadTile *tile, const STK::Camera &cam, const STK::Viewport &vp, int parent_vis, std::vector< std::shared_ptr< TileRender > > &render_tiles, QuadTile *normal_map_tile, QuadTile *texture_tile)
 
double calcShortestDistance (QuadTile *tile, const STK::Camera &cam)
 
void genPrefetchTextureList (QuadTile *tile, int numChildLevels, std::vector< std::shared_ptr< MapTextureData > > &textures)
 
double calcTileNormalAngle (QuadTile *tile, const STK::Camera &cam)
 
bool calcIntersectingTiles (QuadTile *tile, const STK::Vector3d &pos, const STK::Vector3d &dir, std::vector< std::shared_ptr< GeometryData > > &tiles)
 
std::shared_ptr< TileRendergetOrCreateTileRender (const QuadCoo &quad, std::shared_ptr< GeometryData > geometry_data, const std::shared_ptr< MapTextureData > &texture_data, const STK::Vector4f &texture_xfm, const std::shared_ptr< TextureData > &normal_map_data, const STK::Vector4f &normal_map_xfm, const std::shared_ptr< TextureData > &overlay_data, unsigned short renderMask)
 
void cleanupRenderTiles ()
 

Protected Attributes

std::shared_ptr< STK::ShaderProgramManager_shaderManager
 
std::shared_ptr< STK::FontManager_fontManager
 
std::shared_ptr< LocalOrigin_localOrigin
 
std::mutex _quadTileMutex
 
QuadTile_renderRoot
 
bool _renderQuadTreeDirty
 
bool _pendingData
 
bool _dirty = false
 
std::shared_ptr< Maria::TileCache_geometryData
 
std::shared_ptr< Maria::TileCache_normalMapData
 
std::shared_ptr< Maria::TileCache_textureData
 
std::shared_ptr< Maria::TileCache_overlayData
 
std::shared_ptr< Maria::TileCache_forestData
 
std::shared_ptr< GeometryDataFactory_geometryDataFactory
 
Maria::MapContentQuery _geometryMapQuery
 
Maria::MapContentQuery _normalMapQuery
 
int _geometryMapResolution
 
int _textureMapResolution
 
int _normalMapResolution
 
bool _heightAboveEllipsoid = true
 
std::shared_ptr< Maria::TileCacheManager_tileCacheManager
 
std::shared_ptr< Maria::ElevationData_elevationData
 
std::shared_ptr< Maria::IMapTileProvider_elevationMapProvider
 
std::shared_ptr< Maria::IMapTileProvider_normalMapProvider
 
std::shared_ptr< Maria::MapLayer_mapRenderer
 
std::vector< std::shared_ptr< MapTextureData > > _updateTextures
 
std::vector< std::shared_ptr< TileRender > > _renderList
 
std::map< Maria::TileId, std::shared_ptr< TileRender > > _tileRenderCache
 
std::shared_ptr< Maria3D::LabelRenderer_labelRenderer
 
std::shared_ptr< MapLabels_mapLabels
 
std::shared_ptr< ForestRendererforest_renderer_
 
int min_forest_level_ = 14
 
int max_forest_level_ = 15
 
int _pendingGeometryData
 
int _pendingNormalData
 
int _pendingTextureData
 
int _pendingOverlayData
 
GLuint texcoord_buffer_id_
 
GLuint index_buffer_id_
 
int index_buffer_size_
 
GLuint subtile_index_buffer_id_ [4]
 
int subtile_index_buffer_size_ [4]
 
std::vector< uint16_t > collision_tri_index_array_
 
TerrainShader _terrainShader
 
TerrainShader _overlayTerrainShader
 
float tile_error_scale_
 
std::shared_ptr< Maria::SystemTicker_systemTicker
 
int64_t _frameTimestamp
 
const int _maxRenderTiles = 1000
 
- Protected Attributes inherited from STK::GraphicsModel
std::string name_
 
STK::Matrix4x4f transform_
 
std::shared_ptr< STK::CubeMapenv_map_
 
bool wireframe_
 
bool invisible_
 
bool cast_shadows_
 
bool debug_gfx_
 

Additional Inherited Members

- Public Types inherited from STK::GraphicsModel
using filter_fn = std::function< bool(const GraphicsModel &)>
 

Detailed Description

Globe - Main rendering class for the global terrain surface. Detailed description.

See also
Class1

Member Function Documentation

◆ calcBoundingBox()

void Globe::calcBoundingBox ( STK::Vector3f min,
STK::Vector3f max 
)
virtual

Implements STK::GraphicsModel.

◆ calcBoundingSphere()

void Globe::calcBoundingSphere ( STK::Vector3f center,
double &  radius 
)
virtual

Implements STK::GraphicsModel.

◆ calcRayIntersection()

bool Globe::calcRayIntersection ( const STK::Vector3d pos,
const STK::Vector3d dir,
STK::Vector3d intersection 
)

Calculate intersection between the currently loaded globe geometry and a ray in geocentric coordinates. Returns true if an intersection was found. The intersecting point is returned in the intersection argument.

◆ calcVisualElevation()

double Globe::calcVisualElevation ( double  lat,
double  lon,
double  pixelSize 
)

Calculate fast approximation of elevation from geometry tiles. This method will calculate the elevation based on the currently visible set of tiles. It assumes that updateAndCull() has been called first. This method will not load any data, and if no tile geometry is available it will simply return 0.0 This method should only be called from the rendering thread.

◆ drawRenderTiles()

void Globe::drawRenderTiles ( const STK::Camera cam,
const std::vector< std::shared_ptr< STK::Uniform > > *  uniforms 
)

Draw the current set of render tiles. This method will render the result of the previous updateAndCull() step.

◆ drawShadowMap()

void Globe::drawShadowMap ( const STK::Camera cam,
const STK::Viewport vp,
const STK::Camera shd_cam,
const STK::Viewport shd_vp,
STK::ShaderProgram shader,
STK::ShaderProgram tex_shader 
)
virtual

Implements STK::GraphicsModel.

◆ geometryLoadAsync()

std::shared_ptr< GeometryData > Globe::geometryLoadAsync ( const QuadTile tile)

Asynchronous loading of tile data. This method will add a load request to the data loader thread and the return immediately.

◆ geometryLoadSync()

std::shared_ptr< GeometryData > Globe::geometryLoadSync ( const QuadTile tile,
long  timeout_ms = 0 
)

Synchronous loading of tile data. This method will block until the requested data has been loaded or optionally until timeout_ms miliseconds have passed. Note that if the request times out, it will not be cancelled and it will remain in pending state.

◆ getElevationData()

std::shared_ptr< Maria::ElevationData > Maria3D::Globe::getElevationData ( ) const
inline

Get the elevation data object used for calculating the globe.

◆ getGeometryData()

std::shared_ptr< GeometryData > Maria3D::Globe::getGeometryData ( QuadTile tile)
inline

Get geometry data either from the tile object or from the data store.

◆ getMaxNormalMapLevel()

int Globe::getMaxNormalMapLevel ( const QuadCoo quad) const

Get the maximum normal map quad tree level for the given quad.

◆ getMaxTextureLevel()

int Globe::getMaxTextureLevel ( const QuadCoo quad) const

Get the maximum texture quad tree level for the given coordinates.

◆ getReadyGeometryData()

std::shared_ptr< GeometryData > Maria3D::Globe::getReadyGeometryData ( QuadTile tile)
inline

Get a ready data object for this tile. Returns the geometry data object for this tile, but only if the data object is ready, i.e. it has been loaded and processed. If no such data object exists, NULL is returned.

◆ getTextureData()

std::shared_ptr< MapTextureData > Maria3D::Globe::getTextureData ( QuadTile tile)
inline

Get texture data from the data store. This method is thread-safe.

◆ initShaders()

bool Globe::initShaders ( )

Set up graphics and shaders. This method requires a valid OpenGL context

◆ normalMapLoadAsync()

std::shared_ptr< TextureData > Globe::normalMapLoadAsync ( const QuadTile tile)

Asynchronous loading of texture data. This method will add a load request to the data loader thread and the return immediately.

◆ normalMapLoadSync()

std::shared_ptr< TextureData > Globe::normalMapLoadSync ( const QuadTile tile,
long  timeout_ms = 0 
)

Synchronous loading of normal map data. This method will block until the requested data has been loaded or optionally until timeout_ms miliseconds have passed. Note that if the request times out, it will not be cancelled and it will remain in pending state.

◆ redraw()

void Globe::redraw ( const STK::Camera cam,
const STK::Viewport vp,
int  render_mask = STK::OpaqueMask,
const std::vector< std::shared_ptr< STK::Uniform > > *  uniforms = nullptr 
)

Draw a frame. This method will call both updateAndCull() and drawRenderTiles(). If you need more control over the update and rendering, you can call these explicitly instead.

◆ removeOverlay()

void Maria3D::Globe::removeOverlay ( )

Remove the overlay layer.

◆ setHeightAboveEllipsoid()

void Globe::setHeightAboveEllipsoid ( bool  geoidCorrection)

Enable geoid correction. This will modify the elevation values in the 3D geometry by the undulation in that location. This is to convert elevations from height above sea level to height above ellipsoid (HAE). For correctly referencing 3D Tiles databases all elevations should be HAE.

◆ setMapTemplateXml()

void Globe::setMapTemplateXml ( const std::string &  xml)

Set up data sources and map layers.

◆ setOverlay()

void Maria3D::Globe::setOverlay ( const Maria::MapContentQuery mcq)

Set up overlay layer with the given map content query. This method will set up an overlay texture layer pulling tiles from the data set specified by the given data query. This is typically used for the tiled draw object layer. This will also set up an overlay label layer, pulling labels from these map tiles and displaying them in 3D.

◆ updateAndCull()

bool Globe::updateAndCull ( const STK::Camera cam,
const STK::Viewport vp 
)

Calculate set of render tiles. This method will calculate the set of rendering tiles based on the camera and viewport parameters.


The documentation for this class was generated from the following files: