diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index ce2c44a952..a288bbebca 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -26,52 +26,54 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableglobe.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableglobe.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/geometry.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/grid.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/basicgrid.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapgrid.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/globemesh.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/patchrenderer.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapglobe.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunklodglobe.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/frustrumculler.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturetileset.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/twmstileprovider.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmappyramid.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gdaldataconverter.h + ${CMAKE_CURRENT_SOURCE_DIR}/globes/renderableglobe.h + ${CMAKE_CURRENT_SOURCE_DIR}/globes/globemesh.h + ${CMAKE_CURRENT_SOURCE_DIR}/globes/clipmapglobe.h + ${CMAKE_CURRENT_SOURCE_DIR}/globes/clipmappyramid.h + ${CMAKE_CURRENT_SOURCE_DIR}/globes/chunklodglobe.h + ${CMAKE_CURRENT_SOURCE_DIR}/globes/chunknode.h - ${CMAKE_CURRENT_SOURCE_DIR}/datastructures/chunknode.h - ${CMAKE_CURRENT_SOURCE_DIR}/datastructures/latlon.h - ${CMAKE_CURRENT_SOURCE_DIR}/datastructures/angle.h - ${CMAKE_CURRENT_SOURCE_DIR}/datastructures/lrucache.h + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/trianglesoup.h + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/grid.h + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/basicgrid.h + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/clipmapgrid.h + + ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/geodetic2.h + ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/angle.h + + ${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/patchrenderer.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/frustrumculler.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/texturetileset.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/twmstileprovider.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/gdaldataconverter.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.h ) set(SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableglobe.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/geometry.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/grid.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/basicgrid.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapgrid.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/globemesh.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/patchrenderer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapglobe.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunklodglobe.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/frustrumculler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturetileset.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/twmstileprovider.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmappyramid.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gdaldataconverter.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/datastructures/chunknode.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/datastructures/latlon.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/datastructures/angle.inl - ${CMAKE_CURRENT_SOURCE_DIR}/datastructures/lrucache.inl + ${CMAKE_CURRENT_SOURCE_DIR}/globes/renderableglobe.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/globes/globemesh.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/globes/clipmapglobe.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/globes/clipmappyramid.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/globes/chunklodglobe.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/globes/chunknode.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/trianglesoup.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/grid.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/basicgrid.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/clipmapgrid.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/geodetic2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/angle.inl + + ${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/patchrenderer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/frustrumculler.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/texturetileset.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/twmstileprovider.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/gdaldataconverter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.inl ) source_group("Source Files" FILES ${SOURCE_FILES}) diff --git a/modules/globebrowsing/datastructures/angle.h b/modules/globebrowsing/geodetics/angle.h similarity index 99% rename from modules/globebrowsing/datastructures/angle.h rename to modules/globebrowsing/geodetics/angle.h index 8d021430ec..fc3e1a4692 100644 --- a/modules/globebrowsing/datastructures/angle.h +++ b/modules/globebrowsing/geodetics/angle.h @@ -177,7 +177,7 @@ using fAngle = Angle; -#include +#include diff --git a/modules/globebrowsing/datastructures/angle.inl b/modules/globebrowsing/geodetics/angle.inl similarity index 99% rename from modules/globebrowsing/datastructures/angle.inl rename to modules/globebrowsing/geodetics/angle.inl index f022fda1c6..d0f4f5a513 100644 --- a/modules/globebrowsing/datastructures/angle.inl +++ b/modules/globebrowsing/geodetics/angle.inl @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include diff --git a/modules/globebrowsing/datastructures/latlon.cpp b/modules/globebrowsing/geodetics/geodetic2.cpp similarity index 72% rename from modules/globebrowsing/datastructures/latlon.cpp rename to modules/globebrowsing/geodetics/geodetic2.cpp index 03627bd254..206e386c8e 100644 --- a/modules/globebrowsing/datastructures/latlon.cpp +++ b/modules/globebrowsing/geodetics/geodetic2.cpp @@ -22,11 +22,12 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include -#include -#include -#include +#include +#include + +#include #define _USE_MATH_DEFINES #include @@ -36,85 +37,89 @@ namespace { } namespace openspace { - ////////////////////////////////////////////////////////////////////////////////////////// - // LATITUDE LONGITUDE // - ////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // GEODETIC2 // + ////////////////////////////////////////////////////////////////////////////////////// - LatLon::LatLon() + Geodetic2::Geodetic2() : lat(0) , lon(0) {} - LatLon::LatLon(Scalar latitude, Scalar longitude) + Geodetic2::Geodetic2(Scalar latitude, Scalar longitude) : lat(latitude) , lon(longitude) { } - LatLon::LatLon(const LatLon& p) - : LatLon(p.lat, p.lon) + Geodetic2::Geodetic2(const Geodetic2& p) + : Geodetic2(p.lat, p.lon) { } - LatLon LatLon::fromCartesian(const Vec3& v) { + Geodetic2 Geodetic2::fromCartesian(const Vec3& v) { Scalar r = glm::length(v); - return LatLon(glm::asin(v.z / r), atan2(v.y, v.x)); + return Geodetic2(glm::asin(v.z / r), atan2(v.y, v.x)); } - Vec3 LatLon::asUnitCartesian() const{ + Vec3 Geodetic2::asUnitCartesian() const{ return Vec3( glm::cos(lat) * glm::cos(lon), glm::cos(lat) * glm::sin(lon), glm::sin(lat)); } - Vec2 LatLon::toLonLatVec2() const { + Vec2 Geodetic2::toLonLatVec2() const { return Vec2(lon, lat); } - bool LatLon::operator==(const LatLon& other) const { + bool Geodetic2::operator==(const Geodetic2& other) const { return lat == other.lat && lon == other.lon; } - LatLon LatLon ::operator+(const LatLon& other) const { - return LatLon(lat - other.lat, lon - other.lon); + Geodetic2 Geodetic2 ::operator+(const Geodetic2& other) const { + return Geodetic2(lat - other.lat, lon - other.lon); } - LatLon LatLon ::operator-(const LatLon& other) const { - return LatLon(lat - other.lat, lon - other.lon); + Geodetic2 Geodetic2 ::operator-(const Geodetic2& other) const { + return Geodetic2(lat - other.lat, lon - other.lon); } - LatLon LatLon::operator*(Scalar scalar) const { - return LatLon(lat * scalar, lon * scalar); + Geodetic2 Geodetic2::operator*(Scalar scalar) const { + return Geodetic2(lat * scalar, lon * scalar); } - LatLon LatLon::operator/(Scalar scalar) const { - return LatLon(lat / scalar, lon / scalar); + Geodetic2 Geodetic2::operator/(Scalar scalar) const { + return Geodetic2(lat / scalar, lon / scalar); } - ////////////////////////////////////////////////////////////////////////////////////////// - // LATITUDE LONGITUDE PATCH // - ////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // GEODETICPATCH // + ////////////////////////////////////////////////////////////////////////////////////// - LatLonPatch::LatLonPatch(Scalar centerLat, Scalar centerLon, Scalar halfSizeLat, Scalar halfSizeLon) - : _center(LatLon(centerLat, centerLon)) - , _halfSize(LatLon(halfSizeLat, halfSizeLon)) + GeodeticPatch::GeodeticPatch( + Scalar centerLat, + Scalar centerLon, + Scalar halfSizeLat, + Scalar halfSizeLon) + : _center(Geodetic2(centerLat, centerLon)) + , _halfSize(Geodetic2(halfSizeLat, halfSizeLon)) { } - LatLonPatch::LatLonPatch(const LatLon& center, const LatLon& halfSize) + GeodeticPatch::GeodeticPatch(const Geodetic2& center, const Geodetic2& halfSize) : _center(center) , _halfSize(halfSize) { } - LatLonPatch::LatLonPatch(const LatLonPatch& patch) + GeodeticPatch::GeodeticPatch(const GeodeticPatch& patch) : _center(patch._center) , _halfSize(patch._halfSize) { @@ -122,56 +127,56 @@ namespace openspace { } - void LatLonPatch::setCenter(const LatLon& center) { + void GeodeticPatch::setCenter(const Geodetic2& center) { _center = center; } - void LatLonPatch::setHalfSize(const LatLon& halfSize) { + void GeodeticPatch::setHalfSize(const Geodetic2& halfSize) { _halfSize = halfSize; } - Scalar LatLonPatch::minimalBoundingRadius() const { - const LatLon& cornerNearEquator = _center.lat > 0 ? southWestCorner() : northWestCorner(); + Scalar GeodeticPatch::minimalBoundingRadius() const { + const Geodetic2& cornerNearEquator = _center.lat > 0 ? southWestCorner() : northWestCorner(); return glm::length(_center.asUnitCartesian() - cornerNearEquator.asUnitCartesian()); } - Scalar LatLonPatch::unitArea() const { + Scalar GeodeticPatch::unitArea() const { Scalar deltaTheta = 2 * _halfSize.lon; Scalar phiMin = _center.lat - _halfSize.lat; Scalar phiMax = _center.lat + _halfSize.lat; return deltaTheta * (sin(phiMax) - sin(phiMin)); } - const LatLon& LatLonPatch::center() const { + const Geodetic2& GeodeticPatch::center() const { return _center; } - const LatLon& LatLonPatch::halfSize() const { + const Geodetic2& GeodeticPatch::halfSize() const { return _halfSize; } - LatLon LatLonPatch::size() const { - return LatLon(2 * _halfSize.lat, 2 * _halfSize.lon); + Geodetic2 GeodeticPatch::size() const { + return Geodetic2(2 * _halfSize.lat, 2 * _halfSize.lon); } - LatLon LatLonPatch::northWestCorner() const{ - return LatLon(_center.lat + _halfSize.lat, _center.lon - _halfSize.lon); + Geodetic2 GeodeticPatch::northWestCorner() const{ + return Geodetic2(_center.lat + _halfSize.lat, _center.lon - _halfSize.lon); } - LatLon LatLonPatch::northEastCorner() const{ - return LatLon(_center.lat + _halfSize.lat, _center.lon + _halfSize.lon); + Geodetic2 GeodeticPatch::northEastCorner() const{ + return Geodetic2(_center.lat + _halfSize.lat, _center.lon + _halfSize.lon); } - LatLon LatLonPatch::southWestCorner() const{ - return LatLon(_center.lat - _halfSize.lat, _center.lon - _halfSize.lon); + Geodetic2 GeodeticPatch::southWestCorner() const{ + return Geodetic2(_center.lat - _halfSize.lat, _center.lon - _halfSize.lon); } - LatLon LatLonPatch::southEastCorner() const{ - return LatLon(_center.lat - _halfSize.lat, _center.lon + _halfSize.lon); + Geodetic2 GeodeticPatch::southEastCorner() const{ + return Geodetic2(_center.lat - _halfSize.lat, _center.lon + _halfSize.lon); } - LatLon LatLonPatch::clamp(const LatLon& p) const { + Geodetic2 GeodeticPatch::clamp(const Geodetic2& p) const { using Ang = Angle; // Convert to Angles for normalization @@ -191,21 +196,21 @@ namespace openspace { pointLon.normalizeAround(centerLon); // get clamp bounds - LatLon max = northEastCorner(); - LatLon min = southWestCorner(); + Geodetic2 max = northEastCorner(); + Geodetic2 min = southWestCorner(); - return LatLon( + return Geodetic2( glm::clamp(pointLat.asRadians(), min.lat, max.lat), glm::clamp(pointLon.asRadians(), min.lon, max.lon) ); } - LatLon LatLonPatch::closestCorner(const LatLon& p) const { + Geodetic2 GeodeticPatch::closestCorner(const Geodetic2& p) const { using Ang = Angle; // LatLon vector from patch center to the point - LatLon centerToPoint = p - _center; + Geodetic2 centerToPoint = p - _center; // Normalize the difference angles to be centered around 0. Ang latDiff = Ang::fromRadians(centerToPoint.lat).normalizeAround(Ang::ZERO); @@ -222,11 +227,11 @@ namespace openspace { // We then assigned the corner's longitude coordinate in a similar fashion Scalar cornerLon = _center.lon + _halfSize.lon * (lonDiff > Ang::ZERO ? 1 : -1); - return LatLon(cornerLat, cornerLon); + return Geodetic2(cornerLat, cornerLon); } - LatLon LatLonPatch::closestPoint(const LatLon& p) const { + Geodetic2 GeodeticPatch::closestPoint(const Geodetic2& p) const { // This method finds the closest point on the patch, to the provided // point p. As we are deali ng with latitude-longitude patches, distance in this // context refers to great-circle distance. @@ -277,8 +282,8 @@ namespace openspace { Ang longitudeDistanceToClosestPatchEdge = centerToPointLon.abs() - Ang::fromRadians(_halfSize.lon); // get clamp bounds - LatLon max = northEastCorner(); - LatLon min = southWestCorner(); + Geodetic2 max = northEastCorner(); + Geodetic2 min = southWestCorner(); // If the longitude distance to the closest patch edge is larger than 90 deg // the latitude will have to be clamped to its closest corner, as explained in @@ -290,7 +295,7 @@ namespace openspace { // Longitude is just clamped normally Scalar clampedLon = glm::clamp(pointLon.asRadians(), min.lon, max.lon); - return LatLon(clampedLat, clampedLon); + return Geodetic2(clampedLat, clampedLon); } } // namespace openspace diff --git a/modules/globebrowsing/datastructures/latlon.h b/modules/globebrowsing/geodetics/geodetic2.h similarity index 71% rename from modules/globebrowsing/datastructures/latlon.h rename to modules/globebrowsing/geodetics/geodetic2.h index 476c2e3f13..132bd72d43 100644 --- a/modules/globebrowsing/datastructures/latlon.h +++ b/modules/globebrowsing/geodetics/geodetic2.h @@ -42,22 +42,22 @@ namespace openspace { -struct LatLon { - LatLon(); - LatLon(Scalar latitude, Scalar longitude); - LatLon(const LatLon& src); +struct Geodetic2 { + Geodetic2(); + Geodetic2(Scalar latitude, Scalar longitude); + Geodetic2(const Geodetic2& src); - static LatLon fromCartesian(const Vec3& v); + static Geodetic2 fromCartesian(const Vec3& v); Vec3 asUnitCartesian() const; Vec2 toLonLatVec2() const; - inline bool operator==(const LatLon& other) const; - inline bool operator!=(const LatLon& other) const { return !(*this == (other)); } + inline bool operator==(const Geodetic2& other) const; + inline bool operator!=(const Geodetic2& other) const { return !(*this == (other)); } - inline LatLon operator+(const LatLon& other) const; - inline LatLon operator-(const LatLon& other) const; - inline LatLon operator*(Scalar scalar) const; - inline LatLon operator/(Scalar scalar) const; + inline Geodetic2 operator+(const Geodetic2& other) const; + inline Geodetic2 operator-(const Geodetic2& other) const; + inline Geodetic2 operator*(Scalar scalar) const; + inline Geodetic2 operator/(Scalar scalar) const; Scalar lat; Scalar lon; @@ -66,15 +66,15 @@ struct LatLon { -class LatLonPatch { +class GeodeticPatch { public: - LatLonPatch(Scalar, Scalar, Scalar, Scalar); - LatLonPatch(const LatLon& center, const LatLon& halfSize); - LatLonPatch(const LatLonPatch& patch); + GeodeticPatch(Scalar, Scalar, Scalar, Scalar); + GeodeticPatch(const Geodetic2& center, const Geodetic2& halfSize); + GeodeticPatch(const GeodeticPatch& patch); - void setCenter(const LatLon&); - void setHalfSize(const LatLon&); + void setCenter(const Geodetic2&); + void setHalfSize(const Geodetic2&); /** @@ -89,35 +89,35 @@ public: Scalar unitArea() const; - LatLon northWestCorner() const; - LatLon northEastCorner() const; - LatLon southWestCorner() const; - LatLon southEastCorner() const; + Geodetic2 northWestCorner() const; + Geodetic2 northEastCorner() const; + Geodetic2 southWestCorner() const; + Geodetic2 southEastCorner() const; /** * Clamps a point to the patch region */ - LatLon clamp(const LatLon& p) const; + Geodetic2 clamp(const Geodetic2& p) const; /** * Returns the corner of the patch that is closest to the given point p */ - LatLon closestCorner(const LatLon& p) const; + Geodetic2 closestCorner(const Geodetic2& p) const; /** * Returns a point on the patch that minimizes the great-circle distance to * the given point p. */ - LatLon closestPoint(const LatLon& p) const; + Geodetic2 closestPoint(const Geodetic2& p) const; - const LatLon& center() const; - const LatLon& halfSize() const; - LatLon size() const; + const Geodetic2& center() const; + const Geodetic2& halfSize() const; + Geodetic2 size() const; private: - LatLon _center; - LatLon _halfSize; + Geodetic2 _center; + Geodetic2 _halfSize; }; diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 78cbdee253..aaa77ca89b 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -24,9 +24,9 @@ #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/modules/globebrowsing/rendering/chunklodglobe.cpp b/modules/globebrowsing/globes/chunklodglobe.cpp similarity index 92% rename from modules/globebrowsing/rendering/chunklodglobe.cpp rename to modules/globebrowsing/globes/chunklodglobe.cpp index ca086d8284..1b562b91bc 100644 --- a/modules/globebrowsing/rendering/chunklodglobe.cpp +++ b/modules/globebrowsing/globes/chunklodglobe.cpp @@ -22,9 +22,9 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include -#include +#include // open space includes #include @@ -50,8 +50,8 @@ namespace { namespace openspace { - const LatLonPatch ChunkLodGlobe::LEFT_HEMISPHERE = LatLonPatch(0, -M_PI/2, M_PI/2, M_PI/2); - const LatLonPatch ChunkLodGlobe::RIGHT_HEMISPHERE = LatLonPatch(0, M_PI/2, M_PI/2, M_PI/2); + const GeodeticPatch ChunkLodGlobe::LEFT_HEMISPHERE = GeodeticPatch(0, -M_PI/2, M_PI/2, M_PI/2); + const GeodeticPatch ChunkLodGlobe::RIGHT_HEMISPHERE = GeodeticPatch(0, M_PI/2, M_PI/2, M_PI/2); ChunkLodGlobe::ChunkLodGlobe(const ghoul::Dictionary& dictionary) @@ -84,9 +84,9 @@ namespace openspace { auto geometry = std::shared_ptr(new BasicGrid( 10, 10, - Geometry::Positions::No, - Geometry::TextureCoordinates::Yes, - Geometry::Normals::No)); + TriangleSoup::Positions::No, + TriangleSoup::TextureCoordinates::Yes, + TriangleSoup::Normals::No)); _patchRenderer.reset(new LatLonPatchRenderer(geometry)); diff --git a/modules/globebrowsing/rendering/chunklodglobe.h b/modules/globebrowsing/globes/chunklodglobe.h similarity index 92% rename from modules/globebrowsing/rendering/chunklodglobe.h rename to modules/globebrowsing/globes/chunklodglobe.h index 419ac4c0a0..fe05305d5e 100644 --- a/modules/globebrowsing/rendering/chunklodglobe.h +++ b/modules/globebrowsing/globes/chunklodglobe.h @@ -39,9 +39,9 @@ -#include -#include -#include +#include +#include +#include namespace ghoul { namespace opengl { @@ -90,8 +90,8 @@ namespace openspace { std::unique_ptr _patchRenderer; - static const LatLonPatch LEFT_HEMISPHERE; - static const LatLonPatch RIGHT_HEMISPHERE; + static const GeodeticPatch LEFT_HEMISPHERE; + static const GeodeticPatch RIGHT_HEMISPHERE; properties::IntProperty _rotation; diff --git a/modules/globebrowsing/datastructures/chunknode.cpp b/modules/globebrowsing/globes/chunknode.cpp similarity index 89% rename from modules/globebrowsing/datastructures/chunknode.cpp rename to modules/globebrowsing/globes/chunknode.cpp index ee00247c72..7896b15282 100644 --- a/modules/globebrowsing/datastructures/chunknode.cpp +++ b/modules/globebrowsing/globes/chunknode.cpp @@ -22,13 +22,14 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include + #include #include #include -#include -#include +#include @@ -41,7 +42,7 @@ namespace openspace { int ChunkNode::instanceCount = 0; int ChunkNode::renderedPatches = 0; -ChunkNode::ChunkNode(ChunkLodGlobe& owner, const LatLonPatch& patch, ChunkNode* parent) +ChunkNode::ChunkNode(ChunkLodGlobe& owner, const GeodeticPatch& patch, ChunkNode* parent) : _owner(owner) , _patch(patch) , _parent(parent) @@ -77,7 +78,7 @@ void ChunkNode::render(const RenderData& data, ChunkIndex traverseData) { // Returns true or false wether this node can be merge or not bool ChunkNode::internalUpdateChunkTree(const RenderData& data, ChunkIndex& traverseData) { using namespace glm; - LatLon center = _patch.center(); + Geodetic2 center = _patch.center(); //LDEBUG("x: " << patch.x << " y: " << patch.y << " level: " << patch.level << " lat: " << center.lat << " lon: " << center.lon); @@ -152,8 +153,8 @@ int ChunkNode::calculateDesiredLevel(const RenderData& data, const ChunkIndex& t Vec3 globeToCamera = cameraPosition - globePosition; - LatLon cameraPositionOnGlobe = LatLon::fromCartesian(globeToCamera); - LatLon closestPatchPoint = _patch.closestPoint(cameraPositionOnGlobe); + Geodetic2 cameraPositionOnGlobe = Geodetic2::fromCartesian(globeToCamera); + Geodetic2 closestPatchPoint = _patch.closestPoint(cameraPositionOnGlobe); Vec3 normalOfClosestPatchPoint = closestPatchPoint.asUnitCartesian(); Scalar cosPatchNormalNormalizedGlobeToCamera = glm::dot(normalOfClosestPatchPoint, glm::normalize(globeToCamera)); @@ -190,15 +191,15 @@ void ChunkNode::split(int depth) { if (depth > 0 && isLeaf()) { // Defining short handles for center, halfSize and quarterSize - const LatLon& c = _patch.center(); - const LatLon& hs = _patch.halfSize(); - LatLon qs = LatLon(0.5 * hs.lat, 0.5 * hs.lon); + const Geodetic2& c = _patch.center(); + const Geodetic2& hs = _patch.halfSize(); + Geodetic2 qs = Geodetic2(0.5 * hs.lat, 0.5 * hs.lon); // Subdivide bounds - LatLonPatch nwBounds = LatLonPatch(LatLon(c.lat + qs.lat, c.lon - qs.lon), qs); - LatLonPatch neBounds = LatLonPatch(LatLon(c.lat - qs.lat, c.lon - qs.lon), qs); - LatLonPatch swBounds = LatLonPatch(LatLon(c.lat + qs.lat, c.lon + qs.lon), qs); - LatLonPatch seBounds = LatLonPatch(LatLon(c.lat - qs.lat, c.lon + qs.lon), qs); + GeodeticPatch nwBounds = GeodeticPatch(Geodetic2(c.lat + qs.lat, c.lon - qs.lon), qs); + GeodeticPatch neBounds = GeodeticPatch(Geodetic2(c.lat - qs.lat, c.lon - qs.lon), qs); + GeodeticPatch swBounds = GeodeticPatch(Geodetic2(c.lat + qs.lat, c.lon + qs.lon), qs); + GeodeticPatch seBounds = GeodeticPatch(Geodetic2(c.lat - qs.lat, c.lon + qs.lon), qs); // Create new chunk nodes _children[Quad::NORTH_WEST] = std::unique_ptr(new ChunkNode(_owner, nwBounds, this)); diff --git a/modules/globebrowsing/datastructures/chunknode.h b/modules/globebrowsing/globes/chunknode.h similarity index 93% rename from modules/globebrowsing/datastructures/chunknode.h rename to modules/globebrowsing/globes/chunknode.h index bb3cb9778e..26c2261e74 100644 --- a/modules/globebrowsing/datastructures/chunknode.h +++ b/modules/globebrowsing/globes/chunknode.h @@ -30,8 +30,8 @@ #include #include -#include -#include +#include +#include @@ -69,7 +69,7 @@ struct ChunkIndex { class ChunkNode { public: - ChunkNode(ChunkLodGlobe&, const LatLonPatch&, ChunkNode* parent = nullptr); + ChunkNode(ChunkLodGlobe&, const GeodeticPatch&, ChunkNode* parent = nullptr); ~ChunkNode(); @@ -99,7 +99,7 @@ private: ChunkLodGlobe& _owner; - LatLonPatch _patch; + GeodeticPatch _patch; }; diff --git a/modules/globebrowsing/rendering/clipmapglobe.cpp b/modules/globebrowsing/globes/clipmapglobe.cpp similarity index 93% rename from modules/globebrowsing/rendering/clipmapglobe.cpp rename to modules/globebrowsing/globes/clipmapglobe.cpp index 8626e39105..facd0deafc 100644 --- a/modules/globebrowsing/rendering/clipmapglobe.cpp +++ b/modules/globebrowsing/globes/clipmapglobe.cpp @@ -23,12 +23,9 @@ ****************************************************************************************/ -#define _USE_MATH_DEFINES -#include +#include -#include - -#include +#include // open space includes #include @@ -39,6 +36,9 @@ // ghoul includes #include +#define _USE_MATH_DEFINES +#include + namespace { const std::string _loggerCat = "ClipMapGlobe"; @@ -53,7 +53,7 @@ namespace { namespace openspace { ClipMapGlobe::ClipMapGlobe(const ghoul::Dictionary& dictionary) : _rotation("rotation", "Rotation", 0, 0, 360) - , _clipMapPyramid(LatLon(M_PI / 2, M_PI / 2)) + , _clipMapPyramid(Geodetic2(M_PI / 2, M_PI / 2)) { std::string name; bool success = dictionary.getValue(SceneGraphNode::KeyName, name); @@ -101,10 +101,10 @@ namespace openspace { // render patches for (size_t i = minDepth; i < maxDepth; i++) { - LatLon patchSize = _clipMapPyramid.getPatchSizeAtLevel(i); + Geodetic2 patchSize = _clipMapPyramid.getPatchSizeAtLevel(i); _outerPatchRenderer->renderPatch(patchSize, data, 6.3e6); } - LatLon patchSize = _clipMapPyramid.getPatchSizeAtLevel(maxDepth); + Geodetic2 patchSize = _clipMapPyramid.getPatchSizeAtLevel(maxDepth); _innerPatchRenderer->renderPatch(patchSize, data, 6.3e6); } diff --git a/modules/globebrowsing/rendering/clipmapglobe.h b/modules/globebrowsing/globes/clipmapglobe.h similarity index 91% rename from modules/globebrowsing/rendering/clipmapglobe.h rename to modules/globebrowsing/globes/clipmapglobe.h index ead63ca4cf..b1770555f2 100644 --- a/modules/globebrowsing/rendering/clipmapglobe.h +++ b/modules/globebrowsing/globes/clipmapglobe.h @@ -30,11 +30,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ghoul { namespace opengl { diff --git a/modules/globebrowsing/rendering/clipmappyramid.cpp b/modules/globebrowsing/globes/clipmappyramid.cpp similarity index 90% rename from modules/globebrowsing/rendering/clipmappyramid.cpp rename to modules/globebrowsing/globes/clipmappyramid.cpp index 9ebf92421b..c5d7cd1907 100644 --- a/modules/globebrowsing/rendering/clipmappyramid.cpp +++ b/modules/globebrowsing/globes/clipmappyramid.cpp @@ -24,7 +24,7 @@ -#include +#include #define _USE_MATH_DEFINES #include @@ -37,7 +37,7 @@ namespace { } namespace openspace { - ClipMapPyramid::ClipMapPyramid(LatLon sizeLevel0) + ClipMapPyramid::ClipMapPyramid(Geodetic2 sizeLevel0) : _sizeLevel0(sizeLevel0) { @@ -46,9 +46,9 @@ namespace openspace { ClipMapPyramid::~ClipMapPyramid() {} - LatLon ClipMapPyramid::getPatchSizeAtLevel(int level) + Geodetic2 ClipMapPyramid::getPatchSizeAtLevel(int level) { - return LatLon(_sizeLevel0.lat / pow(2, level), _sizeLevel0.lon / pow(2, level)); + return Geodetic2(_sizeLevel0.lat / pow(2, level), _sizeLevel0.lon / pow(2, level)); } diff --git a/modules/globebrowsing/rendering/clipmappyramid.h b/modules/globebrowsing/globes/clipmappyramid.h similarity index 93% rename from modules/globebrowsing/rendering/clipmappyramid.h rename to modules/globebrowsing/globes/clipmappyramid.h index 303b825037..3b71309857 100644 --- a/modules/globebrowsing/rendering/clipmappyramid.h +++ b/modules/globebrowsing/globes/clipmappyramid.h @@ -26,7 +26,7 @@ #define __CLIPMAPPYRAMID_H__ // open space includes -#include +#include namespace openspace { @@ -37,13 +37,13 @@ namespace openspace { The parameter needs to be M_PI / pow(2, i) where i is a positive or zero valued integer. */ - ClipMapPyramid(LatLon sizeLevel0); + ClipMapPyramid(Geodetic2 sizeLevel0); ~ClipMapPyramid(); - LatLon getPatchSizeAtLevel(int level); + Geodetic2 getPatchSizeAtLevel(int level); private: - const LatLon _sizeLevel0; + const Geodetic2 _sizeLevel0; }; } // namespace openspace diff --git a/modules/globebrowsing/rendering/globemesh.cpp b/modules/globebrowsing/globes/globemesh.cpp similarity index 97% rename from modules/globebrowsing/rendering/globemesh.cpp rename to modules/globebrowsing/globes/globemesh.cpp index ee70305d99..60542bf6a7 100644 --- a/modules/globebrowsing/rendering/globemesh.cpp +++ b/modules/globebrowsing/globes/globemesh.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include // open space includes #include @@ -49,7 +49,7 @@ namespace { namespace openspace { GlobeMesh::GlobeMesh(const ghoul::Dictionary& dictionary) : _programObject(nullptr) - , _grid(10, 10, Geometry::Positions::Yes, Geometry::TextureCoordinates::No, Geometry::Normals::No) + , _grid(10, 10, TriangleSoup::Positions::Yes, TriangleSoup::TextureCoordinates::No, TriangleSoup::Normals::No) , _rotation("rotation", "Rotation", 0, 0, 360) { std::string name; diff --git a/modules/globebrowsing/rendering/globemesh.h b/modules/globebrowsing/globes/globemesh.h similarity index 94% rename from modules/globebrowsing/rendering/globemesh.h rename to modules/globebrowsing/globes/globemesh.h index ebe36625b7..133f6a32e3 100644 --- a/modules/globebrowsing/rendering/globemesh.h +++ b/modules/globebrowsing/globes/globemesh.h @@ -31,9 +31,9 @@ #include #include -#include -#include -#include +#include +#include +#include namespace ghoul { namespace opengl { diff --git a/modules/globebrowsing/rendering/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp similarity index 58% rename from modules/globebrowsing/rendering/renderableglobe.cpp rename to modules/globebrowsing/globes/renderableglobe.cpp index 3093493c48..6686bf8fc4 100644 --- a/modules/globebrowsing/rendering/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -22,11 +22,11 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include -#include -#include -#include +#include +#include +#include // open space includes #include @@ -38,49 +38,49 @@ #include namespace { - const std::string _loggerCat = "RenderableGlobe"; + const std::string _loggerCat = "RenderableGlobe"; - const std::string keyFrame = "Frame"; - const std::string keyGeometry = "Geometry"; - const std::string keyShading = "PerformShading"; + const std::string keyFrame = "Frame"; + const std::string keyGeometry = "Geometry"; + const std::string keyShading = "PerformShading"; - const std::string keyBody = "Body"; + const std::string keyBody = "Body"; } namespace openspace { - RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) - : DistanceSwitch() - , _rotation("rotation", "Rotation", 0, 0, 360) - { - std::string name; - bool success = dictionary.getValue(SceneGraphNode::KeyName, name); - ghoul_assert(success, - "RenderableGlobe need the '" << SceneGraphNode::KeyName << "' be specified"); - setName(name); - dictionary.getValue(keyFrame, _frame); - dictionary.getValue(keyBody, _target); - if (_target != "") - setBody(_target); + RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) + : DistanceSwitch() + , _rotation("rotation", "Rotation", 0, 0, 360) + { + std::string name; + bool success = dictionary.getValue(SceneGraphNode::KeyName, name); + ghoul_assert(success, + "RenderableGlobe need the '" << SceneGraphNode::KeyName << "' be specified"); + setName(name); + dictionary.getValue(keyFrame, _frame); + dictionary.getValue(keyBody, _target); + if (_target != "") + setBody(_target); - // Mainly for debugging purposes @AA - addProperty(_rotation); - - addSwitchValue(std::shared_ptr(new ClipMapGlobe(dictionary)), 1e7); - addSwitchValue(std::shared_ptr(new ChunkLodGlobe(dictionary)), 1e9); - addSwitchValue(std::shared_ptr(new GlobeMesh(dictionary)), 1e10); + // Mainly for debugging purposes @AA + addProperty(_rotation); + + addSwitchValue(std::shared_ptr(new ClipMapGlobe(dictionary)), 1e7); + addSwitchValue(std::shared_ptr(new ChunkLodGlobe(dictionary)), 1e9); + addSwitchValue(std::shared_ptr(new GlobeMesh(dictionary)), 1e10); - } + } - RenderableGlobe::~RenderableGlobe() { - } + RenderableGlobe::~RenderableGlobe() { + } - void RenderableGlobe::update(const UpdateData& data) { - // set spice-orientation in accordance to timestamp - _stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time); - _time = data.time; - DistanceSwitch::update(data); - } + void RenderableGlobe::update(const UpdateData& data) { + // set spice-orientation in accordance to timestamp + _stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time); + _time = data.time; + DistanceSwitch::update(data); + } } // namespace openspace diff --git a/modules/globebrowsing/rendering/renderableglobe.h b/modules/globebrowsing/globes/renderableglobe.h similarity index 94% rename from modules/globebrowsing/rendering/renderableglobe.h rename to modules/globebrowsing/globes/renderableglobe.h index 26bce946d8..dc8ac50daa 100644 --- a/modules/globebrowsing/rendering/renderableglobe.h +++ b/modules/globebrowsing/globes/renderableglobe.h @@ -33,9 +33,9 @@ #include #include -#include -#include -#include +#include +#include +#include namespace ghoul { diff --git a/modules/globebrowsing/rendering/basicgrid.cpp b/modules/globebrowsing/meshes/basicgrid.cpp similarity index 93% rename from modules/globebrowsing/rendering/basicgrid.cpp rename to modules/globebrowsing/meshes/basicgrid.cpp index 801985607b..f9eb432b40 100644 --- a/modules/globebrowsing/rendering/basicgrid.cpp +++ b/modules/globebrowsing/meshes/basicgrid.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include namespace { const std::string _loggerCat = "BasicGrid"; @@ -33,9 +33,9 @@ namespace openspace { BasicGrid::BasicGrid( unsigned int xSegments, unsigned int ySegments, - Geometry::Positions usePositions, - Geometry::TextureCoordinates useTextureCoordinates, - Geometry::Normals useNormals) + TriangleSoup::Positions usePositions, + TriangleSoup::TextureCoordinates useTextureCoordinates, + TriangleSoup::Normals useNormals) : Grid( xSegments, ySegments, @@ -43,19 +43,19 @@ BasicGrid::BasicGrid( useTextureCoordinates, useNormals) { - _geometry = std::unique_ptr(new Geometry( + _geometry = std::unique_ptr(new TriangleSoup( CreateElements(xSegments, ySegments), usePositions, useTextureCoordinates, useNormals)); - if (usePositions == Geometry::Positions::Yes) { + if (usePositions == TriangleSoup::Positions::Yes) { _geometry->setVertexPositions(CreatePositions(_xSegments, _ySegments)); } - if (useTextureCoordinates == Geometry::TextureCoordinates::Yes) { + if (useTextureCoordinates == TriangleSoup::TextureCoordinates::Yes) { _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(_xSegments, _ySegments)); } - if (useNormals == Geometry::Normals::Yes) { + if (useNormals == TriangleSoup::Normals::Yes) { _geometry->setVertexNormals(CreateNormals(_xSegments, _ySegments)); } } diff --git a/modules/globebrowsing/rendering/basicgrid.h b/modules/globebrowsing/meshes/basicgrid.h similarity index 94% rename from modules/globebrowsing/rendering/basicgrid.h rename to modules/globebrowsing/meshes/basicgrid.h index a2f1fd76ef..bfa8935f53 100644 --- a/modules/globebrowsing/rendering/basicgrid.h +++ b/modules/globebrowsing/meshes/basicgrid.h @@ -28,7 +28,7 @@ #include -#include +#include #include @@ -50,9 +50,9 @@ public: BasicGrid( unsigned int xSegments, unsigned int ySegments, - Geometry::Positions usePositions, - Geometry::TextureCoordinates useTextureCoordinates, - Geometry::Normals useNormals); + TriangleSoup::Positions usePositions, + TriangleSoup::TextureCoordinates useTextureCoordinates, + TriangleSoup::Normals useNormals); ~BasicGrid(); diff --git a/modules/globebrowsing/rendering/clipmapgrid.cpp b/modules/globebrowsing/meshes/clipmapgrid.cpp similarity index 96% rename from modules/globebrowsing/rendering/clipmapgrid.cpp rename to modules/globebrowsing/meshes/clipmapgrid.cpp index b535c872d8..98b4799041 100644 --- a/modules/globebrowsing/rendering/clipmapgrid.cpp +++ b/modules/globebrowsing/meshes/clipmapgrid.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include #include @@ -37,7 +37,7 @@ namespace openspace { ////////////////////////////////////////////////////////////////////////////////////////// ClipMapGrid::ClipMapGrid(unsigned int segments) - : Grid(segments, segments, Geometry::Positions::No, Geometry::TextureCoordinates::Yes, Geometry::Normals::No) + : Grid(segments, segments, TriangleSoup::Positions::No, TriangleSoup::TextureCoordinates::Yes, TriangleSoup::Normals::No) { } @@ -66,11 +66,11 @@ int ClipMapGrid::segments() const { OuterClipMapGrid::OuterClipMapGrid(unsigned int segments) : ClipMapGrid(segments) { - _geometry = std::unique_ptr(new Geometry( + _geometry = std::unique_ptr(new TriangleSoup( CreateElements(segments, segments), - Geometry::Positions::No, - Geometry::TextureCoordinates::Yes, - Geometry::Normals::No)); + TriangleSoup::Positions::No, + TriangleSoup::TextureCoordinates::Yes, + TriangleSoup::Normals::No)); _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments)); } @@ -323,11 +323,11 @@ std::vector OuterClipMapGrid::CreateNormals(int xRes, int yRes) { InnerClipMapGrid::InnerClipMapGrid(unsigned int segments) : ClipMapGrid(segments) { - _geometry = std::unique_ptr(new Geometry( + _geometry = std::unique_ptr(new TriangleSoup( CreateElements(segments, segments), - Geometry::Positions::No, - Geometry::TextureCoordinates::Yes, - Geometry::Normals::No)); + TriangleSoup::Positions::No, + TriangleSoup::TextureCoordinates::Yes, + TriangleSoup::Normals::No)); _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments)); } diff --git a/modules/globebrowsing/rendering/clipmapgrid.h b/modules/globebrowsing/meshes/clipmapgrid.h similarity index 99% rename from modules/globebrowsing/rendering/clipmapgrid.h rename to modules/globebrowsing/meshes/clipmapgrid.h index f3e650a2cd..7f580f02fd 100644 --- a/modules/globebrowsing/rendering/clipmapgrid.h +++ b/modules/globebrowsing/meshes/clipmapgrid.h @@ -25,7 +25,7 @@ #ifndef __CLIPMAPGEOMETRY_H__ #define __CLIPMAPGEOMETRY_H__ -#include +#include #include #include diff --git a/modules/globebrowsing/rendering/grid.cpp b/modules/globebrowsing/meshes/grid.cpp similarity index 91% rename from modules/globebrowsing/rendering/grid.cpp rename to modules/globebrowsing/meshes/grid.cpp index fa112d4e82..cc3a848ce4 100644 --- a/modules/globebrowsing/rendering/grid.cpp +++ b/modules/globebrowsing/meshes/grid.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include namespace { const std::string _loggerCat = "Grid"; @@ -33,9 +33,9 @@ namespace openspace { Grid::Grid( int xSegments, int ySegments, - Geometry::Positions usePositions, - Geometry::TextureCoordinates useTextures, - Geometry::Normals useNormals) + TriangleSoup::Positions usePositions, + TriangleSoup::TextureCoordinates useTextures, + TriangleSoup::Normals useNormals) : _xSegments(xSegments) , _ySegments(ySegments) { @@ -47,7 +47,7 @@ Grid::~Grid() } -Geometry& Grid::geometry() +TriangleSoup& Grid::geometry() { return *_geometry; } diff --git a/modules/globebrowsing/rendering/grid.h b/modules/globebrowsing/meshes/grid.h similarity index 89% rename from modules/globebrowsing/rendering/grid.h rename to modules/globebrowsing/meshes/grid.h index 496319b47a..b78eddbd73 100644 --- a/modules/globebrowsing/rendering/grid.h +++ b/modules/globebrowsing/meshes/grid.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include @@ -40,12 +40,12 @@ public: Grid( int xSegments, int ySegments, - Geometry::Positions usePositions = Geometry::Positions::No, - Geometry::TextureCoordinates useTextures = Geometry::TextureCoordinates::No, - Geometry::Normals useNormals = Geometry::Normals::No); + TriangleSoup::Positions usePositions = TriangleSoup::Positions::No, + TriangleSoup::TextureCoordinates useTextures = TriangleSoup::TextureCoordinates::No, + TriangleSoup::Normals useNormals = TriangleSoup::Normals::No); ~Grid(); - Geometry& geometry(); + TriangleSoup& geometry(); /** Returns the number of grid cells in the x direction. Hence the number of vertices @@ -65,7 +65,7 @@ protected: virtual std::vector CreateTextureCoordinates( int xSegments, int ySegments) = 0; virtual std::vector CreateNormals( int xSegments, int ySegments) = 0; - std::unique_ptr _geometry; + std::unique_ptr _geometry; const int _xSegments; const int _ySegments; diff --git a/modules/globebrowsing/rendering/geometry.cpp b/modules/globebrowsing/meshes/trianglesoup.cpp similarity index 90% rename from modules/globebrowsing/rendering/geometry.cpp rename to modules/globebrowsing/meshes/trianglesoup.cpp index c17905fac0..99b739f64e 100644 --- a/modules/globebrowsing/rendering/geometry.cpp +++ b/modules/globebrowsing/meshes/trianglesoup.cpp @@ -22,16 +22,16 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include namespace { - const std::string _loggerCat = "Geometry"; + const std::string _loggerCat = "TriangleSoup"; } namespace openspace { -Geometry::Geometry(std::vector elements, +TriangleSoup::TriangleSoup(std::vector elements, Positions usePositions, TextureCoordinates useTextures, Normals useNormals) : _vaoID(0) ,_vertexBufferID(0) @@ -43,14 +43,14 @@ Geometry::Geometry(std::vector elements, setElements(elements); } -Geometry::~Geometry() { +TriangleSoup::~TriangleSoup() { glDeleteBuffers(1, &_vertexBufferID); glDeleteBuffers(1, &_elementBufferID); glDeleteVertexArrays(1, &_vaoID); } -void Geometry::setVertexPositions(std::vector positions) { +void TriangleSoup::setVertexPositions(std::vector positions) { _useVertexPositions = true; _gpuDataNeedUpdate = true; _vertexData.resize(positions.size()); @@ -64,7 +64,7 @@ void Geometry::setVertexPositions(std::vector positions) { } -void Geometry::setVertexTextureCoordinates(std::vector textures) { +void TriangleSoup::setVertexTextureCoordinates(std::vector textures) { _useTextureCoordinates = true; _gpuDataNeedUpdate = true; _vertexData.resize(textures.size()); @@ -76,7 +76,7 @@ void Geometry::setVertexTextureCoordinates(std::vector textures) { } -void Geometry::setVertexNormals(std::vector normals) { +void TriangleSoup::setVertexNormals(std::vector normals) { _useVertexNormals = true; _gpuDataNeedUpdate = true; _vertexData.resize(normals.size()); @@ -89,7 +89,7 @@ void Geometry::setVertexNormals(std::vector normals) { } -void Geometry::setElements(std::vector elements) { +void TriangleSoup::setElements(std::vector elements) { _elementData.resize(elements.size()); _gpuDataNeedUpdate = true; for (size_t i = 0; i < elements.size(); i++) @@ -98,7 +98,7 @@ void Geometry::setElements(std::vector elements) { } } -bool Geometry::updateDataInGPU() { +bool TriangleSoup::updateDataInGPU() { // Create VAO if (_vaoID == 0) glGenVertexArrays(1, &_vaoID); @@ -161,7 +161,7 @@ bool Geometry::updateDataInGPU() { return true; } -void Geometry::drawUsingActiveProgram() { +void TriangleSoup::drawUsingActiveProgram() { if (_gpuDataNeedUpdate) { updateDataInGPU(); } diff --git a/modules/globebrowsing/rendering/geometry.h b/modules/globebrowsing/meshes/trianglesoup.h similarity index 96% rename from modules/globebrowsing/rendering/geometry.h rename to modules/globebrowsing/meshes/trianglesoup.h index e4eeeed9c1..23b3e6d04f 100644 --- a/modules/globebrowsing/rendering/geometry.h +++ b/modules/globebrowsing/meshes/trianglesoup.h @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __GEOMETRY_H__ -#define __GEOMETRY_H__ +#ifndef __TRIANGLESOUP_H__ +#define __TRIANGLESOUP_H__ #include #include @@ -44,19 +44,19 @@ namespace openspace { // TODO : Possibly render triangle strips in this class instead of triangles since // that is faster -class Geometry +class TriangleSoup { public: enum class Positions { Yes, No }; enum class TextureCoordinates { Yes, No }; enum class Normals { Yes, No }; - Geometry( + TriangleSoup( std::vector elements, // At least elements are required Positions usePositions = Positions::No, TextureCoordinates useTextures = TextureCoordinates::No, Normals useNormals = Normals::No); - ~Geometry(); + ~TriangleSoup(); // Setters void setVertexPositions(std::vector positions); @@ -100,4 +100,4 @@ private: } // namespace openspace -#endif // __GEOMETRY_H__ \ No newline at end of file +#endif // __TRIANGLESOUP_H__ \ No newline at end of file diff --git a/modules/globebrowsing/rendering/distanceswitch.cpp b/modules/globebrowsing/other/distanceswitch.cpp similarity index 98% rename from modules/globebrowsing/rendering/distanceswitch.cpp rename to modules/globebrowsing/other/distanceswitch.cpp index e2fda3b1af..aa1fe9ad73 100644 --- a/modules/globebrowsing/rendering/distanceswitch.cpp +++ b/modules/globebrowsing/other/distanceswitch.cpp @@ -23,7 +23,7 @@ ****************************************************************************************/ // open space includes -#include +#include namespace { const std::string _loggerCat = "DistanceSwitch"; diff --git a/modules/globebrowsing/rendering/distanceswitch.h b/modules/globebrowsing/other/distanceswitch.h similarity index 100% rename from modules/globebrowsing/rendering/distanceswitch.h rename to modules/globebrowsing/other/distanceswitch.h diff --git a/modules/globebrowsing/rendering/frustrumculler.cpp b/modules/globebrowsing/other/frustrumculler.cpp similarity index 96% rename from modules/globebrowsing/rendering/frustrumculler.cpp rename to modules/globebrowsing/other/frustrumculler.cpp index 1b5f24bfe4..87dd03a06e 100644 --- a/modules/globebrowsing/rendering/frustrumculler.cpp +++ b/modules/globebrowsing/other/frustrumculler.cpp @@ -23,7 +23,7 @@ ****************************************************************************************/ -#include +#include namespace { const std::string _loggerCat = "FrustrumCuller"; @@ -56,7 +56,7 @@ namespace openspace { } - bool FrustrumCuller::isVisible(const RenderData& data, const LatLonPatch& patch, double radius) { + bool FrustrumCuller::isVisible(const RenderData& data, const GeodeticPatch& patch, double radius) { // An axis aligned bounding box based on the patch's minimum boudning sphere is // used for testnig diff --git a/modules/globebrowsing/rendering/frustrumculler.h b/modules/globebrowsing/other/frustrumculler.h similarity index 97% rename from modules/globebrowsing/rendering/frustrumculler.h rename to modules/globebrowsing/other/frustrumculler.h index 4974de6640..583c1c073a 100644 --- a/modules/globebrowsing/rendering/frustrumculler.h +++ b/modules/globebrowsing/other/frustrumculler.h @@ -32,8 +32,7 @@ #include -#include - +#include namespace openspace { @@ -65,7 +64,7 @@ namespace openspace { */ bool isVisible( const RenderData& data, - const LatLonPatch& patch, + const GeodeticPatch& patch, double radius); private: diff --git a/modules/globebrowsing/rendering/gdaldataconverter.cpp b/modules/globebrowsing/other/gdaldataconverter.cpp similarity index 98% rename from modules/globebrowsing/rendering/gdaldataconverter.cpp rename to modules/globebrowsing/other/gdaldataconverter.cpp index b01b679c71..b986833071 100644 --- a/modules/globebrowsing/rendering/gdaldataconverter.cpp +++ b/modules/globebrowsing/other/gdaldataconverter.cpp @@ -23,7 +23,7 @@ ****************************************************************************************/ -#include +#include namespace { const std::string _loggerCat = "GdalDataConverter"; diff --git a/modules/globebrowsing/rendering/gdaldataconverter.h b/modules/globebrowsing/other/gdaldataconverter.h similarity index 100% rename from modules/globebrowsing/rendering/gdaldataconverter.h rename to modules/globebrowsing/other/gdaldataconverter.h diff --git a/modules/globebrowsing/datastructures/lrucache.h b/modules/globebrowsing/other/lrucache.h similarity index 97% rename from modules/globebrowsing/datastructures/lrucache.h rename to modules/globebrowsing/other/lrucache.h index 3162a4ea44..bb3ccfd944 100644 --- a/modules/globebrowsing/datastructures/lrucache.h +++ b/modules/globebrowsing/other/lrucache.h @@ -65,6 +65,6 @@ namespace openspace { } // namespace openspace -#include +#include #endif // __LRU_CACHE_H__ diff --git a/modules/globebrowsing/datastructures/lrucache.inl b/modules/globebrowsing/other/lrucache.inl similarity index 100% rename from modules/globebrowsing/datastructures/lrucache.inl rename to modules/globebrowsing/other/lrucache.inl diff --git a/modules/globebrowsing/rendering/patchrenderer.cpp b/modules/globebrowsing/other/patchrenderer.cpp similarity index 92% rename from modules/globebrowsing/rendering/patchrenderer.cpp rename to modules/globebrowsing/other/patchrenderer.cpp index 6c4c23437c..ebf302e336 100644 --- a/modules/globebrowsing/rendering/patchrenderer.cpp +++ b/modules/globebrowsing/other/patchrenderer.cpp @@ -22,9 +22,9 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include -#include +#include // open space includes #include @@ -56,7 +56,7 @@ namespace openspace { // PATCH RENDERER // ////////////////////////////////////////////////////////////////////////////////////// PatchRenderer::PatchRenderer() - : _tileSet(LatLon(M_PI, M_PI * 2), LatLon(M_PI / 2, -M_PI), 0) + : _tileSet(Geodetic2(M_PI, M_PI * 2), Geodetic2(M_PI / 2, -M_PI), 0) { } @@ -89,7 +89,7 @@ namespace openspace { } void LatLonPatchRenderer::renderPatch( - const LatLonPatch& patch, const RenderData& data, double radius) + const GeodeticPatch& patch, const RenderData& data, double radius) { // Get the textures that should be used for rendering @@ -98,7 +98,7 @@ namespace openspace { renderPatch(patch, data, radius, ti); } - void LatLonPatchRenderer::renderPatch(const LatLonPatch& patch,const RenderData& data, + void LatLonPatchRenderer::renderPatch(const GeodeticPatch& patch,const RenderData& data, double radius, const TileIndex& tileIndex) { @@ -141,7 +141,7 @@ namespace openspace { _programObject->setUniform("textureSampler", texUnit); _programObject->setUniform("uvTransformPatchToTile", uvTransform); - LatLon swCorner = patch.southWestCorner(); + Geodetic2 swCorner = patch.southWestCorner(); _programObject->setUniform("segmentsPerPatch", _grid->xSegments()); _programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform); _programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2())); @@ -179,7 +179,7 @@ namespace openspace { } void ClipMapPatchRenderer::renderPatch( - const LatLon& patchSize, + const Geodetic2& patchSize, const RenderData& data, double radius) { @@ -194,22 +194,22 @@ namespace openspace { // Snap patch position int segmentsPerPatch = _grid->segments(); - LatLon stepSize = LatLon( + Geodetic2 stepSize = Geodetic2( patchSize.lat / segmentsPerPatch, patchSize.lon / segmentsPerPatch); ivec2 patchesToCoverGlobe = ivec2( M_PI / patchSize.lat + 0.5, M_PI * 2 / patchSize.lon + 0.5); - LatLon cameraPosLatLon = LatLon::fromCartesian(data.camera.position().dvec3()); + Geodetic2 cameraPosLatLon = Geodetic2::fromCartesian(data.camera.position().dvec3()); ivec2 intSnapCoord = ivec2( cameraPosLatLon.lat / (M_PI * 2) * segmentsPerPatch * patchesToCoverGlobe.y, cameraPosLatLon.lon / (M_PI) * segmentsPerPatch * patchesToCoverGlobe.x); - LatLon newPatchCenter = LatLon( + Geodetic2 newPatchCenter = Geodetic2( stepSize.lat * intSnapCoord.x, stepSize.lon * intSnapCoord.y); - LatLonPatch newPatch( + GeodeticPatch newPatch( newPatchCenter, - LatLon(patchSize.lat / 2, patchSize.lon / 2)); + Geodetic2(patchSize.lat / 2, patchSize.lon / 2)); ivec2 contraction = ivec2(intSnapCoord.y % 2, intSnapCoord.x % 2); @@ -220,7 +220,7 @@ namespace openspace { // Get the textures that should be used for rendering TileIndex tileIndex = _tileSet.getTileIndex(newPatch); - LatLonPatch tilePatch = _tileSet.getTilePositionAndScale(tileIndex); + GeodeticPatch tilePatch = _tileSet.getTilePositionAndScale(tileIndex); std::shared_ptr tile00 = _tileSet.getTile(tileIndex); glm::mat3 uvTransform = _tileSet.getUvTransformationPatchToTile(newPatch, tileIndex); diff --git a/modules/globebrowsing/other/patchrenderer.h b/modules/globebrowsing/other/patchrenderer.h new file mode 100644 index 0000000000..97da5f93a4 --- /dev/null +++ b/modules/globebrowsing/other/patchrenderer.h @@ -0,0 +1,108 @@ +/***************************************************************************************** +* * +* OpenSpace * +* * +* Copyright (c) 2014-2016 * +* * +* Permission is hereby granted, free of charge, to any person obtaining a copy of this * +* software and associated documentation files (the "Software"), to deal in the Software * +* without restriction, including without limitation the rights to use, copy, modify, * +* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * +* permit persons to whom the Software is furnished to do so, subject to the following * +* conditions: * +* * +* The above copyright notice and this permission notice shall be included in all copies * +* or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * +* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * +* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * +* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * +* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * +* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * +****************************************************************************************/ + +#ifndef __LATLONPATCH_H__ +#define __LATLONPATCH_H__ + +#include +#include + +// open space includes +#include + +#include +#include +#include +#include +#include + +namespace ghoul { +namespace opengl { + class ProgramObject; +} +} + + +namespace openspace { + + class LonLatPatch; + class TriangleSoup; + + using std::shared_ptr; + using std::unique_ptr; + using ghoul::opengl::ProgramObject; + + class PatchRenderer { + public: + + PatchRenderer(); + ~PatchRenderer(); + + protected: + + unique_ptr _programObject; + TextureTileSet _tileSet; + }; + + + ////////////////////////////////////////////////////////////////////////////////////// + // PATCH RENDERER SUBCLASSES // + ////////////////////////////////////////////////////////////////////////////////////// + + class LatLonPatchRenderer : public PatchRenderer { + public: + LatLonPatchRenderer(shared_ptr grid); + + void renderPatch( + const GeodeticPatch& patch, + const RenderData& data, + double radius); + + void renderPatch( + const GeodeticPatch& patch, + const RenderData& data, + double radius, + const TileIndex& ti); + private: + shared_ptr _grid; + TwmsTileProvider tileProvider; + }; + + + + class ClipMapPatchRenderer : public PatchRenderer { + public: + ClipMapPatchRenderer(shared_ptr grid); + + void renderPatch( + const Geodetic2& patchSize, + const RenderData& data, + double radius); + private: + shared_ptr _grid; + }; + +} // namespace openspace + +#endif // __LATLONPATCH_H__ \ No newline at end of file diff --git a/modules/globebrowsing/rendering/texturetileset.cpp b/modules/globebrowsing/other/texturetileset.cpp similarity index 88% rename from modules/globebrowsing/rendering/texturetileset.cpp rename to modules/globebrowsing/other/texturetileset.cpp index b453b037c5..a867743dcc 100644 --- a/modules/globebrowsing/rendering/texturetileset.cpp +++ b/modules/globebrowsing/other/texturetileset.cpp @@ -22,9 +22,9 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include -#include +#include #include #include @@ -43,7 +43,7 @@ namespace { namespace openspace { - TextureTileSet::TextureTileSet(LatLon sizeLevel0, LatLon offsetLevel0, int depth) + TextureTileSet::TextureTileSet(Geodetic2 sizeLevel0, Geodetic2 offsetLevel0, int depth) : _sizeLevel0(sizeLevel0) , _offsetLevel0(offsetLevel0) , _depth(depth) @@ -88,7 +88,7 @@ namespace openspace { } - TileIndex TextureTileSet::getTileIndex(LatLonPatch patch) { + TileIndex TextureTileSet::getTileIndex(GeodeticPatch patch) { // Calculate the level of the index depanding on the size of the incoming patch. // The level is as big as possible (as far down as possible) but it can't be // too big since at maximum four tiles should be used to cover a patch @@ -113,7 +113,7 @@ namespace openspace { return tileIndex; } - std::shared_ptr TextureTileSet::getTile(LatLonPatch patch) { + std::shared_ptr TextureTileSet::getTile(GeodeticPatch patch) { return getTile(getTileIndex(patch)); } @@ -121,30 +121,30 @@ namespace openspace { return _testTexture; } - LatLonPatch TextureTileSet::getTilePositionAndScale(const TileIndex& tileIndex) { - LatLon tileSize = LatLon( + GeodeticPatch TextureTileSet::getTilePositionAndScale(const TileIndex& tileIndex) { + Geodetic2 tileSize = Geodetic2( _sizeLevel0.lat / pow(2, tileIndex.level), _sizeLevel0.lon / pow(2, tileIndex.level)); - LatLon northWest = LatLon( + Geodetic2 northWest = Geodetic2( _offsetLevel0.lat + tileIndex.y * tileSize.lat, _offsetLevel0.lon + tileIndex.x * tileSize.lon); - return LatLonPatch( - LatLon(northWest.lat - tileSize.lat / 2, northWest.lon + tileSize.lon / 2), - LatLon(tileSize.lat / 2, tileSize.lon / 2)); + return GeodeticPatch( + Geodetic2(northWest.lat - tileSize.lat / 2, northWest.lon + tileSize.lon / 2), + Geodetic2(tileSize.lat / 2, tileSize.lon / 2)); } glm::mat3 TextureTileSet::getUvTransformationPatchToTile( - LatLonPatch patch, + GeodeticPatch patch, const TileIndex& tileIndex) { - LatLonPatch tile = getTilePositionAndScale(tileIndex); + GeodeticPatch tile = getTilePositionAndScale(tileIndex); return getUvTransformationPatchToTile(patch, tile); } glm::mat3 TextureTileSet::getUvTransformationPatchToTile( - LatLonPatch patch, - LatLonPatch tile) + GeodeticPatch patch, + GeodeticPatch tile) { Vec2 posDiff = patch.southWestCorner().toLonLatVec2() - diff --git a/modules/globebrowsing/rendering/texturetileset.h b/modules/globebrowsing/other/texturetileset.h similarity index 88% rename from modules/globebrowsing/rendering/texturetileset.h rename to modules/globebrowsing/other/texturetileset.h index 9f65766e42..7154f21517 100644 --- a/modules/globebrowsing/rendering/texturetileset.h +++ b/modules/globebrowsing/other/texturetileset.h @@ -28,11 +28,9 @@ #include #include -#include - -#include - +#include +#include ////////////////////////////////////////////////////////////////////////////////////////// @@ -46,7 +44,7 @@ namespace openspace { class TextureTileSet { public: - TextureTileSet(LatLon sizeLevel0, LatLon offsetLevel0, int depth); + TextureTileSet(Geodetic2 sizeLevel0, Geodetic2 offsetLevel0, int depth); ~TextureTileSet(); /** @@ -55,12 +53,12 @@ namespace openspace { Without the tile being smaller than the patch in lat-lon space. The tile is at least as big as the patch. */ - TileIndex getTileIndex(LatLonPatch patch); + TileIndex getTileIndex(GeodeticPatch patch); /** Returns a texture that can be used for the specified patch */ - std::shared_ptr getTile(LatLonPatch patch); + std::shared_ptr getTile(GeodeticPatch patch); /** Returns the texture for the given tile index. The indices reaches from left @@ -73,26 +71,26 @@ namespace openspace { A tile can be defined with a tile index or a LatLonPatch which defines the position and the size of the tile. */ - LatLonPatch getTilePositionAndScale(const TileIndex& tileIndex); + GeodeticPatch getTilePositionAndScale(const TileIndex& tileIndex); /** A transformation (translation and scaling) from the texture space of a patch to the texture space of a tile. */ glm::mat3 getUvTransformationPatchToTile( - LatLonPatch patch, + GeodeticPatch patch, const TileIndex& tileIndex); /** Overloaded function */ glm::mat3 getUvTransformationPatchToTile( - LatLonPatch patch, - LatLonPatch tile); + GeodeticPatch patch, + GeodeticPatch tile); private: - LatLon _sizeLevel0; - LatLon _offsetLevel0; + Geodetic2 _sizeLevel0; + Geodetic2 _offsetLevel0; int _depth; std::shared_ptr _testTexture; diff --git a/modules/globebrowsing/rendering/twmstileprovider.cpp b/modules/globebrowsing/other/twmstileprovider.cpp similarity index 99% rename from modules/globebrowsing/rendering/twmstileprovider.cpp rename to modules/globebrowsing/other/twmstileprovider.cpp index 908a280362..ea6974abcc 100644 --- a/modules/globebrowsing/rendering/twmstileprovider.cpp +++ b/modules/globebrowsing/other/twmstileprovider.cpp @@ -23,7 +23,7 @@ ****************************************************************************************/ -#include +#include #include diff --git a/modules/globebrowsing/rendering/twmstileprovider.h b/modules/globebrowsing/other/twmstileprovider.h similarity index 98% rename from modules/globebrowsing/rendering/twmstileprovider.h rename to modules/globebrowsing/other/twmstileprovider.h index b965d128a3..6d3f740094 100644 --- a/modules/globebrowsing/rendering/twmstileprovider.h +++ b/modules/globebrowsing/other/twmstileprovider.h @@ -25,6 +25,8 @@ #ifndef __TWMS_TILE_PROVIDER_H__ #define __TWMS_TILE_PROVIDER_H__ +#include + #include #include @@ -32,7 +34,6 @@ - ////////////////////////////////////////////////////////////////////////////////////// // TILE INDEX // ////////////////////////////////////////////////////////////////////////////////////// @@ -49,9 +50,6 @@ namespace openspace { }; } -#include - - ////////////////////////////////////////////////////////////////////////////////////////// // TWMS TILE PROVIDER // diff --git a/modules/globebrowsing/shaders/simple_fs.glsl b/modules/globebrowsing/shaders/simple_fs.glsl index efe7c44597..ae9fd13355 100644 --- a/modules/globebrowsing/shaders/simple_fs.glsl +++ b/modules/globebrowsing/shaders/simple_fs.glsl @@ -51,7 +51,7 @@ Fragment getFragment() { Fragment frag; frag.color = texture(textureSampler, vec2(uvTransformPatchToTile * vec3(vs_uv.s, vs_uv.t, 1))); - frag.color = 0.001*frag.color + 0.999*texture(textureSampler, vs_uv); + //frag.color = 0.001*frag.color + 0.999*texture(textureSampler, vs_uv); vec4 uvColor = vec4(fract(vs_uv * segmentsPerPatch), 0.4,1); frag.color = frag.color.a < 0.1 ? uvColor * 0.5 : frag.color; diff --git a/tests/main.cpp b/tests/main.cpp index 95e1200112..3ca71a4a53 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -33,16 +33,16 @@ //#include //#include //#include -//#include -//#include -//#include +#include +#include +#include //#include //#include //#include //#include //#include -#include +//#include #include #include diff --git a/tests/test_angle.inl b/tests/test_angle.inl index 0113617356..2d8b0c82a7 100644 --- a/tests/test_angle.inl +++ b/tests/test_angle.inl @@ -25,7 +25,7 @@ #include "gtest/gtest.h" #include -#include +#include #include #include diff --git a/tests/test_chunknode.inl b/tests/test_chunknode.inl index b6e3713aae..72e30d36d0 100644 --- a/tests/test_chunknode.inl +++ b/tests/test_chunknode.inl @@ -25,8 +25,8 @@ #include "gtest/gtest.h" #include -#include -#include +#include +#include #include #include diff --git a/tests/test_latlonpatch.inl b/tests/test_latlonpatch.inl index 90a764d130..55eccc9df5 100644 --- a/tests/test_latlonpatch.inl +++ b/tests/test_latlonpatch.inl @@ -24,7 +24,7 @@ #include "gtest/gtest.h" -#include +#include #define _USE_MATH_DEFINES #include @@ -36,7 +36,7 @@ using namespace openspace; TEST_F(LatLonPatchTest, findCenterControlPoint) { - LatLonPatch patch(0, 0, M_PI / 4, M_PI / 4); + GeodeticPatch patch(0, 0, M_PI / 4, M_PI / 4); } @@ -45,15 +45,15 @@ TEST_F(LatLonPatchTest, findCenterControlPoint) { TEST_F(LatLonPatchTest, TestFindClosestCorner) { Scalar piOver4 = M_PI / 4; - LatLon halfSize(piOver4, piOver4); - LatLon center(0, 0); - LatLonPatch patch(center, halfSize); + Geodetic2 halfSize(piOver4, piOver4); + Geodetic2 center(0, 0); + GeodeticPatch patch(center, halfSize); Scalar piOver3 = M_PI / 3; - LatLon point(piOver3, piOver3); + Geodetic2 point(piOver3, piOver3); - LatLon closestCorner = patch.closestCorner(point); - LatLon northEastCorner = patch.northEastCorner(); + Geodetic2 closestCorner = patch.closestCorner(point); + Geodetic2 northEastCorner = patch.northEastCorner(); ASSERT_EQ(closestCorner.lat, northEastCorner.lat); ASSERT_EQ(closestCorner.lon, northEastCorner.lon); @@ -65,14 +65,14 @@ TEST_F(LatLonPatchTest, TestFindClosestCorner2) { Scalar piOver6 = M_PI / 4; Scalar piOver3 = M_PI / 3; - LatLon halfSize(1.1*piOver6, 1.1*piOver6); - LatLon center(piOver6, piOver6); - LatLonPatch patch(center, halfSize); + Geodetic2 halfSize(1.1*piOver6, 1.1*piOver6); + Geodetic2 center(piOver6, piOver6); + GeodeticPatch patch(center, halfSize); - LatLon point(0, 0); + Geodetic2 point(0, 0); - LatLon closestCorner = patch.closestCorner(point); - LatLon expectedCorner = patch.southWestCorner(); + Geodetic2 closestCorner = patch.closestCorner(point); + Geodetic2 expectedCorner = patch.southWestCorner(); ASSERT_EQ(closestCorner.lat, expectedCorner.lat); ASSERT_EQ(closestCorner.lon, expectedCorner.lon); @@ -81,64 +81,64 @@ TEST_F(LatLonPatchTest, TestFindClosestCorner2) { TEST_F(LatLonPatchTest, TestSphericalClamp1) { - LatLonPatch patch(0, 0, M_PI / 4, M_PI / 4); + GeodeticPatch patch(0, 0, M_PI / 4, M_PI / 4); // inside patch latitude-wise, east of patch longitude-wise - LatLon point(M_PI / 6, M_PI - 0.01); + Geodetic2 point(M_PI / 6, M_PI - 0.01); - LatLon clampedPoint = patch.closestPoint(point); - LatLon neCorner = patch.northEastCorner(); + Geodetic2 clampedPoint = patch.closestPoint(point); + Geodetic2 neCorner = patch.northEastCorner(); ASSERT_EQ(clampedPoint.lat, neCorner.lat); ASSERT_EQ(clampedPoint.lon, neCorner.lon); } TEST_F(LatLonPatchTest, TestSphericalClamp2) { - LatLonPatch patch(0, 0, M_PI / 4, M_PI / 4); + GeodeticPatch patch(0, 0, M_PI / 4, M_PI / 4); // inside patch latitude-wise, west of patch longitude-wise - LatLon point(M_PI / 6, M_PI + 0.01); + Geodetic2 point(M_PI / 6, M_PI + 0.01); - LatLon clampedPoint = patch.closestPoint(point); - LatLon nwCorner = patch.northWestCorner(); + Geodetic2 clampedPoint = patch.closestPoint(point); + Geodetic2 nwCorner = patch.northWestCorner(); ASSERT_EQ(clampedPoint.lat, nwCorner.lat); ASSERT_EQ(clampedPoint.lon, nwCorner.lon); } TEST_F(LatLonPatchTest, TestSphericalClamp3) { - LatLonPatch patch(0, 0, M_PI / 4, M_PI / 4); + GeodeticPatch patch(0, 0, M_PI / 4, M_PI / 4); // North east of patch - LatLon point(M_PI / 3, M_PI - 0.01); + Geodetic2 point(M_PI / 3, M_PI - 0.01); - LatLon clampedPoint = patch.closestPoint(point); - LatLon neCorner = patch.northEastCorner(); + Geodetic2 clampedPoint = patch.closestPoint(point); + Geodetic2 neCorner = patch.northEastCorner(); ASSERT_EQ(clampedPoint.lat, neCorner.lat); ASSERT_EQ(clampedPoint.lon, neCorner.lon); } TEST_F(LatLonPatchTest, TestSphericalClamp4) { - LatLonPatch patch(0, 0, M_PI / 4, M_PI / 4); + GeodeticPatch patch(0, 0, M_PI / 4, M_PI / 4); // South east of patch - LatLon point(-M_PI / 3, M_PI - 0.01); + Geodetic2 point(-M_PI / 3, M_PI - 0.01); - LatLon clampedPoint = patch.closestPoint(point); - LatLon seCorner = patch.southEastCorner(); + Geodetic2 clampedPoint = patch.closestPoint(point); + Geodetic2 seCorner = patch.southEastCorner(); ASSERT_EQ(clampedPoint.lat, seCorner.lat); ASSERT_EQ(clampedPoint.lon, seCorner.lon); } TEST_F(LatLonPatchTest, TestSphericalClamp5) { - LatLonPatch patch(0, 0, M_PI / 4, M_PI / 4); + GeodeticPatch patch(0, 0, M_PI / 4, M_PI / 4); // South west of patch - LatLon point(-M_PI / 3, 3*M_PI + 0.01); + Geodetic2 point(-M_PI / 3, 3*M_PI + 0.01); - LatLon clampedPoint = patch.closestPoint(point); - LatLon swCorner = patch.southWestCorner(); + Geodetic2 clampedPoint = patch.closestPoint(point); + Geodetic2 swCorner = patch.southWestCorner(); ASSERT_EQ(clampedPoint.lat, swCorner.lat); ASSERT_EQ(clampedPoint.lon, swCorner.lon); } @@ -148,7 +148,7 @@ int radAsDeg(double rads) { } TEST_F(LatLonPatchTest, PrintingSphericalClamp) { - LatLonPatch patch(0, 0, M_PI / 4, M_PI / 4); + GeodeticPatch patch(0, 0, M_PI / 4, M_PI / 4); using Ang = Angle; Ang delta = Ang::fromDegrees(30); @@ -156,8 +156,8 @@ TEST_F(LatLonPatchTest, PrintingSphericalClamp) { for (Ang lat = Ang::fromDegrees(90); lat > -Ang::QUARTER; lat -= delta) { for (Ang lon = Ang::fromDegrees(180); lon > -Ang::HALF; lon -= delta) { - LatLon point(lat.asRadians(), lon.asRadians()); - LatLon clamped = patch.closestPoint(point); + Geodetic2 point(lat.asRadians(), lon.asRadians()); + Geodetic2 clamped = patch.closestPoint(point); std::cout << radAsDeg(point.lat) << ", " << radAsDeg(point.lon) << " --> " diff --git a/tests/test_lrucache.inl b/tests/test_lrucache.inl index 08d9c1863a..6420e1febf 100644 --- a/tests/test_lrucache.inl +++ b/tests/test_lrucache.inl @@ -24,7 +24,7 @@ #include "gtest/gtest.h" -#include +#include #define _USE_MATH_DEFINES #include diff --git a/tests/test_texturetileset.inl b/tests/test_texturetileset.inl index 42858f5e2a..de7fabcf3a 100644 --- a/tests/test_texturetileset.inl +++ b/tests/test_texturetileset.inl @@ -24,7 +24,7 @@ #include "gtest/gtest.h" -#include +#include #define _USE_MATH_DEFINES #include @@ -37,9 +37,9 @@ using namespace openspace; TEST_F(TextureTileSetTest, getTileIndexLevel) { // Create a tile set with maximum depth 0 - TextureTileSet tileSet(LatLon(M_PI, M_PI * 2), LatLon(M_PI / 2, - M_PI), 0); + TextureTileSet tileSet(Geodetic2(M_PI, M_PI * 2), Geodetic2(M_PI / 2, - M_PI), 0); - LatLonPatch patch(LatLon(0, 0), LatLon(M_PI / 16, M_PI / 8)); + GeodeticPatch patch(Geodetic2(0, 0), Geodetic2(M_PI / 16, M_PI / 8)); TileIndex tileIndex0 = tileSet.getTileIndex(patch); // Maximum level is 0 @@ -47,10 +47,10 @@ TEST_F(TextureTileSetTest, getTileIndexLevel) { // Create a tile set with maximum depth 10 - TextureTileSet tileSetDepth10(LatLon(M_PI, M_PI * 2), LatLon(M_PI / 2, - M_PI), 10); + TextureTileSet tileSetDepth10(Geodetic2(M_PI, M_PI * 2), Geodetic2(M_PI / 2, - M_PI), 10); // A big tile that covers the whole latlon space - LatLonPatch patchBig(LatLon(0, 0), LatLon(M_PI / 2, M_PI)); + GeodeticPatch patchBig(Geodetic2(0, 0), Geodetic2(M_PI / 2, M_PI)); tileIndex0 = tileSetDepth10.getTileIndex(patchBig); // Should return 0 since the tile covers the whole latlon space @@ -58,7 +58,7 @@ TEST_F(TextureTileSetTest, getTileIndexLevel) { // An edge case tile that covers a fourth of the latlon space - LatLonPatch patchEdgeCase(LatLon(0, 0), LatLon(M_PI / 4, M_PI / 2)); + GeodeticPatch patchEdgeCase(Geodetic2(0, 0), Geodetic2(M_PI / 4, M_PI / 2)); TileIndex tileIndex1 = tileSetDepth10.getTileIndex(patchEdgeCase); // Now it can go up a level @@ -66,7 +66,7 @@ TEST_F(TextureTileSetTest, getTileIndexLevel) { // Bigger than the edge case - LatLonPatch patchEdgeCaseBigger(LatLon(0, 0), LatLon(M_PI / 4 + 0.001, M_PI / 2 + 0.001)); + GeodeticPatch patchEdgeCaseBigger(Geodetic2(0, 0), Geodetic2(M_PI / 4 + 0.001, M_PI / 2 + 0.001)); tileIndex0 = tileSetDepth10.getTileIndex(patchEdgeCaseBigger); // Should return 0 again @@ -76,9 +76,9 @@ TEST_F(TextureTileSetTest, getTileIndexLevel) { TEST_F(TextureTileSetTest, getTileIndexXY) { // Create a tile set with maximum depth 0 - TextureTileSet tileSet(LatLon(M_PI, M_PI * 2), LatLon(M_PI / 2, - M_PI), 0); + TextureTileSet tileSet(Geodetic2(M_PI, M_PI * 2), Geodetic2(M_PI / 2, - M_PI), 0); - LatLonPatch patch(LatLon(0, 0), LatLon(M_PI / 16, M_PI / 8)); + GeodeticPatch patch(Geodetic2(0, 0), Geodetic2(M_PI / 16, M_PI / 8)); TileIndex tileIndex0 = tileSet.getTileIndex(patch); // Maximum level is 0 so the x y indices should also be 0 @@ -87,10 +87,10 @@ TEST_F(TextureTileSetTest, getTileIndexXY) { // Create a tile set with maximum depth 10 - TextureTileSet tileSetDepth10(LatLon(M_PI, M_PI * 2), LatLon(M_PI / 2, - M_PI), 10); + TextureTileSet tileSetDepth10(Geodetic2(M_PI, M_PI * 2), Geodetic2(M_PI / 2, - M_PI), 10); // A big tile that covers the whole latlon space - LatLonPatch patchBig(LatLon(0, 0), LatLon(M_PI / 2, M_PI)); + GeodeticPatch patchBig(Geodetic2(0, 0), Geodetic2(M_PI / 2, M_PI)); tileIndex0 = tileSetDepth10.getTileIndex(patchBig); // Should return 0 in x and y since the tile covers the whole latlon space @@ -99,7 +99,7 @@ TEST_F(TextureTileSetTest, getTileIndexXY) { // A tile that covers a fourth of the latlon space - LatLonPatch patchEdgeCase(LatLon(0, 0), LatLon(M_PI / 4, M_PI / 2)); + GeodeticPatch patchEdgeCase(Geodetic2(0, 0), Geodetic2(M_PI / 4, M_PI / 2)); TileIndex tileIndex1 = tileSetDepth10.getTileIndex(patchEdgeCase); // Now it can go up a level (1) @@ -109,7 +109,7 @@ TEST_F(TextureTileSetTest, getTileIndexXY) { // A smaller edge case tile - LatLonPatch patchEdgeCase2(LatLon(0, 0), LatLon(M_PI / 8, M_PI / 4)); + GeodeticPatch patchEdgeCase2(Geodetic2(0, 0), Geodetic2(M_PI / 8, M_PI / 4)); TileIndex tileIndex11 = tileSetDepth10.getTileIndex(patchEdgeCase2); // Now it can go up two levels (2) @@ -122,10 +122,10 @@ TEST_F(TextureTileSetTest, getTileIndexXY) { TEST_F(TextureTileSetTest, getUvTransformationPatchToTile) { // Create a tile set with maximum depth 0 - TextureTileSet tileSet(LatLon(M_PI, M_PI * 2), LatLon(M_PI / 2, -M_PI), 0); + TextureTileSet tileSet(Geodetic2(M_PI, M_PI * 2), Geodetic2(M_PI / 2, -M_PI), 0); // Create a patch that covers the whole latlon space - LatLonPatch patch(LatLon(0, 0), LatLon(M_PI / 2, M_PI)); + GeodeticPatch patch(Geodetic2(0, 0), Geodetic2(M_PI / 2, M_PI)); // Should be a 1:1 mapping glm::mat3 patchToTileTransform = @@ -134,7 +134,7 @@ TEST_F(TextureTileSetTest, getUvTransformationPatchToTile) { ASSERT_EQ(patchToTileTransform, glm::mat3(1)); // Create a smaller patch in the upper west side - patch = LatLonPatch(LatLon(M_PI / 4, - M_PI / 2), LatLon(M_PI / 4, M_PI / 2)); + patch = GeodeticPatch(Geodetic2(M_PI / 4, - M_PI / 2), Geodetic2(M_PI / 4, M_PI / 2)); patchToTileTransform = tileSet.getUvTransformationPatchToTile(patch, { 0,0,0 }); diff --git a/tests/test_twmstileprovider.inl b/tests/test_twmstileprovider.inl index 3c350b76ac..ce63f9d32d 100644 --- a/tests/test_twmstileprovider.inl +++ b/tests/test_twmstileprovider.inl @@ -24,7 +24,7 @@ #include "gtest/gtest.h" -#include +#include #include #define _USE_MATH_DEFINES