mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-10 05:32:18 -06:00
Merge branch 'develop' of https://github.com/OpenSpace/OpenSpace into develop
This commit is contained in:
@@ -27,18 +27,24 @@
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SettingsEngine : public properties::PropertyOwner {
|
||||
public:
|
||||
SettingsEngine();
|
||||
SettingsEngine();
|
||||
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
properties::FloatProperty _eyeSeparation;
|
||||
void initEyeSeparation();
|
||||
void initSceneFiles();
|
||||
|
||||
properties::FloatProperty _eyeSeparation;
|
||||
properties::OptionProperty _scenes;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
#endif //#ifndef __SETTINGSENGINE_H__
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
|
||||
/**
|
||||
* Returns the list of available options.
|
||||
* /return The list of available options
|
||||
* \return The list of available options
|
||||
*/
|
||||
const std::vector<Option>& options() const;
|
||||
|
||||
@@ -107,6 +107,12 @@ public:
|
||||
*/
|
||||
void setValue(int value) override;
|
||||
|
||||
/**
|
||||
* Get the description of the option that matches <code>value</code>
|
||||
* \param value The value of the option
|
||||
*/
|
||||
std::string getDescriptionByValue(int value);
|
||||
|
||||
private:
|
||||
static const std::string OptionsKey;
|
||||
std::string generateAdditionalDescription() const;
|
||||
|
||||
@@ -21,6 +21,8 @@ helper.setCommonKeys = function()
|
||||
|
||||
openspace.bindKey("f", helper.property.invert('Interaction.rotationalFriction'))
|
||||
openspace.bindKey("Shift+f", helper.property.invert('Interaction.zoomFriction'))
|
||||
|
||||
openspace.bindKey("w", "openspace.toggleFade(3)")
|
||||
end
|
||||
|
||||
helper.setDeltaTimeKeys = function(t)
|
||||
|
||||
@@ -416,28 +416,34 @@ bool OpenSpaceEngine::initialize() {
|
||||
ConfigurationManager::KeyShutdownCountdown, _shutdownWait
|
||||
);
|
||||
|
||||
// Load scenegraph
|
||||
if (!commandlineArgumentPlaceholders.sceneName.empty())
|
||||
configurationManager().setValue(
|
||||
ConfigurationManager::KeyConfigScene,
|
||||
commandlineArgumentPlaceholders.sceneName);
|
||||
|
||||
// Initialize the SettingsEngine
|
||||
_settingsEngine->initialize();
|
||||
|
||||
// Initialize the Scene
|
||||
Scene* sceneGraph = new Scene;
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
|
||||
// initialize the RenderEngine
|
||||
_renderEngine->initialize();
|
||||
sceneGraph->initialize();
|
||||
|
||||
std::string scenePath = "";
|
||||
configurationManager().getValue(ConfigurationManager::KeyConfigScene, scenePath);
|
||||
sceneGraph->scheduleLoadSceneFile(scenePath);
|
||||
|
||||
// Initialize the RenderEngine
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
_renderEngine->initialize();
|
||||
_renderEngine->setGlobalBlackOutFactor(0.0);
|
||||
_renderEngine->startFading(1, 3.0);
|
||||
|
||||
std::string sceneDescriptionPath = "";
|
||||
if (commandlineArgumentPlaceholders.sceneName.empty()) {
|
||||
success = configurationManager().getValue(
|
||||
ConfigurationManager::KeyConfigScene, sceneDescriptionPath);
|
||||
}
|
||||
else
|
||||
sceneDescriptionPath = commandlineArgumentPlaceholders.sceneName;
|
||||
sceneGraph->scheduleLoadSceneFile(sceneDescriptionPath);
|
||||
|
||||
//_interactionHandler->setKeyboardController(new interaction::KeyboardControllerFixed);
|
||||
//_interactionHandler->setMouseController(new interaction::OrbitalMouseController);
|
||||
|
||||
// Run start up scripts
|
||||
runPreInitializationScripts(sceneDescriptionPath);
|
||||
runPreInitializationScripts(scenePath);
|
||||
|
||||
// Load a light and a monospaced font
|
||||
loadFonts();
|
||||
|
||||
@@ -25,17 +25,56 @@
|
||||
#include <openspace/engine/settingsengine.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/configurationmanager.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
|
||||
#include <ghoul/ghoul.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SettingsEngine::SettingsEngine() :
|
||||
_eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f)
|
||||
SettingsEngine::SettingsEngine()
|
||||
: _eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f)
|
||||
, _scenes("scenes", "Scene", properties::OptionProperty::DisplayType::DROPDOWN)
|
||||
{
|
||||
setName("Global Properties");
|
||||
}
|
||||
|
||||
void SettingsEngine::initialize() {
|
||||
initEyeSeparation();
|
||||
initSceneFiles();
|
||||
}
|
||||
|
||||
|
||||
void SettingsEngine::initEyeSeparation() {
|
||||
addProperty(_eyeSeparation);
|
||||
setName("Global");
|
||||
|
||||
// Set interaction to change the window's (SGCT's) eye separation
|
||||
_eyeSeparation.onChange(
|
||||
[this](){ OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); });
|
||||
[this]() { OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); });
|
||||
}
|
||||
|
||||
void SettingsEngine::initSceneFiles() {
|
||||
addProperty(_scenes);
|
||||
|
||||
// Load all matching files in the Scene
|
||||
// TODO: match regex with either with new ghoul readFiles or local code
|
||||
std::string sceneDir = "${SCENE}";
|
||||
std::vector<std::string> scenes = ghoul::filesystem::Directory(sceneDir).readFiles();
|
||||
for (std::size_t i = 0; i < scenes.size(); ++i) {
|
||||
_scenes.addOption(i, scenes[i]);
|
||||
}
|
||||
|
||||
// Set interaction to change ConfigurationManager and schedule the load
|
||||
_scenes.onChange(
|
||||
[this]() {
|
||||
std::string sceneFile = _scenes.getDescriptionByValue(_scenes);
|
||||
OsEng.configurationManager().setValue(
|
||||
ConfigurationManager::KeyConfigScene, sceneFile);
|
||||
OsEng.renderEngine().scene()->scheduleLoadSceneFile(sceneFile);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -103,6 +103,14 @@ void OptionProperty::setValue(int value) {
|
||||
LERROR("Could not find an option for value '" << value << "' in OptionProperty");
|
||||
}
|
||||
|
||||
std::string OptionProperty::getDescriptionByValue(int value) {
|
||||
for (auto option : _options) {
|
||||
if (option.value == value) {
|
||||
return option.description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string OptionProperty::generateAdditionalDescription() const {
|
||||
// @REFACTOR from selectionproperty.cpp, possible refactoring? ---abock
|
||||
std::string result;
|
||||
|
||||
@@ -325,11 +325,19 @@ void RenderEngine::preSynchronization() {
|
||||
|
||||
void RenderEngine::postSynchronizationPreDraw() {
|
||||
//temporary fade funtionality
|
||||
float fadedIn = 1.0;
|
||||
float fadedOut = 0.0;
|
||||
// Don't restart the fade if you've already done it in that direction
|
||||
if ( (_fadeDirection > 0 && _globalBlackOutFactor == fadedIn)
|
||||
|| (_fadeDirection < 0 && _globalBlackOutFactor == fadedOut)) {
|
||||
_fadeDirection = 0;
|
||||
}
|
||||
|
||||
if (_fadeDirection != 0) {
|
||||
if (_currentFadeTime > _fadeDuration){
|
||||
_globalBlackOutFactor = _fadeDirection > 0 ? fadedIn : fadedOut;
|
||||
_fadeDirection = 0;
|
||||
_globalBlackOutFactor = fminf(1.f, fmaxf(0.f, _globalBlackOutFactor));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (_fadeDirection < 0)
|
||||
_globalBlackOutFactor = glm::smoothstep(1.f, 0.f, _currentFadeTime / _fadeDuration);
|
||||
@@ -711,6 +719,13 @@ scripting::LuaLibrary RenderEngine::luaLibrary() {
|
||||
"bool",
|
||||
"Sets the performance measurements"
|
||||
},
|
||||
{
|
||||
"toggleFade",
|
||||
&luascriptfunctions::toggleFade,
|
||||
"number",
|
||||
"Toggles fading in or out",
|
||||
true
|
||||
},
|
||||
{
|
||||
"fadeIn",
|
||||
&luascriptfunctions::fadeIn,
|
||||
|
||||
@@ -107,6 +107,25 @@ int setPerformanceMeasurement(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* toggleFade(float):
|
||||
* Toggle a global fade over (float) seconds
|
||||
*/
|
||||
int toggleFade(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 1)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
|
||||
|
||||
double t = luaL_checknumber(L, -1);
|
||||
|
||||
float fadedIn = 1.0;
|
||||
int direction = OsEng.renderEngine().globalBlackOutFactor() == fadedIn ? -1 : 1;
|
||||
|
||||
OsEng.renderEngine().startFading(direction, static_cast<float>(t));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* fadeIn(float):
|
||||
|
||||
@@ -91,9 +91,12 @@ void Scene::update(const UpdateData& data) {
|
||||
if (!_sceneGraphToLoad.empty()) {
|
||||
OsEng.renderEngine().scene()->clearSceneGraph();
|
||||
try {
|
||||
// Reset the InteractionManager to Orbital/default mode
|
||||
// TODO: Decide if it belongs in the scene and/or how it gets reloaded
|
||||
OsEng.interactionHandler().setInteractionModeToOrbital();
|
||||
|
||||
loadSceneInternal(_sceneGraphToLoad);
|
||||
_sceneGraphToLoad = "";
|
||||
|
||||
|
||||
// After loading the scene, the keyboard bindings have been set
|
||||
|
||||
std::string type;
|
||||
@@ -109,6 +112,9 @@ void Scene::update(const UpdateData& data) {
|
||||
if (hasType && hasFile) {
|
||||
OsEng.interactionHandler().writeKeyboardDocumentation(type, file);
|
||||
}
|
||||
|
||||
LINFO("Loaded " << _sceneGraphToLoad);
|
||||
_sceneGraphToLoad = "";
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERROR(e.what());
|
||||
@@ -150,6 +156,7 @@ void Scene::scheduleLoadSceneFile(const std::string& sceneDescriptionFilePath) {
|
||||
}
|
||||
|
||||
void Scene::clearSceneGraph() {
|
||||
LINFO("Clearing current scene graph");
|
||||
// deallocate the scene graph. Recursive deallocation will occur
|
||||
_graph.clear();
|
||||
//if (_root) {
|
||||
|
||||
@@ -374,8 +374,10 @@ function (handle_internal_modules)
|
||||
if (OPENSPACE_DEPENDENCIES)
|
||||
foreach (dependency ${OPENSPACE_DEPENDENCIES})
|
||||
create_option_name(${dependency} dependencyOptionName)
|
||||
set(${dependencyOptionName} ON CACHE BOOL "ff" FORCE)
|
||||
message(STATUS "${dependencyOptionName} was set to build, due to dependency towards ${optionName}")
|
||||
if (NOT ${dependencyOptionName})
|
||||
set(${dependencyOptionName} ON CACHE BOOL "ff" FORCE)
|
||||
message(STATUS "${dependencyOptionName} was set to build, due to dependency towards ${optionName}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
Reference in New Issue
Block a user