cesium-native 0.64.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 <optional>
17
18namespace Cesium3DTilesSelection {
19
25class CESIUM3DTILESSELECTION_API ViewState final {
26
27public:
33 [[deprecated("Use ViewState::ViewState instead.")]] static ViewState create(
34 const glm::dvec3& position,
35 const glm::dvec3& direction,
36 const glm::dvec3& up,
37 const glm::dvec2& viewportSize,
38 double horizontalFieldOfView,
39 double verticalFieldOfView,
40 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
41
59 const glm::dvec3& position,
60 const glm::dvec3& direction,
61 const glm::dvec3& up,
62 const glm::dvec2& viewportSize,
63 double horizontalFieldOfView,
64 double verticalFieldOfView,
65 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
66
81 const glm::dmat4& viewMatrix,
82 const glm::dmat4& projectionMatrix,
83 const glm::dvec2& viewportSize,
84 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
85
104 const glm::dvec3& position,
105 const glm::dvec3& direction,
106 const glm::dvec3& up,
107 const glm::dvec2& viewportSize,
108 double left,
109 double right,
110 double bottom,
111 double top,
112 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
113
128 const BoundingVolume& boundingVolume,
129 double geometricErrorThreshold,
130 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
131
136 const glm::dvec3& getPosition() const noexcept { return this->_position; }
137
142 const glm::dvec3& getDirection() const noexcept { return this->_direction; }
143
148 glm::dvec3 getUp() const noexcept {
149 return {
150 this->_viewMatrix[0][1],
151 this->_viewMatrix[1][1],
152 this->_viewMatrix[2][1]};
153 }
154
161 const std::optional<CesiumGeospatial::Cartographic>&
162 getPositionCartographic() const noexcept {
163 return this->_positionCartographic;
164 }
165
169 const glm::dvec2& getViewportSize() const noexcept {
170 return this->_viewportSize;
171 }
172
177 double getHorizontalFieldOfView() const noexcept;
178
183 double getVerticalFieldOfView() const noexcept;
184
188 const glm::dmat4& getViewMatrix() const noexcept { return this->_viewMatrix; }
189
193 const glm::dmat4& getProjectionMatrix() const noexcept {
194 return this->_projectionMatrix;
195 }
196
200 std::optional<double> getGeometricErrorThreshold() const {
201 return this->_geometricErrorThreshold;
202 }
203
214 bool
215 isBoundingVolumeVisible(const BoundingVolume& boundingVolume) const noexcept;
216
227 const BoundingVolume& boundingVolume) const noexcept;
228
243 double computeScreenSpaceError(double geometricError, double distance)
244 const noexcept;
245
246private:
247 glm::dvec3 _position;
248 glm::dvec3 _direction;
249 glm::dvec2 _viewportSize;
251
252 std::optional<CesiumGeospatial::Cartographic> _positionCartographic;
253
255 glm::dmat4 _viewMatrix;
256 glm::dmat4 _projectionMatrix;
257 std::optional<double> _geometricErrorThreshold;
258};
259
260} // namespace Cesium3DTilesSelection
const glm::dvec3 & getDirection() const noexcept
Gets the look direction of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:142
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.
std::optional< double > getGeometricErrorThreshold() const
Gets the geometric error threshold.
Definition ViewState.h:200
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:162
const glm::dvec2 & getViewportSize() const noexcept
Gets the size of the viewport in pixels.
Definition ViewState.h:169
const glm::dmat4 & getViewMatrix() const noexcept
Gets the view matrix for the ViewState.
Definition ViewState.h:188
const glm::dmat4 & getProjectionMatrix() const noexcept
Gets the projection matrix for the ViewState.
Definition ViewState.h:193
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.
ViewState(const BoundingVolume &boundingVolume, double geometricErrorThreshold, const CesiumGeospatial::Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84)
Creates a new instance of a view state from a bounding volume associated with a geographic area,...
glm::dvec3 getUp() const noexcept
Gets the up direction of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:148
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:136
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.