cesium-native 0.65.0
Loading...
Searching...
No Matches
ViewState.h
1#pragma once
2
3#include <Cesium3DTilesSelection/BoundingVolume.h>
4#include <Cesium3DTilesSelection/GeneralCullingVolume.h>
5#include <Cesium3DTilesSelection/Library.h>
6#include <CesiumGeometry/CullingVolume.h>
7#include <CesiumGeometry/Plane.h>
8#include <CesiumGeospatial/Cartographic.h>
9#include <CesiumGeospatial/Ellipsoid.h>
10
11#include <glm/mat3x3.hpp>
12#include <glm/mat4x4.hpp>
13#include <glm/vec2.hpp>
14#include <glm/vec3.hpp>
15
16#include <functional>
17#include <memory>
18#include <optional>
19#include <utility>
20
21namespace Cesium3DTilesSelection {
22
23class Tile;
24
31class CESIUM3DTILESSELECTION_API ViewStateMeasureDelegate {
32public:
41 const Tile& tile,
42 double distance,
43 uint32_t depth) const = 0;
47 virtual ~ViewStateMeasureDelegate() = default;
48};
49
55class CESIUM3DTILESSELECTION_API ViewState final {
56
57public:
63 [[deprecated("Use ViewState::ViewState instead.")]] static ViewState create(
64 const glm::dvec3& position,
65 const glm::dvec3& direction,
66 const glm::dvec3& up,
67 const glm::dvec2& viewportSize,
68 double horizontalFieldOfView,
69 double verticalFieldOfView,
70 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
71
89 const glm::dvec3& position,
90 const glm::dvec3& direction,
91 const glm::dvec3& up,
92 const glm::dvec2& viewportSize,
93 double horizontalFieldOfView,
94 double verticalFieldOfView,
95 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
96
111 const glm::dmat4& viewMatrix,
112 const glm::dmat4& projectionMatrix,
113 const glm::dvec2& viewportSize,
114 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
115
134 const glm::dvec3& position,
135 const glm::dvec3& direction,
136 const glm::dvec3& up,
137 const glm::dvec2& viewportSize,
138 double left,
139 double right,
140 double bottom,
141 double top,
142 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
143
159 const BoundingVolume& boundingVolume,
160 std::shared_ptr<ViewStateMeasureDelegate> pMeasureDelegate,
161 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
162
167 const glm::dvec3& getPosition() const noexcept { return this->_position; }
168
173 const glm::dvec3& getDirection() const noexcept { return this->_direction; }
174
179 glm::dvec3 getUp() const noexcept {
180 return {
181 this->_viewMatrix[0][1],
182 this->_viewMatrix[1][1],
183 this->_viewMatrix[2][1]};
184 }
185
192 const std::optional<CesiumGeospatial::Cartographic>&
193 getPositionCartographic() const noexcept {
194 return this->_positionCartographic;
195 }
196
200 const glm::dvec2& getViewportSize() const noexcept {
201 return this->_viewportSize;
202 }
203
208 double getHorizontalFieldOfView() const noexcept;
209
214 double getVerticalFieldOfView() const noexcept;
215
219 const glm::dmat4& getViewMatrix() const noexcept { return this->_viewMatrix; }
220
224 const glm::dmat4& getProjectionMatrix() const noexcept {
225 return this->_projectionMatrix;
226 }
227
238 bool
239 isBoundingVolumeVisible(const BoundingVolume& boundingVolume) const noexcept;
240
251 const BoundingVolume& boundingVolume) const noexcept;
252
267 double computeScreenSpaceError(double geometricError, double distance)
268 const noexcept;
269
290 const Tile& tile,
291 double distance,
292 uint32_t depth) const noexcept;
293
294private:
295 glm::dvec3 _position;
296 glm::dvec3 _direction;
297 glm::dvec2 _viewportSize;
299
300 std::optional<CesiumGeospatial::Cartographic> _positionCartographic;
301
303 glm::dmat4 _viewMatrix;
304 glm::dmat4 _projectionMatrix;
305 std::shared_ptr<ViewStateMeasureDelegate> _pMeasureDelegate;
306};
307
308} // namespace Cesium3DTilesSelection
A tile in a Tileset.
Definition Tile.h:123
A handler for customizing calculation of the selection measure for tiles. By default that value is th...
Definition ViewState.h:31
virtual ~ViewStateMeasureDelegate()=default
destructor
virtual double computeSelectionMeasure(const Tile &tile, double distance, uint32_t depth) const =0
Compute the error measure, a generalization of screen space error.
ViewState(const BoundingVolume &boundingVolume, std::shared_ptr< ViewStateMeasureDelegate > pMeasureDelegate, const CesiumGeospatial::Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84)
Creates a new instance of a view state from a bounding volume associated with a geographic area,...
const glm::dvec3 & getDirection() const noexcept
Gets the look direction of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:173
ViewState(const glm::dvec3 &position, const glm::dvec3 &direction, const glm::dvec3 &up, const glm::dvec2 &viewportSize, double horizontalFieldOfView, double verticalFieldOfView, const CesiumGeospatial::Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84)
Creates a new instance.
double getHorizontalFieldOfView() const noexcept
Gets the horizontal field-of-view angle in radians. This is only valid for a symmetric perspective pr...
double computeDistanceSquaredToBoundingVolume(const BoundingVolume &boundingVolume) const noexcept
Computes the squared distance to the given BoundingVolume.
static ViewState create(const glm::dvec3 &position, const glm::dvec3 &direction, const glm::dvec3 &up, const glm::dvec2 &viewportSize, double horizontalFieldOfView, double verticalFieldOfView, const CesiumGeospatial::Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84)
Creates a new instance of a view state with a symmetric perspective projection.
ViewState(const glm::dmat4 &viewMatrix, const glm::dmat4 &projectionMatrix, const glm::dvec2 &viewportSize, const CesiumGeospatial::Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84)
Creates a new instance of a view state with a general projection, including skewed perspective and or...
double computeScreenSpaceError(double geometricError, double distance) const noexcept
Computes the screen space error from a given geometric error.
const std::optional< CesiumGeospatial::Cartographic > & getPositionCartographic() const noexcept
Gets the position of the camera as a longitude / latitude / height.
Definition ViewState.h:193
const glm::dvec2 & getViewportSize() const noexcept
Gets the size of the viewport in pixels.
Definition ViewState.h:200
const glm::dmat4 & getViewMatrix() const noexcept
Gets the view matrix for the ViewState.
Definition ViewState.h:219
const glm::dmat4 & getProjectionMatrix() const noexcept
Gets the projection matrix for the ViewState.
Definition ViewState.h:224
ViewState(const glm::dvec3 &position, const glm::dvec3 &direction, const glm::dvec3 &up, const glm::dvec2 &viewportSize, double left, double right, double bottom, double top, const CesiumGeospatial::Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84)
Creates a new instance of a view state with an orthographic projection.
glm::dvec3 getUp() const noexcept
Gets the up direction of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:179
double computeScreenSpaceError(const Tile &tile, double distance, uint32_t depth) const noexcept
Computes the screen space error.
bool isBoundingVolumeVisible(const BoundingVolume &boundingVolume) const noexcept
Returns whether the given BoundingVolume is visible for this camera.
double getVerticalFieldOfView() const noexcept
Gets the vertical field-of-view angle in radians. This is only valid for a symmetric perspective proj...
const glm::dvec3 & getPosition() const noexcept
Gets the position of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:167
A quadratic surface defined in Cartesian coordinates.
Definition Ellipsoid.h:39
Classes that implement the 3D Tiles standard.
std::variant< CesiumGeometry::BoundingSphere, CesiumGeometry::OrientedBoundingBox, CesiumGeospatial::BoundingRegion, CesiumGeospatial::BoundingRegionWithLooseFittingHeights, CesiumGeospatial::S2CellBoundingVolume, CesiumGeometry::BoundingCylinderRegion > BoundingVolume
A bounding volume.
std::variant< CesiumGeometry::CullingVolume, BoundingVolume > GeneralCullingVolume
A general culling volume for selecting and filtering tiles.