From 8da0684ae29fecb01997ca9329d96e4e783cb300 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 7 Dec 2016 21:56:59 +0100 Subject: [PATCH] More cleanup for newhorizons and globebrowsing module --- modules/globebrowsing/CMakeLists.txt | 33 +- modules/globebrowsing/chunk/chunkrenderer.cpp | 471 ------------------ modules/globebrowsing/meshes/clipmapgrid.cpp | 447 ----------------- modules/globebrowsing/meshes/clipmapgrid.h | 132 ----- modules/globebrowsing/tile/tileioresult.cpp | 49 -- modules/globebrowsing/tile/tileioresult.h | 46 -- modules/globebrowsing/tile/tilepile.h | 54 -- modules/newhorizons/newhorizonsmodule.cpp | 14 +- .../newhorizons/rendering/renderablefov.cpp | 1 - modules/newhorizons/util/hongkangparser.cpp | 100 ++-- modules/newhorizons/util/imagesequencer.cpp | 108 ++-- 11 files changed, 124 insertions(+), 1331 deletions(-) delete mode 100644 modules/globebrowsing/chunk/chunkrenderer.cpp delete mode 100644 modules/globebrowsing/meshes/clipmapgrid.cpp delete mode 100644 modules/globebrowsing/meshes/clipmapgrid.h delete mode 100644 modules/globebrowsing/tile/tileioresult.cpp delete mode 100644 modules/globebrowsing/tile/tileioresult.h delete mode 100644 modules/globebrowsing/tile/tilepile.h diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index bdc3d1488b..d5859f8bed 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -32,6 +32,7 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/geometry/aabb.h ${CMAKE_CURRENT_SOURCE_DIR}/geometry/angle.h + ${CMAKE_CURRENT_SOURCE_DIR}/geometry/angle.inl ${CMAKE_CURRENT_SOURCE_DIR}/geometry/convexhull.h ${CMAKE_CURRENT_SOURCE_DIR}/geometry/ellipsoid.h ${CMAKE_CURRENT_SOURCE_DIR}/geometry/geodetic2.h @@ -45,14 +46,16 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/meshes/skirtedgrid.h ${CMAKE_CURRENT_SOURCE_DIR}/meshes/trianglesoup.h - ${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.h - ${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.h - ${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.h - ${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.h ${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentjobmanager.h ${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentjobmanager.inl ${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentqueue.h ${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentqueue.inl + ${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.inl + ${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.inl + ${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunkrenderer.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpulayermanager.h @@ -85,7 +88,6 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling.cpp ${CMAKE_CURRENT_SOURCE_DIR}/geometry/aabb.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/geometry/angle.inl ${CMAKE_CURRENT_SOURCE_DIR}/geometry/convexhull.cpp ${CMAKE_CURRENT_SOURCE_DIR}/geometry/ellipsoid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/geometry/geodetic2.cpp @@ -99,6 +101,15 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/meshes/skirtedgrid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/meshes/trianglesoup.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunkrenderer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpulayermanager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layershadermanager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layermanager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctilereader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tile.cpp @@ -114,18 +125,6 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileprovider.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileproviderbyindex.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileproviderbylevel.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunkrenderer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpulayermanager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layershadermanager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layermanager.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentjobmanager.inl - ${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.inl - ${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.inl - ${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.cpp ) source_group("Source Files" FILES ${SOURCE_FILES}) diff --git a/modules/globebrowsing/chunk/chunkrenderer.cpp b/modules/globebrowsing/chunk/chunkrenderer.cpp deleted file mode 100644 index 8696ecf39d..0000000000 --- a/modules/globebrowsing/chunk/chunkrenderer.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/***************************************************************************************** -* * -* 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. * -****************************************************************************************/ - - -#include -#include -#include -#include - -// open space includes -#include -#include -#include - -// ghoul includes -#include -#include -#include - -// STL includes -#include - -#define _USE_MATH_DEFINES -#include - -namespace { - const std::string _loggerCat = "PatchRenderer"; - - const char* keyFrame = "Frame"; - const char* keyGeometry = "Geometry"; - const char* keyShading = "PerformShading"; - - const char* keyBody = "Body"; -} - -namespace openspace { - - - ChunkRenderer::ChunkRenderer( - std::shared_ptr grid, - std::shared_ptr tileProviderManager) - : _tileProviderManager(tileProviderManager) - , _grid(grid) - { - _globalRenderingShaderProvider = std::make_shared( - "GlobalChunkedLodPatch", - "${MODULE_GLOBEBROWSING}/shaders/globalchunkedlodpatch_vs.glsl", - "${MODULE_GLOBEBROWSING}/shaders/globalchunkedlodpatch_fs.glsl"); - - _localRenderingShaderProvider = std::make_shared( - "LocalChunkedLodPatch", - "${MODULE_GLOBEBROWSING}/shaders/localchunkedlodpatch_vs.glsl", - "${MODULE_GLOBEBROWSING}/shaders/localchunkedlodpatch_fs.glsl"); - - _globalProgramUniformHandler = std::make_shared(); - _localProgramUniformHandler = std::make_shared(); - - } - - void ChunkRenderer::renderChunk(const Chunk& chunk, const RenderData& data) { - if (chunk.index().level < 10) { - renderChunkGlobally(chunk, data); - } - else { - renderChunkLocally(chunk, data); - } - } - - void ChunkRenderer::update() { - // unued atm. Could be used for caching or precalculating - } - - - void ChunkRenderer::setDepthTransformUniforms( - std::shared_ptr uniformIdHandler, - LayeredTextures::TextureCategory textureCategory, - LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes blendLayerSuffix, - size_t layerIndex, - const TileDepthTransform& tileDepthTransform) - { - uniformIdHandler->programObject().setUniform( - uniformIdHandler->getId( - textureCategory, - blendLayerSuffix, - layerIndex, - LayeredTextureShaderUniformIdHandler::GlslTileDataId::depthTransform_depthScale), - tileDepthTransform.depthScale); - - uniformIdHandler->programObject().setUniform( - uniformIdHandler->getId( - textureCategory, - blendLayerSuffix, - layerIndex, - LayeredTextureShaderUniformIdHandler::GlslTileDataId::depthTransform_depthOffset), - tileDepthTransform.depthOffset); - - } - - void ChunkRenderer::activateTileAndSetTileUniforms( - std::shared_ptr uniformIdHandler, - LayeredTextures::TextureCategory textureCategory, - LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes blendLayerSuffix, - size_t layerIndex, - ghoul::opengl::TextureUnit& texUnit, - const TileAndTransform& tileAndTransform) - { - - // Blend tile with two parents - // The texture needs a unit to sample from - texUnit.activate(); - tileAndTransform.tile.texture->bind(); - - uniformIdHandler->programObject().setUniform( - uniformIdHandler->getId( - textureCategory, - blendLayerSuffix, - layerIndex, - LayeredTextureShaderUniformIdHandler::GlslTileDataId::textureSampler), - texUnit); - uniformIdHandler->programObject().setUniform( - uniformIdHandler->getId( - textureCategory, - blendLayerSuffix, - layerIndex, - LayeredTextureShaderUniformIdHandler::GlslTileDataId::uvTransform_uvScale), - tileAndTransform.uvTransform.uvScale); - uniformIdHandler->programObject().setUniform( - uniformIdHandler->getId( - textureCategory, - blendLayerSuffix, - layerIndex, - LayeredTextureShaderUniformIdHandler::GlslTileDataId::uvTransform_uvOffset), - tileAndTransform.uvTransform.uvOffset); - } - - - ProgramObject* ChunkRenderer::getActivatedProgramWithTileData( - LayeredTextureShaderProvider* layeredTextureShaderProvider, - std::shared_ptr programUniformHandler, - const Chunk& chunk) - { - const ChunkIndex& chunkIndex = chunk.index(); - - std::array >, - LayeredTextures::NUM_TEXTURE_CATEGORIES> tileProviders; - LayeredTexturePreprocessingData layeredTexturePreprocessingData; - - for (size_t category = 0; category < LayeredTextures::NUM_TEXTURE_CATEGORIES; category++) { - tileProviders[category] = _tileProviderManager->getTileProviderGroup(category).getActiveTileProviders(); - - LayeredTextureInfo layeredTextureInfo; - layeredTextureInfo.lastLayerIdx = tileProviders[category].size() - 1; - layeredTextureInfo.layerBlendingEnabled = _tileProviderManager->getTileProviderGroup(category).levelBlendingEnabled; - - layeredTexturePreprocessingData.layeredTextureInfo[category] = layeredTextureInfo; - } - - layeredTexturePreprocessingData.keyValuePairs.push_back( - std::pair( - "useAtmosphere", - std::to_string(chunk.owner()->atmosphereEnabled))); - - layeredTexturePreprocessingData.keyValuePairs.push_back( - std::pair( - "showChunkEdges", - std::to_string(chunk.owner()->debugOptions.showChunkEdges))); - - - layeredTexturePreprocessingData.keyValuePairs.push_back( - std::pair( - "showHeightResolution", - std::to_string(chunk.owner()->debugOptions.showHeightResolution))); - - layeredTexturePreprocessingData.keyValuePairs.push_back( - std::pair( - "showHeightIntensities", - std::to_string(chunk.owner()->debugOptions.showHeightIntensities))); - - layeredTexturePreprocessingData.keyValuePairs.push_back( - std::pair( - "defaultHeight", - std::to_string(Chunk::DEFAULT_HEIGHT))); - - - - - // Now the shader program can be accessed - ProgramObject* programObject = - layeredTextureShaderProvider->getUpdatedShaderProgram( - layeredTexturePreprocessingData); - - programUniformHandler->updateIdsIfNecessary(layeredTextureShaderProvider); - - // Activate the shader program - programObject->activate(); - - // Initialize all texture units - struct BlendTexUnits { - ghoul::opengl::TextureUnit blendTexture0; - ghoul::opengl::TextureUnit blendTexture1; - ghoul::opengl::TextureUnit blendTexture2; - }; - std::array, LayeredTextures::NUM_TEXTURE_CATEGORIES> texUnits; - for (size_t category = 0; category < LayeredTextures::NUM_TEXTURE_CATEGORIES; category++) { - texUnits[category].resize(tileProviders[category].size()); - } - - // Go through all the categories - for (size_t category = 0; category < LayeredTextures::NUM_TEXTURE_CATEGORIES; category++) { - // Go through all the providers in this category - int i = 0; - for (auto it = tileProviders[category].begin(); it != tileProviders[category].end(); it++) { - auto tileProvider = it->get(); - - // Get the texture that should be used for rendering - TileAndTransform tileAndTransform = TileSelector::getHighestResolutionTile(tileProvider, chunkIndex); - if (tileAndTransform.tile.status == Tile::Status::Unavailable) { - tileAndTransform.tile = tileProvider->getDefaultTile(); - tileAndTransform.uvTransform.uvOffset = { 0, 0 }; - tileAndTransform.uvTransform.uvScale = { 1, 1 }; - } - - activateTileAndSetTileUniforms( - programUniformHandler, - LayeredTextures::TextureCategory(category), - LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes::none, - i, - texUnits[category][i].blendTexture0, - tileAndTransform); - - // If blending is enabled, two more textures are needed - if (layeredTexturePreprocessingData.layeredTextureInfo[category].layerBlendingEnabled) { - TileAndTransform tileAndTransformParent1 = TileSelector::getHighestResolutionTile(tileProvider, chunkIndex, 1); - if (tileAndTransformParent1.tile.status == Tile::Status::Unavailable) { - tileAndTransformParent1 = tileAndTransform; - } - activateTileAndSetTileUniforms( - programUniformHandler, - LayeredTextures::TextureCategory(category), - LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes::Parent1, - i, - texUnits[category][i].blendTexture1, - tileAndTransformParent1); - - TileAndTransform tileAndTransformParent2 = TileSelector::getHighestResolutionTile(tileProvider, chunkIndex, 2); - if (tileAndTransformParent2.tile.status == Tile::Status::Unavailable) { - tileAndTransformParent2 = tileAndTransformParent1; - } - activateTileAndSetTileUniforms( - programUniformHandler, - LayeredTextures::TextureCategory(category), - LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes::Parent2, - i, - texUnits[category][i].blendTexture2, - tileAndTransformParent2); - } - - /* - if (category == LayeredTextures::HeightMaps && tileAndTransform.tile.preprocessData) { - //auto preprocessingData = tileAndTransform.tile.preprocessData; - //float noDataValue = preprocessingData->noDataValues[0]; - programObject->setUniform( - "minimumValidHeight[" + std::to_string(i) + "]", - -100000); - } - */ - i++; - } - } - - // Go through all the height maps and set depth tranforms - int i = 0; - auto it = tileProviders[LayeredTextures::HeightMaps].begin(); - auto end = tileProviders[LayeredTextures::HeightMaps].end(); - for (; it != end; it++) { - auto tileProvider = *it; - - TileDepthTransform depthTransform = tileProvider->depthTransform(); - setDepthTransformUniforms( - programUniformHandler, - LayeredTextures::TextureCategory::HeightMaps, - LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes::none, - i, - depthTransform); - i++; - } - - // The length of the skirts is proportional to its size - programObject->setUniform("skirtLength", min(static_cast(chunk.surfacePatch().halfSize().lat * 1000000), 8700.0f)); - programObject->setUniform("xSegments", _grid->xSegments()); - - if (chunk.owner()->debugOptions.showHeightResolution) { - programObject->setUniform("vertexResolution", glm::vec2(_grid->xSegments(), _grid->ySegments())); - } - - return programObject; - } - - void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& data){ - - ProgramObject* programObject = getActivatedProgramWithTileData( - _globalRenderingShaderProvider.get(), - _globalProgramUniformHandler, - chunk); - if (programObject == nullptr) { - return; - } - - const Ellipsoid& ellipsoid = chunk.owner()->ellipsoid(); - - bool performAnyBlending = false; - - for (int i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; ++i) { - LayeredTextures::TextureCategory category = (LayeredTextures::TextureCategory)i; - if(_tileProviderManager->getTileProviderGroup(i).levelBlendingEnabled && _tileProviderManager->getTileProviderGroup(category).getActiveTileProviders().size() > 0){ - performAnyBlending = true; - break; - } - } - if (performAnyBlending) { - // Calculations are done in the reference frame of the globe. Hence, the camera - // position needs to be transformed with the inverse model matrix - glm::dmat4 inverseModelTransform = chunk.owner()->inverseModelTransform(); - glm::dvec3 cameraPosition = - glm::dvec3(inverseModelTransform * glm::dvec4(data.camera.positionVec3(), 1)); - float distanceScaleFactor = chunk.owner()->lodScaleFactor * ellipsoid.minimumRadius(); - programObject->setUniform("cameraPosition", vec3(cameraPosition)); - programObject->setUniform("distanceScaleFactor", distanceScaleFactor); - programObject->setUniform("chunkLevel", chunk.index().level); - } - - // Calculate other uniform variables needed for rendering - Geodetic2 swCorner = chunk.surfacePatch().getCorner(Quad::SOUTH_WEST); - auto patchSize = chunk.surfacePatch().size(); - - dmat4 modelTransform = chunk.owner()->modelTransform(); - dmat4 viewTransform = data.camera.combinedViewMatrix(); - mat4 modelViewTransform = mat4(viewTransform * modelTransform); - mat4 modelViewProjectionTransform = data.camera.projectionMatrix() * modelViewTransform; - - // Upload the uniform variables - programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform); - programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2())); - programObject->setUniform("lonLatScalingFactor", vec2(patchSize.toLonLatVec2())); - programObject->setUniform("radiiSquared", vec3(ellipsoid.radiiSquared())); - - if (_tileProviderManager->getTileProviderGroup( - LayeredTextures::NightTextures).getActiveTileProviders().size() > 0 || - _tileProviderManager->getTileProviderGroup( - LayeredTextures::WaterMasks).getActiveTileProviders().size() > 0) { - glm::vec3 directionToSunWorldSpace = - glm::normalize(-data.modelTransform.translation); - glm::vec3 directionToSunCameraSpace = - (viewTransform * glm::dvec4(directionToSunWorldSpace, 0)); - data.modelTransform.translation; - programObject->setUniform("modelViewTransform", modelViewTransform); - programObject->setUniform("lightDirectionCameraSpace", -directionToSunCameraSpace); - } - - // OpenGL rendering settings - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); - - // render - _grid->geometry().drawUsingActiveProgram(); - - // disable shader - programObject->deactivate(); - } - - - - void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& data) { - - ProgramObject* programObject = getActivatedProgramWithTileData( - _localRenderingShaderProvider.get(), - _localProgramUniformHandler, - chunk); - if (programObject == nullptr) { - return; - } - - using namespace glm; - - const Ellipsoid& ellipsoid = chunk.owner()->ellipsoid(); - - - bool performAnyBlending = false; - for (int i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; ++i) { - LayeredTextures::TextureCategory category = (LayeredTextures::TextureCategory)i; - if (_tileProviderManager->getTileProviderGroup(i).levelBlendingEnabled && _tileProviderManager->getTileProviderGroup(category).getActiveTileProviders().size() > 0) { - performAnyBlending = true; - break; - } - } - if (performAnyBlending) { - float distanceScaleFactor = chunk.owner()->lodScaleFactor * chunk.owner()->ellipsoid().minimumRadius(); - programObject->setUniform("distanceScaleFactor", distanceScaleFactor); - programObject->setUniform("chunkLevel", chunk.index().level); - } - - // Calculate other uniform variables needed for rendering - dmat4 modelTransform = chunk.owner()->modelTransform(); - dmat4 viewTransform = data.camera.combinedViewMatrix(); - dmat4 modelViewTransform = viewTransform * modelTransform; - - std::vector cornerNames = { "p01", "p11", "p00", "p10" }; - std::vector cornersCameraSpace(4); - for (int i = 0; i < 4; ++i) { - Quad q = (Quad)i; - Geodetic2 corner = chunk.surfacePatch().getCorner(q); - Vec3 cornerModelSpace = ellipsoid.cartesianSurfacePosition(corner); - Vec3 cornerCameraSpace = Vec3(dmat4(modelViewTransform) * glm::dvec4(cornerModelSpace, 1)); - cornersCameraSpace[i] = cornerCameraSpace; - programObject->setUniform(cornerNames[i], vec3(cornerCameraSpace)); - } - - vec3 patchNormalCameraSpace = normalize( - cross(cornersCameraSpace[Quad::SOUTH_EAST] - cornersCameraSpace[Quad::SOUTH_WEST], - cornersCameraSpace[Quad::NORTH_EAST] - cornersCameraSpace[Quad::SOUTH_WEST])); - - programObject->setUniform("patchNormalCameraSpace", patchNormalCameraSpace); - programObject->setUniform("projectionTransform", data.camera.projectionMatrix()); - - if (_tileProviderManager->getTileProviderGroup( - LayeredTextures::NightTextures).getActiveTileProviders().size() > 0 || - _tileProviderManager->getTileProviderGroup( - LayeredTextures::WaterMasks).getActiveTileProviders().size() > 0) { - glm::vec3 directionToSunWorldSpace = - glm::normalize(-data.modelTransform.translation); - glm::vec3 directionToSunCameraSpace = - (viewTransform * glm::dvec4(directionToSunWorldSpace, 0)); - data.modelTransform.translation; - programObject->setUniform("lightDirectionCameraSpace", -directionToSunCameraSpace); - } - - - // OpenGL rendering settings - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); - - // render - _grid->geometry().drawUsingActiveProgram(); - - // disable shader - programObject->deactivate(); - } -} // namespace openspace diff --git a/modules/globebrowsing/meshes/clipmapgrid.cpp b/modules/globebrowsing/meshes/clipmapgrid.cpp deleted file mode 100644 index 4a99bb8c2d..0000000000 --- a/modules/globebrowsing/meshes/clipmapgrid.cpp +++ /dev/null @@ -1,447 +0,0 @@ -/***************************************************************************************** -* * -* 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. * -****************************************************************************************/ - -#include - -#include - -namespace { - const std::string _loggerCat = "ClipMapGrid"; -} - -namespace openspace { -namespace globebrowsing { - -////////////////////////////////////////////////////////////////////////////////////////// -// CLIPMAP GRID (Abstract class) // -////////////////////////////////////////////////////////////////////////////////////////// - -ClipMapGrid::ClipMapGrid(unsigned int segments) - : Grid( - segments, - segments, - TriangleSoup::Positions::No, - TriangleSoup::TextureCoordinates::Yes, - TriangleSoup::Normals::No) -{} - -ClipMapGrid::~ClipMapGrid() -{} - -int ClipMapGrid::xSegments() const { - return segments(); -} - -int ClipMapGrid::ySegments() const { - return segments(); -} - -int ClipMapGrid::segments() const { - return _xSegments; -} - -////////////////////////////////////////////////////////////////////////////////////////// -// OUTER CLIPMAP GRID // -////////////////////////////////////////////////////////////////////////////////////////// - -OuterClipMapGrid::OuterClipMapGrid(unsigned int segments) -: ClipMapGrid(segments) -{ - _geometry = std::unique_ptr(new TriangleSoup( - CreateElements(segments, segments), - TriangleSoup::Positions::No, - TriangleSoup::TextureCoordinates::Yes, - TriangleSoup::Normals::No)); - - _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments)); -} - -OuterClipMapGrid::~OuterClipMapGrid() -{ - -} - -size_t OuterClipMapGrid::numElements(int segments) -{ - int numElementsInTotalSquare = 6 * (segments + 1) * (segments + 1); - int numElementsInHole = 6 * (segments / 4 * segments / 4); - return numElementsInTotalSquare - numElementsInHole; -} - -size_t OuterClipMapGrid::numVerticesBottom(int segments) -{ - return (segments + 1 + 2) * (segments / 4 + 1 + 1); -} - -size_t OuterClipMapGrid::numVerticesLeft(int segments) -{ - return (segments / 4 + 1 + 1) * (segments / 2 + 1); -} - -size_t OuterClipMapGrid::numVerticesRight(int segments) -{ - return (segments / 4 + 1 + 1) * (segments / 2 + 1); -} - -size_t OuterClipMapGrid::numVerticesTop(int segments) -{ - return (segments + 1 + 2) * (segments / 4 + 1 + 1); -} - -size_t OuterClipMapGrid::numVertices(int segments) -{ - return numVerticesBottom(segments) + - numVerticesLeft(segments) + - numVerticesRight(segments) + - numVerticesTop(segments); -} - -void OuterClipMapGrid::validate(int xRes, int yRes) { - - ghoul_assert(xRes == yRes, - "segments must be equal in x and in y. "); - int segments = xRes; - ghoul_assert(segments >= 8, - "segments must be at least 8. (" << segments << ")"); - ghoul_assert(segments == pow(2, int(log2(segments))), - "segments must be a power of 2. (" << segments << ")"); -} - -std::vector OuterClipMapGrid::CreateElements(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector elements; - elements.reserve(numElements(segments)); - - // The clipmap geometry is built up by four parts as follows: - // 0 = Bottom part - // 1 = Left part - // 2 = Right part - // 3 = Top part - // - // 33333333 - // 33333333 - // 11 22 - // 11 22 - // 00000000 - // 00000000 - - - // x v01---v11 x .. - // | / | - // x v00---v10 x .. - // - // x x x x .. - // : : : : - - unsigned int previousVerts[4]; - previousVerts[0] = 0; - previousVerts[1] = previousVerts[0] + numVerticesBottom(segments); - previousVerts[2] = previousVerts[1] + numVerticesLeft(segments); - previousVerts[3] = previousVerts[2] + numVerticesRight(segments); - - // Build the bottom part of the clipmap geometry - for (unsigned int y = 0; y < segments / 4 + 1; y++) { - for (unsigned int x = 0; x < segments + 2; x++) { - GLuint v00 = previousVerts[0] + (y + 0) * (segments + 3) + x + 0; - GLuint v10 = previousVerts[0] + (y + 0) * (segments + 3) + x + 1; - GLuint v01 = previousVerts[0] + (y + 1) * (segments + 3) + x + 0; - GLuint v11 = previousVerts[0] + (y + 1) * (segments + 3) + x + 1; - - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); - - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } - - // Build the left part of the clipmap geometry - for (unsigned int y = 0; y < segments / 2; y++) { - for (unsigned int x = 0; x < segments / 4 + 1; x++) { - GLuint v00 = previousVerts[1] + (y + 0) * (segments / 4 + 2) + x + 0; - GLuint v10 = previousVerts[1] + (y + 0) * (segments / 4 + 2) + x + 1; - GLuint v01 = previousVerts[1] + (y + 1) * (segments / 4 + 2) + x + 0; - GLuint v11 = previousVerts[1] + (y + 1) * (segments / 4 + 2) + x + 1; - - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); - - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } - - // Build the left part of the clipmap geometry - for (unsigned int y = 0; y < segments / 2; y++) { - for (unsigned int x = 0; x < segments / 4 + 1; x++) { - GLuint v00 = previousVerts[2] + (y + 0) * (segments / 4 + 2) + x + 0; - GLuint v10 = previousVerts[2] + (y + 0) * (segments / 4 + 2) + x + 1; - GLuint v01 = previousVerts[2] + (y + 1) * (segments / 4 + 2) + x + 0; - GLuint v11 = previousVerts[2] + (y + 1) * (segments / 4 + 2) + x + 1; - - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); - - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } - - // Build the left part of the clipmap geometry - for (unsigned int y = 0; y < segments / 4 + 1; y++) { - for (unsigned int x = 0; x < segments + 2; x++) { - GLuint v00 = previousVerts[3] + (y + 0) * (segments + 3) + x + 0; - GLuint v10 = previousVerts[3] + (y + 0) * (segments + 3) + x + 1; - GLuint v01 = previousVerts[3] + (y + 1) * (segments + 3) + x + 0; - GLuint v11 = previousVerts[3] + (y + 1) * (segments + 3) + x + 1; - - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); - - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } - return elements; -} - -std::vector OuterClipMapGrid::CreatePositions(int xRes, int yRes) -{ - validate(xRes, yRes); - int segments = xRes; - std::vector positions; - positions.reserve(numVertices(segments)); - std::vector templateTextureCoords = CreateTextureCoordinates(xRes, yRes); - - // Copy from 2d texture coordinates and use as template to create positions - for (unsigned int i = 0; i < templateTextureCoords.size(); i++) { - positions.push_back( - glm::vec4( - templateTextureCoords[i].x, - templateTextureCoords[i].y, - 0, - 1)); - } - - return positions; -} - -std::vector OuterClipMapGrid::CreateTextureCoordinates(int xRes, int yRes){ - validate(xRes, yRes); - int segments = xRes; - std::vector textureCoordinates; - textureCoordinates.reserve(numVertices(segments)); - - // Build the bottom part of the clipmap geometry - for (int y = -1; y < segments / 4 + 1; y++) { - for (int x = -1; x < segments + 2; x++) { - textureCoordinates.push_back(glm::vec2( - static_cast(x) / segments, - static_cast(y) / segments)); - } - } - - // Build the left part of the clipmap geometry - for (int y = segments / 4; y < 3 * segments / 4 + 1; y++) { - for (int x = -1; x < segments / 4 + 1; x++) { - textureCoordinates.push_back(glm::vec2( - static_cast(x) / segments, - static_cast(y) / segments)); - } - } - - // Build the right part of the clipmap geometry - for (int y = segments / 4; y < 3 * segments / 4 + 1; y++) { - for (int x = 3 * segments / 4; x < segments + 2; x++) { - float u = static_cast(x) / segments; - float v = static_cast(y) / segments; - textureCoordinates.push_back(glm::vec2(u, v)); - } - } - - // Build the top part of the clipmap geometry - for (int y = 3 * segments / 4; y < segments + 2; y++) { - for (int x = -1; x < segments + 2; x++) { - textureCoordinates.push_back(glm::vec2( - static_cast(x) / segments, - static_cast(y) / segments)); - } - } - - return textureCoordinates; -} - -std::vector OuterClipMapGrid::CreateNormals(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector normals; - normals.reserve(numVertices(segments)); - - for (int y = -1; y < segments + 2; y++) { - for (int x = -1; x < segments + 2; x++) { - normals.push_back(glm::vec3(0, 0, 1)); - } - } - - return normals; -} - -////////////////////////////////////////////////////////////////////////////////////////// -// INNER CLIPMAP GRID // -////////////////////////////////////////////////////////////////////////////////////////// - -InnerClipMapGrid::InnerClipMapGrid(unsigned int segments) - : ClipMapGrid(segments) -{ - _geometry = std::unique_ptr(new TriangleSoup( - CreateElements(segments, segments), - TriangleSoup::Positions::No, - TriangleSoup::TextureCoordinates::Yes, - TriangleSoup::Normals::No)); - - _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments)); -} - -InnerClipMapGrid::~InnerClipMapGrid() -{ - -} - -size_t InnerClipMapGrid::numElements(int segments) -{ - return segments * segments * 6; -} - -size_t InnerClipMapGrid::numVertices(int segments) -{ - return (segments + 1) * (segments + 1); -} - -void InnerClipMapGrid::validate(int xRes, int yRes) { - - ghoul_assert(xRes == yRes, - "segments must be equal in x and in y. "); - int segments = xRes; - ghoul_assert(segments >= 1, - "segments must be at least 1. (" << segments << ")"); -} - -std::vector InnerClipMapGrid::CreateElements(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector elements; - elements.reserve(numElements(segments)); - - // x v01---v11 x .. - // | / | - // x v00---v10 x .. - // - // x x x x .. - // : : : : - - for (unsigned int y = 0; y < segments + 2; y++) { - for (unsigned int x = 0; x < segments + 2; x++) { - GLuint v00 = (y + 0) * (segments + 3) + x + 0; - GLuint v10 = (y + 0) * (segments + 3) + x + 1; - GLuint v01 = (y + 1) * (segments + 3) + x + 0; - GLuint v11 = (y + 1) * (segments + 3) + x + 1; - - elements.push_back(v00); - elements.push_back(v10); - elements.push_back(v11); - - elements.push_back(v00); - elements.push_back(v11); - elements.push_back(v01); - } - } - - return elements; -} - -std::vector InnerClipMapGrid::CreatePositions(int xRes, int yRes) -{ - validate(xRes, yRes); - int segments = xRes; - std::vector positions; - positions.reserve(numVertices(segments)); - std::vector templateTextureCoords = CreateTextureCoordinates(xRes, yRes); - - // Copy from 2d texture coordinates and use as template to create positions - for (unsigned int i = 0; i < templateTextureCoords.size(); i++) { - positions.push_back( - glm::vec4( - templateTextureCoords[i].x, - templateTextureCoords[i].y, - 0, - 1)); - } - - return positions; -} - -std::vector InnerClipMapGrid::CreateTextureCoordinates(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector textureCoordinates; - textureCoordinates.reserve(numVertices(segments)); - - // Build the bottom part of the clipmap geometry - for (int y = -1; y < segments + 2; y++) { - for (int x = -1; x < segments + 2; x++) { - textureCoordinates.push_back(glm::vec2( - static_cast(x) / segments, - static_cast(y) / segments)); - } - } - - return textureCoordinates; -} - -std::vector InnerClipMapGrid::CreateNormals(int xRes, int yRes) { - validate(xRes, yRes); - int segments = xRes; - std::vector normals; - normals.reserve(numVertices(segments)); - - for (int y = -1; y < segments + 2; y++) { - for (int x = -1; x < segments + 2; x++) { - normals.push_back(glm::vec3(0, 0, 1)); - } - } - - return normals; -} - -} // namespace globebrowsing -} // namespace openspace \ No newline at end of file diff --git a/modules/globebrowsing/meshes/clipmapgrid.h b/modules/globebrowsing/meshes/clipmapgrid.h deleted file mode 100644 index 6f15d193f9..0000000000 --- a/modules/globebrowsing/meshes/clipmapgrid.h +++ /dev/null @@ -1,132 +0,0 @@ -/***************************************************************************************** -* * -* 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 __CLIPMAPGEOMETRY_H__ -#define __CLIPMAPGEOMETRY_H__ - -#include - -#include -#include - -namespace openspace { -namespace globebrowsing { - -////////////////////////////////////////////////////////////////////////////////////////// -// CLIPMAP GRID (Abstract class) // -////////////////////////////////////////////////////////////////////////////////////////// - -/** -This class defines a grid used for the layers of a geometry clipmap. A geometry -clipmap is built up from a pyramid of clipmaps so the majority of the grids used -are of the class OuterClipMapGrid. The vertex positions and texture coordinated are -defined differently than for a normal BasicGrid. Other than having the basic grid -vertices it also creates padding of one grid cell on the perimeter. This padding can be -used when rendering a ClipMapGrid so that an inner layer of the pyramid can move and -snap to the outer layers grid cells. -*/ -class ClipMapGrid : public Grid -{ -public: - ClipMapGrid(unsigned int segments); - - ~ClipMapGrid(); - - virtual int xSegments() const; - virtual int ySegments() const; - - /** - Returns the segments of the grid. A ClipMapGrid must have the segments in x and - y direction equal so this function works as a wrapper for xSegments() and - ySegments(). - */ - int segments() const; -}; - -////////////////////////////////////////////////////////////////////////////////////////// -// OUTER CLIPMAP GRID // -////////////////////////////////////////////////////////////////////////////////////////// - -/** -The outer layers of a geometry clipmap pyramid can be built up by grids with sizes -increasing with the power of 2. The OuterClipMapGrid has a whole in the middle where -a smaller ClipMapGrid of half the size can fit. -*/ -class OuterClipMapGrid : public ClipMapGrid -{ -public: - OuterClipMapGrid(unsigned int segments); - - ~OuterClipMapGrid(); - -protected: - virtual std::vector CreateElements(int xSegments, int ySegments); - virtual std::vector CreatePositions(int xSegments, int ySegments); - virtual std::vector CreateTextureCoordinates(int xSegments, int ySegments); - virtual std::vector CreateNormals(int xSegments, int ySegments); - -private: - void validate(int xSegments, int ySegments); - - static size_t numVerticesBottom(int segments); - static size_t numVerticesLeft(int segments); - static size_t numVerticesRight(int segments); - static size_t numVerticesTop(int segments); - - static size_t numElements(int segments); - static size_t numVertices(int segments); -}; - -////////////////////////////////////////////////////////////////////////////////////////// -// INNER CLIPMAP GRID // -////////////////////////////////////////////////////////////////////////////////////////// - -/** -The InnerClipMapGrid can be used for the inner most (smallest) grid of a geometry clipmap -pyramid. The only difference from a OuterClipMapGrid is that this grid does not have -a whole where a smaller ClipMapGrid can be positioned. -*/ -class InnerClipMapGrid : public ClipMapGrid -{ -public: - InnerClipMapGrid(unsigned int segments); - - ~InnerClipMapGrid(); - -private: - virtual std::vector CreateElements( int xSegments, int ySegments); - virtual std::vector CreatePositions(int xSegments, int ySegments); - virtual std::vector CreateTextureCoordinates(int xSegments, int ySegments); - virtual std::vector CreateNormals(int xSegments, int ySegments); - - void validate(int xSegments, int ySegments); - - static size_t numElements(int segments); - static size_t numVertices(int segments); -}; - -} // namespace globebrowsing -} // namespace openspace - -#endif // __CLIPMAPGEOMETRY_H__ \ No newline at end of file diff --git a/modules/globebrowsing/tile/tileioresult.cpp b/modules/globebrowsing/tile/tileioresult.cpp deleted file mode 100644 index c83ecb6433..0000000000 --- a/modules/globebrowsing/tile/tileioresult.cpp +++ /dev/null @@ -1,49 +0,0 @@ - /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ - -#include -#include - -#include -#include // abspath -#include - -#include -#include - -#include - -#include -#include - -namespace { - const std::string _loggerCat = "RawTile"; -} - -namespace openspace { -namespace globebrowsing { - - -} // namespace globebrowsing -} // namespace openspace diff --git a/modules/globebrowsing/tile/tileioresult.h b/modules/globebrowsing/tile/tileioresult.h deleted file mode 100644 index b6073358da..0000000000 --- a/modules/globebrowsing/tile/tileioresult.h +++ /dev/null @@ -1,46 +0,0 @@ -/***************************************************************************************** -* * -* 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 __TILE_IO_RESULT_H__ -#define __TILE_IO_RESULT_H__ - -#include -#include - -#include -#include - -#include "gdal_priv.h" - -#include -#include - -namespace openspace { -namespace globebrowsing { - - -} // namespace globebrowsing -} // namespace openspace - -#endif // __TILE_IO_RESULT_H__ \ No newline at end of file diff --git a/modules/globebrowsing/tile/tilepile.h b/modules/globebrowsing/tile/tilepile.h deleted file mode 100644 index 72ff0b54dd..0000000000 --- a/modules/globebrowsing/tile/tilepile.h +++ /dev/null @@ -1,54 +0,0 @@ -/***************************************************************************************** - * * - * 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 __OPENSPACE_MODULE_GLOBEBROWSING_TILEPILE_H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING_TILEPILE_H__ - -#include // Texture - -#include -#include -#include - -#include -#include - - -namespace openspace { -namespace globebrowsing { - - using namespace ghoul::opengl; - /* - struct ChunkTilePile { - std::array chunkTiles; - }; - */ - -} // namespace globebrowsing -} // namespace openspace - - - - -#endif // __OPENSPACE_MODULE_GLOBEBROWSING_TILEPILE_H__ diff --git a/modules/newhorizons/newhorizonsmodule.cpp b/modules/newhorizons/newhorizonsmodule.cpp index 49e3beb07e..59168a207c 100644 --- a/modules/newhorizons/newhorizonsmodule.cpp +++ b/modules/newhorizons/newhorizonsmodule.cpp @@ -24,23 +24,21 @@ #include -#include -#include - -#include - #include -#include #include +#include #include #include -#include +#include #include #include #include -#include +#include +#include + +#include namespace openspace { diff --git a/modules/newhorizons/rendering/renderablefov.cpp b/modules/newhorizons/rendering/renderablefov.cpp index 389e986d47..f906129321 100644 --- a/modules/newhorizons/rendering/renderablefov.cpp +++ b/modules/newhorizons/rendering/renderablefov.cpp @@ -322,7 +322,6 @@ glm::dvec3 RenderableFov::bisection(glm::dvec3 p1, glm::dvec3 p2) { } } - void RenderableFov::fovSurfaceIntercept(bool H[], std::vector bounds) { _nrInserted = 0; _fovPlane.clear(); // empty the array diff --git a/modules/newhorizons/util/hongkangparser.cpp b/modules/newhorizons/util/hongkangparser.cpp index 7c510675b7..1d0f6fdd83 100644 --- a/modules/newhorizons/util/hongkangparser.cpp +++ b/modules/newhorizons/util/hongkangparser.cpp @@ -27,35 +27,23 @@ #include #include -#include #include #include +#include #include -#include #include -#include -#include -#include - -#include - -#include - -#include -#include -#include - namespace { const char* keyTranslation = "DataInputTranslation"; - const std::string PlaybookIdentifierName = "HongKang"; + const char* PlaybookIdentifierName = "HongKang"; } namespace openspace { -HongKangParser::HongKangParser(std::string name, std::string fileName, + +HongKangParser::HongKangParser(std::string name, std::string fileName, std::string spacecraft, ghoul::Dictionary translationDictionary, std::vector potentialTargets) @@ -98,12 +86,12 @@ void HongKangParser::findPlaybookSpecifiedTarget(std::string line, std::string& std::vector ptarg = _potentialTargets; for (const auto& p : ptarg) { // loop over all targets and determine from 4th col which target this instrument points to - if (line.find(p) != std::string::npos){ + if (line.find(p) != std::string::npos) { target = p; break; } else { - // not found - we set void until we have more info. + // not found - we set void until we have more info. target = "VOID"; } } @@ -129,7 +117,7 @@ bool HongKangParser::create() { if (position != std::string::npos){ std::string extension = ghoul::filesystem::File(_fileName).fileExtension(); - if (extension == "txt") {// Hong Kang. pre-parsed playbook + if (extension == "txt") { // Hong Kang. pre-parsed playbook std::ifstream file; file.exceptions(std::ofstream::failbit | std::ofstream::badbit); //std::ifstream file(_fileName , std::ios::binary); @@ -159,7 +147,7 @@ bool HongKangParser::create() { std::string cameraTarget = "VOID"; std::string scannerTarget = "VOID"; - while (!file.eof()){ + while (!file.eof()) { std::getline(file, line); std::string event = line.substr(0, line.find_first_of(" ")); @@ -174,8 +162,8 @@ bool HongKangParser::create() { //store the time, this is used for getNextCaptureTime() _captureProgression.push_back(time); - if (it->second->getDecoderType() == "CAMERA"){ - if (capture_start == -1){ + if (it->second->getDecoderType() == "CAMERA") { + if (capture_start == -1) { //encountered new camera sequence- store start time capture_start = time; previousCamera = it->first; @@ -197,7 +185,7 @@ bool HongKangParser::create() { //createImage(image, time, time + shutter, cameraSpiceID, cameraTarget, _defaultCaptureImage); //IFF spaccraft has decided to switch target, store in target map (used for: 'next observation focus') - if (previousTarget != image.target){ + if (previousTarget != image.target) { previousTarget = image.target; std::pair v_target = std::make_pair(time, image.target); _targetTimes.push_back(v_target); @@ -208,7 +196,7 @@ bool HongKangParser::create() { //compute and store the range for each subset _subsetMap[image.target]._range.include(time); } - if (it->second->getDecoderType() == "SCANNER"){ // SCANNER START + if (it->second->getDecoderType() == "SCANNER") { // SCANNER START scan_start = time; InstrumentDecoder* scanner = static_cast(it->second.get()); @@ -218,10 +206,10 @@ bool HongKangParser::create() { std::streampos len = file.tellg(); std::string linePeek; bool foundstop = false; - while (!file.eof() && !foundstop){ + while (!file.eof() && !foundstop) { //continue grabbing next line until we find what we need getline(file, linePeek); - if (linePeek.find(endNominal) != std::string::npos){ + if (linePeek.find(endNominal) != std::string::npos) { foundstop = true; met = linePeek.substr(25, 9); @@ -250,8 +238,8 @@ bool HongKangParser::create() { file.seekg(len, std::ios_base::beg); } } - else{ // we have reached the end of a scan or consecutive capture sequence! - if (capture_start != -1){ + else { // we have reached the end of a scan or consecutive capture sequence! + if (capture_start != -1) { //end of capture sequence for camera, store end time of this sequence capture_stop = time; cameraRange = { capture_start, capture_stop }; @@ -266,13 +254,11 @@ bool HongKangParser::create() { } } - sendPlaybookInformation(PlaybookIdentifierName); return true; } -bool HongKangParser::augmentWithSpice(Image& image, - std::string spacecraft, +bool HongKangParser::augmentWithSpice(Image& image, std::string spacecraft, std::vector payload, std::vector potentialTargets) { @@ -290,7 +276,7 @@ bool HongKangParser::augmentWithSpice(Image& image, bool _withinFOV = false; for (int j = 0; j < image.activeInstruments.size(); ++j) { double time = image.timeRange.start; - for (int k = 0; k < exposureTime; k++){ + for (int k = 0; k < exposureTime; k++) { time += k; _withinFOV = SpiceManager::ref().isTargetInFieldOfView( potentialTargets[i], @@ -311,54 +297,34 @@ bool HongKangParser::augmentWithSpice(Image& image, return false; } -//Image HongKangParser::createImage(double startTime, double stopTime, std::vector instr, std::string targ, std::string path) { -// image.startTime = startTime; -// image.stopTime = stopTime; -// image.path = path; -// for (int i = 0; i < instr.size(); i++){ -// image.activeInstruments.push_back(instr[i]); -// } -// image.target = targ; -// image.projected = false; -// image.isPlaceholder = true; -//} - -double HongKangParser::getETfromMet(std::string line){ +double HongKangParser::getETfromMet(std::string line) { std::string::size_type sz; return getETfromMet(std::stod(line, &sz)); } -double HongKangParser::getETfromMet(double met){ - double diff; - double referenceET = +double HongKangParser::getETfromMet(double met) { + const double referenceET = SpiceManager::ref().ephemerisTimeFromDate("2015-07-14T11:50:00.00"); - double et = referenceET; //_metRef += 3; // MET reference time is off by 3 sec? - diff = std::abs(met - _metRef); - if (met > _metRef){ - et = referenceET + diff; - } else if (met < _metRef){ - et = referenceET - diff; + const double diff = std::abs(met - _metRef); + if (met > _metRef) { + return referenceET + diff; + } else if (met < _metRef) { + return referenceET - diff; } - return et; } - -double HongKangParser::getMetFromET(double et){ - double met; - double referenceET = +double HongKangParser::getMetFromET(double et) { + const double referenceET = SpiceManager::ref().ephemerisTimeFromDate("2015-07-14T11:50:00.00"); - if (et >= referenceET){ - met = _metRef + (et - referenceET); - }else{ - met = _metRef - (referenceET - et); + if (et >= referenceET) { + return _metRef + (et - referenceET); + }else { + return _metRef - (referenceET - et); } - - return met; } - -} \ No newline at end of file +} // namespace openspace \ No newline at end of file diff --git a/modules/newhorizons/util/imagesequencer.cpp b/modules/newhorizons/util/imagesequencer.cpp index 7541b7a0ce..641d171fe5 100644 --- a/modules/newhorizons/util/imagesequencer.cpp +++ b/modules/newhorizons/util/imagesequencer.cpp @@ -23,6 +23,7 @@ ****************************************************************************************/ #include + #include #include #include @@ -30,6 +31,7 @@ #include #include +#include #include #include #include @@ -44,10 +46,6 @@ #include #include - - - - namespace { const std::string _loggerCat = "ImageSequencer"; } @@ -65,13 +63,14 @@ ImageSequencer::ImageSequencer() {} ImageSequencer& ImageSequencer::ref() { - assert(_instance != nullptr); + ghoul_assert(_instance != nullptr, "Instance has not been initialized"); return *_instance; } void ImageSequencer::initialize() { - assert(_instance == nullptr); + ghoul_assert(_instance == nullptr, "Instance already has been initialized"); _instance = new ImageSequencer; - _instance->_defaultCaptureImage = absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder_blank.png"); + _instance->_defaultCaptureImage = + absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder_blank.png"); } void ImageSequencer::deinitialize() { @@ -101,12 +100,19 @@ std::pair ImageSequencer::getNextTarget() { }; std::pair findEqualToThis; findEqualToThis.first = _currentTime; - auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime); + auto it = std::lower_bound( + _targetTimes.begin(), + _targetTimes.end(), + findEqualToThis, + compareTime + ); - if (it != _targetTimes.end() && it != _targetTimes.begin()) + if (it != _targetTimes.end() && it != _targetTimes.begin()) { return (*it); - else - return std::make_pair(0.0, ""); + } + else { + return { 0.0, "" }; + } } std::pair ImageSequencer::getCurrentTarget() { @@ -116,26 +122,39 @@ std::pair ImageSequencer::getCurrentTarget() { }; std::pair findEqualToThis; findEqualToThis.first = _currentTime; - auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime); + auto it = std::lower_bound( + _targetTimes.begin(), + _targetTimes.end(), + findEqualToThis, + compareTime + ); if (it != _targetTimes.end() && it != _targetTimes.begin()){ - return *std::prev(it); + return *(std::prev(it)); } else - return std::make_pair(0.0, "No Target"); + return { 0.0, "No Target" }; } -std::pair> ImageSequencer::getIncidentTargetList(int range) { +std::pair> ImageSequencer::getIncidentTargetList( + int range) +{ std::pair> incidentTargets; - auto compareTime = [](const std::pair &a, - const std::pair &b)->bool{ + auto compareTime = [](const std::pair& a, + const std::pair& b) -> bool { return a.first < b.first; }; + // what to look for std::pair findEqualToThis; findEqualToThis.first = _currentTime; - auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime); + auto it = std::lower_bound( + _targetTimes.begin(), + _targetTimes.end(), + findEqualToThis, + compareTime + ); if (it != _targetTimes.end() && it != _targetTimes.begin()){ // move the iterator to the first element of the range @@ -146,17 +165,18 @@ std::pair> ImageSequencer::getIncidentTargetLis incidentTargets.first = it->first; incidentTargets.second.push_back(it->second); it++; - if (it == _targetTimes.end()) + if (it == _targetTimes.end()) { break; + } } } return incidentTargets; } -double ImageSequencer::getIntervalLength(){ +double ImageSequencer::getIntervalLength() { double upcoming = getNextCaptureTime(); - if (_nextCapture != upcoming){ + if (_nextCapture != upcoming) { _nextCapture = upcoming; _intervalLength = upcoming - _currentTime; } @@ -164,46 +184,56 @@ double ImageSequencer::getIntervalLength(){ } double ImageSequencer::getNextCaptureTime(){ - auto compareTime = [](const double &a, const double &b)->bool{ + auto compareTime = [](const double &a, const double &b) -> bool { return a < b; }; double nextCaptureTime = 0; - auto it = std::lower_bound(_captureProgression.begin(), _captureProgression.end(), _currentTime, compareTime); - if (it != _captureProgression.end()) + auto it = std::lower_bound( + _captureProgression.begin(), + _captureProgression.end(), + _currentTime, + compareTime + ); + if (it != _captureProgression.end()) { nextCaptureTime = *it; + } return nextCaptureTime; } -Image ImageSequencer::getLatestImageForInstrument(const std::string& _instrumentID){ + +Image ImageSequencer::getLatestImageForInstrument(const std::string& _instrumentID) { auto it = _latestImages.find(_instrumentID); - if (it != _latestImages.end()) + if (it != _latestImages.end()) { return _latestImages[_instrumentID]; + } else { return Image(); } } -std::map ImageSequencer::getActiveInstruments(){ +std::map ImageSequencer::getActiveInstruments() { // first set all instruments to off - for (auto i : _switchingMap) + for (const auto& i : _switchingMap) { _switchingMap[i.first] = false; + } + // go over the filetranslation map - for (const auto &key : _fileTranslation){ + for (const auto& key : _fileTranslation) { // for each spice-instrument - for (const auto &instrumentID : key.second->getTranslation()){ + for (const auto& instrumentID : key.second->getTranslation()) { // check if the spice-instrument is active - if (instrumentActive(instrumentID)){ - // go over switching map - for (const auto &instrument : _switchingMap){ - // if instrument is present in switching map - if (instrumentID == instrument.first){ - // set as active - _switchingMap[instrumentID] = true; - } + if (instrumentActive(instrumentID)) { + // go over switching map + for (const auto& instrument : _switchingMap) { + // if instrument is present in switching map + if (instrumentID == instrument.first) { + // set as active + _switchingMap[instrumentID] = true; } } } } + } // return entire map, seen in GUI. return _switchingMap; } @@ -215,7 +245,7 @@ bool ImageSequencer::instrumentActive(std::string instrumentID) { //if so, then get the corresponding spiceID std::vector spiceIDs = _fileTranslation[i.first]->getTranslation(); //check which specific subinstrument is firing - for (auto s : spiceIDs) { + for (const auto& s : spiceIDs) { if (s == instrumentID) { return true; }