Enable subdirectories for modules

Move newhorizons scene modules into subdirectories
This commit is contained in:
Alexander Bock
2016-04-15 09:52:08 -04:00
parent 46b207b379
commit 588bc74a88
76 changed files with 108 additions and 101 deletions

49
.gitignore vendored
View File

@@ -40,16 +40,15 @@ gui/externaltimecontrol/CMakeLists.txt
gui/externaltimecontrol/main.cpp
gui/externaltimecontrol/mainwindow.cpp
gui/externaltimecontrol/mainwindow.h
include/openspace/version.h
data/scene/67P/obj/67P_rotated_5_130.obj
data/spice/NewHorizonsKernels/
data/spice/RosettaKernels/
data/scene/plutoprojectionhybrid/textures/
data/scene/plutoprojectionhybrid/textures/Shenk_180.jpg
data/scene/plutoprojectionhybrid/textures/barycenter.png
data/scene/plutoprojectionhybrid/textures/defaultProj.png
data/scene/plutoprojectionhybrid/textures/pluto_highres_180.jpg
data/scene/plutoprojectionhybrid/utcEvents.txt
data/scene/newhorizons/pluto/plutoprojectionhybrid/textures/
data/scene/newhorizons/pluto/plutoprojectionhybrid/textures/Shenk_180.jpg
data/scene/newhorizons/pluto/plutoprojectionhybrid/textures/barycenter.png
data/scene/newhorizons/pluto/plutoprojectionhybrid/textures/defaultProj.png
data/scene/newhorizons/pluto/plutoprojectionhybrid/textures/pluto_highres_180.jpg
data/scene/newhorizons/pluto/plutoprojectionhybrid/utcEvents.txt
data/scene/rosetta/obj/mainbodyros.obj
data/scene/rosetta/obj/solarpanelleft.obj
data/scene/rosetta/obj/solarpanelright.obj
@@ -69,7 +68,7 @@ data/scene/uranus/textures/uranus.jpg
data/scene/venus/textures/venus.jpg
data/scene/vestaprojection/VestaComet/VestaComet_5000.obj
data/spice/DawnKernels/
data/scene/jupiterprojection/ProjectionsOfInterest/
data/scene/newhorizons/jupiter/jupiterprojection/ProjectionsOfInterest/
data/scene/67P/textures/black.jpg
data/scene/67P/textures/defaultProj.jpg
data/scene/67P/textures/gray.jpg
@@ -77,12 +76,12 @@ data/scene/67P/textures/gray.png
data/scene/67P/textures/texmapflipped.jpg
data/scene/67P/textures/white.jpg
data/scene/67P/textures/white.png
data/scene/callistoprojection/textures/callisto.jpg
data/scene/newhorizons/jupiter/callistoprojection/textures/callisto.jpg
data/scene/ceres/textures/gray.png
data/scene/charonprojection/textures/Charon-Text.png
data/scene/charonprojection/textures/charon_highres.jpg
data/scene/charonprojection/textures/charon_highres_annotated.jpg
data/scene/charonprojection/textures/defaultProj.png
data/scene/newhorizons/pluto/charonprojection/textures/Charon-Text.png
data/scene/newhorizons/pluto/charonprojection/textures/charon_highres.jpg
data/scene/newhorizons/pluto/charonprojection/textures/charon_highres_annotated.jpg
data/scene/newhorizons/pluto/charonprojection/textures/defaultProj.png
data/scene/dawn/obj/mainbodydawn.obj
data/scene/dawn/obj/solarpanelleft.obj
data/scene/dawn/obj/solarpanelright.obj
@@ -93,25 +92,25 @@ data/scene/earth/textures/earth_bluemarble.jpg
data/scene/earth/textures/earth_bluemarble_height.jpg
data/scene/earth/textures/earth_night.jpg
data/scene/earth/textures/marker.png
data/scene/europaprojection/textures/europa.jpg
data/scene/ganymedeprojection/textures/ganymede.jpg
data/scene/ioprojection/textures/io.jpg
data/scene/newhorizons/jupiter/europaprojection/textures/europa.jpg
data/scene/newhorizons/jupiter/ganymedeprojection/textures/ganymede.jpg
data/scene/newhorizons/jupiter/ioprojection/textures/io.jpg
data/scene/jupiter/textures/jupiter.jpg
data/scene/mars/textures/mars.jpg
data/scene/mercury/textures/mercury.jpg
data/scene/milkyway/textures/DarkUniverse_mellinger_8k.jpg
data/scene/neptune/textures/neptune.jpg
data/scene/newhorizons/models/Labels.obj
data/scene/newhorizons/models/NewHorizonsCleanModel.obj
data/scene/newhorizons/textures/NHTextureFlipCol.jpg
data/scene/newhorizons/textures/goldfoilbump.tif
data/scene/newhorizons/textures/labels.png
data/scene/newhorizons/newhorizons/models/Labels.obj
data/scene/newhorizons/newhorizons/models/NewHorizonsCleanModel.obj
data/scene/newhorizons/newhorizons/textures/NHTextureFlipCol.jpg
data/scene/newhorizons/newhorizons/textures/goldfoilbump.tif
data/scene/newhorizons/newhorizons/textures/labels.png
data/scene/pluto/textures/
data/scene/pluto/textures/Shenk_180.jpg
data/scene/pluto/textures/pluto_highres_180.jpg
data/scene/plutoprojectionhybrid/assets/core_v9h_obs_getmets_v8_time_fix_nofrcd_mld.txt
data/scene/plutoprojectionhybrid/textures/3.jpg
data/scene/plutoprojectionhybrid/textures/Pluto-Text.png
data/scene/newhorizons/pluto/plutoprojectionhybrid/assets/core_v9h_obs_getmets_v8_time_fix_nofrcd_mld.txt
data/scene/newhorizons/pluto/plutoprojectionhybrid/textures/3.jpg
data/scene/newhorizons/pluto/plutoprojectionhybrid/textures/Pluto-Text.png
data/scene/vestaprojection/VestaComet/VestaComet.mtl
data/scene/vestaprojection/textures/defaultProj_backup.png
data/scene/vestaprojection/textures/dummy.jpg
@@ -120,4 +119,4 @@ data/scene/vestaprojection/textures/projectMe.png
data/spice/MAR063.BSP
data/spice/de430_1850-2150.bsp
data/spice/jup260.bsp
data/scene/plutoprojectionhybrid/images
data/scene/newhorizons/pluto/plutoprojectionhybrid/images

View File

@@ -16,29 +16,24 @@ return {
"saturn",
"uranus",
"neptune",
"plutoprojectionhybrid",
"charonprojection",
"kerberos",
"nix",
"styx",
"hydra",
"newhorizons/pluto/plutoprojectionhybrid",
"newhorizons/pluto/charonprojection",
"newhorizons/pluto/kerberos",
"newhorizons/pluto/nix",
"newhorizons/pluto/styx",
"newhorizons/pluto/hydra",
"stars",
-- "stars-denver",
"milkyway",
-- "milkyway-eso",
"imageplane",
--"constellationbounds",
--"io",
--"europa",
--"ganymede",
--"callisto",
"jupiterprojection",
"ioprojection",
"europaprojection",
"ganymedeprojection",
"callistoprojection",
"newhorizons",
"newhorizonsfov",
"newhorizons/jupiter/jupiterprojection",
"newhorizons/jupiter/ioprojection",
"newhorizons/jupiter/europaprojection",
"newhorizons/jupiter/ganymedeprojection",
"newhorizons/jupiter/callistoprojection",
"newhorizons/newhorizons",
"newhorizons/newhorizonsfov",
}
}

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 284 KiB

After

Width:  |  Height:  |  Size: 284 KiB

View File

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 188 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 3.4 MiB

View File

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 2.7 MiB

View File

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 175 KiB

View File

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 156 KiB

View File

Before

Width:  |  Height:  |  Size: 282 KiB

After

Width:  |  Height:  |  Size: 282 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 304 B

After

Width:  |  Height:  |  Size: 304 B

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

@@ -89,7 +89,7 @@ return {
Body = "NEW HORIZONS",
Geometry = {
Type = "MultiModelGeometry",
GeometryFile = "${OPENSPACE_DATA}/scene/newhorizons/models/NewHorizonsCleanModel.obj",
GeometryFile = "models/NewHorizonsCleanModel.obj",
Magnification = 4,
},
Textures = {
@@ -151,7 +151,7 @@ return {
Body = "NEW HORIZONS",
Geometry = {
Type = "MultiModelGeometry",
GeometryFile = "${OPENSPACE_DATA}/scene/newhorizons/models/Labels.obj",
GeometryFile = "models/Labels.obj",
Magnification = 4,
},
Textures = {

View File

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View File

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View File

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View File

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View File

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View File

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 587 B

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 587 B

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 587 B

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 587 B

View File

@@ -175,9 +175,14 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) {
std::sort(keys.begin(), keys.end());
ghoul::filesystem::Directory oldDirectory = FileSys.currentDirectory();
for (const std::string& key : keys) {
std::string moduleName = moduleDictionary.value<std::string>(key);
std::string modulePath = FileSys.pathByAppendingComponent(sceneDirectory, moduleName);
std::string fullModuleName = moduleDictionary.value<std::string>(key);
std::string modulePath = FileSys.pathByAppendingComponent(sceneDirectory, fullModuleName);
std::string moduleName = fullModuleName;
std::string::size_type pos = fullModuleName.find_last_of(FileSys.PathSeparator);
if (pos != std::string::npos)
moduleName = fullModuleName.substr(pos + 1);
if (!FileSys.directoryExists(modulePath)) {
LERROR("Could not load module '" << moduleName << "'. Directory did not exist");
continue;
@@ -188,70 +193,78 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) {
moduleName + _moduleExtension
);
if (!FileSys.fileExists(moduleFile)) {
LERROR("Could not load module file '" << moduleFile << "'. File did not exist");
continue;
}
ghoul::Dictionary moduleDictionary;
try {
ghoul::lua::loadDictionaryFromFile(moduleFile, moduleDictionary, state);
}
catch (...) {
continue;
}
std::vector<std::string> keys = moduleDictionary.keys();
for (const std::string& key : keys) {
if (!moduleDictionary.hasValue<ghoul::Dictionary>(key)) {
LERROR("SceneGraphNode '" << key << "' is not a table in module '"
<< moduleFile << "'");
std::vector<ghoul::Dictionary> moduleDictionaries;
if (FileSys.fileExists(moduleFile)) {
// We have a module file, so it is a direct include
try {
ghoul::Dictionary moduleDictionary;
ghoul::lua::loadDictionaryFromFile(moduleFile, moduleDictionary, state);
moduleDictionaries.push_back(std::move(moduleDictionary));
}
catch (...) {
continue;
}
}
// else {
// // If we do not have a module file, we have to include all subdirectories
// ghoul::filesystem::
// ghoul::filesystem::Directory d = modulePath;
// }
for (const ghoul::Dictionary& moduleDictionary : moduleDictionaries) {
std::vector<std::string> keys = moduleDictionary.keys();
for (const std::string& key : keys) {
if (!moduleDictionary.hasValue<ghoul::Dictionary>(key)) {
LERROR("SceneGraphNode '" << key << "' is not a table in module '"
<< moduleFile << "'");
continue;
}
ghoul::Dictionary element;
std::string nodeName;
std::string parentName;
ghoul::Dictionary element;
std::string nodeName;
std::string parentName;
moduleDictionary.getValue(key, element);
element.setValue(KeyPathModule, modulePath);
moduleDictionary.getValue(key, element);
element.setValue(KeyPathModule, modulePath);
element.getValue(SceneGraphNode::KeyName, nodeName);
element.getValue(SceneGraphNode::KeyParentName, parentName);
element.getValue(SceneGraphNode::KeyName, nodeName);
element.getValue(SceneGraphNode::KeyParentName, parentName);
FileSys.setCurrentDirectory(modulePath);
SceneGraphNode* node = SceneGraphNode::createFromDictionary(element);
if (node == nullptr) {
LERROR("Error loading SceneGraphNode '" << nodeName << "' in module '" << moduleName << "'");
continue;
//clear();
//return false;
}
FileSys.setCurrentDirectory(modulePath);
SceneGraphNode* node = SceneGraphNode::createFromDictionary(element);
if (node == nullptr) {
LERROR("Error loading SceneGraphNode '" << nodeName << "' in module '" << moduleName << "'");
continue;
//clear();
//return false;
}
dependencies[nodeName].push_back(parentName);
parents[nodeName] = parentName;
// Also include loaded dependencies
dependencies[nodeName].push_back(parentName);
parents[nodeName] = parentName;
// Also include loaded dependencies
if (element.hasKey(SceneGraphNode::KeyDependencies)) {
if (element.hasValue<ghoul::Dictionary>(SceneGraphNode::KeyDependencies)) {
ghoul::Dictionary nodeDependencies;
element.getValue(SceneGraphNode::KeyDependencies, nodeDependencies);
if (element.hasKey(SceneGraphNode::KeyDependencies)) {
if (element.hasValue<ghoul::Dictionary>(SceneGraphNode::KeyDependencies)) {
ghoul::Dictionary nodeDependencies;
element.getValue(SceneGraphNode::KeyDependencies, nodeDependencies);
std::vector<std::string> keys = nodeDependencies.keys();
for (const std::string& key : keys) {
std::string value = nodeDependencies.value<std::string>(key);
dependencies[nodeName].push_back(value);
std::vector<std::string> keys = nodeDependencies.keys();
for (const std::string& key : keys) {
std::string value = nodeDependencies.value<std::string>(key);
dependencies[nodeName].push_back(value);
}
}
else {
LERROR("Dependencies did not have the corrent type");
}
}
else {
LERROR("Dependencies did not have the corrent type");
}
SceneGraphNodeInternal* internalNode = new SceneGraphNodeInternal;
internalNode->node = node;
_nodes.push_back(internalNode);
}
SceneGraphNodeInternal* internalNode = new SceneGraphNodeInternal;
internalNode->node = node;
_nodes.push_back(internalNode);
}
}
ghoul::lua::destroyLuaState(state);