Some cleanup of scene files

Exceptions in preInitialization scripts no long crash the application
This commit is contained in:
Alexander Bock
2016-10-31 11:43:36 +01:00
parent c880ee421a
commit fd98f311d3
5 changed files with 7 additions and 220 deletions
-53
View File
@@ -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",
}
}
-93
View File
@@ -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",
}
}
-46
View File
@@ -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"
}
}
@@ -132,7 +132,7 @@ void RenderableCrawlingLine::render(const RenderData& data) {
_program->setUniform("ModelTransform", transform);
int frame = _frameCounter % 60;
float fadingFactor = static_cast<float>(sin((frame * pi_c()) / 60));
float fadingFactor = static_cast<float>(sin((frame * 3.14159) / 60));
float alpha = 0.6f + fadingFactor*0.4f;
glLineWidth(2.f);
+6 -27
View File
@@ -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();