mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 06:19:02 -06:00
Retrieve modules path from scene file instead openspace.cfg
This commit is contained in:
@@ -64,8 +64,7 @@ public:
|
||||
/*
|
||||
* Load the scenegraph from the provided folder
|
||||
*/
|
||||
bool loadScene(const std::string& sceneDescriptionFilePath,
|
||||
const std::string& defaultModulePath);
|
||||
bool loadScene(const std::string& sceneDescriptionFilePath);
|
||||
|
||||
void loadModule(const std::string& modulePath);
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace openspace {
|
||||
namespace constants {
|
||||
namespace openspaceengine {
|
||||
const std::string keyPaths = "Paths";
|
||||
const std::string keyPathScene = "Paths.SCENEPATH";
|
||||
const std::string keyConfigSgct = "SGCTConfig";
|
||||
const std::string keyConfigScene = "Scene";
|
||||
const std::string keyStartupScript = "StartupScripts";
|
||||
@@ -39,6 +38,7 @@ namespace openspaceengine {
|
||||
} // namespace openspaceengine
|
||||
|
||||
namespace scenegraph {
|
||||
const std::string keyPathScene = "ScenePath";
|
||||
const std::string keyModules = "Modules";
|
||||
const std::string keyCamera = "Camera";
|
||||
const std::string keyFocusObject = "Focus";
|
||||
|
||||
Submodule openspace-data updated: 1eeafe77a9...5cc1475bcd
@@ -6,14 +6,12 @@ return {
|
||||
SHADERS = "${BASE_PATH}/shaders",
|
||||
OPENSPACE_DATA = "${BASE_PATH}/openspace-data",
|
||||
TESTDIR = "${BASE_PATH}/src/tests",
|
||||
SCENEPATH = "${OPENSPACE_DATA}/scene",
|
||||
-- SCENEPATH = "${OPENSPACE_DATA}/ABufferVolumes",
|
||||
CONFIG = "${BASE_PATH}/config"
|
||||
},
|
||||
SGCTConfig = "${SGCT}/single.xml",
|
||||
--SGCTConfig = "${SGCT}/two_nodes.xml",
|
||||
--SGCTConfig = "${SGCT}/single_sbs_stereo.xml",
|
||||
Scene = "${SCENEPATH}/default.scene",
|
||||
Scene = "${OPENSPACE_DATA}/scene/default.scene",
|
||||
SpiceTimeKernel = "${OPENSPACE_DATA}/spice/naif0010.tls",
|
||||
StartupScripts = {
|
||||
"${SCRIPTS}/default_startup.lua"
|
||||
|
||||
@@ -351,28 +351,6 @@ bool OpenSpaceEngine::initialize()
|
||||
SceneGraph* sceneGraph = new SceneGraph;
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
|
||||
std::string sceneDescriptionPath;
|
||||
bool success = OsEng.configurationManager().getValueSafe(
|
||||
constants::openspaceengine::keyConfigScene, sceneDescriptionPath);
|
||||
if (!success) {
|
||||
LFATAL("The configuration does not contain a scene file under key '" <<
|
||||
constants::openspaceengine::keyConfigScene << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FileSys.fileExists(sceneDescriptionPath)) {
|
||||
LFATAL("Could not find scene description '" << sceneDescriptionPath << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string scenePath;
|
||||
success = _configurationManager->getValueSafe(
|
||||
constants::openspaceengine::keyPathScene, scenePath);
|
||||
if (!success) {
|
||||
LFATAL("Could not find key '" << constants::openspaceengine::keyPathScene <<
|
||||
"' in configuration file '" << sceneDescriptionPath << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// initialize the RenderEngine, needs ${SCENEPATH} to be set
|
||||
@@ -380,7 +358,13 @@ bool OpenSpaceEngine::initialize()
|
||||
_renderEngine->setRuntimeData(initialData);
|
||||
sceneGraph->setRuntimeData(initialData);
|
||||
sceneGraph->initialize();
|
||||
sceneGraph->loadScene(sceneDescriptionPath, scenePath);
|
||||
|
||||
std::string sceneDescriptionPath;
|
||||
bool success = OsEng.configurationManager().getValueSafe(
|
||||
constants::openspaceengine::keyConfigScene, sceneDescriptionPath);
|
||||
if (success)
|
||||
sceneGraph->loadScene(sceneDescriptionPath);
|
||||
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
|
||||
#ifdef FLARE_ONLY
|
||||
|
||||
@@ -468,8 +468,7 @@ void SceneGraph::render(Camera* camera)
|
||||
_root->render(camera);
|
||||
}
|
||||
|
||||
bool SceneGraph::loadScene(const std::string& sceneDescriptionFilePath,
|
||||
const std::string& defaultModulePath)
|
||||
bool SceneGraph::loadScene(const std::string& sceneDescriptionFilePath)
|
||||
{
|
||||
using ghoul::Dictionary;
|
||||
using ghoul::lua::loadDictionaryFromFile;
|
||||
@@ -490,6 +489,28 @@ bool SceneGraph::loadScene(const std::string& sceneDescriptionFilePath,
|
||||
Dictionary dictionary;
|
||||
//load default.scene
|
||||
loadDictionaryFromFile(sceneDescriptionFilePath, dictionary);
|
||||
|
||||
std::string&& sceneDescriptionDirectory =
|
||||
ghoul::filesystem::File(sceneDescriptionFilePath).directoryName();
|
||||
std::string moduleDirectory(".");
|
||||
dictionary.getValueSafe(constants::scenegraph::keyPathScene, moduleDirectory);
|
||||
|
||||
// The scene path could either be an absolute or relative path to the description
|
||||
// paths directory
|
||||
std::string&& relativeCandidate = sceneDescriptionDirectory +
|
||||
ghoul::filesystem::FileSystem::PathSeparator + moduleDirectory;
|
||||
std::string&& absoluteCandidate = absPath(moduleDirectory);
|
||||
|
||||
if (FileSys.directoryExists(relativeCandidate))
|
||||
moduleDirectory = relativeCandidate;
|
||||
else if (FileSys.directoryExists(absoluteCandidate))
|
||||
moduleDirectory = absoluteCandidate;
|
||||
else {
|
||||
LFATAL("The '" << constants::scenegraph::keyPathScene << "' pointed to a "
|
||||
"path '" << moduleDirectory << "' that did not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
Dictionary moduleDictionary;
|
||||
if (dictionary.getValue(constants::scenegraph::keyModules, moduleDictionary)) {
|
||||
std::vector<std::string> keys = moduleDictionary.keys();
|
||||
@@ -497,7 +518,7 @@ bool SceneGraph::loadScene(const std::string& sceneDescriptionFilePath,
|
||||
for (const std::string& key : keys) {
|
||||
std::string moduleFolder;
|
||||
if (moduleDictionary.getValue(key, moduleFolder))
|
||||
loadModule(defaultModulePath + "/" + moduleFolder);
|
||||
loadModule(moduleDirectory + "/" + moduleFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user