cesium-native 0.44.2
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/vec2.hpp>
12#include <glm/vec3.hpp>
13
14#include <vector>
15
16namespace Cesium3DTilesSelection {
17
23class CESIUM3DTILESSELECTION_API ViewState final {
24
25 // TODO: Add support for orthographic and off-center perspective frustums
26public:
44 const glm::dvec3& position,
45 const glm::dvec3& direction,
46 const glm::dvec3& up,
47 const glm::dvec2& viewportSize,
48 double horizontalFieldOfView,
49 double verticalFieldOfView,
50 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
51
56 const glm::dvec3& getPosition() const noexcept { return this->_position; }
57
62 const glm::dvec3& getDirection() const noexcept { return this->_direction; }
63
68 const glm::dvec3& getUp() const noexcept { return this->_up; }
69
76 const std::optional<CesiumGeospatial::Cartographic>&
77 getPositionCartographic() const noexcept {
78 return this->_positionCartographic;
79 }
80
84 const glm::dvec2& getViewportSize() const noexcept {
85 return this->_viewportSize;
86 }
87
91 double getHorizontalFieldOfView() const noexcept {
92 return this->_horizontalFieldOfView;
93 }
94
98 double getVerticalFieldOfView() const noexcept {
99 return this->_verticalFieldOfView;
100 }
101
112 bool
113 isBoundingVolumeVisible(const BoundingVolume& boundingVolume) const noexcept;
114
125 const BoundingVolume& boundingVolume) const noexcept;
126
141 double computeScreenSpaceError(double geometricError, double distance)
142 const noexcept;
143
144private:
157 ViewState(
158 const glm::dvec3& position,
159 const glm::dvec3& direction,
160 const glm::dvec3& up,
161 const glm::dvec2& viewportSize,
162 double horizontalFieldOfView,
163 double verticalFieldOfView,
164 const std::optional<CesiumGeospatial::Cartographic>& positionCartographic,
165 const CesiumGeospatial::Ellipsoid& ellipsoid);
166
167 const glm::dvec3 _position;
168 const glm::dvec3 _direction;
169 const glm::dvec3 _up;
170 const glm::dvec2 _viewportSize;
171 const double _horizontalFieldOfView;
172 const double _verticalFieldOfView;
173 const CesiumGeospatial::Ellipsoid _ellipsoid;
174
175 const double _sseDenominator;
176 const std::optional<CesiumGeospatial::Cartographic> _positionCartographic;
177
178 const CesiumGeometry::CullingVolume _cullingVolume;
179};
180
181} // namespace Cesium3DTilesSelection
The state of the view that is used during the traversal of a tileset.
Definition ViewState.h:23
const glm::dvec3 & getDirection() const noexcept
Gets the look direction of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:62
const glm::dvec3 & getUp() const noexcept
Gets the up direction of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:68
double getHorizontalFieldOfView() const noexcept
Gets the horizontal field-of-view angle in radians.
Definition ViewState.h:91
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.
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:77
const glm::dvec2 & getViewportSize() const noexcept
Gets the size of the viewport in pixels.
Definition ViewState.h:84
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.
Definition ViewState.h:98
const glm::dvec3 & getPosition() const noexcept
Gets the position of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:56
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 > BoundingVolume
A bounding volume.
A culling volume, defined by four planes.