cesium-native 0.43.0
Loading...
Searching...
No Matches
ViewState.h
1#pragma once
2
3#include "BoundingVolume.h"
4#include "Library.h"
5
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/vec2.hpp>
13#include <glm/vec3.hpp>
14
15#include <vector>
16
17namespace Cesium3DTilesSelection {
18
24class CESIUM3DTILESSELECTION_API ViewState final {
25
26 // TODO: Add support for orthographic and off-center perspective frustums
27public:
45 const glm::dvec3& position,
46 const glm::dvec3& direction,
47 const glm::dvec3& up,
48 const glm::dvec2& viewportSize,
49 double horizontalFieldOfView,
50 double verticalFieldOfView,
51 const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
52
57 const glm::dvec3& getPosition() const noexcept { return this->_position; }
58
63 const glm::dvec3& getDirection() const noexcept { return this->_direction; }
64
69 const glm::dvec3& getUp() const noexcept { return this->_up; }
70
77 const std::optional<CesiumGeospatial::Cartographic>&
78 getPositionCartographic() const noexcept {
79 return this->_positionCartographic;
80 }
81
85 const glm::dvec2& getViewportSize() const noexcept {
86 return this->_viewportSize;
87 }
88
92 double getHorizontalFieldOfView() const noexcept {
93 return this->_horizontalFieldOfView;
94 }
95
99 double getVerticalFieldOfView() const noexcept {
100 return this->_verticalFieldOfView;
101 }
102
113 bool
114 isBoundingVolumeVisible(const BoundingVolume& boundingVolume) const noexcept;
115
126 const BoundingVolume& boundingVolume) const noexcept;
127
142 double computeScreenSpaceError(double geometricError, double distance)
143 const noexcept;
144
145private:
158 ViewState(
159 const glm::dvec3& position,
160 const glm::dvec3& direction,
161 const glm::dvec3& up,
162 const glm::dvec2& viewportSize,
163 double horizontalFieldOfView,
164 double verticalFieldOfView,
165 const std::optional<CesiumGeospatial::Cartographic>& positionCartographic,
166 const CesiumGeospatial::Ellipsoid& ellipsoid);
167
168 const glm::dvec3 _position;
169 const glm::dvec3 _direction;
170 const glm::dvec3 _up;
171 const glm::dvec2 _viewportSize;
172 const double _horizontalFieldOfView;
173 const double _verticalFieldOfView;
174 const CesiumGeospatial::Ellipsoid _ellipsoid;
175
176 const double _sseDenominator;
177 const std::optional<CesiumGeospatial::Cartographic> _positionCartographic;
178
179 const CullingVolume _cullingVolume;
180};
181
182} // namespace Cesium3DTilesSelection
The state of the view that is used during the traversal of a tileset.
Definition ViewState.h:24
const glm::dvec3 & getDirection() const noexcept
Gets the look direction of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:63
const glm::dvec3 & getUp() const noexcept
Gets the up direction of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:69
double getHorizontalFieldOfView() const noexcept
Gets the horizontal field-of-view angle in radians.
Definition ViewState.h:92
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:78
const glm::dvec2 & getViewportSize() const noexcept
Gets the size of the viewport in pixels.
Definition ViewState.h:85
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:99
const glm::dvec3 & getPosition() const noexcept
Gets the position of the camera in Earth-centered, Earth-fixed coordinates.
Definition ViewState.h:57
A quadratic surface defined in Cartesian coordinates.
Definition Ellipsoid.h:38
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.