From fd98f311d36101e28d9670bf22c3e69f519b4894 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 31 Oct 2016 11:43:36 +0100 Subject: [PATCH] Some cleanup of scene files Exceptions in preInitialization scripts no long crash the application --- data/scene/debugmodel.scene | 53 ----------- data/scene/default-moon.scene | 93 ------------------- data/scene/globebrowsing-debug.scene | 46 --------- .../rendering/renderablecrawlingline.cpp | 2 +- src/engine/openspaceengine.cpp | 33 ++----- 5 files changed, 7 insertions(+), 220 deletions(-) delete mode 100644 data/scene/debugmodel.scene delete mode 100644 data/scene/default-moon.scene delete mode 100644 data/scene/globebrowsing-debug.scene diff --git a/data/scene/debugmodel.scene b/data/scene/debugmodel.scene deleted file mode 100644 index c53596b87e..0000000000 --- a/data/scene/debugmodel.scene +++ /dev/null @@ -1,53 +0,0 @@ --- TextureResolution = "low" -TextureResolution = "med" --- TextureResolution = "high" - -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. - ]]-- - - dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) - - openspace.spice.loadKernel("${SPICE}/naif0011.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") - - openspace.time.setTime("2018-10-25T04:00:00.00") - openspace.time.setDeltaTime(0) -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", false) - openspace.setPropertyValue("SunGlare.renderable.enabled", false) - openspace.setPropertyValue("SunMarker.renderable.enabled", false) - - openspace.printInfo("Done setting default values") - - openspace.resetCameraDirection() -end - -return { - ScenePath = ".", - CommonFolder = "common", - Camera = { - Focus = "DebugModel", - Position = {292946.630948, 377755.961928, 366248.427057}, - Rotation = {0.732615, -0.137003, 0.430036, 0.509485}, - }, - Modules = { - "sun", - "stars", - "debugmodel", - } -} - diff --git a/data/scene/default-moon.scene b/data/scene/default-moon.scene deleted file mode 100644 index 90748de3bf..0000000000 --- a/data/scene/default-moon.scene +++ /dev/null @@ -1,93 +0,0 @@ -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. - ]]-- - - --YYYY-MM-DDTHH:MN:SS - --openspace.time.setTime(openspace.time.currentWallTime()) - --[[ - -- March 9, 2016 total eclipse times from land - -- Palembang, South Sumatra, Indonesia - -- Partial solar eclipse begins: 6:20 a.m. local Western Indonesian Time - -- Total solar eclipse begins: 7:20 a.m. local time - -- Maximum eclipse: 7:21 a.m. local time - -- Total solar eclipse ends: 7:22 a.m. local time - -- Partial solar eclipse ends: 8:31 a.m. local time - - -- 6:20 -> 23:20 day before in UTC - ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") - - openspace.time.setTime("2016-03-08T22:45:00") - - - -- Total Lunar Eclipse Jan 31, 2018 at 10:51:13 UTC - -- Regions seeing, at least, some parts of the eclipse: North/East Europe, - -- Asia, Australia, North/East Africa, North America, North/East South America, - -- Pacific, Atlantic, Indian Ocean, Arctic, Antarctica. - --openspace.time.setTime("2018-01-31T10:30:00") - - --openspace.time.setDeltaTime(200.0) - dofile(openspace.absPath('${SCRIPTS}/bind_keys.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", false) - openspace.setPropertyValue("SunMarker.renderable.enabled", false) - openspace.setPropertyValue("EarthMarker.renderable.enabled", false) - --openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false) - openspace.setPropertyValue("PlutoTrail.renderable.enabled", false) - openspace.setPropertyValue("PlutoTexture.renderable.enabled", false) - - openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55) - openspace.setPropertyValue("MilkyWay.renderable.segments", 50) - - openspace.printInfo("Done setting default values") -end - -return { - ScenePath = ".", - CommonFolder = "common", - Camera = { - Focus = "Earth", - --Focus = "Moon", - Position = {526781518487.171326, 257168309890.072144, -1381125204152.817383}, - Rotation = {-0.106166, 0.981574, -0.084545, 0.134513}, - }, - Modules = { - "sun", - "mercury", - "venus", - "earth", - "moon", - "mars", - --"jupiter", - "saturn", - "uranus", - "neptune", - "stars", - -- "stars-denver", - "milkyway", - -- "milkyway-eso", - --"constellationbounds", - -- "fieldlines", - --"io", - --"europa", - --"ganymede", - --"callisto", - --"gridGalactic", - --"gridEcliptic", - --"gridEquatorial", - } -} - diff --git a/data/scene/globebrowsing-debug.scene b/data/scene/globebrowsing-debug.scene deleted file mode 100644 index ef64c4ef0d..0000000000 --- a/data/scene/globebrowsing-debug.scene +++ /dev/null @@ -1,46 +0,0 @@ -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.spice.loadKernel("${SPICE}/naif0011.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") - - openspace.time.setTime("2015 NOV 24 00:00:00") - - - dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) -end - -function postInitialization() - openspace.printInfo("Setting default values") - - openspace.setInteractionMode('GlobeBrowsing') - - openspace.time.setDeltaTime(0) - openspace.restoreCameraStateFromFile("debugstart.view") - openspace.resetCameraDirection() - openspace.gui.show() - - openspace.printInfo("Done setting default values") -end - - -return { - ScenePath = ".", - CommonFolder = "common", - Camera = { - Focus = "DebugGlobe", - Position = {3428016.852415, 616607.056698, 60430.587719}, - Rotation = {0.178551, -0.280661, 0.916566, 0.221935}, - }, - - Modules = { - "debugglobe" - } -} - diff --git a/modules/newhorizons/rendering/renderablecrawlingline.cpp b/modules/newhorizons/rendering/renderablecrawlingline.cpp index 4c538c180a..1c0035e086 100644 --- a/modules/newhorizons/rendering/renderablecrawlingline.cpp +++ b/modules/newhorizons/rendering/renderablecrawlingline.cpp @@ -132,7 +132,7 @@ void RenderableCrawlingLine::render(const RenderData& data) { _program->setUniform("ModelTransform", transform); int frame = _frameCounter % 60; - float fadingFactor = static_cast(sin((frame * pi_c()) / 60)); + float fadingFactor = static_cast(sin((frame * 3.14159) / 60)); float alpha = 0.6f + fadingFactor*0.4f; glLineWidth(2.f); diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index d1585f7d85..d39b89dfa3 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -471,13 +471,13 @@ bool OpenSpaceEngine::initialize() { _renderEngine->setGlobalBlackOutFactor(0.0); _renderEngine->startFading(1, 3.0); - - //_interactionHandler->setKeyboardController(new interaction::KeyboardControllerFixed); - //_interactionHandler->setMouseController(new interaction::OrbitalMouseController); - // Run start up scripts - runPreInitializationScripts(scenePath); - + try { + runPreInitializationScripts(scenePath); + } + catch (const ghoul::RuntimeError& e) { + LFATALC(e.component, e.message); + } #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED LINFO("Initializing GUI"); @@ -642,24 +642,6 @@ void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) { scripts.getValue(key, scriptPath); std::string&& absoluteScriptPath = absPath(scriptPath); _engine->scriptEngine().runScriptFile(absoluteScriptPath); - - //@JK - //temporary solution to ensure that startup scripts may be syncrhonized over parallel connection - /* - std::ifstream scriptFile; - scriptFile.open(absoluteScriptPath.c_str()); - std::string line; - - while(getline(scriptFile,line)){ - //valid line and not a comment - if(line.size() > 0 && line.at(0) != '-'){ - std::string lib, func; - if(_engine->scriptEngine().parseLibraryAndFunctionNames(lib, func, line) && - _engine->scriptEngine().shouldScriptBeSent(lib, func)){ - _engine->scriptEngine().cacheScript(lib, func, line); - } - } - }*/ } } @@ -902,9 +884,6 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { // Step the camera using the current mouse velocities which are synced //_interactionHandler->updateCamera(); - - - #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED if (_isMaster && _gui->isEnabled() && _windowWrapper->isRegularRendering()) { glm::vec2 mousePosition = _windowWrapper->mousePosition();