mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-24 04:59:24 -06:00
Save and Load camera position
This commit is contained in:
2
data/iswa/magnetosphere.pos
Normal file
2
data/iswa/magnetosphere.pos
Normal file
@@ -0,0 +1,2 @@
|
||||
-6.23538e+09 -7.4768e+10 1.28478e+11
|
||||
-0.0115185 0.6478 0.00979661 0.761661
|
||||
72
data/scene/iswa.scene
Normal file
72
data/scene/iswa.scene
Normal file
@@ -0,0 +1,72 @@
|
||||
function preInitialization()
|
||||
--[[
|
||||
The scripts in this function are executed after the scene is loaded but before the
|
||||
scene elements have been initialized, thus they should be used to set the time at
|
||||
which the scene should start and other settings that might determine initialization
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
--openspace.time.setTime(openspace.time.currentWallTime())
|
||||
openspace.time.setTime('2015-03-15T11:00:00.00')
|
||||
openspace.time.setDeltaTime(0)
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys_iswa.lua'))
|
||||
end
|
||||
|
||||
function postInitialization()
|
||||
--[[
|
||||
The scripts in this function are executed after all objects in the scene have been
|
||||
created and initialized, but before the first render call. This is the place to set
|
||||
graphical settings for the renderables.
|
||||
]]--
|
||||
openspace.printInfo("Setting default values")
|
||||
openspace.setPropertyValue("Sun.renderable.enabled", true)
|
||||
openspace.setPropertyValue("SunGlare.renderable.enabled", false)
|
||||
openspace.setPropertyValue("SunMarker.renderable.enabled", false)
|
||||
openspace.setPropertyValue("EarthMarker.renderable.enabled", false)
|
||||
openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false)
|
||||
|
||||
openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55)
|
||||
openspace.setPropertyValue("MilkyWay.renderable.segments", 50)
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
|
||||
if openspace.modules.isLoaded("ISWA") then
|
||||
|
||||
openspace.restoreCameraPosition('${OPENSPACE_DATA}/iswa/magnetosphere.pos');
|
||||
openspace.iswa.addCdfFiles("${OPENSPACE_DATA}/iswa/cdflist.json");
|
||||
|
||||
--openspace.iswa.addCygnet(7);
|
||||
|
||||
--openspace.iswa.addCygnet(-4,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-5,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-6,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-7,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-8,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-9,"Data","Gm");
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
ScenePath = ".",
|
||||
CommonFolder = "common",
|
||||
Camera = {
|
||||
Focus = "Earth",
|
||||
},
|
||||
Modules = {
|
||||
"sun",
|
||||
--"mercury",
|
||||
--"venus",
|
||||
"earth",
|
||||
--"mars",
|
||||
--"jupiter",
|
||||
--"saturn",
|
||||
--"uranus",
|
||||
--"neptune",
|
||||
"stars",
|
||||
--"stars-denver",
|
||||
"milkyway",
|
||||
--"milkyway-eso",
|
||||
"constellationbounds",
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
virtual void update(Camera& camera, const InputState& inputState, double deltaTime) = 0;
|
||||
virtual void initialize(const Camera& camera) = 0;
|
||||
|
||||
virtual void stop() = 0;
|
||||
protected:
|
||||
/**
|
||||
Inner class that acts as a smoothing filter to a variable. The filter has a step
|
||||
@@ -164,6 +164,7 @@ public:
|
||||
|
||||
virtual void update(Camera& camera, const InputState& inputState, double deltaTime);
|
||||
virtual void initialize(const Camera& camera);
|
||||
void stop(){_globalRotationMouseState.velocity.set(glm::dvec2(0.0),1.0);}
|
||||
|
||||
protected:
|
||||
void updateMouseStatesFromInput(const InputState& inputState, double deltaTime);
|
||||
|
||||
@@ -8,11 +8,12 @@ return {
|
||||
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
|
||||
-- of all entities that will be visible during an instance of OpenSpace
|
||||
-- Scene = "${SCENE}/default-moon.scene",
|
||||
Scene = "${SCENE}/default.scene",
|
||||
-- Scene = "${SCENE}/default.scene",
|
||||
-- Scene = "${SCENE}/globebrowsing.scene",
|
||||
-- Scene = "${SCENE}/rosetta.scene",
|
||||
-- Scene = "${SCENE}/dawn.scene",
|
||||
-- Scene = "${SCENE}/newhorizons.scene",
|
||||
Scene = "${SCENE}/iswa.scene",
|
||||
|
||||
Paths = {
|
||||
SGCT = "${BASE_PATH}/config/sgct",
|
||||
|
||||
@@ -15,10 +15,4 @@ openspace.bindKey("q", helper.renderable.toggle('SunMarker'))
|
||||
openspace.bindKey("e", helper.renderable.toggle('EarthMarker'))
|
||||
openspace.bindKey("x", helper.renderable.toggle('Constellation Bounds'))
|
||||
|
||||
openspace.bindKey("c", "openspace.parallel.setAddress('130.236.142.51');openspace.parallel.setPassword('newhorizons-20150714');openspace.parallel.connect();")
|
||||
|
||||
openspace.bindKey("h", "openspace.iswa.setBaseUrl('http://iswa-demo-server.herokuapp.com/')");
|
||||
openspace.bindKey("g", "openspace.iswa.setBaseUrl('http://128.183.168.116:3000/')");
|
||||
openspace.bindKey("l", "openspace.iswa.setBaseUrl('http://localhost:3000/')");
|
||||
|
||||
openspace.bindKey("v", "openspace.time.setTime('2015-03-15T02:00:00.00')");
|
||||
openspace.bindKey("c", "openspace.parallel.setAddress('130.236.142.51');openspace.parallel.setPassword('newhorizons-20150714');openspace.parallel.connect();")
|
||||
27
scripts/bind_keys_iswa.lua
Normal file
27
scripts/bind_keys_iswa.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
--[[ OpenSpace keybinding script ]]--
|
||||
|
||||
-- Load the common helper functions
|
||||
dofile(openspace.absPath('${SCRIPTS}/common.lua'))
|
||||
|
||||
openspace.clearKeys()
|
||||
helper.setCommonKeys()
|
||||
helper.setDeltaTimeKeys({
|
||||
1, 5, 10, 20, 40, 60, 120, 360, 720, 1440,
|
||||
2880, 5760, 11520, 23040, 46080, 92160, 184320, 368640, 737280, 1474560,
|
||||
2949120, 5898240, 11796480, 23592960, 47185920, 94371840, 188743680, 377487360
|
||||
})
|
||||
|
||||
openspace.bindKey("q", helper.renderable.toggle('SunMarker'))
|
||||
openspace.bindKey("e", helper.renderable.toggle('EarthMarker'))
|
||||
openspace.bindKey("x", helper.renderable.toggle('Constellation Bounds'))
|
||||
|
||||
openspace.bindKey("c", "openspace.parallel.setAddress('130.236.142.51');openspace.parallel.setPassword('newhorizons-20150714');openspace.parallel.connect();")
|
||||
|
||||
openspace.bindKey("h", "openspace.iswa.setBaseUrl('http://iswa-demo-server.herokuapp.com/')");
|
||||
openspace.bindKey("g", "openspace.iswa.setBaseUrl('http://128.183.168.116:3000/')");
|
||||
openspace.bindKey("l", "openspace.iswa.setBaseUrl('http://localhost:3000/')");
|
||||
|
||||
openspace.bindKey("v", "openspace.time.setTime('2015-03-15T02:00:00.00')");
|
||||
|
||||
openspace.bindKey("s", "openspace.saveCameraPosition('${OPENSPACE_DATA}/iswa/magnetosphere.pos');");
|
||||
openspace.bindKey("a", "openspace.restoreCameraPosition('${OPENSPACE_DATA}/iswa/magnetosphere.pos');");
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <ghoul/misc/interpolator.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
@@ -771,6 +770,7 @@ void InteractionHandler::restoreCameraPosition(const std::string& filepath) {
|
||||
_camera->setRotation(r);
|
||||
_currentInteractionMode->initialize(*_camera);
|
||||
_cameraUpdatedFromScript = true;
|
||||
_currentInteractionMode->stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ void OrbitalInteractionMode::updateCameraStateFromMouseStates(Camera& camera) {
|
||||
}
|
||||
{ // Do global rotation
|
||||
dvec2 smoothMouseVelocity = _globalRotationMouseState.velocity.get();
|
||||
dvec3 eulerAngles(smoothMouseVelocity.y, smoothMouseVelocity.x, 0);
|
||||
dvec3 eulerAngles(-smoothMouseVelocity.y, -smoothMouseVelocity.x, 0);
|
||||
dquat rotationDiffCamSpace = dquat(eulerAngles);
|
||||
|
||||
dquat newRotationCamspace = _globalCameraRotation * rotationDiffCamSpace;
|
||||
|
||||
Reference in New Issue
Block a user