mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-31 08:29:04 -06:00
Merge branch 'thesis/2018/dsn' of github.com:OpenSpace/OpenSpace into thesis/2018/dsn
This commit is contained in:
74
data/assets/examples/globetranslation.asset
Normal file
74
data/assets/examples/globetranslation.asset
Normal file
@@ -0,0 +1,74 @@
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
local earth = asset.require('scene/solarsystem/planets/earth/earth')
|
||||
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
|
||||
|
||||
|
||||
local textures = asset.syncedResource({
|
||||
Name = "New Horizons Textures",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "newhorizons_textures",
|
||||
Version = 3
|
||||
})
|
||||
|
||||
local models = asset.syncedResource({
|
||||
Name = "New Horizons Model",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "newhorizons_model",
|
||||
Version = 1
|
||||
})
|
||||
|
||||
local Example_Fixed_Height = {
|
||||
Identifier = "Example_Fixed_Height",
|
||||
Parent = earth.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earth.Earth.Identifier,
|
||||
Longitude = 0.0,
|
||||
Latitude = 0.0,
|
||||
FixedAltitude = 10000000.0
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableModel",
|
||||
Body = "NEW HORIZONS",
|
||||
Geometry = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/NewHorizonsCleanModel.obj"
|
||||
},
|
||||
ColorTexture = textures .. "/NHTexture.jpg",
|
||||
},
|
||||
GUI = {
|
||||
Path = "/Example"
|
||||
}
|
||||
}
|
||||
|
||||
local Example_Adaptive_Height = {
|
||||
Identifier = "Example_Adaptive_Height",
|
||||
Parent = earth.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earth.Earth.Identifier,
|
||||
Longitude = -74.006,
|
||||
Latitude = 40.7128
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableModel",
|
||||
Body = "NEW HORIZONS",
|
||||
Geometry = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/NewHorizonsCleanModel.obj"
|
||||
},
|
||||
ColorTexture = textures .. "/NHTexture.jpg",
|
||||
},
|
||||
GUI = {
|
||||
Path = "/Example"
|
||||
}
|
||||
}
|
||||
|
||||
assetHelper.registerSceneGraphNodesAndExport(asset, {
|
||||
Example_Fixed_Height,
|
||||
Example_Adaptive_Height
|
||||
})
|
||||
@@ -6,6 +6,9 @@ local earthAsset = asset.require('scene/solarsystem/planets/earth/earth')
|
||||
local sceneHelper = asset.require('util/scene_helper')
|
||||
local propertyHelper = asset.require('util/property_helper')
|
||||
|
||||
local globeTranslation = asset.require('examples/globetranslation')
|
||||
|
||||
|
||||
local models = asset.syncedResource({
|
||||
Name = "Dsn models",
|
||||
Type = "HttpSynchronization",
|
||||
@@ -53,13 +56,33 @@ local stationSiteMap = {
|
||||
}
|
||||
|
||||
--------------------- Goldstone ------------------------
|
||||
local RotationMatrixGoldstone = {
|
||||
-0.9740529, 0.1544376, -0.1654387,
|
||||
-0.2245064, -0.7517193, 0.6200927,
|
||||
-0.0285979, 0.6411452, 0.7668866
|
||||
}
|
||||
|
||||
local RotationMatrixCanberra = {
|
||||
0.7544932, 0.2119603, -0.6211383,
|
||||
-0.6211383, 0.5362649, -0.5714955,
|
||||
0.2119603, 0.8170023, 0.5362649
|
||||
}
|
||||
|
||||
local RotationMatrixMadrid = {
|
||||
0.7257154, 0.1897224, -0.6613188,
|
||||
0.6879883, -0.1958808, 0.6987867,
|
||||
0.0030358, -0.9620999, -0.2726805
|
||||
}
|
||||
|
||||
local DSS14 = {
|
||||
Identifier = "DSS14",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = { -2350973.5,-4636119.5, 3697665 }
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 243.11046,
|
||||
Latitude = 35.4259,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -68,7 +91,8 @@ local DSS14 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/70m_dish/70m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/70m_dish/truss_dish_AO.jpg"
|
||||
ColorTexture = models .. "/70m_dish/truss_dish_AO.jpg",
|
||||
ModelTransform = RotationMatrixGoldstone
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -82,9 +106,11 @@ local DSS15 = {
|
||||
Identifier = "DSS15",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = { -2350973.5, -4636120, 3697665.5 }
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 243.11046379722,
|
||||
Latitude = 35.42590143888,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -93,7 +119,8 @@ local DSS15 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png" ,
|
||||
ModelTransform = RotationMatrixGoldstone
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -102,14 +129,15 @@ local DSS15 = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
local DSS24 = {
|
||||
Identifier = "DSS24",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {-2352268.0,-4641634.5,3689828.75 }
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 243.12521,
|
||||
Latitude = 35.33989,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -118,7 +146,9 @@ local DSS24 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixGoldstone
|
||||
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -131,9 +161,11 @@ local DSS25 = {
|
||||
Identifier = "DSS25",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {-2352383.75,-4641748,3689626.25 }
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 243.12464,
|
||||
Latitude = 35.33761,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -142,7 +174,8 @@ local DSS25 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixGoldstone
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -156,8 +189,10 @@ local DSS26 = {
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {-2352253.25,-4641961,3689457.25}
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 243.12698,
|
||||
Latitude = 35.33569,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -166,7 +201,8 @@ local DSS26 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixGoldstone
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -182,9 +218,11 @@ local DSS43 = {
|
||||
Identifier = "DSS43",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {-4455882,2679347,-3695353.25 }
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 148.98127,
|
||||
Latitude = -35.40242,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -193,7 +231,8 @@ local DSS43 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/70m_dish/70m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/70m_dish/truss_dish_AO.jpg"
|
||||
ColorTexture = models .. "/70m_dish/truss_dish_AO.jpg",
|
||||
ModelTransform = RotationMatrixCanberra
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -207,8 +246,10 @@ local DSS34 = {
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {-4456134,2679425.5,-3694997.5}
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 148.98127,
|
||||
Latitude = -35.40242,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -217,7 +258,8 @@ local DSS34 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixCanberra
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -230,9 +272,11 @@ local DSS35 = {
|
||||
Identifier = "DSS35",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {-4456261,2679554.75,-3694756 }
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 148.98146,
|
||||
Latitude = -35.3958,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -241,7 +285,8 @@ local DSS35 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixCanberra
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -254,9 +299,11 @@ local DSS36 = {
|
||||
Identifier = "DSS36",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {-4456158,2679802,-3694689.75 }
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 148.97854,
|
||||
Latitude = -35.39511,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -265,7 +312,8 @@ local DSS36 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixCanberra
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -279,9 +327,11 @@ local DSS45 = {
|
||||
Identifier = "DSS45",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {-4455930.5,2679756.25,-3694974.25}
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 148.97768,
|
||||
Latitude = -35.39846,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -290,7 +340,8 @@ local DSS45 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixCanberra
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -307,8 +358,10 @@ local DSS63 = {
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {4842262,-359673.125,4137003.5}
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 355.75199,
|
||||
Latitude = 40.43121,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -317,7 +370,8 @@ local DSS63 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/70m_dish/70m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/70m_dish/truss_dish_AO.jpg"
|
||||
ColorTexture = models .. "/70m_dish/truss_dish_AO.jpg",
|
||||
ModelTransform = RotationMatrixMadrid
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -331,8 +385,10 @@ local DSS65 = {
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {4842509.5,-359920.125,4136644.5 }
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 355.7493,
|
||||
Latitude = 40.42721,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -341,7 +397,8 @@ local DSS65 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixMadrid
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -354,9 +411,11 @@ local DSS54 = {
|
||||
Identifier = "DSS54",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {4842605,-360216.15625,4136511.75 }
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 355.7459,
|
||||
Latitude = 40.42562,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -365,7 +424,8 @@ local DSS54 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixMadrid
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -378,9 +438,11 @@ local DSS55 = {
|
||||
Identifier = "DSS55",
|
||||
Parent = earthAsset.Earth.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = {4842696,-360097.96875,4136388.25 }
|
||||
Translation = {
|
||||
Type = "GlobeTranslation",
|
||||
Globe = earthAsset.Earth.Identifier,
|
||||
Longitude = 355.74737,
|
||||
Latitude = 40.4243,
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -389,7 +451,8 @@ local DSS55 = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = models .. "/34m_dish/34m_dish.obj"
|
||||
},
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png"
|
||||
ColorTexture = models .. "/34m_dish/base_AO.png",
|
||||
ModelTransform = RotationMatrixMadrid
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -398,9 +461,6 @@ local DSS55 = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
assetHelper.registerSceneGraphNodesAndExport(asset, {
|
||||
DSS14, DSS15, DSS24, DSS25, DSS26, DSS43, DSS34, DSS35, DSS36, DSS45, DSS63, DSS65, DSS54, DSS55
|
||||
})
|
||||
|
||||
Submodule ext/ghoul updated: c0f31b5e55...655809e25c
@@ -33,6 +33,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ellipsoid.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/gdalwrapper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/geodeticpatch.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/globetranslation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/gpulayergroup.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/layer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/layeradjustment.h
|
||||
@@ -67,6 +68,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ellipsoid.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/gdalwrapper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/geodeticpatch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/globetranslation.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/gpulayergroup.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/layer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/layeradjustment.cpp
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <modules/globebrowsing/src/dashboarditemglobelocation.h>
|
||||
#include <modules/globebrowsing/src/gdalwrapper.h>
|
||||
#include <modules/globebrowsing/src/geodeticpatch.h>
|
||||
#include <modules/globebrowsing/src/globetranslation.h>
|
||||
#include <modules/globebrowsing/src/memoryawaretilecache.h>
|
||||
#include <modules/globebrowsing/src/tileprovider.h>
|
||||
#include <openspace/engine/globalscallbacks.h>
|
||||
@@ -216,18 +217,18 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) {
|
||||
// Deinitialize
|
||||
global::callback::deinitialize.emplace_back([&]() { GdalWrapper::destroy(); });
|
||||
|
||||
// Get factories
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(fRenderable, "Renderable factory was not created");
|
||||
// Create factory for TileProviders
|
||||
fRenderable->registerClass<globebrowsing::RenderableGlobe>("RenderableGlobe");
|
||||
|
||||
auto fTranslation = FactoryManager::ref().factory<Translation>();
|
||||
ghoul_assert(fTranslation, "Translation factory was not created");
|
||||
fTranslation->registerClass<globebrowsing::GlobeTranslation>("GlobeTranslation");
|
||||
|
||||
auto fTileProvider =
|
||||
std::make_unique<ghoul::TemplateFactory<tileprovider::TileProvider>>();
|
||||
ghoul_assert(fTileProvider, "TileProvider factory was not created");
|
||||
|
||||
// Register renderable class
|
||||
fRenderable->registerClass<globebrowsing::RenderableGlobe>("RenderableGlobe");
|
||||
|
||||
// Register TileProvider classes
|
||||
fTileProvider->registerClass<tileprovider::DefaultTileProvider>(
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(
|
||||
layergroupid::TypeID::DefaultTileLayer
|
||||
|
||||
231
modules/globebrowsing/src/globetranslation.cpp
Normal file
231
modules/globebrowsing/src/globetranslation.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* 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 <modules/globebrowsing/src/globetranslation.h>
|
||||
|
||||
#include <modules/globebrowsing/globebrowsingmodule.h>
|
||||
#include <modules/globebrowsing/src/renderableglobe.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo GlobeInfo = {
|
||||
"Globe",
|
||||
"Attached Globe",
|
||||
"The globe on which the longitude/latitude is specified"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LongitudeInfo = {
|
||||
"Longitude",
|
||||
"Longitude",
|
||||
"The longitude of the location on the globe's surface. The value can range from "
|
||||
"-180 to 180, with negative values representing the western hemisphere of the "
|
||||
"globe. The default value is 0.0"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LatitudeInfo = {
|
||||
"Latitude",
|
||||
"Latitude",
|
||||
"The latitude of the location on the globe's surface. The value can range from "
|
||||
"-90 to 90, with negative values representing the southern hemisphere of the "
|
||||
"globe. The default value is 0.0"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FixedAltitudeInfo = {
|
||||
"FixedAltitude",
|
||||
"Fixed Altitude",
|
||||
"The altitude in meters of the location on the globe's surface. This value is "
|
||||
"used if the 'UseFixedAltitude' property is 'true'. The default value is 10000km."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo UseFixedAltitudeInfo = {
|
||||
"UseFixedAltitude",
|
||||
"Use Fixed Altitude",
|
||||
"If this value is 'true', the altitude specified in 'FixedAltitude' is used for "
|
||||
"this translation. If it is 'false', the altitude will be computed based on the "
|
||||
"height information that is available about the globe to which this translation "
|
||||
"is attached. The default value is 'true'."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace::globebrowsing {
|
||||
|
||||
documentation::Documentation GlobeTranslation::Documentation() {
|
||||
using namespace openspace::documentation;
|
||||
|
||||
return {
|
||||
"Spice Translation",
|
||||
"space_translation_spicetranslation",
|
||||
{
|
||||
{
|
||||
"Type",
|
||||
new StringEqualVerifier("GlobeTranslation"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
GlobeInfo.identifier,
|
||||
new StringAnnotationVerifier(
|
||||
"A valid scene graph node with a RenderableGlobe"
|
||||
),
|
||||
Optional::No,
|
||||
GlobeInfo.description
|
||||
},
|
||||
{
|
||||
LongitudeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LongitudeInfo.description
|
||||
},
|
||||
{
|
||||
LatitudeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LatitudeInfo.description,
|
||||
},
|
||||
{
|
||||
FixedAltitudeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FixedAltitudeInfo.description
|
||||
},
|
||||
{
|
||||
UseFixedAltitudeInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
UseFixedAltitudeInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
GlobeTranslation::GlobeTranslation(const ghoul::Dictionary& dictionary)
|
||||
: _globe(GlobeInfo)
|
||||
, _longitude(LongitudeInfo, 0.0, -180.0, 180.0)
|
||||
, _latitude(LatitudeInfo, 0.0, -90.0, 90.0)
|
||||
, _fixedAltitude(FixedAltitudeInfo, 1e8, 0.0, 1e12)
|
||||
, _useFixedAltitude(UseFixedAltitudeInfo, false)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"GlobeTranslation"
|
||||
);
|
||||
|
||||
_globe = dictionary.value<std::string>(GlobeInfo.identifier);
|
||||
if (dictionary.hasKey(LongitudeInfo.identifier)) {
|
||||
_longitude = dictionary.value<double>(LongitudeInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKey(LatitudeInfo.identifier)) {
|
||||
_latitude = dictionary.value<double>(LatitudeInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKey(FixedAltitudeInfo.identifier)) {
|
||||
_fixedAltitude = dictionary.value<double>(FixedAltitudeInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKey(UseFixedAltitudeInfo.identifier)) {
|
||||
_useFixedAltitude = dictionary.value<bool>(UseFixedAltitudeInfo.identifier);
|
||||
}
|
||||
|
||||
_globe.onChange([this]() {
|
||||
fillAttachedNode();
|
||||
_positionIsDirty = true;
|
||||
});
|
||||
|
||||
_longitude.onChange([this]() { _positionIsDirty = true; });
|
||||
_latitude.onChange([this]() { _positionIsDirty = true; });
|
||||
_fixedAltitude.onChange([this]() { _positionIsDirty = true; });
|
||||
_useFixedAltitude.onChange([this]() { _positionIsDirty = true; });
|
||||
}
|
||||
|
||||
void GlobeTranslation::fillAttachedNode() {
|
||||
SceneGraphNode* n = sceneGraphNode(_globe);
|
||||
if (n->renderable() && dynamic_cast<RenderableGlobe*>(n->renderable())) {
|
||||
_attachedNode = dynamic_cast<RenderableGlobe*>(n->renderable());
|
||||
}
|
||||
else {
|
||||
LERRORC(
|
||||
"GlobeTranslation",
|
||||
"Could not set attached node as it does not have a RenderableGlobe"
|
||||
);
|
||||
// Reset the globe name to it's previous name
|
||||
_globe = _attachedNode->identifier();
|
||||
}
|
||||
}
|
||||
|
||||
glm::dvec3 GlobeTranslation::position(const UpdateData&) const {
|
||||
if (!_attachedNode) {
|
||||
// @TODO(abock): The const cast should be removed on a redesign of the translation
|
||||
// to make the position function not constant. Const casting this
|
||||
// away is fine as the factories that create the translations don't
|
||||
// create them as constant objects
|
||||
const_cast<GlobeTranslation*>(this)->fillAttachedNode();
|
||||
_positionIsDirty = true;
|
||||
}
|
||||
|
||||
if (!_useFixedAltitude) {
|
||||
// If we don't use the fixed altitude, we have to compute the height every frame
|
||||
_positionIsDirty = true;
|
||||
}
|
||||
|
||||
if (!_positionIsDirty) {
|
||||
return _position;
|
||||
}
|
||||
|
||||
|
||||
GlobeBrowsingModule& mod = *(global::moduleEngine.module<GlobeBrowsingModule>());
|
||||
|
||||
glm::vec3 pos = mod.cartesianCoordinatesFromGeo(
|
||||
*_attachedNode,
|
||||
_latitude,
|
||||
_longitude,
|
||||
_fixedAltitude
|
||||
);
|
||||
|
||||
if (_useFixedAltitude) {
|
||||
_position = glm::dvec3(pos);
|
||||
_positionIsDirty = true;
|
||||
|
||||
return _position;
|
||||
}
|
||||
else {
|
||||
SurfacePositionHandle h = _attachedNode->calculateSurfacePositionHandle(pos);
|
||||
|
||||
pos = mod.cartesianCoordinatesFromGeo(
|
||||
*_attachedNode,
|
||||
_latitude,
|
||||
_longitude,
|
||||
h.heightToSurface
|
||||
);
|
||||
|
||||
_position = glm::dvec3(pos);
|
||||
return _position;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::globebrowsing
|
||||
63
modules/globebrowsing/src/globetranslation.h
Normal file
63
modules/globebrowsing/src/globetranslation.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* 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___GLOBETRANSLATION___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___GLOBETRANSLATION___H__
|
||||
|
||||
#include <openspace/scene/translation.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/doubleproperty.h>
|
||||
|
||||
namespace openspace::globebrowsing {
|
||||
|
||||
class RenderableGlobe;
|
||||
|
||||
class GlobeTranslation : public Translation {
|
||||
public:
|
||||
GlobeTranslation(const ghoul::Dictionary& dictionary);
|
||||
|
||||
glm::dvec3 position(const UpdateData& data) const override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
void fillAttachedNode();
|
||||
|
||||
properties::StringProperty _globe;
|
||||
properties::DoubleProperty _longitude;
|
||||
properties::DoubleProperty _latitude;
|
||||
properties::DoubleProperty _fixedAltitude;
|
||||
properties::BoolProperty _useFixedAltitude;
|
||||
|
||||
RenderableGlobe* _attachedNode = nullptr;
|
||||
|
||||
mutable bool _positionIsDirty = true;
|
||||
mutable glm::dvec3 _position;
|
||||
};
|
||||
|
||||
} // namespace openspace::globebrowsing
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GLOBETRANSLATION___H__
|
||||
Reference in New Issue
Block a user