mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 12:39:24 -05:00
Globe browsing interaction mode follows the rotation of the globe.
This commit is contained in:
@@ -2,34 +2,28 @@ return {
|
||||
-- Earth barycenter module
|
||||
{
|
||||
Name = "EarthBarycenter",
|
||||
Parent = "Root",
|
||||
Parent = "SolarSystemBarycenter",
|
||||
Static = true,
|
||||
--[[
|
||||
Ephemeris = {
|
||||
Type = "Kepler",
|
||||
Inclination = 0.00041,
|
||||
AscendingNode = 349.2,
|
||||
Perihelion = 102.8517,
|
||||
SemiMajorAxis = 1.00002,
|
||||
DailyMotion = 0.9855796,
|
||||
Eccentricity = 0.0166967,
|
||||
MeanLongitude = 328.40353
|
||||
}
|
||||
--]]
|
||||
Ephemeris = {
|
||||
Type = "Static"
|
||||
}
|
||||
Type = "Spice",
|
||||
Body = "EARTH BARYCENTER",
|
||||
Reference = "ECLIPJ2000",
|
||||
Observer = "SUN",
|
||||
Kernels = {
|
||||
"${OPENSPACE_DATA}/spice/de430_1850-2150.bsp"
|
||||
}
|
||||
},
|
||||
},
|
||||
-- RenderableGlobe module
|
||||
{
|
||||
Name = "DebugGlobe",
|
||||
Parent = "Root",
|
||||
Parent = "EarthBarycenter",
|
||||
Renderable = {
|
||||
Type = "RenderableGlobe",
|
||||
Frame = "IAU_EARTH",
|
||||
Body = "EARTH",
|
||||
--Radii = {6378137.0, 6378137.0, 6356752.314245}, -- Earth's radii
|
||||
Radii = {3396190.0, 3396190.0, 3376200.0}, -- Mars' radii
|
||||
Radii = {6378137.0, 6378137.0, 6356752.314245}, -- Earth's radii
|
||||
--Radii = {3396190.0, 3396190.0, 3376200.0}, -- Mars' radii
|
||||
CameraMinHeight = 1000,
|
||||
InteractionDepthBelowEllipsoid = 10000, -- Useful when having negative height map values
|
||||
SegmentsPerPatch = 90,
|
||||
@@ -62,18 +56,17 @@ return {
|
||||
{
|
||||
Name = "ESRI Imagery World 2D",
|
||||
FilePath = "map_service_configs/ESRI_Imagery_World_2D.wms",
|
||||
Enabled = true,
|
||||
},
|
||||
{
|
||||
Name = "MARS_Viking_MDIM21",
|
||||
FilePath = "map_service_configs/MARS_Viking_MDIM21.xml",
|
||||
Enabled = true,
|
||||
},
|
||||
},
|
||||
GrayScaleOverlays = {
|
||||
{
|
||||
Name = "CTX Mosaic",
|
||||
FilePath = "map_service_configs/CTX_Mosaic.xml",
|
||||
Enabled = true,
|
||||
},
|
||||
},
|
||||
NightTextures = {
|
||||
@@ -86,11 +79,11 @@ return {
|
||||
{
|
||||
Name = "Terrain tileset",
|
||||
FilePath = "map_service_configs/TERRAIN.wms",
|
||||
Enabled = true,
|
||||
},
|
||||
{
|
||||
Name = "Mola Elevation",
|
||||
FilePath = "map_service_configs/Mola_Elevation.xml",
|
||||
Enabled = true,
|
||||
},
|
||||
},
|
||||
WaterMasks = {
|
||||
@@ -128,11 +121,10 @@ return {
|
||||
--]]
|
||||
GuiName = "/Solar/Planets/DebugGlobe"
|
||||
},
|
||||
--[[
|
||||
-- EarthTrail module
|
||||
{
|
||||
Name = "EarthTrail",
|
||||
Parent = "EarthBarycenter",
|
||||
Parent = "SolarSystemBarycenter",
|
||||
Renderable = {
|
||||
Type = "RenderableTrail",
|
||||
Body = "EARTH",
|
||||
@@ -145,5 +137,4 @@ return {
|
||||
},
|
||||
GuiName = "/Solar/EarthTrail"
|
||||
},
|
||||
--]]
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ return {
|
||||
|
||||
Modules = {
|
||||
"debugglobe",
|
||||
"sun",
|
||||
"stars",
|
||||
"milkyway",
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
${SCENE}/iswa/tfs/colormap_autumn.png
|
||||
@@ -154,6 +154,7 @@ protected:
|
||||
|
||||
SceneGraphNode* _focusNode = nullptr;
|
||||
glm::dvec3 _previousFocusNodePosition;
|
||||
glm::dquat _previousFocusNodeRotation;
|
||||
};
|
||||
|
||||
class KeyframeInteractionMode : public InteractionMode
|
||||
|
||||
@@ -173,11 +173,11 @@ namespace openspace {
|
||||
void RenderableGlobe::update(const UpdateData& data) {
|
||||
|
||||
// set spice-orientation in accordance to timestamp
|
||||
//_chunkedLodGlobe->setStateMatrix(
|
||||
// SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time));
|
||||
_chunkedLodGlobe->setStateMatrix(
|
||||
SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time));
|
||||
// We currently do not consider rotation anywhere in the rendering.
|
||||
// @TODO Consider rotation everywhere in the rendering (culling, splitting, camera, etc)
|
||||
_chunkedLodGlobe->setStateMatrix(glm::dmat3(1.0));
|
||||
//_chunkedLodGlobe->setStateMatrix(glm::dmat3(1.0));
|
||||
_time = data.time;
|
||||
_distanceSwitch.update(data);
|
||||
|
||||
@@ -195,6 +195,10 @@ namespace openspace {
|
||||
return _ellipsoid;
|
||||
}
|
||||
|
||||
const glm::dmat3& RenderableGlobe::stateMatrix() {
|
||||
return _chunkedLodGlobe->stateMatrix();
|
||||
}
|
||||
|
||||
float RenderableGlobe::getHeight(glm::dvec3 position) {
|
||||
// Get the tile provider for the height map
|
||||
const auto& heightMapProviders = _tileProviderManager->getActivatedLayerCategory(LayeredTextures::HeightMaps);
|
||||
|
||||
@@ -112,6 +112,7 @@ public:
|
||||
|
||||
glm::dvec3 projectOnEllipsoid(glm::dvec3 position);
|
||||
const Ellipsoid& ellipsoid();
|
||||
const glm::dmat3& stateMatrix();
|
||||
float getHeight(glm::dvec3 position);
|
||||
float cameraMinHeight();
|
||||
double interactionDepthBelowEllipsoid();
|
||||
|
||||
@@ -151,6 +151,7 @@ InteractionMode::~InteractionMode() {
|
||||
void InteractionMode::setFocusNode(SceneGraphNode* focusNode) {
|
||||
_focusNode = focusNode;
|
||||
_previousFocusNodePosition = _focusNode->worldPosition().dvec3();
|
||||
_previousFocusNodeRotation = dquat();
|
||||
}
|
||||
|
||||
SceneGraphNode* InteractionMode::focusNode() {
|
||||
@@ -412,6 +413,7 @@ void GlobeBrowsingInteractionMode::setFocusNode(SceneGraphNode* focusNode) {
|
||||
|
||||
void GlobeBrowsingInteractionMode::updateCameraStateFromMouseStates(Camera& camera) {
|
||||
if (_focusNode && _globe) {
|
||||
|
||||
// Declare variables to use in interaction calculations
|
||||
// Shrink interaction ellipsoid to enable interaction below height = 0
|
||||
double ellipsoidShrinkTerm = _globe->interactionDepthBelowEllipsoid();
|
||||
@@ -419,13 +421,13 @@ void GlobeBrowsingInteractionMode::updateCameraStateFromMouseStates(Camera& came
|
||||
|
||||
// Read the current state of the camera and focusnode
|
||||
dvec3 camPos = camera.positionVec3();
|
||||
|
||||
// Follow focus nodes movement
|
||||
dvec3 centerPos = _focusNode->worldPosition().dvec3();
|
||||
|
||||
// Follow focus nodes movement
|
||||
dvec3 focusNodeDiff = centerPos - _previousFocusNodePosition;
|
||||
_previousFocusNodePosition = centerPos;
|
||||
camPos += focusNodeDiff;
|
||||
|
||||
|
||||
dquat totalRotation = camera.rotationQuaternion();
|
||||
dvec3 lookUp = camera.lookUpVectorWorldSpace();
|
||||
dvec3 camDirection = camera.viewDirectionWorldSpace();
|
||||
@@ -433,8 +435,8 @@ void GlobeBrowsingInteractionMode::updateCameraStateFromMouseStates(Camera& came
|
||||
dvec3 posDiff = camPos - centerPos;
|
||||
dvec3 directionFromSurfaceToCamera =
|
||||
_globe->ellipsoid().geodeticSurfaceNormal(
|
||||
_globe->ellipsoid().cartesianToGeodetic2(camPos));
|
||||
dvec3 centerToEllipsoidSurface = _globe->projectOnEllipsoid(camPos) -
|
||||
_globe->ellipsoid().cartesianToGeodetic2(posDiff));
|
||||
dvec3 centerToEllipsoidSurface = _globe->projectOnEllipsoid(posDiff) -
|
||||
directionFromSurfaceToCamera * ellipsoidShrinkTerm;
|
||||
dvec3 ellipsoidSurfaceToCamera = camPos - (centerPos + centerToEllipsoidSurface);
|
||||
|
||||
@@ -451,6 +453,12 @@ void GlobeBrowsingInteractionMode::updateCameraStateFromMouseStates(Camera& came
|
||||
dquat globalCameraRotation = normalize(quat_cast(inverse(lookAtMat)));
|
||||
dquat localCameraRotation = inverse(globalCameraRotation) * totalRotation;
|
||||
|
||||
// Rotate with the globe
|
||||
dmat3 globeStateMatrix = _globe->stateMatrix();
|
||||
dquat globeRotation = quat_cast(globeStateMatrix);
|
||||
dquat focusNodeRotationDiff = _previousFocusNodeRotation * inverse(globeRotation);
|
||||
_previousFocusNodeRotation = globeRotation;
|
||||
|
||||
{ // Do local roll
|
||||
glm::dquat cameraRollRotation =
|
||||
glm::angleAxis(_mouseStates->_localRollMouseState.velocity.get().x, dvec3(0, 0, 1));
|
||||
@@ -476,20 +484,21 @@ void GlobeBrowsingInteractionMode::updateCameraStateFromMouseStates(Camera& came
|
||||
|
||||
glm::dvec3 rotationDiffVec3 =
|
||||
(distFromCenterToCamera * directionFromSurfaceToCamera)
|
||||
* rotationDiffWorldSpace
|
||||
* rotationDiffWorldSpace * focusNodeRotationDiff
|
||||
- (distFromCenterToCamera * directionFromSurfaceToCamera);
|
||||
|
||||
camPos += rotationDiffVec3;
|
||||
dvec3 posDiff = camPos - centerPos;
|
||||
|
||||
directionFromSurfaceToCamera =
|
||||
_globe->ellipsoid().geodeticSurfaceNormal(
|
||||
_globe->ellipsoid().cartesianToGeodetic2(camPos));
|
||||
centerToEllipsoidSurface = _globe->projectOnEllipsoid(camPos) -
|
||||
_globe->ellipsoid().cartesianToGeodetic2(posDiff));
|
||||
centerToEllipsoidSurface = _globe->projectOnEllipsoid(posDiff) -
|
||||
directionFromSurfaceToCamera * ellipsoidShrinkTerm;
|
||||
ellipsoidSurfaceToCamera = camPos - (centerPos + centerToEllipsoidSurface);
|
||||
|
||||
glm::dvec3 lookUpWhenFacingSurface =
|
||||
globalCameraRotation * glm::dvec3(camera.lookUpVectorCameraSpace());
|
||||
inverse(focusNodeRotationDiff) * globalCameraRotation * glm::dvec3(camera.lookUpVectorCameraSpace());
|
||||
glm::dmat4 lookAtMat = glm::lookAt(
|
||||
glm::dvec3(0, 0, 0),
|
||||
-directionFromSurfaceToCamera,
|
||||
@@ -516,9 +525,14 @@ void GlobeBrowsingInteractionMode::updateCameraStateFromMouseStates(Camera& came
|
||||
camPos += directionFromSurfaceToCamera *
|
||||
glm::max(heightToSurfaceAndPadding - distFromEllipsoidSurfaceToCamera, 0.0);
|
||||
}
|
||||
|
||||
// Update the camera state
|
||||
camera.setPositionVec3(camPos);
|
||||
camera.setRotation(globalCameraRotation * localCameraRotation);
|
||||
camera.setPositionVec3(camPos);
|
||||
|
||||
// Unfortunately need to synch since interactionhandler is updated after synch..
|
||||
camera.preSynchronization();
|
||||
camera.postSynchronizationPreDraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user