mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-02 01:30:34 -06:00
More restructuring work on SceneGraph
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <openspace/util/camera.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/scene/scenegraph.h>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
@@ -95,7 +96,7 @@ public:
|
||||
*/
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name) const;
|
||||
|
||||
std::vector<SceneGraphNode*> allSceneGraphNodes() const;
|
||||
std::vector<SceneGraphNode*> allSceneGraphNodes();
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to change the
|
||||
@@ -115,9 +116,10 @@ private:
|
||||
std::string _focus;
|
||||
|
||||
// actual scenegraph
|
||||
SceneGraphNode* _root;
|
||||
std::vector<SceneGraphNode*> _nodes;
|
||||
std::map<std::string, SceneGraphNode*> _allNodes;
|
||||
SceneGraph _graph;
|
||||
//SceneGraphNode* _root;
|
||||
//std::vector<SceneGraphNode*> _nodes;
|
||||
//std::map<std::string, SceneGraphNode*> _allNodes;
|
||||
|
||||
std::string _sceneGraphToLoad;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class SceneGraphNode;
|
||||
|
||||
class SceneGraph {
|
||||
public:
|
||||
SceneGraph() = default;
|
||||
SceneGraph();
|
||||
|
||||
void clear();
|
||||
bool loadFromFile(const std::string& sceneDescription);
|
||||
@@ -46,18 +46,34 @@ public:
|
||||
bool removeSceneGraphNode(SceneGraphNode* node);
|
||||
|
||||
// topological sort
|
||||
std::vector<SceneGraphNode*> linearList();
|
||||
const std::vector<SceneGraphNode*>& linearList();
|
||||
|
||||
SceneGraphNode* rootNode() const;
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name) const;
|
||||
|
||||
private:
|
||||
bool nodeIsDependentOnRoot(const std::string& nodeName);
|
||||
struct SceneGraphNodeInternal {
|
||||
SceneGraphNode* node;
|
||||
// From nodes that are dependent on this one
|
||||
std::vector<SceneGraphNodeInternal*> incomingEdges;
|
||||
// To nodes that this node depends on
|
||||
std::vector<SceneGraphNodeInternal*> outgoingEdges;
|
||||
};
|
||||
|
||||
bool nodeIsDependentOnRoot(SceneGraphNodeInternal* node);
|
||||
bool topologicalSort();
|
||||
|
||||
std::vector<SceneGraphNode*> _nodes;
|
||||
SceneGraphNodeInternal* nodeByName(const std::string& name);
|
||||
|
||||
SceneGraphNode* _rootNode;
|
||||
std::vector<SceneGraphNodeInternal*> _nodes;
|
||||
std::vector<SceneGraphNode*> _topologicalSortedNodes;
|
||||
|
||||
// child -> parent
|
||||
std::unordered_multimap<std::string, std::string> _forwardEdges;
|
||||
//std::unordered_multimap<std::string, std::string> _forwardEdges;
|
||||
// Edges are in reverse order of dependency
|
||||
// parent -> child
|
||||
std::unordered_multimap<std::string, std::string> _backwardEdges;
|
||||
//std::unordered_multimap<std::string, std::string> _backwardEdges;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __SCENEGRAPHLOADER_H__
|
||||
#define __SCENEGRAPHLOADER_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SceneGraphNode;
|
||||
|
||||
class SceneGraphLoader {
|
||||
public:
|
||||
static bool load(const std::string& sceneDescription, std::vector<SceneGraphNode*>& nodes);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
|
||||
//// std includes
|
||||
//#include <vector>
|
||||
//#include <map>
|
||||
//#include <set>
|
||||
//#include <mutex>
|
||||
//
|
||||
//#include <openspace/util/camera.h>
|
||||
//#include <openspace/util/updatestructures.h>
|
||||
//#include <openspace/scripting/scriptengine.h>
|
||||
//
|
||||
//#include <ghoul/opengl/programobject.h>
|
||||
//#include <ghoul/misc/dictionary.h>
|
||||
//
|
||||
//namespace openspace {
|
||||
//
|
||||
//
|
||||
//class SceneGraphNode;
|
||||
//
|
||||
//// Notifications:
|
||||
//// SceneGraphFinishedLoading
|
||||
//class SceneGraph {
|
||||
//public:
|
||||
// // constructors & destructor
|
||||
// SceneGraph();
|
||||
// ~SceneGraph();
|
||||
//
|
||||
// /**
|
||||
// * Initalizes the SceneGraph by loading modules from the ${SCENEPATH} directory
|
||||
// */
|
||||
// bool initialize();
|
||||
//
|
||||
// /*
|
||||
// * Clean up everything
|
||||
// */
|
||||
// bool deinitialize();
|
||||
//
|
||||
// /*
|
||||
// * Load the scenegraph from the provided folder
|
||||
// */
|
||||
// void scheduleLoadSceneFile(const std::string& sceneDescriptionFilePath);
|
||||
// void clearSceneGraph();
|
||||
//
|
||||
// void loadModule(const std::string& modulePath);
|
||||
//
|
||||
// /*
|
||||
// * Updates all SceneGraphNodes relative positions
|
||||
// */
|
||||
// void update(const UpdateData& data);
|
||||
//
|
||||
// /*
|
||||
// * Evaluates if the SceneGraphNodes are visible to the provided camera
|
||||
// */
|
||||
// void evaluate(Camera* camera);
|
||||
//
|
||||
// /*
|
||||
// * Render visible SceneGraphNodes using the provided camera
|
||||
// */
|
||||
// void render(const RenderData& data);
|
||||
//
|
||||
// /*
|
||||
// * Returns the root SceneGraphNode
|
||||
// */
|
||||
// SceneGraphNode* root() const;
|
||||
//
|
||||
// /**
|
||||
// * Return the scenegraph node with the specified name or <code>nullptr</code> if that
|
||||
// * name does not exist
|
||||
// */
|
||||
// SceneGraphNode* sceneGraphNode(const std::string& name) const;
|
||||
//
|
||||
// std::vector<SceneGraphNode*> allSceneGraphNodes() const;
|
||||
//
|
||||
// /**
|
||||
// * Returns the Lua library that contains all Lua functions available to change the
|
||||
// * scene graph. The functions contained are
|
||||
// * - openspace::luascriptfunctions::property_setValue
|
||||
// * - openspace::luascriptfunctions::property_getValue
|
||||
// * \return The Lua library that contains all Lua functions available to change the
|
||||
// * scene graph
|
||||
// */
|
||||
// static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
//
|
||||
//private:
|
||||
// bool loadSceneInternal(const std::string& sceneDescriptionFilePath);
|
||||
//
|
||||
// void writePropertyDocumentation(const std::string& filename, const std::string& type);
|
||||
//
|
||||
// std::string _focus;
|
||||
//
|
||||
// // actual scenegraph
|
||||
// SceneGraphNode* _root;
|
||||
// std::vector<SceneGraphNode*> _nodes;
|
||||
// std::map<std::string, SceneGraphNode*> _allNodes;
|
||||
//
|
||||
// std::string _sceneGraphToLoad;
|
||||
//
|
||||
// std::mutex _programUpdateLock;
|
||||
// std::set<ghoul::opengl::ProgramObject*> _programsToUpdate;
|
||||
// std::vector<ghoul::opengl::ProgramObject*> _programs;
|
||||
//
|
||||
// typedef std::map<std::string, ghoul::Dictionary> NodeMap;
|
||||
// typedef std::multimap<std::string, std::string> DependencyMap;
|
||||
// typedef std::vector<std::string> LoadedList;
|
||||
//
|
||||
// struct LoadMaps {
|
||||
// NodeMap nodes;
|
||||
// DependencyMap dependencies;
|
||||
// LoadedList loadedNodes;
|
||||
// };
|
||||
//
|
||||
// void loadModules(const std::string& directory, const ghoul::Dictionary& dictionary);
|
||||
// void loadModule(LoadMaps& m,const std::string& modulePath, lua_State* state);
|
||||
// void loadNodes(const std::string& parentName, LoadMaps& m);
|
||||
// void loadNode(const ghoul::Dictionary& dictionary);
|
||||
//};
|
||||
//
|
||||
//} // namespace openspace
|
||||
|
||||
#endif // __SCENEGRAPHLOADER_H__
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <openspace/scripting/script_helper.h>
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/scene/scenegraphloader.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include "ghoul/io/texture/texturereader.h"
|
||||
@@ -148,7 +147,6 @@ int loadScene(lua_State* L) {
|
||||
|
||||
Scene::Scene()
|
||||
: _focus(SceneGraphNode::RootNodeName)
|
||||
, _root(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -259,13 +257,14 @@ void Scene::update(const UpdateData& data) {
|
||||
OsEng.renderEngine()->abuffer()->invalidateABuffer();
|
||||
#endif
|
||||
}
|
||||
for (SceneGraphNode* node : _nodes)
|
||||
for (SceneGraphNode* node : _graph.linearList())
|
||||
node->update(data);
|
||||
}
|
||||
|
||||
void Scene::evaluate(Camera* camera) {
|
||||
if (_root)
|
||||
_root->evaluate(camera);
|
||||
for (SceneGraphNode* node : _graph.linearList())
|
||||
node->evaluate(camera);
|
||||
//_root->evaluate(camera);
|
||||
}
|
||||
|
||||
void Scene::render(const RenderData& data) {
|
||||
@@ -286,8 +285,10 @@ void Scene::render(const RenderData& data) {
|
||||
program->setIgnoreSubroutineUniformLocationError(true);
|
||||
}
|
||||
|
||||
if (_root)
|
||||
_root->render(data);
|
||||
for (SceneGraphNode* node : _graph.linearList())
|
||||
node->render(data);
|
||||
//if (_root)
|
||||
// _root->render(data);
|
||||
}
|
||||
|
||||
void Scene::scheduleLoadSceneFile(const std::string& sceneDescriptionFilePath) {
|
||||
@@ -296,83 +297,94 @@ void Scene::scheduleLoadSceneFile(const std::string& sceneDescriptionFilePath) {
|
||||
|
||||
void Scene::clearSceneGraph() {
|
||||
// deallocate the scene graph. Recursive deallocation will occur
|
||||
if (_root) {
|
||||
_root->deinitialize();
|
||||
delete _root;
|
||||
_root = nullptr;
|
||||
}
|
||||
_graph.clear();
|
||||
//if (_root) {
|
||||
// _root->deinitialize();
|
||||
// delete _root;
|
||||
// _root = nullptr;
|
||||
//}
|
||||
|
||||
_nodes.erase(_nodes.begin(), _nodes.end());
|
||||
_allNodes.erase(_allNodes.begin(), _allNodes.end());
|
||||
// _nodes.erase(_nodes.begin(), _nodes.end());
|
||||
// _allNodes.erase(_allNodes.begin(), _allNodes.end());
|
||||
|
||||
_focus.clear();
|
||||
}
|
||||
|
||||
bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
|
||||
using ghoul::Dictionary;
|
||||
using ghoul::lua::loadDictionaryFromFile;
|
||||
// using ghoul::Dictionary;
|
||||
// using ghoul::lua::loadDictionaryFromFile;
|
||||
|
||||
if (!FileSys.fileExists(sceneDescriptionFilePath)) {
|
||||
LFATAL("Scene description file '" << sceneDescriptionFilePath << "' not found");
|
||||
return false;
|
||||
}
|
||||
//if (!FileSys.fileExists(sceneDescriptionFilePath)) {
|
||||
// LFATAL("Scene description file '" << sceneDescriptionFilePath << "' not found");
|
||||
// return false;
|
||||
//}
|
||||
|
||||
LDEBUG("Loading scenegraph nodes");
|
||||
if (_root != nullptr) {
|
||||
LFATAL("Scenegraph already loaded");
|
||||
return false;
|
||||
}
|
||||
// LDEBUG("Loading scenegraph nodes");
|
||||
// if (_root != nullptr) {
|
||||
// LFATAL("Scenegraph already loaded");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
OsEng.disableBarrier();
|
||||
// OsEng.disableBarrier();
|
||||
|
||||
_root = new SceneGraphNode();
|
||||
_root->setName(SceneGraphNode::RootNodeName);
|
||||
_nodes.push_back(_root);
|
||||
_allNodes.emplace(SceneGraphNode::RootNodeName, _root);
|
||||
_focus = SceneGraphNode::RootNodeName;
|
||||
// _root = new SceneGraphNode();
|
||||
// _root->setName(SceneGraphNode::RootNodeName);
|
||||
// _nodes.push_back(_root);
|
||||
// _allNodes.emplace(SceneGraphNode::RootNodeName, _root);
|
||||
// _focus = SceneGraphNode::RootNodeName;
|
||||
|
||||
bool success = SceneGraphLoader::load(sceneDescriptionFilePath, _nodes);
|
||||
// bool success = SceneGraphLoader::load(sceneDescriptionFilePath, _nodes);
|
||||
|
||||
|
||||
Dictionary dictionary;
|
||||
//load default.scene
|
||||
loadDictionaryFromFile(sceneDescriptionFilePath, dictionary);
|
||||
ghoul::Dictionary dictionary;
|
||||
////load default.scene
|
||||
ghoul::lua::loadDictionaryFromFile(sceneDescriptionFilePath, dictionary);
|
||||
|
||||
std::string&& sceneDescriptionDirectory =
|
||||
ghoul::filesystem::File(sceneDescriptionFilePath).directoryName();
|
||||
std::string moduleDirectory(".");
|
||||
dictionary.getValue(constants::scenegraph::keyPathScene, moduleDirectory);
|
||||
//std::string&& sceneDescriptionDirectory =
|
||||
// ghoul::filesystem::File(sceneDescriptionFilePath).directoryName();
|
||||
//std::string moduleDirectory(".");
|
||||
//dictionary.getValue(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);
|
||||
//// 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");
|
||||
OsEng.enableBarrier();
|
||||
return false;
|
||||
}
|
||||
//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");
|
||||
// OsEng.enableBarrier();
|
||||
// return false;
|
||||
//}
|
||||
|
||||
// Load the modules/scenegraph nodes
|
||||
loadModules(moduleDirectory, dictionary);
|
||||
//// Load the modules/scenegraph nodes
|
||||
//loadModules(moduleDirectory, dictionary);
|
||||
|
||||
_graph.loadFromFile(sceneDescriptionFilePath);
|
||||
|
||||
// TODO: Make it less hard-coded and more flexible when nodes are not found
|
||||
Dictionary cameraDictionary;
|
||||
ghoul::Dictionary cameraDictionary;
|
||||
if (dictionary.getValue(constants::scenegraph::keyCamera, cameraDictionary)) {
|
||||
LDEBUG("Camera dictionary found");
|
||||
std::string focus;
|
||||
|
||||
if (cameraDictionary.hasKey(constants::scenegraph::keyFocusObject)
|
||||
&& cameraDictionary.getValue(constants::scenegraph::keyFocusObject, focus)) {
|
||||
auto focusIterator = _allNodes.find(focus);
|
||||
if (focusIterator != _allNodes.end()) {
|
||||
&& cameraDictionary.getValue(constants::scenegraph::keyFocusObject, focus))
|
||||
{
|
||||
auto focusIterator = std::find_if(
|
||||
_graph.linearList().begin(),
|
||||
_graph.linearList().end(),
|
||||
[focus](SceneGraphNode* node) {
|
||||
return node->name() == focus;
|
||||
}
|
||||
);
|
||||
|
||||
if (focusIterator != _graph.linearList().end()) {
|
||||
_focus = focus;
|
||||
LDEBUG("Setting camera focus to '" << _focus << "'");
|
||||
}
|
||||
@@ -382,7 +394,7 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
|
||||
}
|
||||
|
||||
// Initialize all nodes
|
||||
for (SceneGraphNode* node : _nodes) {
|
||||
for (SceneGraphNode* node : _graph.linearList()) {
|
||||
bool success = node->initialize();
|
||||
if (success)
|
||||
LDEBUG(node->name() << " initialized successfully!");
|
||||
@@ -392,23 +404,36 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
|
||||
|
||||
// update the position of all nodes
|
||||
// TODO need to check this; unnecessary? (ab)
|
||||
for (SceneGraphNode* node : _nodes)
|
||||
for (SceneGraphNode* node : _graph.linearList()) {
|
||||
node->update({ Time::ref().currentTime() });
|
||||
}
|
||||
|
||||
for (auto it = _graph.linearList().rbegin(); it != _graph.linearList().rend(); ++it)
|
||||
(*it)->calculateBoundingSphere();
|
||||
|
||||
|
||||
// Calculate the bounding sphere for the scenegraph
|
||||
_root->calculateBoundingSphere();
|
||||
//_root->calculateBoundingSphere();
|
||||
|
||||
// set the camera position
|
||||
Camera* c = OsEng.ref().renderEngine()->camera();
|
||||
auto focusIterator = _allNodes.find(_focus);
|
||||
//auto focusIterator = _allNodes.find(_focus);
|
||||
auto focusIterator = std::find_if(
|
||||
_graph.linearList().begin(),
|
||||
_graph.linearList().end(),
|
||||
[&](SceneGraphNode* node) {
|
||||
return node->name() == _focus;
|
||||
}
|
||||
);
|
||||
|
||||
glm::vec2 cameraScaling(1);
|
||||
psc cameraPosition(0,0,1,0);
|
||||
glm::vec3 cameraDirection = glm::vec3(0, 0, -1);
|
||||
|
||||
if (focusIterator != _allNodes.end()) {
|
||||
//if (_focus->)
|
||||
if (focusIterator != _graph.linearList().end()) {
|
||||
LDEBUG("Camera focus is '" << _focus << "'");
|
||||
SceneGraphNode* focusNode = focusIterator->second;
|
||||
SceneGraphNode* focusNode = *focusIterator;
|
||||
//Camera* c = OsEng.interactionHandler().getCamera();
|
||||
|
||||
// TODO: Make distance depend on radius
|
||||
@@ -475,7 +500,7 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
|
||||
}
|
||||
|
||||
|
||||
for (SceneGraphNode* node : _nodes) {
|
||||
for (SceneGraphNode* node : _graph.linearList()) {
|
||||
std::vector<properties::Property*> properties = node->propertiesRecursive();
|
||||
for (properties::Property* p : properties) {
|
||||
OsEng.gui()->_property.registerProperty(p);
|
||||
@@ -505,111 +530,111 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Scene::loadModules(
|
||||
const std::string& directory,
|
||||
const ghoul::Dictionary& dictionary)
|
||||
{
|
||||
// Struct containing dependencies and nodes
|
||||
LoadMaps m;
|
||||
//void Scene::loadModules(
|
||||
// const std::string& directory,
|
||||
// const ghoul::Dictionary& dictionary)
|
||||
//{
|
||||
// // Struct containing dependencies and nodes
|
||||
// LoadMaps m;
|
||||
//
|
||||
// // Get the common directory
|
||||
// std::string commonDirectory(_defaultCommonDirectory);
|
||||
// dictionary.getValue(constants::scenegraph::keyCommonFolder, commonDirectory);
|
||||
// FileSys.registerPathToken(_commonModuleToken, commonDirectory);
|
||||
//
|
||||
// lua_State* state = ghoul::lua::createNewLuaState();
|
||||
// OsEng.scriptEngine()->initializeLuaState(state);
|
||||
//
|
||||
// LDEBUG("Loading common module folder '" << commonDirectory << "'");
|
||||
// // Load common modules into LoadMaps struct
|
||||
// loadModule(m, FileSys.pathByAppendingComponent(directory, commonDirectory), state);
|
||||
//
|
||||
// // Load the rest of the modules into LoadMaps struct
|
||||
// ghoul::Dictionary moduleDictionary;
|
||||
// if (dictionary.getValue(constants::scenegraph::keyModules, moduleDictionary)) {
|
||||
// std::vector<std::string> keys = moduleDictionary.keys();
|
||||
// std::sort(keys.begin(), keys.end());
|
||||
// for (const std::string& key : keys) {
|
||||
// std::string moduleFolder;
|
||||
// if (moduleDictionary.getValue(key, moduleFolder)) {
|
||||
// loadModule(m, FileSys.pathByAppendingComponent(directory, moduleFolder), state);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Load and construct scenegraphnodes from LoadMaps struct
|
||||
// loadNodes(SceneGraphNode::RootNodeName, m);
|
||||
//
|
||||
// // Remove loaded nodes from dependency list
|
||||
// for(const auto& name: m.loadedNodes) {
|
||||
// m.dependencies.erase(name);
|
||||
// }
|
||||
//
|
||||
// // Check to see what dependencies are not resolved.
|
||||
// for(auto& node: m.dependencies) {
|
||||
// LWARNING(
|
||||
// "'" << node.second << "'' not loaded, parent '"
|
||||
// << node.first << "' not defined!");
|
||||
// }
|
||||
//}
|
||||
|
||||
// Get the common directory
|
||||
std::string commonDirectory(_defaultCommonDirectory);
|
||||
dictionary.getValue(constants::scenegraph::keyCommonFolder, commonDirectory);
|
||||
FileSys.registerPathToken(_commonModuleToken, commonDirectory);
|
||||
//void Scene::loadModule(LoadMaps& m,const std::string& modulePath, lua_State* state) {
|
||||
// auto pos = modulePath.find_last_of(ghoul::filesystem::FileSystem::PathSeparator);
|
||||
// if (pos == modulePath.npos) {
|
||||
// LERROR("Bad format for module path: " << modulePath);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// std::string fullModule = modulePath + modulePath.substr(pos) + _moduleExtension;
|
||||
// LDEBUG("Loading nodes from: " << fullModule);
|
||||
//
|
||||
// ghoul::filesystem::Directory oldDirectory = FileSys.currentDirectory();
|
||||
// FileSys.setCurrentDirectory(modulePath);
|
||||
//
|
||||
// ghoul::Dictionary moduleDictionary;
|
||||
// ghoul::lua::loadDictionaryFromFile(fullModule, moduleDictionary, state);
|
||||
// std::vector<std::string> keys = moduleDictionary.keys();
|
||||
// for (const std::string& key : keys) {
|
||||
// if (!moduleDictionary.hasValue<ghoul::Dictionary>(key)) {
|
||||
// LERROR("SceneGraphElement '" << key << "' is not a table in module '"
|
||||
// << fullModule << "'");
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// ghoul::Dictionary element;
|
||||
// std::string nodeName;
|
||||
// std::string parentName;
|
||||
//
|
||||
// moduleDictionary.getValue(key, element);
|
||||
// element.setValue(constants::scenegraph::keyPathModule, modulePath);
|
||||
//
|
||||
// element.getValue(constants::scenegraphnode::keyName, nodeName);
|
||||
// element.getValue(constants::scenegraphnode::keyParentName, parentName);
|
||||
//
|
||||
// m.nodes[nodeName] = element;
|
||||
// m.dependencies.emplace(parentName,nodeName);
|
||||
// }
|
||||
//
|
||||
// FileSys.setCurrentDirectory(oldDirectory);
|
||||
//}
|
||||
|
||||
lua_State* state = ghoul::lua::createNewLuaState();
|
||||
OsEng.scriptEngine()->initializeLuaState(state);
|
||||
|
||||
LDEBUG("Loading common module folder '" << commonDirectory << "'");
|
||||
// Load common modules into LoadMaps struct
|
||||
loadModule(m, FileSys.pathByAppendingComponent(directory, commonDirectory), state);
|
||||
|
||||
// Load the rest of the modules into LoadMaps struct
|
||||
ghoul::Dictionary moduleDictionary;
|
||||
if (dictionary.getValue(constants::scenegraph::keyModules, moduleDictionary)) {
|
||||
std::vector<std::string> keys = moduleDictionary.keys();
|
||||
std::sort(keys.begin(), keys.end());
|
||||
for (const std::string& key : keys) {
|
||||
std::string moduleFolder;
|
||||
if (moduleDictionary.getValue(key, moduleFolder)) {
|
||||
loadModule(m, FileSys.pathByAppendingComponent(directory, moduleFolder), state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load and construct scenegraphnodes from LoadMaps struct
|
||||
loadNodes(SceneGraphNode::RootNodeName, m);
|
||||
|
||||
// Remove loaded nodes from dependency list
|
||||
for(const auto& name: m.loadedNodes) {
|
||||
m.dependencies.erase(name);
|
||||
}
|
||||
|
||||
// Check to see what dependencies are not resolved.
|
||||
for(auto& node: m.dependencies) {
|
||||
LWARNING(
|
||||
"'" << node.second << "'' not loaded, parent '"
|
||||
<< node.first << "' not defined!");
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::loadModule(LoadMaps& m,const std::string& modulePath, lua_State* state) {
|
||||
auto pos = modulePath.find_last_of(ghoul::filesystem::FileSystem::PathSeparator);
|
||||
if (pos == modulePath.npos) {
|
||||
LERROR("Bad format for module path: " << modulePath);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string fullModule = modulePath + modulePath.substr(pos) + _moduleExtension;
|
||||
LDEBUG("Loading nodes from: " << fullModule);
|
||||
|
||||
ghoul::filesystem::Directory oldDirectory = FileSys.currentDirectory();
|
||||
FileSys.setCurrentDirectory(modulePath);
|
||||
|
||||
ghoul::Dictionary moduleDictionary;
|
||||
ghoul::lua::loadDictionaryFromFile(fullModule, moduleDictionary, state);
|
||||
std::vector<std::string> keys = moduleDictionary.keys();
|
||||
for (const std::string& key : keys) {
|
||||
if (!moduleDictionary.hasValue<ghoul::Dictionary>(key)) {
|
||||
LERROR("SceneGraphElement '" << key << "' is not a table in module '"
|
||||
<< fullModule << "'");
|
||||
continue;
|
||||
}
|
||||
|
||||
ghoul::Dictionary element;
|
||||
std::string nodeName;
|
||||
std::string parentName;
|
||||
|
||||
moduleDictionary.getValue(key, element);
|
||||
element.setValue(constants::scenegraph::keyPathModule, modulePath);
|
||||
|
||||
element.getValue(constants::scenegraphnode::keyName, nodeName);
|
||||
element.getValue(constants::scenegraphnode::keyParentName, parentName);
|
||||
|
||||
m.nodes[nodeName] = element;
|
||||
m.dependencies.emplace(parentName,nodeName);
|
||||
}
|
||||
|
||||
FileSys.setCurrentDirectory(oldDirectory);
|
||||
}
|
||||
|
||||
void Scene::loadNodes(const std::string& parentName, LoadMaps& m) {
|
||||
auto eqRange = m.dependencies.equal_range(parentName);
|
||||
for (auto it = eqRange.first; it != eqRange.second; ++it) {
|
||||
auto node = m.nodes.find((*it).second);
|
||||
loadNode(node->second);
|
||||
loadNodes((*it).second, m);
|
||||
}
|
||||
m.loadedNodes.emplace_back(parentName);
|
||||
}
|
||||
|
||||
void Scene::loadNode(const ghoul::Dictionary& dictionary) {
|
||||
SceneGraphNode* node = SceneGraphNode::createFromDictionary(dictionary);
|
||||
if(node) {
|
||||
_allNodes.emplace(node->name(), node);
|
||||
_nodes.push_back(node);
|
||||
}
|
||||
}
|
||||
//void Scene::loadNodes(const std::string& parentName, LoadMaps& m) {
|
||||
// auto eqRange = m.dependencies.equal_range(parentName);
|
||||
// for (auto it = eqRange.first; it != eqRange.second; ++it) {
|
||||
// auto node = m.nodes.find((*it).second);
|
||||
// loadNode(node->second);
|
||||
// loadNodes((*it).second, m);
|
||||
// }
|
||||
// m.loadedNodes.emplace_back(parentName);
|
||||
//}
|
||||
//
|
||||
//void Scene::loadNode(const ghoul::Dictionary& dictionary) {
|
||||
// SceneGraphNode* node = SceneGraphNode::createFromDictionary(dictionary);
|
||||
// if(node) {
|
||||
// _allNodes.emplace(node->name(), node);
|
||||
// _nodes.push_back(node);
|
||||
// }
|
||||
//}
|
||||
|
||||
//void SceneGraph::loadModule(const std::string& modulePath) {
|
||||
// auto pos = modulePath.find_last_of(ghoul::filesystem::FileSystem::PathSeparator);
|
||||
@@ -653,19 +678,15 @@ void Scene::loadNode(const ghoul::Dictionary& dictionary) {
|
||||
//}
|
||||
|
||||
SceneGraphNode* Scene::root() const {
|
||||
return _root;
|
||||
return _graph.rootNode();
|
||||
}
|
||||
|
||||
SceneGraphNode* Scene::sceneGraphNode(const std::string& name) const {
|
||||
auto it = _allNodes.find(name);
|
||||
if (it == _allNodes.end())
|
||||
return nullptr;
|
||||
else
|
||||
return it->second;
|
||||
return _graph.sceneGraphNode(name);
|
||||
}
|
||||
|
||||
std::vector<SceneGraphNode*> Scene::allSceneGraphNodes() const {
|
||||
return _nodes;
|
||||
std::vector<SceneGraphNode*> Scene::allSceneGraphNodes() {
|
||||
return _graph.linearList();
|
||||
}
|
||||
|
||||
void Scene::writePropertyDocumentation(const std::string& filename, const std::string& type) {
|
||||
@@ -678,7 +699,7 @@ void Scene::writePropertyDocumentation(const std::string& filename, const std::s
|
||||
}
|
||||
|
||||
using properties::Property;
|
||||
for (SceneGraphNode* node : _nodes) {
|
||||
for (SceneGraphNode* node : _graph.linearList()) {
|
||||
std::vector<Property*> properties = node->propertiesRecursive();
|
||||
if (!properties.empty()) {
|
||||
file << node->name() << std::endl;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
|
||||
#include <stack>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SceneGraph";
|
||||
@@ -42,10 +43,17 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SceneGraph::SceneGraph() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SceneGraph::clear() {
|
||||
// Untested ---abock
|
||||
for (SceneGraphNode* n : _nodes)
|
||||
for (SceneGraphNodeInternal* n : _nodes) {
|
||||
delete n->node;
|
||||
delete n;
|
||||
}
|
||||
|
||||
_nodes.clear();
|
||||
}
|
||||
@@ -123,6 +131,9 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) {
|
||||
LERROR("Specification for 'common' folder has invalid type");
|
||||
}
|
||||
|
||||
std::map<std::string, std::vector<std::string>> dependencies;
|
||||
std::map<std::string, std::string> parents;
|
||||
|
||||
std::sort(keys.begin(), keys.end());
|
||||
ghoul::filesystem::Directory oldDirectory = FileSys.currentDirectory();
|
||||
for (const std::string& key : keys) {
|
||||
@@ -149,9 +160,11 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) {
|
||||
if (!s)
|
||||
continue;
|
||||
|
||||
SceneGraphNode* root = new SceneGraphNode;
|
||||
root->setName(SceneGraphNode::RootNodeName);
|
||||
_nodes.push_back(root);
|
||||
_rootNode = new SceneGraphNode;
|
||||
_rootNode->setName(SceneGraphNode::RootNodeName);
|
||||
SceneGraphNodeInternal* internalRoot = new SceneGraphNodeInternal;
|
||||
internalRoot->node = _rootNode;
|
||||
_nodes.push_back(internalRoot);
|
||||
|
||||
std::vector<std::string> keys = moduleDictionary.keys();
|
||||
for (const std::string& key : keys) {
|
||||
@@ -178,33 +191,60 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) {
|
||||
clear();
|
||||
return false;
|
||||
}
|
||||
_nodes.push_back(node);
|
||||
|
||||
_forwardEdges.emplace(nodeName, parentName);
|
||||
_backwardEdges.emplace(parentName, nodeName);
|
||||
dependencies[nodeName].push_back(parentName);
|
||||
parents[nodeName] = parentName;
|
||||
// Also include loaded dependencies
|
||||
|
||||
SceneGraphNodeInternal* internalNode = new SceneGraphNodeInternal;
|
||||
internalNode->node = node;
|
||||
_nodes.push_back(internalNode);
|
||||
}
|
||||
}
|
||||
FileSys.setCurrentDirectory(oldDirectory);
|
||||
|
||||
for (SceneGraphNode* node : _nodes) {
|
||||
if (!nodeIsDependentOnRoot(node->name())) {
|
||||
LERROR("Node '" << node->name() << "' has no direct connection to Root.");
|
||||
for (SceneGraphNodeInternal* node : _nodes) {
|
||||
if (node->node == rootNode())
|
||||
continue;
|
||||
std::string parent = parents[node->node->name()];
|
||||
SceneGraphNode* parentNode = sceneGraphNode(parent);
|
||||
if (parentNode)
|
||||
|
||||
node->node->setParent(parentNode);
|
||||
}
|
||||
|
||||
// Setup dependencies
|
||||
for (SceneGraphNodeInternal* node : _nodes) {
|
||||
std::vector<std::string> nodeDependencies = dependencies[node->node->name()];
|
||||
|
||||
for (const std::string& dep : nodeDependencies) {
|
||||
SceneGraphNodeInternal* n = nodeByName(dep);
|
||||
if (n == nullptr) {
|
||||
LERROR("Dependent node '" << dep << "' was not loaded for '" <<node->node->name() << "'");
|
||||
continue;
|
||||
}
|
||||
node->outgoingEdges.push_back(n);
|
||||
n->incomingEdges.push_back(n);
|
||||
}
|
||||
}
|
||||
|
||||
for (SceneGraphNodeInternal* node : _nodes) {
|
||||
if (!nodeIsDependentOnRoot(node)) {
|
||||
LERROR("Node '" << node->node->name() << "' has no direct connection to Root.");
|
||||
//clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SceneGraph::nodeIsDependentOnRoot(const std::string& nodeName) {
|
||||
if (nodeName == SceneGraphNode::RootNodeName)
|
||||
bool SceneGraph::nodeIsDependentOnRoot(SceneGraphNodeInternal* node) {
|
||||
if (node->node->name() == SceneGraphNode::RootNodeName)
|
||||
return true;
|
||||
else {
|
||||
auto range = _forwardEdges.equal_range(nodeName);
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
bool dep = nodeIsDependentOnRoot(it->second);
|
||||
for (SceneGraphNodeInternal* n : node->outgoingEdges) {
|
||||
bool dep = nodeIsDependentOnRoot(n);
|
||||
if (dep)
|
||||
return true;
|
||||
}
|
||||
@@ -216,19 +256,33 @@ bool SceneGraph::topologicalSort() {
|
||||
if (_nodes.empty())
|
||||
return true;
|
||||
|
||||
std::string name;
|
||||
auto findByName = [&name](const SceneGraphNode * const node) {
|
||||
return node->name() == name;
|
||||
};
|
||||
name = SceneGraphNode::RootNodeName;
|
||||
|
||||
auto it = std::find_if(_nodes.begin(), _nodes.end(), findByName);
|
||||
ghoul_assert(it != _node.end(), "Could not find Root node");
|
||||
|
||||
SceneGraphNode* root = *it;
|
||||
// Only the Root node can have an in-degree of 0
|
||||
SceneGraphNodeInternal* root = nodeByName(SceneGraphNode::RootNodeName);
|
||||
ghoul_assert(root != nullptr, "Could not find Root node");
|
||||
|
||||
std::stack<SceneGraphNodeInternal*> zeroInDegreeNodes;
|
||||
zeroInDegreeNodes.push(root);
|
||||
|
||||
std::unordered_map<SceneGraphNodeInternal*, size_t> inDegrees;
|
||||
for (SceneGraphNodeInternal* node : _nodes)
|
||||
inDegrees[node] = node->incomingEdges.size();
|
||||
|
||||
_topologicalSortedNodes.clear();
|
||||
_topologicalSortedNodes.reserve(_nodes.size());
|
||||
while (!zeroInDegreeNodes.empty()) {
|
||||
SceneGraphNodeInternal* node = zeroInDegreeNodes.top();
|
||||
|
||||
_topologicalSortedNodes.push_back(node->node);
|
||||
|
||||
for (SceneGraphNodeInternal* n : node->outgoingEdges) {
|
||||
inDegrees[n] -= 1;
|
||||
if (inDegrees[n] == 0)
|
||||
zeroInDegreeNodes.push(n);
|
||||
}
|
||||
|
||||
zeroInDegreeNodes.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SceneGraph::addSceneGraphNode(SceneGraphNode* node) {
|
||||
@@ -240,8 +294,41 @@ bool SceneGraph::removeSceneGraphNode(SceneGraphNode* node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<SceneGraphNode*> SceneGraph::linearList() {
|
||||
return _nodes;
|
||||
SceneGraph::SceneGraphNodeInternal* SceneGraph::nodeByName(const std::string& name) {
|
||||
auto it = std::find_if(
|
||||
_nodes.begin(),
|
||||
_nodes.end(),
|
||||
[name](SceneGraphNodeInternal* node) {
|
||||
return node->node->name() == name;
|
||||
}
|
||||
);
|
||||
|
||||
if (it == _nodes.end())
|
||||
return nullptr;
|
||||
else
|
||||
return *it;
|
||||
}
|
||||
|
||||
const std::vector<SceneGraphNode*>& SceneGraph::linearList() {
|
||||
return _topologicalSortedNodes;
|
||||
}
|
||||
|
||||
SceneGraphNode* SceneGraph::rootNode() const {
|
||||
return _rootNode;
|
||||
}
|
||||
|
||||
SceneGraphNode* SceneGraph::sceneGraphNode(const std::string& name) const {
|
||||
auto it = std::find_if(
|
||||
_nodes.begin(),
|
||||
_nodes.end(),
|
||||
[name](SceneGraphNodeInternal* node) {
|
||||
return node->node->name() == name;
|
||||
}
|
||||
);
|
||||
if (it != _nodes.end())
|
||||
return (*it)->node;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -1,924 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/scene/scenegraphloader.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/constants.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SceneGraphLoader";
|
||||
const std::string _moduleExtension = ".mod";
|
||||
const std::string _commonModuleToken = "${COMMON_MODULE}";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
bool SceneGraphLoader::load(const std::string& sceneDescription, std::vector<SceneGraphNode*>& nodes)
|
||||
{
|
||||
nodes.clear();
|
||||
std::string absSceneFile = absPath(sceneDescription);
|
||||
|
||||
// See if scene file exists
|
||||
if (!FileSys.fileExists(absSceneFile, true)) {
|
||||
LERROR("Could not load scene file '" << absSceneFile << "'. " <<
|
||||
"File not found");
|
||||
return false;
|
||||
}
|
||||
LINFO("Loading SceneGraph from file '" << absSceneFile << "'");
|
||||
|
||||
// Load dictionary
|
||||
ghoul::Dictionary sceneDictionary;
|
||||
bool success = ghoul::lua::loadDictionaryFromFile(absSceneFile, sceneDictionary);
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
std::string sceneDescriptionDirectory =
|
||||
ghoul::filesystem::File(absSceneFile, true).directoryName();
|
||||
std::string sceneDirectory(".");
|
||||
sceneDictionary.getValue(constants::scenegraph::keyPathScene, sceneDirectory);
|
||||
|
||||
// The scene path could either be an absolute or relative path to the description
|
||||
// paths directory
|
||||
std::string relativeCandidate = sceneDescriptionDirectory +
|
||||
ghoul::filesystem::FileSystem::PathSeparator + sceneDirectory;
|
||||
std::string absoluteCandidate = absPath(sceneDirectory);
|
||||
|
||||
if (FileSys.directoryExists(relativeCandidate))
|
||||
sceneDirectory = relativeCandidate;
|
||||
else if (FileSys.directoryExists(absoluteCandidate))
|
||||
sceneDirectory = absoluteCandidate;
|
||||
else {
|
||||
LERROR("The '" << constants::scenegraph::keyPathScene << "' pointed to a "
|
||||
"path '" << sceneDirectory << "' that did not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
struct SceneGraphNodeInformation {
|
||||
std::string parent;
|
||||
std::string module;
|
||||
std::string modulePath;
|
||||
ghoul::Dictionary dictionary;
|
||||
};
|
||||
std::map<std::string, SceneGraphNodeInformation> nodeInformation;
|
||||
|
||||
using constants::scenegraph::keyModules;
|
||||
ghoul::Dictionary moduleDictionary;
|
||||
success = sceneDictionary.getValue(keyModules, moduleDictionary);
|
||||
if (!success)
|
||||
// There are no modules that are loaded
|
||||
return true;
|
||||
|
||||
lua_State* state = ghoul::lua::createNewLuaState();
|
||||
OsEng.scriptEngine()->initializeLuaState(state);
|
||||
|
||||
std::vector<std::string> keys = moduleDictionary.keys();
|
||||
|
||||
// Get the common directory
|
||||
using constants::scenegraph::keyCommonFolder;
|
||||
bool commonFolderSpecified = sceneDictionary.hasKey(keyCommonFolder);
|
||||
bool commonFolderCorrectType = sceneDictionary.hasKeyAndValue<std::string>(keyCommonFolder);
|
||||
|
||||
if (commonFolderSpecified) {
|
||||
if (commonFolderCorrectType) {
|
||||
std::string commonFolder = sceneDictionary.value<std::string>(keyCommonFolder);
|
||||
if (!FileSys.directoryExists(commonFolder))
|
||||
LERROR("Specified common folder '" << commonFolder << "' did not exist");
|
||||
else {
|
||||
if (!commonFolder.empty()) {
|
||||
FileSys.registerPathToken(_commonModuleToken, commonFolder);
|
||||
keys.push_back(commonFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
LERROR("Specification for 'common' folder has invalid type");
|
||||
}
|
||||
|
||||
|
||||
std::sort(keys.begin(), keys.end());
|
||||
for (const std::string& key : keys) {
|
||||
std::string moduleName = moduleDictionary.value<std::string>(key);
|
||||
std::string modulePath = FileSys.pathByAppendingComponent(sceneDirectory, moduleName);
|
||||
|
||||
if (!FileSys.directoryExists(modulePath)) {
|
||||
LERROR("Could not load module '" << moduleName << "'. Directory did not exist");
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string moduleFile = FileSys.pathByAppendingComponent(
|
||||
modulePath,
|
||||
moduleName + _moduleExtension
|
||||
);
|
||||
|
||||
if (!FileSys.fileExists(moduleFile)) {
|
||||
LERROR("Could not load module file '" << moduleFile << "'. File did not exist");
|
||||
continue;
|
||||
}
|
||||
|
||||
ghoul::Dictionary moduleDictionary;
|
||||
bool s = ghoul::lua::loadDictionaryFromFile(moduleFile, moduleDictionary, state);
|
||||
if (!s)
|
||||
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 << "'");
|
||||
continue;
|
||||
}
|
||||
|
||||
ghoul::Dictionary element;
|
||||
std::string nodeName;
|
||||
std::string parentName;
|
||||
|
||||
moduleDictionary.getValue(key, element);
|
||||
element.setValue(constants::scenegraph::keyPathModule, modulePath);
|
||||
|
||||
element.getValue(constants::scenegraphnode::keyName, nodeName);
|
||||
element.getValue(constants::scenegraphnode::keyParentName, parentName);
|
||||
|
||||
nodeInformation[nodeName] = {
|
||||
parentName,
|
||||
moduleName,
|
||||
modulePath,
|
||||
element
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Check map for circular dependencies
|
||||
|
||||
// Checks if n1 is dependent on n2
|
||||
std::function<bool(const std::string&, const std::string&)> nodeDependency;
|
||||
nodeDependency = [nodeInformation, nodeDependency](const std::string& n1, const std::string& n2) {
|
||||
const SceneGraphNodeInformation& n1Info = nodeInformation[n1];
|
||||
const std::string& parentName = n1Info.parent;
|
||||
|
||||
if (parentName == SceneGraphNode::RootNodeName)
|
||||
return false;
|
||||
if (parentName == n2)
|
||||
return true;
|
||||
return nodeDependency(parentName, n2);
|
||||
}
|
||||
|
||||
|
||||
// Add Root node to the list of nodes
|
||||
SceneGraphNode* root = new SceneGraphNode();
|
||||
root->setName(SceneGraphNode::RootNodeName);
|
||||
nodes.push_back(root);
|
||||
|
||||
|
||||
|
||||
|
||||
auto dependentNodes = [nodeInformation](const std::string& name) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Check ScenePath variable (absolute/relative path)
|
||||
// Convert Modules dictionary into vector
|
||||
// Determine dependencies between modules (-> store in map)
|
||||
// Check map for circular dependencies
|
||||
// Traverse map from Root by determining it's direct dependencies
|
||||
// Rearrange vector based on dependencies
|
||||
// Create scenegraph nodes in order checking if dependencies have been fulfilled
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
|
||||
//
|
||||
//#include <openspace/abuffer/abuffer.h>
|
||||
//#include <openspace/engine/configurationmanager.h>
|
||||
//#include <openspace/engine/openspaceengine.h>
|
||||
//#include <openspace/gui/gui.h>
|
||||
//#include <openspace/interaction/interactionhandler.h>
|
||||
//#include <openspace/query/query.h>
|
||||
//#include <openspace/rendering/renderengine.h>
|
||||
//#include <openspace/scene/scenegraphnode.h>
|
||||
//#include <openspace/scripting/scriptengine.h>
|
||||
//#include <openspace/scripting/script_helper.h>
|
||||
//#include <openspace/util/constants.h>
|
||||
//#include <openspace/util/time.h>
|
||||
//
|
||||
//#include <ghoul/filesystem/filesystem.h>
|
||||
//#include "ghoul/io/texture/texturereader.h"
|
||||
//#include <ghoul/misc/dictionary.h>
|
||||
//#include "ghoul/logging/logmanager.h"
|
||||
//#include <ghoul/lua/ghoul_lua.h>
|
||||
//#include <ghoul/lua/lua_helper.h>
|
||||
//#include "ghoul/opengl/programobject.h"
|
||||
//#include "ghoul/opengl/texture.h"
|
||||
//
|
||||
//#include <iostream>
|
||||
//#include <fstream>
|
||||
//#include <string>
|
||||
//#include <chrono>
|
||||
//
|
||||
//namespace {
|
||||
// const std::string _loggerCat = "SceneGraph";
|
||||
// const std::string _moduleExtension = ".mod";
|
||||
// const std::string _defaultCommonDirectory = "common";
|
||||
// const std::string _commonModuleToken = "${COMMON_MODULE}";
|
||||
//}
|
||||
//
|
||||
//namespace openspace {
|
||||
//
|
||||
//namespace luascriptfunctions {
|
||||
//
|
||||
///**
|
||||
// * \ingroup LuaScripts
|
||||
// * setPropertyValue(string, *):
|
||||
// * Sets the property identified by the URI in the first argument to the value passed to
|
||||
// * the second argument. The type of the second argument is arbitrary, but it must agree
|
||||
// * with the type the denoted Property expects
|
||||
// */
|
||||
//int property_setValue(lua_State* L) {
|
||||
// static const std::string _loggerCat = "property_setValue";
|
||||
// using ghoul::lua::errorLocation;
|
||||
// using ghoul::lua::luaTypeToString;
|
||||
//
|
||||
// int nArguments = lua_gettop(L);
|
||||
// SCRIPT_CHECK_ARGUMENTS(L, 2, nArguments);
|
||||
//
|
||||
// std::string uri = luaL_checkstring(L, -2);
|
||||
// const int type = lua_type(L, -1);
|
||||
//
|
||||
// openspace::properties::Property* prop = property(uri);
|
||||
// if (!prop) {
|
||||
// LERROR(errorLocation(L) << "Property with URI '" << uri << "' was not found");
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (type != prop->typeLua()) {
|
||||
// LERROR(errorLocation(L) << "Property '" << uri <<
|
||||
// "' does not accept input of type '" << luaTypeToString(type) <<
|
||||
// "'. Requested type: '" << luaTypeToString(prop->typeLua()) << "'");
|
||||
// return 0;
|
||||
// }
|
||||
// else
|
||||
// prop->setLua(L);
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * \ingroup LuaScripts
|
||||
// * getPropertyValue(string):
|
||||
// * Returns the value of the property identified by the passed URI as a Lua object that can
|
||||
// * be passed to the setPropertyValue method.
|
||||
// */
|
||||
//int property_getValue(lua_State* L) {
|
||||
// static const std::string _loggerCat = "property_getValue";
|
||||
// using ghoul::lua::errorLocation;
|
||||
//
|
||||
// int nArguments = lua_gettop(L);
|
||||
// SCRIPT_CHECK_ARGUMENTS(L, 1, nArguments);
|
||||
//
|
||||
// std::string uri = luaL_checkstring(L, -1);
|
||||
//
|
||||
// openspace::properties::Property* prop = property(uri);
|
||||
// if (!prop) {
|
||||
// LERROR(errorLocation(L) << "Property with URL '" << uri << "' was not found");
|
||||
// return 0;
|
||||
// }
|
||||
// else
|
||||
// prop->getLua(L);
|
||||
// return 1;
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * \ingroup LuaScripts
|
||||
// * getPropertyValue(string):
|
||||
// * Returns the value of the property identified by the passed URI as a Lua object that can
|
||||
// * be passed to the setPropertyValue method.
|
||||
// */
|
||||
//int loadScene(lua_State* L) {
|
||||
// static const std::string _loggerCat = "loadScene";
|
||||
//
|
||||
// int nArguments = lua_gettop(L);
|
||||
// SCRIPT_CHECK_ARGUMENTS(L, 1, nArguments);
|
||||
//
|
||||
// std::string sceneFile = luaL_checkstring(L, -1);
|
||||
//
|
||||
// OsEng.renderEngine()->sceneGraph()->scheduleLoadSceneFile(sceneFile);
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
//} // namespace luascriptfunctions
|
||||
//
|
||||
//SceneGraph::SceneGraph()
|
||||
// : _focus(SceneGraphNode::RootNodeName)
|
||||
// , _root(nullptr)
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//SceneGraph::~SceneGraph() {
|
||||
// deinitialize();
|
||||
//}
|
||||
//
|
||||
//bool SceneGraph::initialize() {
|
||||
// LDEBUG("Initializing SceneGraph");
|
||||
//
|
||||
// using ghoul::opengl::ShaderObject;
|
||||
// using ghoul::opengl::ProgramObject;
|
||||
//
|
||||
// ProgramObject* tmpProgram;
|
||||
//
|
||||
// ghoul::opengl::ProgramObject::ProgramObjectCallback cb = [this](ghoul::opengl::ProgramObject* program) {
|
||||
// _programUpdateLock.lock();
|
||||
// _programsToUpdate.insert(program);
|
||||
// _programUpdateLock.unlock();
|
||||
// };
|
||||
//
|
||||
// // Start Timing for building SceneGraph shaders
|
||||
// typedef std::chrono::high_resolution_clock clock_;
|
||||
// typedef std::chrono::duration<double, std::ratio<1> > second_;
|
||||
// std::chrono::time_point<clock_> beginning(clock_::now());
|
||||
//
|
||||
// // fboPassthrough program
|
||||
// tmpProgram = ProgramObject::Build("fboPassProgram",
|
||||
// "${SHADERS}/fboPass_vs.glsl",
|
||||
// "${SHADERS}/fboPass_fs.glsl");
|
||||
// if (!tmpProgram) return false;
|
||||
// tmpProgram->setProgramObjectCallback(cb);
|
||||
// _programs.push_back(tmpProgram);
|
||||
// OsEng.ref().configurationManager()->setValue("fboPassProgram", tmpProgram);
|
||||
// // projection program
|
||||
// tmpProgram = ProgramObject::Build("projectiveProgram",
|
||||
// "${SHADERS}/projectiveTexture_vs.glsl",
|
||||
// "${SHADERS}/projectiveTexture_fs.glsl");
|
||||
// if (!tmpProgram) return false;
|
||||
// tmpProgram->setProgramObjectCallback(cb);
|
||||
// _programs.push_back(tmpProgram);
|
||||
// OsEng.ref().configurationManager()->setValue("projectiveProgram", tmpProgram);
|
||||
//
|
||||
// // pscstandard
|
||||
// tmpProgram = ProgramObject::Build("pscstandard",
|
||||
// "${SHADERS}/pscstandard_vs.glsl",
|
||||
// "${SHADERS}/pscstandard_fs.glsl");
|
||||
// if( ! tmpProgram) return false;
|
||||
// tmpProgram->setProgramObjectCallback(cb);
|
||||
//
|
||||
// _programs.push_back(tmpProgram);
|
||||
// OsEng.ref().configurationManager()->setValue("pscShader", tmpProgram);
|
||||
//
|
||||
// // pscstandard
|
||||
// tmpProgram = ProgramObject::Build("FovProgram",
|
||||
// "${SHADERS}/fov_vs.glsl",
|
||||
// "${SHADERS}/fov_fs.glsl");
|
||||
// if (!tmpProgram) return false;
|
||||
// tmpProgram->setProgramObjectCallback(cb);
|
||||
// _programs.push_back(tmpProgram);
|
||||
// OsEng.ref().configurationManager()->setValue("FovProgram", tmpProgram);
|
||||
//
|
||||
// // RaycastProgram
|
||||
// tmpProgram = ProgramObject::Build("RaycastProgram",
|
||||
// "${SHADERS}/exitpoints.vert",
|
||||
// "${SHADERS}/exitpoints.frag");
|
||||
// if (!tmpProgram) return false;
|
||||
// tmpProgram->setProgramObjectCallback(cb);
|
||||
// _programs.push_back(tmpProgram);
|
||||
// OsEng.ref().configurationManager()->setValue("RaycastProgram", tmpProgram);
|
||||
//
|
||||
// // Grid program
|
||||
// tmpProgram = ProgramObject::Build("Grid",
|
||||
// "${SHADERS}/grid_vs.glsl",
|
||||
// "${SHADERS}/grid_fs.glsl");
|
||||
// if (!tmpProgram) return false;
|
||||
// tmpProgram->setProgramObjectCallback(cb);
|
||||
// _programs.push_back(tmpProgram);
|
||||
// OsEng.ref().configurationManager()->setValue("GridProgram", tmpProgram);
|
||||
//
|
||||
// // Done building shaders
|
||||
// double elapsed = std::chrono::duration_cast<second_>(clock_::now()-beginning).count();
|
||||
// LINFO("Time to load scene graph shaders: " << elapsed << " seconds");
|
||||
//
|
||||
//
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
//bool SceneGraph::deinitialize() {
|
||||
// clearSceneGraph();
|
||||
//
|
||||
// // clean up all programs
|
||||
// _programsToUpdate.clear();
|
||||
// for (ghoul::opengl::ProgramObject* program : _programs)
|
||||
// delete program;
|
||||
// _programs.clear();
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::update(const UpdateData& data) {
|
||||
// if (!_sceneGraphToLoad.empty()) {
|
||||
// OsEng.renderEngine()->sceneGraph()->clearSceneGraph();
|
||||
// bool success = loadSceneInternal(_sceneGraphToLoad);
|
||||
// _sceneGraphToLoad = "";
|
||||
// if (!success)
|
||||
// return;
|
||||
//#ifndef __APPLE__
|
||||
// OsEng.renderEngine()->abuffer()->invalidateABuffer();
|
||||
//#endif
|
||||
// }
|
||||
// for (SceneGraphNode* node : _nodes)
|
||||
// node->update(data);
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::evaluate(Camera* camera) {
|
||||
// if (_root)
|
||||
// _root->evaluate(camera);
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::render(const RenderData& data) {
|
||||
// bool emptyProgramsToUpdate = _programsToUpdate.empty();
|
||||
//
|
||||
// _programUpdateLock.lock();
|
||||
// for (ghoul::opengl::ProgramObject* program : _programsToUpdate) {
|
||||
// LDEBUG("Attempting to recompile " << program->name());
|
||||
// program->rebuildFromFile();
|
||||
// }
|
||||
// _programsToUpdate.erase(_programsToUpdate.begin(), _programsToUpdate.end());
|
||||
// _programUpdateLock.unlock();
|
||||
//
|
||||
// if (!emptyProgramsToUpdate) {
|
||||
// LDEBUG("Setting uniforms");
|
||||
// // Ignore attribute locations
|
||||
// for (ghoul::opengl::ProgramObject* program : _programs)
|
||||
// program->setIgnoreSubroutineUniformLocationError(true);
|
||||
// }
|
||||
//
|
||||
// if (_root)
|
||||
// _root->render(data);
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::scheduleLoadSceneFile(const std::string& sceneDescriptionFilePath) {
|
||||
// _sceneGraphToLoad = sceneDescriptionFilePath;
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::clearSceneGraph() {
|
||||
// // deallocate the scene graph. Recursive deallocation will occur
|
||||
// if (_root) {
|
||||
// _root->deinitialize();
|
||||
// delete _root;
|
||||
// _root = nullptr;
|
||||
// }
|
||||
//
|
||||
// _nodes.erase(_nodes.begin(), _nodes.end());
|
||||
// _allNodes.erase(_allNodes.begin(), _allNodes.end());
|
||||
//
|
||||
// _focus.clear();
|
||||
//}
|
||||
//
|
||||
//bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
|
||||
// using ghoul::Dictionary;
|
||||
// using ghoul::lua::loadDictionaryFromFile;
|
||||
//
|
||||
// if (!FileSys.fileExists(sceneDescriptionFilePath)) {
|
||||
// LFATAL("Scene description file '" << sceneDescriptionFilePath << "' not found");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// LDEBUG("Loading scenegraph nodes");
|
||||
// if (_root != nullptr) {
|
||||
// LFATAL("Scenegraph already loaded");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// OsEng.disableBarrier();
|
||||
//
|
||||
// // initialize the root node
|
||||
// _root = new SceneGraphNode();
|
||||
// _root->setName(SceneGraphNode::RootNodeName);
|
||||
// _nodes.push_back(_root);
|
||||
// _allNodes.emplace(SceneGraphNode::RootNodeName, _root);
|
||||
// _focus = SceneGraphNode::RootNodeName;
|
||||
//
|
||||
// Dictionary dictionary;
|
||||
// //load default.scene
|
||||
// loadDictionaryFromFile(sceneDescriptionFilePath, dictionary);
|
||||
//
|
||||
// std::string&& sceneDescriptionDirectory =
|
||||
// ghoul::filesystem::File(sceneDescriptionFilePath).directoryName();
|
||||
// std::string moduleDirectory(".");
|
||||
// dictionary.getValue(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");
|
||||
// OsEng.enableBarrier();
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Load the modules/scenegraph nodes
|
||||
// loadModules(moduleDirectory, dictionary);
|
||||
//
|
||||
// // TODO: Make it less hard-coded and more flexible when nodes are not found
|
||||
// Dictionary cameraDictionary;
|
||||
// if (dictionary.getValue(constants::scenegraph::keyCamera, cameraDictionary)) {
|
||||
// LDEBUG("Camera dictionary found");
|
||||
// std::string focus;
|
||||
//
|
||||
// if (cameraDictionary.hasKey(constants::scenegraph::keyFocusObject)
|
||||
// && cameraDictionary.getValue(constants::scenegraph::keyFocusObject, focus)) {
|
||||
// auto focusIterator = _allNodes.find(focus);
|
||||
// if (focusIterator != _allNodes.end()) {
|
||||
// _focus = focus;
|
||||
// LDEBUG("Setting camera focus to '" << _focus << "'");
|
||||
// }
|
||||
// else
|
||||
// LERROR("Could not find focus object '" << focus << "'");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Initialize all nodes
|
||||
// for (SceneGraphNode* node : _nodes) {
|
||||
// bool success = node->initialize();
|
||||
// if (success)
|
||||
// LDEBUG(node->name() << " initialized successfully!");
|
||||
// else
|
||||
// LWARNING(node->name() << " not initialized.");
|
||||
// }
|
||||
//
|
||||
// // update the position of all nodes
|
||||
// // TODO need to check this; unnecessary? (ab)
|
||||
// for (SceneGraphNode* node : _nodes)
|
||||
// node->update({ Time::ref().currentTime() });
|
||||
//
|
||||
// // Calculate the bounding sphere for the scenegraph
|
||||
// _root->calculateBoundingSphere();
|
||||
//
|
||||
// // set the camera position
|
||||
// Camera* c = OsEng.ref().renderEngine()->camera();
|
||||
// auto focusIterator = _allNodes.find(_focus);
|
||||
//
|
||||
// glm::vec2 cameraScaling(1);
|
||||
// psc cameraPosition(0,0,1,0);
|
||||
// glm::vec3 cameraDirection = glm::vec3(0, 0, -1);
|
||||
//
|
||||
// if (focusIterator != _allNodes.end()) {
|
||||
// LDEBUG("Camera focus is '" << _focus << "'");
|
||||
// SceneGraphNode* focusNode = focusIterator->second;
|
||||
// //Camera* c = OsEng.interactionHandler().getCamera();
|
||||
//
|
||||
// // TODO: Make distance depend on radius
|
||||
// // TODO: Set distance and camera direction in some more smart way
|
||||
// // TODO: Set scaling dependent on the position and distance
|
||||
// // set position for camera
|
||||
// const PowerScaledScalar bound = focusNode->calculateBoundingSphere();
|
||||
//
|
||||
// // this part is full of magic!
|
||||
// glm::vec2 boundf = bound.vec2();
|
||||
// //glm::vec2 scaling{1.0f, -boundf[1]};
|
||||
// cameraScaling = glm::vec2(1.f, -boundf[1]);
|
||||
// boundf[0] *= 5.0f;
|
||||
//
|
||||
// //psc cameraPosition = focusNode->position();
|
||||
// //cameraPosition += psc(glm::vec4(0.f, 0.f, boundf));
|
||||
//
|
||||
// //cameraPosition = psc(glm::vec4(0.f, 0.f, 1.f,0.f));
|
||||
//
|
||||
// cameraPosition = focusNode->position();
|
||||
// cameraPosition += psc(glm::vec4(0.f, 0.f, boundf));
|
||||
//
|
||||
// //why this line? (JK)
|
||||
// //cameraPosition = psc(glm::vec4(0.f, 0.f, 1.f, 0.f));
|
||||
//
|
||||
// //c->setPosition(cameraPosition);
|
||||
// // c->setCameraDirection(glm::vec3(0, 0, -1));
|
||||
// // c->setScaling(scaling);
|
||||
//
|
||||
// // Set the focus node for the interactionhandler
|
||||
// OsEng.interactionHandler()->setFocusNode(focusNode);
|
||||
// }
|
||||
//
|
||||
// glm::vec4 position;
|
||||
// if (cameraDictionary.hasKey(constants::scenegraph::keyPositionObject)
|
||||
// && cameraDictionary.getValue(constants::scenegraph::keyPositionObject, position)) {
|
||||
//
|
||||
// LDEBUG("Camera position is ("
|
||||
// << position[0] << ", "
|
||||
// << position[1] << ", "
|
||||
// << position[2] << ", "
|
||||
// << position[3] << ")");
|
||||
//
|
||||
// cameraPosition = psc(position);
|
||||
// //c->setPosition(position);
|
||||
// }
|
||||
//
|
||||
// // the camera position
|
||||
// const SceneGraphNode* fn = OsEng.interactionHandler()->focusNode();
|
||||
// //psc relative = fn->worldPosition() - c->position();
|
||||
// psc relative = fn->worldPosition() - cameraPosition;
|
||||
//
|
||||
// glm::mat4 la = glm::lookAt(cameraPosition.vec3(), fn->worldPosition().vec3(), c->lookUpVector());
|
||||
//
|
||||
// c->setRotation(la);
|
||||
// c->setPosition(cameraPosition);
|
||||
// c->setScaling(cameraScaling);
|
||||
//
|
||||
// glm::vec3 viewOffset;
|
||||
// if (cameraDictionary.hasKey(constants::scenegraph::keyViewOffset)
|
||||
// && cameraDictionary.getValue(constants::scenegraph::keyViewOffset, viewOffset)) {
|
||||
// glm::quat rot = glm::quat(viewOffset);
|
||||
// c->rotate(rot);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// for (SceneGraphNode* node : _nodes) {
|
||||
// std::vector<properties::Property*> properties = node->propertiesRecursive();
|
||||
// for (properties::Property* p : properties) {
|
||||
// OsEng.gui()->_property.registerProperty(p);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // If a LuaDocumentationFile was specified, generate it now
|
||||
// using constants::configurationmanager::keyPropertyDocumentationType;
|
||||
// using constants::configurationmanager::keyPropertyDocumentationFile;
|
||||
// const bool hasType = OsEng.configurationManager()->hasKey(keyPropertyDocumentationType);
|
||||
// const bool hasFile = OsEng.configurationManager()->hasKey(keyPropertyDocumentationFile);
|
||||
// if (hasType && hasFile) {
|
||||
// std::string propertyDocumentationType;
|
||||
// OsEng.configurationManager()->getValue(keyPropertyDocumentationType, propertyDocumentationType);
|
||||
// std::string propertyDocumentationFile;
|
||||
// OsEng.configurationManager()->getValue(keyPropertyDocumentationFile, propertyDocumentationFile);
|
||||
//
|
||||
// propertyDocumentationFile = absPath(propertyDocumentationFile);
|
||||
// writePropertyDocumentation(propertyDocumentationFile, propertyDocumentationType);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// OsEng.runSettingsScripts();
|
||||
//
|
||||
// OsEng.enableBarrier();
|
||||
//
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::loadModules(
|
||||
// const std::string& directory,
|
||||
// const ghoul::Dictionary& dictionary)
|
||||
//{
|
||||
// // Struct containing dependencies and nodes
|
||||
// LoadMaps m;
|
||||
//
|
||||
// // Get the common directory
|
||||
// std::string commonDirectory(_defaultCommonDirectory);
|
||||
// dictionary.getValue(constants::scenegraph::keyCommonFolder, commonDirectory);
|
||||
// FileSys.registerPathToken(_commonModuleToken, commonDirectory);
|
||||
//
|
||||
// lua_State* state = ghoul::lua::createNewLuaState();
|
||||
// OsEng.scriptEngine()->initializeLuaState(state);
|
||||
//
|
||||
// LDEBUG("Loading common module folder '" << commonDirectory << "'");
|
||||
// // Load common modules into LoadMaps struct
|
||||
// loadModule(m, FileSys.pathByAppendingComponent(directory, commonDirectory), state);
|
||||
//
|
||||
// // Load the rest of the modules into LoadMaps struct
|
||||
// ghoul::Dictionary moduleDictionary;
|
||||
// if (dictionary.getValue(constants::scenegraph::keyModules, moduleDictionary)) {
|
||||
// std::vector<std::string> keys = moduleDictionary.keys();
|
||||
// std::sort(keys.begin(), keys.end());
|
||||
// for (const std::string& key : keys) {
|
||||
// std::string moduleFolder;
|
||||
// if (moduleDictionary.getValue(key, moduleFolder)) {
|
||||
// loadModule(m, FileSys.pathByAppendingComponent(directory, moduleFolder), state);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Load and construct scenegraphnodes from LoadMaps struct
|
||||
// loadNodes(SceneGraphNode::RootNodeName, m);
|
||||
//
|
||||
// // Remove loaded nodes from dependency list
|
||||
// for(const auto& name: m.loadedNodes) {
|
||||
// m.dependencies.erase(name);
|
||||
// }
|
||||
//
|
||||
// // Check to see what dependencies are not resolved.
|
||||
// for(auto& node: m.dependencies) {
|
||||
// LWARNING(
|
||||
// "'" << node.second << "'' not loaded, parent '"
|
||||
// << node.first << "' not defined!");
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::loadModule(LoadMaps& m,const std::string& modulePath, lua_State* state) {
|
||||
// auto pos = modulePath.find_last_of(ghoul::filesystem::FileSystem::PathSeparator);
|
||||
// if (pos == modulePath.npos) {
|
||||
// LERROR("Bad format for module path: " << modulePath);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// std::string fullModule = modulePath + modulePath.substr(pos) + _moduleExtension;
|
||||
// LDEBUG("Loading nodes from: " << fullModule);
|
||||
//
|
||||
// ghoul::filesystem::Directory oldDirectory = FileSys.currentDirectory();
|
||||
// FileSys.setCurrentDirectory(modulePath);
|
||||
//
|
||||
// ghoul::Dictionary moduleDictionary;
|
||||
// ghoul::lua::loadDictionaryFromFile(fullModule, moduleDictionary, state);
|
||||
// std::vector<std::string> keys = moduleDictionary.keys();
|
||||
// for (const std::string& key : keys) {
|
||||
// if (!moduleDictionary.hasValue<ghoul::Dictionary>(key)) {
|
||||
// LERROR("SceneGraphElement '" << key << "' is not a table in module '"
|
||||
// << fullModule << "'");
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// ghoul::Dictionary element;
|
||||
// std::string nodeName;
|
||||
// std::string parentName;
|
||||
//
|
||||
// moduleDictionary.getValue(key, element);
|
||||
// element.setValue(constants::scenegraph::keyPathModule, modulePath);
|
||||
//
|
||||
// element.getValue(constants::scenegraphnode::keyName, nodeName);
|
||||
// element.getValue(constants::scenegraphnode::keyParentName, parentName);
|
||||
//
|
||||
// m.nodes[nodeName] = element;
|
||||
// m.dependencies.emplace(parentName,nodeName);
|
||||
// }
|
||||
//
|
||||
// FileSys.setCurrentDirectory(oldDirectory);
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::loadNodes(const std::string& parentName, LoadMaps& m) {
|
||||
// auto eqRange = m.dependencies.equal_range(parentName);
|
||||
// for (auto it = eqRange.first; it != eqRange.second; ++it) {
|
||||
// auto node = m.nodes.find((*it).second);
|
||||
// loadNode(node->second);
|
||||
// loadNodes((*it).second, m);
|
||||
// }
|
||||
// m.loadedNodes.emplace_back(parentName);
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::loadNode(const ghoul::Dictionary& dictionary) {
|
||||
// SceneGraphNode* node = SceneGraphNode::createFromDictionary(dictionary);
|
||||
// if(node) {
|
||||
// _allNodes.emplace(node->name(), node);
|
||||
// _nodes.push_back(node);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
////void SceneGraph::loadModule(const std::string& modulePath) {
|
||||
//// auto pos = modulePath.find_last_of(ghoul::filesystem::FileSystem::PathSeparator);
|
||||
//// if (pos == modulePath.npos) {
|
||||
//// LERROR("Bad format for module path: " << modulePath);
|
||||
//// return;
|
||||
//// }
|
||||
////
|
||||
//// std::string fullModule = modulePath + modulePath.substr(pos) + _moduleExtension;
|
||||
//// LDEBUG("Loading modules from: " << fullModule);
|
||||
////
|
||||
//// ghoul::filesystem::Directory oldDirectory = FileSys.currentDirectory();
|
||||
//// FileSys.setCurrentDirectory(modulePath);
|
||||
////
|
||||
//// ghoul::Dictionary moduleDictionary;
|
||||
//// ghoul::lua::loadDictionaryFromFile(fullModule, moduleDictionary);
|
||||
//// std::vector<std::string> keys = moduleDictionary.keys();
|
||||
//// for (const std::string& key : keys) {
|
||||
//// if (!moduleDictionary.hasValue<ghoul::Dictionary>(key)) {
|
||||
//// LERROR("SceneGraphElement '" << key << "' is not a table in module '"
|
||||
//// << fullModule << "'");
|
||||
//// continue;
|
||||
//// }
|
||||
////
|
||||
//// ghoul::Dictionary element;
|
||||
//// moduleDictionary.getValue(key, element);
|
||||
////
|
||||
//// element.setValue(constants::scenegraph::keyPathModule, modulePath);
|
||||
////
|
||||
//// //each element in this new dictionary becomes a scenegraph node.
|
||||
//// SceneGraphNode* node = SceneGraphNode::createFromDictionary(element);
|
||||
////
|
||||
//// _allNodes.emplace(node->name(), node);
|
||||
//// _nodes.push_back(node);
|
||||
//// }
|
||||
////
|
||||
//// FileSys.setCurrentDirectory(oldDirectory);
|
||||
////
|
||||
//// // Print the tree
|
||||
//// //printTree(_root);
|
||||
////}
|
||||
//
|
||||
//SceneGraphNode* SceneGraph::root() const {
|
||||
// return _root;
|
||||
//}
|
||||
//
|
||||
//SceneGraphNode* SceneGraph::sceneGraphNode(const std::string& name) const {
|
||||
// auto it = _allNodes.find(name);
|
||||
// if (it == _allNodes.end())
|
||||
// return nullptr;
|
||||
// else
|
||||
// return it->second;
|
||||
//}
|
||||
//
|
||||
//std::vector<SceneGraphNode*> SceneGraph::allSceneGraphNodes() const {
|
||||
// return _nodes;
|
||||
//}
|
||||
//
|
||||
//void SceneGraph::writePropertyDocumentation(const std::string& filename, const std::string& type) {
|
||||
// if (type == "text") {
|
||||
// LDEBUG("Writing documentation for properties");
|
||||
// std::ofstream file(filename);
|
||||
// if (!file.good()) {
|
||||
// LERROR("Could not open file '" << filename << "' for writing property documentation");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// using properties::Property;
|
||||
// for (SceneGraphNode* node : _nodes) {
|
||||
// std::vector<Property*> properties = node->propertiesRecursive();
|
||||
// if (!properties.empty()) {
|
||||
// file << node->name() << std::endl;
|
||||
//
|
||||
// for (Property* p : properties) {
|
||||
// file << p->fullyQualifiedIdentifier() << ": " << p->guiName() << std::endl;
|
||||
// }
|
||||
//
|
||||
// file << std::endl;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// LERROR("Undefined type '" << type << "' for Property documentation");
|
||||
//}
|
||||
//
|
||||
//scripting::ScriptEngine::LuaLibrary SceneGraph::luaLibrary() {
|
||||
// return {
|
||||
// "",
|
||||
// {
|
||||
// {
|
||||
// "setPropertyValue",
|
||||
// &luascriptfunctions::property_setValue,
|
||||
// "string, *",
|
||||
// "Sets a property identified by the URI in "
|
||||
// "the first argument. The second argument can be any type, but it has to "
|
||||
// " agree with the type that the property expects"
|
||||
// },
|
||||
// {
|
||||
// "getPropertyValue",
|
||||
// &luascriptfunctions::property_getValue,
|
||||
// "string",
|
||||
// "Returns the value the property, identified by "
|
||||
// "the provided URI."
|
||||
// },
|
||||
// {
|
||||
// "loadScene",
|
||||
// &luascriptfunctions::loadScene,
|
||||
// "string",
|
||||
// "Loads the scene found at the file passed as an "
|
||||
// "argument. If a scene is already loaded, it is unloaded first"
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//}
|
||||
//
|
||||
//} // namespace openspace
|
||||
@@ -109,14 +109,14 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di
|
||||
parentName = "Root";
|
||||
}
|
||||
|
||||
SceneGraphNode* parentNode = sceneGraphNode(parentName);
|
||||
if (parentNode == nullptr) {
|
||||
LFATAL("Could not find parent named '"
|
||||
<< parentName << "' for '" << result->name() << "'."
|
||||
<< " Check module definition order. Skipping module.");
|
||||
}
|
||||
//SceneGraphNode* parentNode = sceneGraphNode(parentName);
|
||||
//if (parentNode == nullptr) {
|
||||
// LFATAL("Could not find parent named '"
|
||||
// << parentName << "' for '" << result->name() << "'."
|
||||
// << " Check module definition order. Skipping module.");
|
||||
//}
|
||||
|
||||
parentNode->addNode(result);
|
||||
//parentNode->addNode(result);
|
||||
|
||||
LDEBUG("Successfully created SceneGraphNode '"
|
||||
<< result->name() << "'");
|
||||
@@ -247,8 +247,8 @@ void SceneGraphNode::evaluate(const Camera* camera, const psc& parentPosition) {
|
||||
}
|
||||
|
||||
// evaluate all the children, tail-recursive function(?)
|
||||
for (SceneGraphNode* child : _children)
|
||||
child->evaluate(camera, psc());
|
||||
//for (SceneGraphNode* child : _children)
|
||||
// child->evaluate(camera, psc());
|
||||
}
|
||||
|
||||
void SceneGraphNode::render(const RenderData& data) {
|
||||
@@ -274,8 +274,8 @@ void SceneGraphNode::render(const RenderData& data) {
|
||||
|
||||
// evaluate all the children, tail-recursive function(?)
|
||||
|
||||
for (SceneGraphNode* child : _children)
|
||||
child->render(newData);
|
||||
//for (SceneGraphNode* child : _children)
|
||||
// child->render(newData);
|
||||
}
|
||||
|
||||
// set & get
|
||||
|
||||
@@ -24,359 +24,358 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <openspace/scene/scenegraphloader.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
class SceneGraphLoaderTest : public testing::Test {};
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, NonExistingFileTest) {
|
||||
const std::string file = "NonExistingFile";
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, IllformedFileTest) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformed.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, IllformedFileTestWrongCommonFolderType) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformedWrongType.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, IllformedFileTestInvalidSceneFolder) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformedInvalidScene.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, IllformedFileTestWrongCommonFolder) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformedWrongCommon.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, IllformedFileTestNonExistingCommonFolder) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformedNonExistingCommon.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test00) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test00.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
EXPECT_TRUE(nodes.empty()) << "No scenegraph nodes loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test00Location) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test00-location.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
EXPECT_TRUE(nodes.empty()) << "No scenegraph nodes loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, AbsoluteScenePath) {
|
||||
const std::string scenePath = absPath("${TEMPORARY}/tmp.scene");
|
||||
std::ofstream scene(scenePath.c_str());
|
||||
|
||||
scene << "return {" << std::endl <<
|
||||
" ScenePath = \"" << absPath("${TESTDIR}/SceneGraphLoaderTest/scene-folder") <<
|
||||
"\"," << std::endl <<
|
||||
" CommonFolder = \"\"," << std::endl <<
|
||||
" Modules = {}}" << std::endl;
|
||||
scene.close();
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(scenePath, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
EXPECT_TRUE(nodes.empty()) << "No scenegraph nodes loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test01) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test01.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 1) << "Correct number of nodes";
|
||||
EXPECT_TRUE(nodes[0]->name() == "Common") << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test01Location) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test01-location.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 1) << "Correct number of nodes";
|
||||
EXPECT_TRUE(nodes[0]->name() == "Common") << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test02) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test02.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 2) << "Correct number of nodes";
|
||||
bool found = false;
|
||||
for (openspace::SceneGraphNode* n : nodes)
|
||||
if (n->name() == "NoDependency")
|
||||
found = true;
|
||||
|
||||
EXPECT_TRUE(found) << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test02Location) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test02-location.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 2) << "Correct number of nodes";
|
||||
bool found = false;
|
||||
for (openspace::SceneGraphNode* n : nodes)
|
||||
if (n->name() == "NoDependency")
|
||||
found = true;
|
||||
|
||||
EXPECT_TRUE(found) << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test03) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test03.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 2) << "Correct number of nodes";
|
||||
bool found = false;
|
||||
for (openspace::SceneGraphNode* n : nodes)
|
||||
if (n->name() == "CommonDependency")
|
||||
found = true;
|
||||
|
||||
EXPECT_TRUE(found) << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test03Location) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test03-location.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 2) << "Correct number of nodes";
|
||||
bool found = false;
|
||||
for (openspace::SceneGraphNode* n : nodes)
|
||||
if (n->name() == "CommonDependency")
|
||||
found = true;
|
||||
|
||||
EXPECT_TRUE(found) << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test04) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test04.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 3) << "Correct number of nodes";
|
||||
bool found = false;
|
||||
for (openspace::SceneGraphNode* n : nodes)
|
||||
if (n->name() == "DirectDependency")
|
||||
found = true;
|
||||
|
||||
EXPECT_TRUE(found) << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test04Location) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test04-location.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 3) << "Correct number of nodes";
|
||||
bool found = false;
|
||||
for (openspace::SceneGraphNode* n : nodes)
|
||||
if (n->name() == "DirectDependency")
|
||||
found = true;
|
||||
|
||||
EXPECT_TRUE(found) << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test05) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test05.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 4) << "Correct number of nodes";
|
||||
bool found = false;
|
||||
for (openspace::SceneGraphNode* n : nodes)
|
||||
if (n->name() == "MultipleDependencies")
|
||||
found = true;
|
||||
|
||||
EXPECT_TRUE(found) << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test05Location) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test05-location.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 4) << "Correct number of nodes";
|
||||
bool found = false;
|
||||
for (openspace::SceneGraphNode* n : nodes)
|
||||
if (n->name() == "MultipleDependencies")
|
||||
found = true;
|
||||
|
||||
EXPECT_TRUE(found) << "Correct node loaded";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test06) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test06.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_FALSE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.empty()) << "Correct number of nodes";
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphLoaderTest, Test06Location) {
|
||||
const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test06-location.scene");
|
||||
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
|
||||
ASSERT_TRUE(success) << "Successful loading";
|
||||
ASSERT_TRUE(nodes.size() == 4) << "Correct number of nodes";
|
||||
bool found = false;
|
||||
for (openspace::SceneGraphNode* n : nodes)
|
||||
if (n->name() == "MultipleDependencies")
|
||||
found = true;
|
||||
|
||||
EXPECT_TRUE(found) << "No scenegraph nodes loaded";
|
||||
}
|
||||
|
||||
//TEST_F(SceneGraphLoaderTest, NonExistingFileTest) {
|
||||
// const std::string file = "NonExistingFile";
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
//
|
||||
//TEST_F(SceneGraphTest, SceneGraphNode) {
|
||||
//
|
||||
// openspace::SceneGraphNode *node =
|
||||
// openspace::SceneGraphNode::createFromDictionary(ghoul::Dictionary());
|
||||
//
|
||||
// // Should not have a renderable and position should be 0,0,0,0 (undefined).
|
||||
// EXPECT_EQ(nullptr, node->renderable());
|
||||
// EXPECT_EQ(openspace::psc(), node->position());
|
||||
//
|
||||
// delete node;
|
||||
// ghoul::Dictionary nodeDictionary;
|
||||
//
|
||||
// ghoul::Dictionary positionDictionary;
|
||||
// ghoul::Dictionary positionPositionArrayDictionary;
|
||||
//
|
||||
// ghoul::Dictionary renderableDictionary;
|
||||
//
|
||||
// renderableDictionary.setValue("Type", std::string("RenderablePlanet"));
|
||||
//
|
||||
// positionPositionArrayDictionary.setValue("1", 1.0);
|
||||
// positionPositionArrayDictionary.setValue("2", 1.0);
|
||||
// positionPositionArrayDictionary.setValue("3", 1.0);
|
||||
// positionPositionArrayDictionary.setValue("4", 1.0);
|
||||
//
|
||||
// positionDictionary.setValue("Type", std::string("Static"));
|
||||
// positionDictionary.setValue("Position", positionPositionArrayDictionary);
|
||||
//
|
||||
// nodeDictionary.setValue("Position", positionDictionary);
|
||||
// nodeDictionary.setValue("Renderable", renderableDictionary);
|
||||
//
|
||||
// node =
|
||||
// openspace::SceneGraphNode::createFromDictionary(nodeDictionary);
|
||||
//
|
||||
// // This node should have a renderable (probably no good values but an existing one)
|
||||
// EXPECT_TRUE(node->renderable());
|
||||
//
|
||||
// // position should be initialized
|
||||
// EXPECT_EQ(openspace::psc(1.0,1.0,1.0,1.0), node->position());
|
||||
//
|
||||
// delete node;
|
||||
// EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
// EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphTest, Loading) {
|
||||
//
|
||||
//
|
||||
// // Should not successfully load a non existing scenegraph
|
||||
// EXPECT_FALSE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTestNonExisting"), absPath("${TESTDIR}")));
|
||||
//
|
||||
// // Existing scenegraph should load
|
||||
// EXPECT_TRUE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTest"), absPath("${TESTDIR}")));
|
||||
// // TODO need to check for correctness
|
||||
//
|
||||
// // This loading should fail regardless of existing or not since the
|
||||
// // scenegraph is already loaded
|
||||
// EXPECT_FALSE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTest"), absPath("${TESTDIR}")));
|
||||
//TEST_F(SceneGraphLoaderTest, IllformedFileTest) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformed.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
// EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphTest, Reinitializing) {
|
||||
//
|
||||
// // Existing scenegraph should load
|
||||
// EXPECT_TRUE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTest"), absPath("${TESTDIR}")));
|
||||
//
|
||||
// _scenegraph->deinitialize();
|
||||
//
|
||||
// // Existing scenegraph should load
|
||||
// EXPECT_TRUE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTest"), absPath("${TESTDIR}")));
|
||||
// // TODO need to check for correctness
|
||||
//TEST_F(SceneGraphLoaderTest, IllformedFileTestWrongCommonFolderType) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformedWrongType.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
// EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
//}
|
||||
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, IllformedFileTestInvalidSceneFolder) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformedInvalidScene.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
// EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, IllformedFileTestWrongCommonFolder) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformedWrongCommon.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
// EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, IllformedFileTestNonExistingCommonFolder) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/illformedNonExistingCommon.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// EXPECT_FALSE(success) << "Unsuccessful loading";
|
||||
// EXPECT_TRUE(nodes.empty()) << "Empty scenegraph nodes list";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test00) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test00.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// EXPECT_TRUE(nodes.empty()) << "No scenegraph nodes loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test00Location) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test00-location.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// EXPECT_TRUE(nodes.empty()) << "No scenegraph nodes loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, AbsoluteScenePath) {
|
||||
// const std::string scenePath = absPath("${TEMPORARY}/tmp.scene");
|
||||
// std::ofstream scene(scenePath.c_str());
|
||||
//
|
||||
// scene << "return {" << std::endl <<
|
||||
// " ScenePath = \"" << absPath("${TESTDIR}/SceneGraphLoaderTest/scene-folder") <<
|
||||
// "\"," << std::endl <<
|
||||
// " CommonFolder = \"\"," << std::endl <<
|
||||
// " Modules = {}}" << std::endl;
|
||||
// scene.close();
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(scenePath, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// EXPECT_TRUE(nodes.empty()) << "No scenegraph nodes loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test01) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test01.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 1) << "Correct number of nodes";
|
||||
// EXPECT_TRUE(nodes[0]->name() == "Common") << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test01Location) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test01-location.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 1) << "Correct number of nodes";
|
||||
// EXPECT_TRUE(nodes[0]->name() == "Common") << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test02) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test02.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 2) << "Correct number of nodes";
|
||||
// bool found = false;
|
||||
// for (openspace::SceneGraphNode* n : nodes)
|
||||
// if (n->name() == "NoDependency")
|
||||
// found = true;
|
||||
//
|
||||
// EXPECT_TRUE(found) << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test02Location) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test02-location.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 2) << "Correct number of nodes";
|
||||
// bool found = false;
|
||||
// for (openspace::SceneGraphNode* n : nodes)
|
||||
// if (n->name() == "NoDependency")
|
||||
// found = true;
|
||||
//
|
||||
// EXPECT_TRUE(found) << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test03) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test03.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 2) << "Correct number of nodes";
|
||||
// bool found = false;
|
||||
// for (openspace::SceneGraphNode* n : nodes)
|
||||
// if (n->name() == "CommonDependency")
|
||||
// found = true;
|
||||
//
|
||||
// EXPECT_TRUE(found) << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test03Location) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test03-location.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 2) << "Correct number of nodes";
|
||||
// bool found = false;
|
||||
// for (openspace::SceneGraphNode* n : nodes)
|
||||
// if (n->name() == "CommonDependency")
|
||||
// found = true;
|
||||
//
|
||||
// EXPECT_TRUE(found) << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test04) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test04.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 3) << "Correct number of nodes";
|
||||
// bool found = false;
|
||||
// for (openspace::SceneGraphNode* n : nodes)
|
||||
// if (n->name() == "DirectDependency")
|
||||
// found = true;
|
||||
//
|
||||
// EXPECT_TRUE(found) << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test04Location) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test04-location.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 3) << "Correct number of nodes";
|
||||
// bool found = false;
|
||||
// for (openspace::SceneGraphNode* n : nodes)
|
||||
// if (n->name() == "DirectDependency")
|
||||
// found = true;
|
||||
//
|
||||
// EXPECT_TRUE(found) << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test05) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test05.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 4) << "Correct number of nodes";
|
||||
// bool found = false;
|
||||
// for (openspace::SceneGraphNode* n : nodes)
|
||||
// if (n->name() == "MultipleDependencies")
|
||||
// found = true;
|
||||
//
|
||||
// EXPECT_TRUE(found) << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test05Location) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test05-location.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 4) << "Correct number of nodes";
|
||||
// bool found = false;
|
||||
// for (openspace::SceneGraphNode* n : nodes)
|
||||
// if (n->name() == "MultipleDependencies")
|
||||
// found = true;
|
||||
//
|
||||
// EXPECT_TRUE(found) << "Correct node loaded";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test06) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test06.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_FALSE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.empty()) << "Correct number of nodes";
|
||||
//}
|
||||
//
|
||||
//TEST_F(SceneGraphLoaderTest, Test06Location) {
|
||||
// const std::string file = absPath("${TESTDIR}/SceneGraphLoaderTest/test06-location.scene");
|
||||
//
|
||||
// std::vector<openspace::SceneGraphNode*> nodes;
|
||||
// bool success = openspace::SceneGraphLoader::load(file, nodes);
|
||||
//
|
||||
// ASSERT_TRUE(success) << "Successful loading";
|
||||
// ASSERT_TRUE(nodes.size() == 4) << "Correct number of nodes";
|
||||
// bool found = false;
|
||||
// for (openspace::SceneGraphNode* n : nodes)
|
||||
// if (n->name() == "MultipleDependencies")
|
||||
// found = true;
|
||||
//
|
||||
// EXPECT_TRUE(found) << "No scenegraph nodes loaded";
|
||||
//}
|
||||
//
|
||||
////
|
||||
////
|
||||
////
|
||||
////TEST_F(SceneGraphTest, SceneGraphNode) {
|
||||
////
|
||||
//// openspace::SceneGraphNode *node =
|
||||
//// openspace::SceneGraphNode::createFromDictionary(ghoul::Dictionary());
|
||||
////
|
||||
//// // Should not have a renderable and position should be 0,0,0,0 (undefined).
|
||||
//// EXPECT_EQ(nullptr, node->renderable());
|
||||
//// EXPECT_EQ(openspace::psc(), node->position());
|
||||
////
|
||||
//// delete node;
|
||||
//// ghoul::Dictionary nodeDictionary;
|
||||
////
|
||||
//// ghoul::Dictionary positionDictionary;
|
||||
//// ghoul::Dictionary positionPositionArrayDictionary;
|
||||
////
|
||||
//// ghoul::Dictionary renderableDictionary;
|
||||
////
|
||||
//// renderableDictionary.setValue("Type", std::string("RenderablePlanet"));
|
||||
////
|
||||
//// positionPositionArrayDictionary.setValue("1", 1.0);
|
||||
//// positionPositionArrayDictionary.setValue("2", 1.0);
|
||||
//// positionPositionArrayDictionary.setValue("3", 1.0);
|
||||
//// positionPositionArrayDictionary.setValue("4", 1.0);
|
||||
////
|
||||
//// positionDictionary.setValue("Type", std::string("Static"));
|
||||
//// positionDictionary.setValue("Position", positionPositionArrayDictionary);
|
||||
////
|
||||
//// nodeDictionary.setValue("Position", positionDictionary);
|
||||
//// nodeDictionary.setValue("Renderable", renderableDictionary);
|
||||
////
|
||||
//// node =
|
||||
//// openspace::SceneGraphNode::createFromDictionary(nodeDictionary);
|
||||
////
|
||||
//// // This node should have a renderable (probably no good values but an existing one)
|
||||
//// EXPECT_TRUE(node->renderable());
|
||||
////
|
||||
//// // position should be initialized
|
||||
//// EXPECT_EQ(openspace::psc(1.0,1.0,1.0,1.0), node->position());
|
||||
////
|
||||
//// delete node;
|
||||
////}
|
||||
////
|
||||
////TEST_F(SceneGraphTest, Loading) {
|
||||
////
|
||||
////
|
||||
//// // Should not successfully load a non existing scenegraph
|
||||
//// EXPECT_FALSE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTestNonExisting"), absPath("${TESTDIR}")));
|
||||
////
|
||||
//// // Existing scenegraph should load
|
||||
//// EXPECT_TRUE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTest"), absPath("${TESTDIR}")));
|
||||
//// // TODO need to check for correctness
|
||||
////
|
||||
//// // This loading should fail regardless of existing or not since the
|
||||
//// // scenegraph is already loaded
|
||||
//// EXPECT_FALSE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTest"), absPath("${TESTDIR}")));
|
||||
////}
|
||||
////
|
||||
////TEST_F(SceneGraphTest, Reinitializing) {
|
||||
////
|
||||
//// // Existing scenegraph should load
|
||||
//// EXPECT_TRUE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTest"), absPath("${TESTDIR}")));
|
||||
////
|
||||
//// _scenegraph->deinitialize();
|
||||
////
|
||||
//// // Existing scenegraph should load
|
||||
//// EXPECT_TRUE(_scenegraph->loadScene(absPath("${TESTDIR}/ScenegraphTest"), absPath("${TESTDIR}")));
|
||||
//// // TODO need to check for correctness
|
||||
////}
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user