mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 09:20:26 -05:00
Merge remote-tracking branch 'origin' into thesis/2018/dsn
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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