Merge branch 'develop' of openspace.itn.liu.se:/openspace into develop

This commit is contained in:
Michal Marcinkowski
2015-03-10 13:17:35 -04:00
9 changed files with 74 additions and 25 deletions

View File

@@ -53,7 +53,7 @@ namespace scripting {
class OpenSpaceEngine {
public:
static bool create(int argc, char** argv, std::vector<std::string>& sgctArguments);
static bool create(int argc, char** argv, std::vector<std::string>& sgctArguments, std::string& openGlVersion);
static void destroy();
static OpenSpaceEngine& ref();

View File

@@ -163,6 +163,11 @@ void openspace::properties::TemplateProperty<T>::setValue(T val)
}
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const TemplateProperty<T>& obj) {
os << obj.value();
return os;
}
template <typename T>
boost::any TemplateProperty<T>::get() const {

View File

@@ -45,6 +45,5 @@ return {
SGCTConfig = "${SGCT}/single.xml",
--SGCTConfig = "${SGCT}/single_fisheye.xml",
--SGCTConfig = "${SGCT}/two_nodes.xml",
--SGCTConfig = "${SGCT}/single_sbs_stereo.xml",
Scene = "${OPENSPACE_DATA}/scene/default.scene",
}

View File

@@ -24,7 +24,6 @@
#include <openspace/engine/openspaceengine.h>
// sgct
#define SGCT_WINDOWS_INCLUDE
#include <sgct.h>
#include <openspace/version.h>
@@ -73,10 +72,13 @@ namespace {
const std::string _defaultCacheLocation = "${BASE_PATH}/cache";
const std::string _sgctConfigArgumentCommand = "-config";
const std::string DefaultOpenGlVersion = "4.3";
struct {
std::string configurationName;
std::string sgctConfigurationName;
std::string openGlVersion;
} commandlineArgumentPlaceholders;
}
@@ -123,8 +125,10 @@ OpenSpaceEngine& OpenSpaceEngine::ref() {
return *_engine;
}
bool OpenSpaceEngine::create(int argc, char** argv,
std::vector<std::string>& sgctArguments)
bool OpenSpaceEngine::create(
int argc, char** argv,
std::vector<std::string>& sgctArguments,
std::string& openGlVersion)
{
assert(_engine == nullptr);
@@ -225,6 +229,9 @@ bool OpenSpaceEngine::create(int argc, char** argv,
sgctConfigurationPath = commandlineArgumentPlaceholders.sgctConfigurationName;
}
openGlVersion = commandlineArgumentPlaceholders.openGlVersion;
LINFO("Using OpenGL version " << openGlVersion);
// Prepend the outgoing sgctArguments with the program name
// as well as the configuration file that sgct is supposed to use
sgctArguments.insert(sgctArguments.begin(), argv[0]);
@@ -354,7 +361,14 @@ bool OpenSpaceEngine::gatherCommandlineArguments() {
"Provides the path to the SGCT configuration file, overriding the value set in"
"the OpenSpace configuration file");
_commandlineParser->addCommand(sgctConfigFileCommand);
commandlineArgumentPlaceholders.openGlVersion = DefaultOpenGlVersion;
CommandlineCommand* openGlVersionCommand = new SingleCommand<std::string>(
&commandlineArgumentPlaceholders.openGlVersion,
"-ogl", "-o",
"Sets the OpenGL version that is to be used; valid values are '4.2' and '4.3'");
_commandlineParser->addCommand(openGlVersionCommand);
return true;
}

View File

@@ -56,11 +56,15 @@ namespace {
const std::string _loggerCat = "main";
}
int main(int argc, char** argv)
{
int main(int argc, char** argv) {
// create the OpenSpace engine and get arguments for the sgct engine
std::vector<std::string> sgctArguments;
const bool success = openspace::OpenSpaceEngine::create(argc, argv, sgctArguments);
std::string openGlVersion = "";
const bool success = openspace::OpenSpaceEngine::create(
argc, argv,
sgctArguments,
openGlVersion
);
if (!success)
return EXIT_FAILURE;
@@ -105,7 +109,17 @@ int main(int argc, char** argv)
#ifdef __APPLE__
sgct::Engine::RunMode rm = sgct::Engine::RunMode::OpenGL_4_1_Core_Profile;
#else
sgct::Engine::RunMode rm = sgct::Engine::RunMode::OpenGL_4_3_Core_Profile;
std::map<std::string, sgct::Engine::RunMode> versionMapping = {
{ "4.2", sgct::Engine::RunMode::OpenGL_4_2_Core_Profile },
{ "4.3", sgct::Engine::RunMode::OpenGL_4_3_Core_Profile },
{ "4.4", sgct::Engine::RunMode::OpenGL_4_4_Core_Profile },
{ "4.5", sgct::Engine::RunMode::OpenGL_4_5_Core_Profile }
};
if (versionMapping.find(openGlVersion) == versionMapping.end()) {
LFATAL("Requested OpenGL version " << openGlVersion << " not supported");
return EXIT_FAILURE;
}
sgct::Engine::RunMode rm = versionMapping[openGlVersion];
#endif
const bool initSuccess = _sgctEngine->init(rm);
if (!initSuccess) {

View File

@@ -66,16 +66,16 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
ghoul_assert(success,
"RenderablePlanet need the '" <<constants::scenegraphnode::keyName<<"' be specified");
std::string path;
success = dictionary.getValue(constants::scenegraph::keyPathModule, path);
ghoul_assert(success,
"RenderablePlanet need the '"<<constants::scenegraph::keyPathModule<<"' be specified");
//std::string path;
//success = dictionary.getValue(constants::scenegraph::keyPathModule, path);
//ghoul_assert(success,
// "RenderablePlanet need the '"<<constants::scenegraph::keyPathModule<<"' be specified");
ghoul::Dictionary geometryDictionary;
success = dictionary.getValue(keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
geometryDictionary.setValue(constants::scenegraph::keyPathModule, path);
//geometryDictionary.setValue(constants::scenegraph::keyPathModule, path);
_geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary);
}
@@ -88,8 +88,9 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
// as the requirements are fixed (ab)
std::string texturePath = "";
success = dictionary.getValue("Textures.Color", texturePath);
if (success)
_colorTexturePath = path + "/" + texturePath;
_colorTexturePath = absPath(texturePath);
//if (success)
//_colorTexturePath = path + "/" + texturePath;
addPropertySubOwner(_geometry);
@@ -195,14 +196,13 @@ void RenderablePlanet::update(const UpdateData& data){
_time = data.time;
}
void RenderablePlanet::loadTexture()
{
void RenderablePlanet::loadTexture() {
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
_texture = ghoul::io::TextureReader::ref().loadTexture(_colorTexturePath);
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
LDEBUG("Loaded texture from '" << _colorTexturePath << "'");
_texture->uploadTexture();
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear

View File

@@ -520,20 +520,27 @@ namespace openspace {
std::string str = "";
openspace::SpiceManager::ref().getDateFromET(openspace::ImageSequencer::ref().getNextCaptureTime(), str);
Freetype::print(font,
_onScreenInformation._position.x * xSize,
_onScreenInformation._position.y * ySize,
"Date: %s",
Time::ref().currentTimeUTC().c_str()
);
progress.append("|");
if (remaining > 0){
glm::vec4 g1(0, t, 0, 1);
glm::vec4 g2(1 - t);
Freetype::print(font,
_onScreenInformation._position.x * xSize,
_onScreenInformation._position.y * ySize,
_onScreenInformation._position.y * ySize - font_size_mono * 2,
g1 + g2,
"Next projection in | %.0f seconds",
remaining
);
Freetype::print(font,
_onScreenInformation._position.x * xSize,
_onScreenInformation._position.y * ySize - font_size_mono * 2,
_onScreenInformation._position.y * ySize - font_size_mono * 2 * 2,
g1 + g2,
"%s %.1f %%",
progress.c_str(), t * 100
@@ -544,7 +551,7 @@ namespace openspace {
std::string active = ImageSequencer::ref().getActiveInstrument();
Freetype::print(font,
_onScreenInformation._position.x * xSize,
_onScreenInformation._position.y * ySize - font_size_mono * 2 * 2,
_onScreenInformation._position.y * ySize - font_size_mono * 3 * 2,
glm::vec4(0.3, 0.6, 1, 1),
"Active Instrument : %s",
active.c_str()

View File

@@ -567,6 +567,9 @@ void SceneGraph::loadModule(LoadMaps& m,const std::string& modulePath, lua_State
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();
@@ -590,6 +593,8 @@ void SceneGraph::loadModule(LoadMaps& m,const std::string& modulePath, lua_State
m.nodes[nodeName] = element;
m.dependencies.emplace(parentName,nodeName);
}
FileSys.setCurrentDirectory(oldDirectory);
}
void SceneGraph::loadNodes(const std::string& parentName, LoadMaps& m) {
@@ -621,6 +626,9 @@ void SceneGraph::loadModule(const std::string& modulePath)
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();
@@ -643,6 +651,8 @@ void SceneGraph::loadModule(const std::string& modulePath)
_nodes.push_back(node);
}
FileSys.setCurrentDirectory(oldDirectory);
// Print the tree
//printTree(_root);
}