cesium-native 0.47.0
Loading...
Searching...
No Matches
ViewState.h
1#pragma once
2
3#include <Cesium3DTilesSelection/BoundingVolume.h>
4#include <Cesium3DTilesSelection/Library.h>
5#include <CesiumGeometry/CullingVolume.h>
6#include <CesiumGeometry/Plane.h>
7#include <CesiumGeospatial/Cartographic.h>
8#include <CesiumGeospatial/Ellipsoid.h>
9
10#include <glm/mat3x3.hpp>
11#include <glm/mat4x4.hpp>
12#include <glm/vec2.hpp>
13#include <glm/vec3.hpp>
14
15#include <optional>
16#include <vector>
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
118 const glm::dvec3& getPosition() const noexcept { return this->_position; }
119
124 const glm::dvec3& getDirection() const noexcept { return this->_direction; }
125
130 glm::dvec3 getUp() const noexcept {
131 return {
132 this->_viewMatrix[0][1],
133 this->_viewMatrix[1][1],
134 this->_viewMatrix[2][1]};
135 }
136
143 const std::optional<CesiumGeospatial::Cartographic>&
144 getPositionCartographic() const noexcept {
145 return this->_positionCartographic;
146 }
147
151 const glm::dvec2& getViewportSize() const noexcept {
152 return this->_viewportSize;
153 }
154
159 double getHorizontalFieldOfView() const noexcept;
160
165 double getVerticalFieldOfView() const noexcept;
166
170 const glm::dmat4& getViewMatrix() const noexcept { return this->_viewMatrix; }
171
175 const glm::dmat4& getProjectionMatrix() const noexcept {
176 return this->_projectionMatrix;
177 }
178
189 bool
190 isBoundingVolumeVisible(const BoundingVolume& boundingVolume) const noexcept;
191
202 const BoundingVolume& boundingVolume) const noexcept;
203
218 double computeScreenSpaceError(double geometricError, double distance)
219 const noexcept;
220
221private:
222 const glm::dvec3 _position;
223 const glm::dvec3 _direction;
224 const glm::dvec2 _viewportSize;
225 const CesiumGeospatial::Ellipsoid _ellipsoid;
226
227 const std::optional<CesiumGeospatial::Cartographic> _positionCartographic;
228
229 const CesiumGeometry::CullingVolume _cullingVolume;
230 const glm::dmat4 _viewMatrix;
231 const glm::dmat4 _projectionMatrix;
232};
233
234} // namespace Cesium3DTilesSelection
The state of the view that is used during the traversal of a tileset.
Definition ViewState.h:25
const glm::dvec3 & getDirection() const noexcept
Gets the look direction of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:124
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:144
const glm::dvec2 & getViewportSize() const noexcept
Gets the size of the viewport in pixels.
Definition ViewState.h:151
const glm::dmat4 & getProjectionMatrix() const noexcept
Gets the projection matrix for the ViewState.
Definition ViewState.h:175
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:130
bool isBoundingVolumeVisible(const BoundingVolume &boundingVolume) const noexcept
Returns whether the given BoundingVolume is visible for this camera.
const glm::dvec3 & getPosition() const noexcept
Gets the position of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:118
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.
A culling volume, defined by four planes.