QGIS API Documentation 3.41.0-Master (cea29feecf2)
|
3 More...
#include <qgs3dutils.h>
Static Public Member Functions | |
static QByteArray | addDefinesToShaderCode (const QByteArray &shaderCode, const QStringList &defines) |
Inserts some define macros into a shader source code. | |
static Qgis::AltitudeBinding | altBindingFromString (const QString &str) |
Converts a string to a value from AltitudeBinding enum. | |
static QString | altBindingToString (Qgis::AltitudeBinding altBind) |
Converts a value from AltitudeBinding enum to a string. | |
static Qgis::AltitudeClamping | altClampingFromString (const QString &str) |
Converts a string to a value from AltitudeClamping enum. | |
static QString | altClampingToString (Qgis::AltitudeClamping altClamp) |
Converts a value from AltitudeClamping enum to a string. | |
static double | calculateEntityGpuMemorySize (Qt3DCore::QEntity *entity) |
Calculates approximate usage of GPU memory by an entity. | |
static QImage | captureSceneDepthBuffer (QgsAbstract3DEngine &engine, Qgs3DMapScene *scene) |
Captures the depth buffer of the current 3D scene of a 3D engine. | |
static QImage | captureSceneImage (QgsAbstract3DEngine &engine, Qgs3DMapScene *scene) |
Captures image of the current 3D scene of a 3D engine. | |
static QHash< QgsMapLayer *, QVector< QgsRayCastingUtils::RayHit > > | castRay (Qgs3DMapScene *scene, const QgsRay3D &ray, const QgsRayCastingUtils::RayCastContext &context) |
Casts a ray through the scene and returns information about the intersecting entities (ray uses World coordinates). | |
static float | clampAltitude (const QgsPoint &p, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, float offset, const QgsPoint ¢roid, const Qgs3DRenderContext &context) |
Clamps altitude of a vertex according to the settings, returns Z value. | |
static void | clampAltitudes (QgsLineString *lineString, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, const QgsPoint ¢roid, float offset, const Qgs3DRenderContext &context) |
Clamps altitude of vertices of a linestring according to the settings. | |
static bool | clampAltitudes (QgsPolygon *polygon, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, float offset, const Qgs3DRenderContext &context) |
Clamps altitude of vertices of a polygon according to the settings. | |
static void | computeBoundingBoxNearFarPlanes (const QgsAABB &bbox, const QMatrix4x4 &viewMatrix, float &fnear, float &ffar) |
This routine computes nearPlane farPlane from the closest and farthest corners point of bounding box bbox. | |
static std::unique_ptr< QgsPointCloudLayer3DRenderer > | convert2DPointCloudRendererTo3D (QgsPointCloudRenderer *renderer) |
Creates a QgsPointCloudLayer3DRenderer matching the symbol settings of a given QgsPointCloudRenderer. | |
static Qgs3DTypes::CullingMode | cullingModeFromString (const QString &str) |
Converts a string to a value from CullingMode enum. | |
static QString | cullingModeToString (Qgs3DTypes::CullingMode mode) |
Converts a value from CullingMode enum to a string. | |
static double | decodeDepth (const QRgb &pixel) |
Decodes the depth value from the pixel's color value The depth value is encoded from OpenGL side (the depth render pass) into the 3 RGB channels to preserve precision. | |
static void | decomposeTransformMatrix (const QMatrix4x4 &matrix, QVector3D &translation, QQuaternion &rotation, QVector3D &scale) |
Tries to decompose a 4x4 transform matrix into translation, rotation and scale components. | |
static void | estimateVectorLayerZRange (QgsVectorLayer *layer, double &zMin, double &zMax) |
Try to estimate range of Z values used in the given vector layer and store that in zMin and zMax. | |
static bool | exportAnimation (const Qgs3DAnimationSettings &animationSettings, Qgs3DMapSettings &mapSettings, int framesPerSecond, const QString &outputDirectory, const QString &fileNameTemplate, const QSize &outputSize, QString &error, QgsFeedback *feedback=nullptr) |
Captures 3D animation frames to the selected folder. | |
static void | extractPointPositions (const QgsFeature &f, const Qgs3DRenderContext &context, const QgsVector3D &chunkOrigin, Qgis::AltitudeClamping altClamp, QVector< QVector3D > &positions) |
Calculates (x,y,z) positions of (multi)point from the given feature. | |
static QgsExpressionContext | globalProjectLayerExpressionContext (QgsVectorLayer *layer) |
Returns expression context for use in preparation of 3D data of a layer. | |
static bool | isCullable (const QgsAABB &bbox, const QMatrix4x4 &viewProjectionMatrix) |
Returns true if bbox is completely outside the current viewing volume. | |
static QgsAABB | layerToWorldExtent (const QgsRectangle &extent, double zMin, double zMax, const QgsCoordinateReferenceSystem &layerCrs, const QgsVector3D &mapOrigin, const QgsCoordinateReferenceSystem &mapCrs, const QgsCoordinateTransformContext &context) |
Converts extent (in map layer's CRS) to axis aligned bounding box in 3D world coordinates. | |
static QgsVector3D | mapToWorldCoordinates (const QgsVector3D &mapCoords, const QgsVector3D &origin) |
Converts map coordinates to 3D world coordinates (applies offset) | |
static QgsAABB | mapToWorldExtent (const QgsBox3D &box3D, const QgsVector3D &mapOrigin) |
Converts 3D box in map coordinates to AABB in world coordinates. | |
static QgsAABB | mapToWorldExtent (const QgsRectangle &extent, double zMin, double zMax, const QgsVector3D &mapOrigin) |
Converts map extent to axis aligned bounding box in 3D world coordinates. | |
static QString | matrix4x4toString (const QMatrix4x4 &m) |
Converts a 4x4 transform matrix to a string. | |
static int | maxZoomLevel (double tile0width, double tileResolution, double maxError) |
Calculates the highest needed zoom level for tiles in quad-tree given width of the base tile (zoom level 0) in map units, resolution of the tile (e.g. | |
static int | openGlMaxClipPlanes (QSurface *surface) |
Gets the maximum number of clip planes that can be used. | |
static QgsPhongMaterialSettings | phongMaterialFromQt3DComponent (Qt3DExtras::QPhongMaterial *material) |
Returns phong material settings object based on the Qt3D material. | |
static void | pitchAndYawFromViewVector (QVector3D vect, double &pitch, double &yaw) |
Function used to extract the pitch and yaw (also known as heading) angles in degrees from the view vector of the camera [cameraViewCenter - cameraPosition]. | |
static Qt3DRender::QCullFace::CullingMode | qt3DcullingMode (Qgs3DTypes::CullingMode mode) |
Converts Qgs3DTypes::CullingMode mode into its Qt3D equivalent. | |
static QgsRay3D | rayFromScreenPoint (const QPoint &point, const QSize &windowSize, Qt3DRender::QCamera *camera) |
Convert from clicked point on the screen to a ray in world coordinates. | |
static QByteArray | removeDefinesFromShaderCode (const QByteArray &shaderCode, const QStringList &defines) |
Removes some define macros from a shader source code. | |
static QVector3D | screenPointToWorldPos (const QPoint &screenPoint, double depth, const QSize &screenSize, Qt3DRender::QCamera *camera) |
Converts the clicked mouse position to the corresponding 3D world coordinates. | |
static float | screenSpaceError (float epsilon, float distance, int screenSize, float fov) |
This routine approximately calculates how an error (epsilon) of an object in world coordinates at given distance (between camera and the object) will look like in screen coordinates. | |
static QVector2D | screenToTextureCoordinates (QVector2D screenXY, QSize winSize) |
Converts from screen coordinates to texture coordinates. | |
static QMatrix4x4 | stringToMatrix4x4 (const QString &str) |
Convert a string to a 4x4 transform matrix. | |
static QVector2D | textureToScreenCoordinates (QVector2D textureXY, QSize winSize) |
Converts from texture coordinates coordinates to screen coordinates. | |
static QgsVector3D | transformWorldCoordinates (const QgsVector3D &worldPoint1, const QgsVector3D &origin1, const QgsCoordinateReferenceSystem &crs1, const QgsVector3D &origin2, const QgsCoordinateReferenceSystem &crs2, const QgsCoordinateTransformContext &context) |
Transforms a world point from (origin1, crs1) to (origin2, crs2) | |
static QgsRectangle | tryReprojectExtent2D (const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs1, const QgsCoordinateReferenceSystem &crs2, const QgsCoordinateTransformContext &context) |
Reprojects extent from crs1 to crs2 coordinate reference system with context context. | |
static QgsRectangle | worldToLayerExtent (const QgsAABB &bbox, const QgsCoordinateReferenceSystem &layerCrs, const QgsVector3D &mapOrigin, const QgsCoordinateReferenceSystem &mapCrs, const QgsCoordinateTransformContext &context) |
Converts axis aligned bounding box in 3D world coordinates to extent in map layer CRS. | |
static QgsVector3D | worldToMapCoordinates (const QgsVector3D &worldCoords, const QgsVector3D &origin) |
Converts 3D world coordinates to map coordinates (applies offset) | |
static QgsRectangle | worldToMapExtent (const QgsAABB &bbox, const QgsVector3D &mapOrigin) |
Converts axis aligned bounding box in 3D world coordinates to extent in map coordinates. | |
3
Miscellaneous utility functions used from 3D code.
Definition at line 58 of file qgs3dutils.h.
|
static |
Inserts some define macros into a shader source code.
shaderCode | shader code |
defines | list of defines to add |
Definition at line 908 of file qgs3dutils.cpp.
|
static |
Converts a string to a value from AltitudeBinding enum.
Definition at line 304 of file qgs3dutils.cpp.
|
static |
Converts a value from AltitudeBinding enum to a string.
Definition at line 291 of file qgs3dutils.cpp.
|
static |
Converts a string to a value from AltitudeClamping enum.
Definition at line 280 of file qgs3dutils.cpp.
|
static |
Converts a value from AltitudeClamping enum to a string.
Definition at line 265 of file qgs3dutils.cpp.
|
static |
Calculates approximate usage of GPU memory by an entity.
Definition at line 150 of file qgs3dutils.cpp.
|
static |
Captures the depth buffer of the current 3D scene of a 3D engine.
The function waits until the scene is not fully loaded/updated before capturing the image.
Definition at line 105 of file qgs3dutils.cpp.
|
static |
Captures image of the current 3D scene of a 3D engine.
The function waits until the scene is not fully loaded/updated before capturing the image.
Definition at line 61 of file qgs3dutils.cpp.
|
static |
Casts a ray through the scene and returns information about the intersecting entities (ray uses World coordinates).
The resulting hits are grouped by layer in a QHash.
Definition at line 823 of file qgs3dutils.cpp.
|
static |
Clamps altitude of a vertex according to the settings, returns Z value.
Definition at line 340 of file qgs3dutils.cpp.
|
static |
Clamps altitude of vertices of a linestring according to the settings.
Definition at line 376 of file qgs3dutils.cpp.
|
static |
Clamps altitude of vertices of a polygon according to the settings.
Definition at line 426 of file qgs3dutils.cpp.
|
static |
This routine computes nearPlane farPlane from the closest and farthest corners point of bounding box bbox.
In case of error, fnear will equal 1e9 and ffar 0.
bbox | in world coordinates |
viewMatrix | camera view matrix |
fnear | near plane |
ffar | far plane |
Definition at line 874 of file qgs3dutils.cpp.
|
static |
Creates a QgsPointCloudLayer3DRenderer matching the symbol settings of a given QgsPointCloudRenderer.
Definition at line 777 of file qgs3dutils.cpp.
|
static |
Converts a string to a value from CullingMode enum.
Definition at line 328 of file qgs3dutils.cpp.
|
static |
Converts a value from CullingMode enum to a string.
Definition at line 312 of file qgs3dutils.cpp.
|
inlinestatic |
Decodes the depth value from the pixel's color value The depth value is encoded from OpenGL side (the depth render pass) into the 3 RGB channels to preserve precision.
Definition at line 237 of file qgs3dutils.h.
|
static |
Tries to decompose a 4x4 transform matrix into translation, rotation and scale components.
It is expected that the matrix has been created by only applying these transforms, otherwise the results are undefined.
Definition at line 944 of file qgs3dutils.cpp.
|
static |
Try to estimate range of Z values used in the given vector layer and store that in zMin and zMax.
The implementation scans a small amount of features and looks at the Z values of geometries (we don't need exact range, just a rough estimate is fine to know where to expect the data to be). For layers with geometries without Z values, the returned range will be [0, 0].
Definition at line 667 of file qgs3dutils.cpp.
|
static |
Captures 3D animation frames to the selected folder.
animationSettings | Settings for keyframes and camera |
mapSettings | 3d map settings |
framesPerSecond | number of frames per second to export |
outputDirectory | output directory where to export frames |
fileNameTemplate | template for exporting the frames. Must be in format prefix####.format, where number of |
e.g. my###.jpg will create frames my001.jpg, my002.jpg, etc
outputSize | size of the frame in pixels |
error | error string in case of failure |
feedback | optional feedback object used to cancel export or report progress |
Definition at line 166 of file qgs3dutils.cpp.
|
static |
Calculates (x,y,z) positions of (multi)point from the given feature.
Definition at line 482 of file qgs3dutils.cpp.
|
static |
Returns expression context for use in preparation of 3D data of a layer.
Definition at line 701 of file qgs3dutils.cpp.
|
static |
Returns true
if bbox is completely outside the current viewing volume.
coarse box vs frustum test for culling.
This is used to perform object culling checks.
corners of oriented box are transformed to clip space and there is a test that all points are on the wrong side of the same plane see http://www.lighthouse3d.com/tutorials/view-frustum-culling/geometric-approach-testing-boxes/
should be equivalent to https://searchcode.com/codesearch/view/35195518/ qt3d /src/threed/painting/qglpainter.cpp bool QGLPainter::isCullable(const QBox3D& box) const
Definition at line 557 of file qgs3dutils.cpp.
|
static |
Converts extent (in map layer's CRS) to axis aligned bounding box in 3D world coordinates.
Definition at line 604 of file qgs3dutils.cpp.
|
static |
Converts map coordinates to 3D world coordinates (applies offset)
Definition at line 573 of file qgs3dutils.cpp.
|
static |
Converts 3D box in map coordinates to AABB in world coordinates.
Definition at line 626 of file qgs3dutils.cpp.
|
static |
Converts map extent to axis aligned bounding box in 3D world coordinates.
Definition at line 616 of file qgs3dutils.cpp.
|
static |
Converts a 4x4 transform matrix to a string.
Definition at line 462 of file qgs3dutils.cpp.
|
static |
Calculates the highest needed zoom level for tiles in quad-tree given width of the base tile (zoom level 0) in map units, resolution of the tile (e.g.
tile's texture width) and desired maximum error in map units.
Definition at line 252 of file qgs3dutils.cpp.
|
static |
Gets the maximum number of clip planes that can be used.
This value depends on the OpenGL implementation. It should be at least 6.
Definition at line 971 of file qgs3dutils.cpp.
|
static |
Returns phong material settings object based on the Qt3D material.
Definition at line 710 of file qgs3dutils.cpp.
|
static |
Function used to extract the pitch and yaw (also known as heading) angles in degrees from the view vector of the camera [cameraViewCenter - cameraPosition].
Definition at line 759 of file qgs3dutils.cpp.
|
static |
Converts Qgs3DTypes::CullingMode mode into its Qt3D equivalent.
mode | culling mode |
Definition at line 891 of file qgs3dutils.cpp.
|
static |
Convert from clicked point on the screen to a ray in world coordinates.
Definition at line 720 of file qgs3dutils.cpp.
|
static |
Removes some define macros from a shader source code.
shaderCode | shader code |
defines | list of defines to remove |
Definition at line 927 of file qgs3dutils.cpp.
|
static |
Converts the clicked mouse position to the corresponding 3D world coordinates.
Definition at line 746 of file qgs3dutils.cpp.
|
static |
This routine approximately calculates how an error (epsilon) of an object in world coordinates at given distance (between camera and the object) will look like in screen coordinates.
epsilon | error in world coordinates |
distance | distance between camera and object |
screenSize | screen width or height in pixels |
fov | camera's field of view in degrees |
Definition at line 848 of file qgs3dutils.cpp.
|
static |
Converts from screen coordinates to texture coordinates.
Definition at line 767 of file qgs3dutils.cpp.
|
static |
Convert a string to a 4x4 transform matrix.
Definition at line 472 of file qgs3dutils.cpp.
|
static |
Converts from texture coordinates coordinates to screen coordinates.
Definition at line 772 of file qgs3dutils.cpp.
|
static |
Transforms a world point from (origin1, crs1) to (origin2, crs2)
Definition at line 646 of file qgs3dutils.cpp.
|
static |
Reprojects extent from crs1 to crs2 coordinate reference system with context context.
If crs1 and crs2 are identical, extent is returned.
extent | extent to reproject |
crs1 | source coordinate reference system |
crs2 | destination coordinate reference system |
context | the context under which the transform is applied |
Definition at line 583 of file qgs3dutils.cpp.
|
static |
Converts axis aligned bounding box in 3D world coordinates to extent in map layer CRS.
Definition at line 610 of file qgs3dutils.cpp.
|
static |
Converts 3D world coordinates to map coordinates (applies offset)
Definition at line 578 of file qgs3dutils.cpp.
|
static |
Converts axis aligned bounding box in 3D world coordinates to extent in map coordinates.
Definition at line 636 of file qgs3dutils.cpp.