Merge branch 'master' into feature/NewAtmosphere

# Conflicts:
#	src/rendering/renderengine.cpp
This commit is contained in:
Alexander Bock
2017-10-24 15:30:22 -04:00
84 changed files with 1634 additions and 783 deletions

View File

@@ -313,7 +313,6 @@ void mainInitFunc() {
void mainPreSyncFunc() {
LTRACE("main::mainPreSyncFunc(begin)");
OsEng.setRunTime(sgct::Engine::getTime());
OsEng.preSynchronization();
LTRACE("main::mainPreSyncFunc(end)");
}

View File

@@ -0,0 +1,21 @@
return {
-- Earth barycenter module
{
Name = "Lua Transformation",
Parent = "SolarSystemBarycenter",
Transform = {
Rotation = {
Type = "LuaRotation",
Script = "rotation.lua"
},
Scale = {
Type = "LuaScale",
Script = "scale.lua"
},
Translation = {
Type = "LuaTranslation",
Script = "translate.lua"
}
}
}
}

View File

@@ -0,0 +1,6 @@
-- t1: Ingame seconds past the J2000 epoch
-- t2: Wallclock milliseconds past the J2000 epoch
function rotation(t1, t2)
return 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0
end

View File

@@ -0,0 +1,6 @@
-- t1: Ingame seconds past the J2000 epoch
-- t2: Wallclock milliseconds past the J2000 epoch
function scale(t1, t2)
return 1.0;
end

View File

@@ -0,0 +1,6 @@
-- t1: Ingame seconds past the J2000 epoch
-- t2: Wallclock milliseconds past the J2000 epoch
function translation(t1, t2)
return 0.0, 0.0, 0.0
end

View File

@@ -0,0 +1,9 @@
<div id="page-content-wrapper">
<div class="container-fluid documentation-container">
<h1>OpenSpace Scene License Information</h1>
<p>Version: {{version.[0]}}.{{version.[1]}}.{{version.[2]}}</p>
{{#each sceneLicenses}}
{{> scenelicense}}
{{/each}}
</div>
</div>

View File

@@ -0,0 +1,16 @@
<div class="documentation-item">
<div class="row">
<div class="col-lg-12">
<p>
<a href="#{{urlify module}}" name="{{urlify module}}">
<span class="documentation-key">{{module}}</span>
</a>
<p>{{name}}</p>
<br />
<p>{{attribution}}</p>
<p>{{url}}</p>
<p>{{licenseText}}</p>
</p>
</div>
</div>
</div>

View File

@@ -0,0 +1,28 @@
window.onload = function () {
var mainTemplateElement = document.getElementById('mainTemplate');
var mainTemplate = Handlebars.compile(mainTemplateElement.innerHTML);
var sceneLicenseTemplate = document.getElementById('sceneLicenseTemplate');
Handlebars.registerPartial('scenelicense', sceneLicenseTemplate.innerHTML);
Handlebars.registerHelper('urlify', function(options, context) {
var data = context.data;
var identifier = options.replace(" ", "-").toLowerCase();
while (data = data._parent) {
if (data.key !== undefined) {
identifier = data.key + "-" + identifier;
}
}
return identifier;
});
var data = {
sceneLicenses: sceneLicenses,
version: version
}
var contents = mainTemplate(data);
document.body.innerHTML = contents;
}

View File

@@ -67,6 +67,8 @@ public:
static const std::string KeyDocumentation;
/// The key that stores the factory documentation values
static const std::string KeyFactoryDocumentation;
/// The key that stores the scene license documentation values
static const std::string KeySceneLicenseDocumentation;
/// The key that stores the location of the scene file that is initially loaded
static const std::string KeyConfigScene;
/// The key that stores the location of the tasks files

View File

@@ -79,9 +79,6 @@ public:
static OpenSpaceEngine& ref();
static bool isCreated();
double runTime();
void setRunTime(double t);
// callbacks
void initialize();
void initializeGL();
@@ -101,9 +98,6 @@ public:
void decode();
void scheduleLoadScene(std::string scenePath);
void enableBarrier();
void disableBarrier();
void writeDocumentation();
void toggleShutdownMode();
@@ -234,8 +228,6 @@ private:
std::vector<std::function<bool (double, double)>> mouseScrollWheel;
} _moduleCallbacks;
double _runTime;
// Structure that is responsible for the delayed shutdown of the application
struct {
// Whether the application is currently in shutdown mode (i.e. counting down the

View File

@@ -49,6 +49,7 @@ public:
double averageDeltaTime() const override;
double deltaTime() const override;
double applicationTime() const override;
glm::vec2 mousePosition() const override;
uint32_t mouseButtons(int maxNumber) const override;
glm::ivec2 currentWindowSize() const override;

View File

@@ -106,6 +106,13 @@ public:
*/
virtual double deltaTime() const;
/**
* Returns the time that has passed (in seconds) since application start
* \return The time that has passed (in seconds) since application start
* @return [description]
*/
virtual double applicationTime() const;
/**
* Returns the location of the mouse cursor in pixel screen coordinates. On default,
* this method returns <code>0,0</code>.

View File

@@ -55,6 +55,7 @@ public:
private:
void parallelConnectionChanged(const ParallelConnection::Status& status);
void addToCommand(std::string c);
std::string sanitizeInput(std::string str);
@@ -68,7 +69,6 @@ private:
properties::Vec4Property _historyTextColor;
properties::IntProperty _historyLength;
size_t _inputPosition;
std::vector<std::string> _commandsHistory;
size_t _activeCommand;

View File

@@ -44,7 +44,9 @@ public:
static void createGlobalSharedMemory();
static void destroyGlobalSharedMemory();
PerformanceManager();
PerformanceManager(std::string loggingDirectory = "${BASE_PATH}",
std::string prefix = "PM-");
~PerformanceManager();
void resetPerformanceMeasurements();

View File

@@ -224,12 +224,20 @@ public:
std::vector<std::string> tags() const;
/**
* Adds a tag to the Property's list of assigned tags. Tags are useful for creating
* groups of Properties that can be used in batch operations.
* Adds a tag to the PropertyOwner's list of assigned tags. Tags are useful for
* creating oups of Properties that can be used in batch operations or to mark up
* PropertyOwners for other usages (such signalling to GUI applications).
* \param tag The string that is to be assigned to the Property
*/
void addTag(std::string tag);
/**
* Removes a tag from this PropertyOwner. No error is reported if the tag does not
* exist
* @param tag The tag is that is to be removed from this PropertyOwner
*/
void removeTag(const std::string& tag);
private:
/// The name of this PropertyOwner
std::string _name;

View File

@@ -67,7 +67,8 @@ public:
enum class FrametimeType {
DtTimeAvg = 0,
FPS,
FPSAvg
FPSAvg,
None
};
RenderEngine();
@@ -111,8 +112,8 @@ public:
void registerScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void unregisterScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void unregisterScreenSpaceRenderable(std::string name);
std::shared_ptr<ScreenSpaceRenderable> screenSpaceRenderable(std::string name);
void unregisterScreenSpaceRenderable(const std::string& name);
std::shared_ptr<ScreenSpaceRenderable> screenSpaceRenderable(const std::string& name);
std::vector<ScreenSpaceRenderable*> screenSpaceRenderables() const;
std::unique_ptr<ghoul::opengl::ProgramObject> buildRenderProgram(
@@ -171,8 +172,6 @@ public:
// Temporary fade functionality
void startFading(int direction, float fadeDuration);
void sortScreenspaceRenderables();
glm::ivec2 renderingResolution() const;
glm::ivec2 fontResolution() const;
@@ -180,7 +179,7 @@ public:
private:
void setRenderer(std::unique_ptr<Renderer> renderer);
RendererImplementation rendererFromString(const std::string& method);
RendererImplementation rendererFromString(const std::string& method) const;
void renderInformation();
@@ -189,7 +188,7 @@ private:
std::unique_ptr<RaycasterManager> _raycasterManager;
std::unique_ptr<DeferredcasterManager> _deferredcasterManager;
properties::BoolProperty _performanceMeasurements;
properties::BoolProperty _doPerformanceMeasurements;
std::unique_ptr<performance::PerformanceManager> _performanceManager;
std::unique_ptr<Renderer> _renderer;

View File

@@ -47,10 +47,13 @@ public:
virtual ~Scale() = default;
virtual bool initialize();
virtual double scaleValue() const = 0;
virtual double scaleValue() const;
virtual void update(const UpdateData& data);
static documentation::Documentation Documentation();
protected:
double _scale;
};
} // namespace openspace

View File

@@ -32,9 +32,12 @@
#include <set>
#include <mutex>
#include <openspace/scene/scenelicense.h>
#include <openspace/scene/scenelicensewriter.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/util/camera.h>
#include <openspace/util/updatestructures.h>
#include <openspace/scripting/scriptengine.h>
#include <ghoul/opengl/programobject.h>
namespace ghoul { class Dictionary; }
@@ -122,6 +125,8 @@ public:
*/
void removeNode(SceneGraphNode* node, UpdateDependencies updateDeps = UpdateDependencies::Yes);
void addSceneLicense(SceneLicense license);
/**
* Update dependencies.
*/
@@ -132,6 +137,14 @@ public:
*/
const std::vector<SceneGraphNode*>& allSceneGraphNodes() const;
/**
* Write information about the license information for the scenegraph nodes that are
* contained in this scene
* \param path The file path that will contain the documentation about the licenses
* used in this scene
*/
void writeSceneLicenseDocumentation(const std::string& path) const;
/**
* Return a a map from name to scene graph node.
*/
@@ -160,6 +173,8 @@ private:
std::vector<SceneGraphNode*> _circularNodes;
std::map<std::string, SceneGraphNode*> _nodesByName;
std::vector<SceneLicense> _licenses;
std::mutex _programUpdateLock;
std::set<ghoul::opengl::ProgramObject*> _programsToUpdate;
std::vector<std::unique_ptr<ghoul::opengl::ProgramObject>> _programs;

View File

@@ -0,0 +1,58 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 __OPENSPACE_CORE___SCENELICENSE___H__
#define __OPENSPACE_CORE___SCENELICENSE___H__
#include <openspace/documentation/documentation.h>
#include <string>
#include <vector>
namespace ghoul {
class Dictionary;
} // namespace ghoul
namespace openspace {
struct SceneLicense {
// module must not be empty
SceneLicense(const ghoul::Dictionary& dictionary, std::string module);
std::string module;
std::string name;
std::string attribution;
std::string url;
std::string licenseText;
static documentation::Documentation Documentation();
};
void writeSceneLicenseDocumentation(const std::vector<SceneLicense>& licenses,
const std::string& file, const std::string& type);
} // namespace openspace
#endif // __OPENSPACE_CORE___SCENELICENSE___H__

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* Copyright (c) 2014-2017 *
* *
* 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 *
@@ -21,20 +21,28 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___SCENELICENSEWRITER___H__
#define __OPENSPACE_CORE___SCENELICENSEWRITER___H__
#include "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
#include <openspace/documentation/documentationgenerator.h>
in vec4 vs_positionScreenSpace;
in vec4 vs_pointColor;
#include <openspace/scene/scenelicense.h>
#include <vector>
Fragment getFragment() {
if (vs_pointColor.a < 0.01) {
discard;
}
Fragment frag;
frag.color = vs_pointColor;
frag.depth = vs_positionScreenSpace.w;
return frag;
}
namespace openspace {
class SceneLicenseWriter : public DocumentationGenerator {
public:
SceneLicenseWriter(const std::vector<SceneLicense>& licenses);
private:
std::string generateJson() const override;
const std::vector<SceneLicense>& _licenses;
};
} // namespace openspace
#endif // __OPENSPACE_CORE___SCENELICENSEWRITER___H__

View File

@@ -26,6 +26,7 @@
#define __OPENSPACE_CORE___SCENELOADER___H__
#include <openspace/scene/scenegraphnode.h>
#include <openspace/scene/scenelicense.h>
#include <openspace/util/camera.h>
#include <ghoul/misc/dictionary.h>
@@ -33,6 +34,7 @@
#include <memory>
#include <string>
#include <utility>
namespace openspace {
@@ -51,7 +53,8 @@ public:
/**
* Import a directory of scene contents into an existing scene.
*/
std::vector<SceneGraphNode*> importDirectory(Scene& scene, const std::string& directory);
std::pair<std::vector<SceneGraphNode*>, std::vector<SceneLicense>>
importDirectory(Scene& scene, const std::string& directory);
/**
* Import a scene graph node from a dictionary into an existing scene.
@@ -98,10 +101,16 @@ private:
*/
std::vector<SceneLoader::LoadedNode> loadModule(const std::string& path, lua_State* luaState);
/**
* Loads an existing license file
*/
std::vector<SceneLicense> loadLicense(const std::string& path, std::string module);
/**
* Load a directory.
*/
std::vector<SceneLoader::LoadedNode> loadDirectory(const std::string& path, lua_State* luaState);
std::pair<std::vector<SceneLoader::LoadedNode>, std::vector<SceneLicense>>
loadDirectory(const std::string& path, lua_State* luaState);
/**
* Load a camera from a dictionary

View File

@@ -48,7 +48,7 @@ public:
virtual ~Translation() = default;
virtual bool initialize();
virtual glm::dvec3 position() const = 0;
virtual glm::dvec3 position() const;
virtual void update(const UpdateData& data);
glm::dvec3 position(double time);
@@ -63,6 +63,8 @@ protected:
void notifyObservers();
std::function<void()> _onParameterChangeCallback;
glm::dvec3 _positionValue;
};
} // namespace openspace

View File

@@ -59,10 +59,10 @@ public:
TransformationManager();
~TransformationManager();
glm::dmat3 frameTransformationMatrix(std::string from, std::string to, double ephemerisTime) const;
glm::dmat3 frameTransformationMatrix(const std::string& from, const std::string& to, double ephemerisTime) const;
private:
glm::dmat3 kameleonTransformationMatrix(std::string from, std::string to, double ephemerisTime) const;
glm::dmat3 kameleonTransformationMatrix(const std::string& from, const std::string& to, double ephemerisTime) const;
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
std::shared_ptr<ccmc::Kameleon> _kameleon;

View File

@@ -37,8 +37,11 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimagelocal.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimageonline.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/luatranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/rotation/luarotation.h
${CMAKE_CURRENT_SOURCE_DIR}/rotation/staticrotation.h
${CMAKE_CURRENT_SOURCE_DIR}/scale/luascale.h
${CMAKE_CURRENT_SOURCE_DIR}/scale/staticscale.h
)
source_group("Header Files" FILES ${HEADER_FILES})
@@ -56,8 +59,11 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimagelocal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimageonline.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/luatranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rotation/luarotation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rotation/staticrotation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/scale/luascale.cpp
${CMAKE_CURRENT_SOURCE_DIR}/scale/staticscale.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})
@@ -67,13 +73,8 @@ set(SHADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/shaders/imageplane_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/path_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/path_gs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/path_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/plane_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/plane_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/pscstandard_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/pscstandard_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderabletrail_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderabletrail_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/screenspace_fs.glsl

View File

@@ -43,10 +43,13 @@
#include <modules/base/rendering/screenspaceimageonline.h>
#include <modules/base/rendering/screenspaceframebuffer.h>
#include <modules/base/translation/luatranslation.h>
#include <modules/base/translation/statictranslation.h>
#include <modules/base/rotation/luarotation.h>
#include <modules/base/rotation/staticrotation.h>
#include <modules/base/scale/luascale.h>
#include <modules/base/scale/staticscale.h>
#include <ghoul/filesystem/filesystem>
@@ -85,16 +88,19 @@ void BaseModule::internalInitialize() {
auto fTranslation = FactoryManager::ref().factory<Translation>();
ghoul_assert(fTranslation, "Ephemeris factory was not created");
fTranslation->registerClass<LuaTranslation>("LuaTranslation");
fTranslation->registerClass<StaticTranslation>("StaticTranslation");
auto fRotation = FactoryManager::ref().factory<Rotation>();
ghoul_assert(fRotation, "Rotation factory was not created");
fRotation->registerClass<LuaRotation>("LuaRotation");
fRotation->registerClass<StaticRotation>("StaticRotation");
auto fScale = FactoryManager::ref().factory<Scale>();
ghoul_assert(fScale, "Scale factory was not created");
fScale->registerClass<LuaScale>("LuaScale");
fScale->registerClass<StaticScale>("StaticScale");
auto fModelGeometry = FactoryManager::ref().factory<modelgeometry::ModelGeometry>();
@@ -112,8 +118,11 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
ScreenSpaceFramebuffer::Documentation(),
ScreenSpaceImageLocal::Documentation(),
ScreenSpaceImageOnline::Documentation(),
LuaRotation::Documentation(),
StaticRotation::Documentation(),
LuaScale::Documentation(),
StaticScale::Documentation(),
LuaTranslation::Documentation(),
StaticTranslation::Documentation(),
modelgeometry::ModelGeometry::Documentation(),
};

View File

@@ -38,7 +38,6 @@
namespace {
const char* KeyName = "Name";
const char* KeyUrl = "URL";
static const openspace::properties::Property::PropertyInfo TexturePathInfo = {
"TexturePath",

View File

@@ -0,0 +1,133 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/rotation/luarotation.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/filesystem/filesystem.h>
#include <chrono>
namespace {
static const openspace::properties::Property::PropertyInfo ScriptInfo = {
"Script",
"Script",
"This value is the path to the Lua script that will be executed to compute the "
"rotation for this transformation. The script needs to define a function "
"'rotation' that takes the current simulation time in seconds past the J2000 "
"epoch as the first argument, the current wall time as milliseconds past the "
"J2000 epoch as the second argument and computes the rotation returned as 9 "
"values."
};} // namespace
namespace openspace {
documentation::Documentation LuaRotation::Documentation() {
using namespace openspace::documentation;
return {
"Lua Rotation",
"base_transform_rotation_lua",
{
{
"Type",
new StringEqualVerifier("LuaRotation"),
Optional::No
},
{
ScriptInfo.identifier,
new StringVerifier,
Optional::No,
ScriptInfo.description
}
}
};
}
LuaRotation::LuaRotation()
: _luaScriptFile(ScriptInfo)
, _state(false)
{
addProperty(_luaScriptFile);
}
LuaRotation::LuaRotation(const ghoul::Dictionary& dictionary)
: LuaRotation()
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"LuaRotation"
);
_luaScriptFile = absPath(dictionary.value<std::string>(ScriptInfo.identifier));
}
void LuaRotation::update(const UpdateData& data) {
ghoul::lua::runScriptFile(_state, _luaScriptFile);
// Get the scaling function
lua_getglobal(_state, "rotation");
bool isFunction = lua_isfunction(_state, -1);
if (!isFunction) {
LERRORC(
"LuaRotation",
"Script '" << _luaScriptFile << "' does not have a function 'rotation'"
);
return;
}
// First argument is the number of seconds past the J2000 epoch in ingame time
lua_pushnumber(_state, data.time.j2000Seconds());
// Second argument is the number of milliseconds past the J2000 epoch in wallclock
using namespace std::chrono;
auto now = high_resolution_clock::now();
lua_pushnumber(
_state,
duration_cast<milliseconds>(now.time_since_epoch()).count()
);
// Execute the scaling function
int success = lua_pcall(_state, 2, 9, 0);
if (success != 0) {
LERRORC(
"LuaScale",
"Error executing 'rotation': " << lua_tostring(_state, -1)
);
}
double values[9];
for (int i = 0; i < 9; ++i) {
values[i] = luaL_checknumber(_state, -1 - i);
}
_matrix = glm::make_mat3(values);
}
} // namespace openspace

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* Copyright (c) 2014-2017 *
* *
* 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 *
@@ -22,32 +22,33 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
#ifndef __OPENSPACE_MODULE_BASE___LUAROTATION___H__
#define __OPENSPACE_MODULE_BASE___LUAROTATION___H__
#include "PowerScaling/powerScaling_vs.hglsl"
#include <openspace/scene/rotation.h>
layout(location = 0) in vec4 in_position;
layout(location = 1) in vec2 in_st;
layout(location = 2) in vec3 in_normal;
#include <openspace/properties/stringproperty.h>
out vec2 vs_st;
out vec4 vs_normal;
out vec4 vs_position;
#include <ghoul/lua/luastate.h>
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
void main() {
vs_st = in_st;
vs_position = in_position;
vec4 tmp = in_position;
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
namespace openspace {
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}
namespace documentation { struct Documentation; }
class LuaRotation : public Rotation {
public:
LuaRotation();
LuaRotation(const ghoul::Dictionary& dictionary);
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
private:
properties::StringProperty _luaScriptFile;
ghoul::lua::LuaState _state;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___LUAROTATION___H__

View File

@@ -0,0 +1,119 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/scale/luascale.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/filesystem/filesystem.h>
#include <chrono>
namespace {
static const openspace::properties::Property::PropertyInfo ScriptInfo = {
"Script",
"Script",
"This value is the path to the Lua script that will be executed to compute the "
"scaling factor for this transformation. The script needs to define a function "
"'scale' that takes the current simulation time in seconds past the J2000 epoch "
"as the first argument, the current wall time as milliseconds past the J2000 "
"epoch the second argument and computes the scaling factor."
};
} // namespace
namespace openspace {
documentation::Documentation LuaScale::Documentation() {
using namespace openspace::documentation;
return {
"Lua Scaling",
"base_scale_lua",
{
{
ScriptInfo.identifier,
new StringVerifier,
Optional::No,
ScriptInfo.description
}
}
};
}
LuaScale::LuaScale()
: _luaScriptFile(ScriptInfo)
, _state(false)
{
addProperty(_luaScriptFile);
}
LuaScale::LuaScale(const ghoul::Dictionary& dictionary)
: LuaScale()
{
documentation::testSpecificationAndThrow(Documentation(), dictionary, "LuaScale");
_luaScriptFile = absPath(dictionary.value<std::string>(ScriptInfo.identifier));
}
void LuaScale::update(const UpdateData& data) {
ghoul::lua::runScriptFile(_state, _luaScriptFile);
// Get the scaling function
lua_getglobal(_state, "scale");
bool isFunction = lua_isfunction(_state, -1);
if (!isFunction) {
LERRORC(
"LuaScale",
"Script '" << _luaScriptFile << "' does not have a function 'scale'"
);
return;
}
// First argument is the number of seconds past the J2000 epoch in ingame time
lua_pushnumber(_state, data.time.j2000Seconds());
// Second argument is the number of milliseconds past the J2000 epoch in wallclock
using namespace std::chrono;
auto now = high_resolution_clock::now();
lua_pushnumber(
_state,
duration_cast<milliseconds>(now.time_since_epoch()).count()
);
// Execute the scaling function
int success = lua_pcall(_state, 2, 1, 0);
if (success != 0) {
LERRORC(
"LuaScale",
"Error executing 'scale': " << lua_tostring(_state, -1)
);
}
_scale = luaL_checknumber(_state, -1);
}
} // namespace openspace

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* Copyright (c) 2014-2017 *
* *
* 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 *
@@ -22,43 +22,33 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
#ifndef __OPENSPACE_MODULE_BASE___LUASCALE___H__
#define __OPENSPACE_MODULE_BASE___LUASCALE___H__
#include "PowerScaling/powerScalingMath.hglsl"
#include <${SHADERS_GENERATED}/constants.hglsl>:notrack
#include <openspace/scene/scale.h>
layout(points) in;
layout(location = 0) in vec4 vs_point_position[];
layout(location = 1) in flat int isHour[];
layout(location = 2) in vec4 vs_point_color[];
#include <openspace/properties/stringproperty.h>
layout(points, max_vertices = 4) out;
layout(location = 0) out vec4 gs_point_position;
layout(location = 1) out vec4 gs_point_color;
#include <ghoul/lua/luastate.h>
uniform mat4 projection;
uniform mat4 ViewProjection;
namespace openspace {
namespace documentation { struct Documentation; }
class LuaScale : public Scale {
public:
LuaScale();
LuaScale(const ghoul::Dictionary& dictionary);
const vec2 corners[4] = vec2[4](
vec2(0.0, 1.0),
vec2(0.0, 0.0),
vec2(1.0, 1.0),
vec2(1.0, 0.0)
);
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
void main() {
gs_point_color = vs_point_color[0];
gs_point_position = vs_point_position[0];
if (isHour[0] == 1) {
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
}
else {
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
return;
}
}
private:
properties::StringProperty _luaScriptFile;
ghoul::lua::LuaState _state;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___LUASCALE___H__

View File

@@ -58,6 +58,8 @@ StaticScale::StaticScale()
: _scaleValue(ScaleInfo, 1.0, 1.0, 1e6)
{
addProperty(_scaleValue);
_scaleValue.onChange([&](){ _scale = _scaleValue; });
}
StaticScale::StaticScale(const ghoul::Dictionary& dictionary)
@@ -68,8 +70,4 @@ StaticScale::StaticScale(const ghoul::Dictionary& dictionary)
_scaleValue = static_cast<float>(dictionary.value<double>(ScaleInfo.identifier));
}
double StaticScale::scaleValue() const {
return _scaleValue;
}
} // namespace openspace

View File

@@ -38,8 +38,6 @@ public:
StaticScale();
StaticScale(const ghoul::Dictionary& dictionary);
double scaleValue() const override;
static documentation::Documentation Documentation();
private:

View File

@@ -29,7 +29,6 @@ in float vs_screenSpaceDepth;
uniform sampler2D texture1;
Fragment getFragment() {
Fragment frag;

View File

@@ -0,0 +1,141 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/translation/luatranslation.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/filesystem/filesystem.h>
#include <chrono>
namespace {
static const openspace::properties::Property::PropertyInfo ScriptInfo = {
"Script",
"Script",
"This value is the path to the Lua script that will be executed to compute the "
"translation for this transformation. The script needs to define a function "
"'translate' that takes the current simulation time in seconds past the J2000 "
"epoch as the first argument, the current wall time as milliseconds past the "
"J2000 epoch as the second argument and computes the translation."
};
} // namespace
namespace openspace {
documentation::Documentation LuaTranslation::Documentation() {
using namespace documentation;
return {
"Lua Translation",
"base_transform_translation_lua",
{
{
"Type",
new StringEqualVerifier("LuaTranslation"),
Optional::No
},
{
ScriptInfo.identifier,
new StringVerifier,
Optional::No,
ScriptInfo.description
}
}
};
}
LuaTranslation::LuaTranslation()
: _luaScriptFile(ScriptInfo)
, _state(false)
{
addProperty(_luaScriptFile);
_luaScriptFile.onChange([&](){
_fileHandle = std::make_unique<ghoul::filesystem::File>(_luaScriptFile);
_fileHandle->setCallback([&](const ghoul::filesystem::File&){
notifyObservers();
});
});
}
LuaTranslation::LuaTranslation(const ghoul::Dictionary& dictionary)
: LuaTranslation()
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"StaticTranslation"
);
_luaScriptFile = absPath(dictionary.value<std::string>(ScriptInfo.identifier));
}
void LuaTranslation::update(const UpdateData& data) {
ghoul::lua::runScriptFile(_state, _luaScriptFile);
// Get the scaling function
lua_getglobal(_state, "translation");
bool isFunction = lua_isfunction(_state, -1);
if (!isFunction) {
LERRORC(
"LuaScale",
"Script '" << _luaScriptFile << "' does not have a function 'translation'"
);
return;
}
// First argument is the number of seconds past the J2000 epoch in ingame time
lua_pushnumber(_state, data.time.j2000Seconds());
// Second argument is the number of milliseconds past the J2000 epoch in wallclock
using namespace std::chrono;
auto now = high_resolution_clock::now();
lua_pushnumber(
_state,
duration_cast<milliseconds>(now.time_since_epoch()).count()
);
// Execute the scaling function
int success = lua_pcall(_state, 2, 3, 0);
if (success != 0) {
LERRORC(
"LuaScale",
"Error executing 'translation': " << lua_tostring(_state, -1)
);
}
double values[3];
for (int i = 0; i < 3; ++i) {
values[i] = luaL_checknumber(_state, -1 - i);
}
_positionValue = glm::make_vec3(values);
}
} // namespace openspace

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* Copyright (c) 2014-2017 *
* *
* 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 *
@@ -22,42 +22,38 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
#ifndef __OPENSPACE_MODULE_BASE___LUATRANSLATION___H__
#define __OPENSPACE_MODULE_BASE___LUATRANSLATION___H__
#include "PowerScaling/powerScaling_vs.hglsl"
#include <openspace/scene/translation.h>
in vec4 in_point_position;
#include <openspace/properties/stringproperty.h>
out vec4 vs_positionScreenSpace;
out vec4 vs_pointColor;
#include <ghoul/filesystem/file.h>
#include <ghoul/lua/luastate.h>
uniform vec3 color;
uniform mat4 modelViewTransform;
uniform mat4 projectionTransform;
uniform int pointSteps;
#include <memory>
namespace openspace {
void main() {
vec4 positionCameraSpace = modelViewTransform * in_point_position;
vec4 positionClipSpace = projectionTransform * positionCameraSpace;
vs_positionScreenSpace = z_normalization(positionClipSpace);
namespace documentation { struct Documentation; }
class LuaTranslation : public Translation {
public:
LuaTranslation();
LuaTranslation(const ghoul::Dictionary& dictionary);
gl_Position = vs_positionScreenSpace;
virtual void update(const UpdateData& data) override;
if (mod(gl_VertexID, pointSteps) == 0) {
vs_pointColor.rgb = color;
gl_PointSize = 5.0f;
}
else {
vs_pointColor.rgb = (color + vec3(0.6, 0.6, 0.6)) / 2.0;
gl_PointSize = 2.f;
}
static documentation::Documentation Documentation();
// I don't like this random variable k defined in powerScalingMath.hglsl.
// Will ignore it and use 10 in protest of psc dependencies. /KB
// float maximumDistance = pow(k, 10);
float maximumDistance = pow(10, 10);
float distanceToCamera = length(positionCameraSpace.xyz);
private:
properties::StringProperty _luaScriptFile;
ghoul::lua::LuaState _state;
vs_pointColor.a = maximumDistance / (distanceToCamera / 100.0);
}
std::unique_ptr<ghoul::filesystem::File> _fileHandle;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___LUATRANSLATION___H__

View File

@@ -69,6 +69,8 @@ StaticTranslation::StaticTranslation()
)
{
addProperty(_position);
_position.onChange([&](){ _positionValue = _position; });
}
StaticTranslation::StaticTranslation(const ghoul::Dictionary& dictionary)
@@ -83,8 +85,4 @@ StaticTranslation::StaticTranslation(const ghoul::Dictionary& dictionary)
_position = dictionary.value<glm::dvec3>(PositionInfo.identifier);
}
glm::dvec3 StaticTranslation::position() const {
return _position;
}
} // namespace openspace

View File

@@ -38,8 +38,6 @@ public:
StaticTranslation();
StaticTranslation(const ghoul::Dictionary& dictionary);
virtual glm::dvec3 position() const override;
static documentation::Documentation Documentation();
private:

View File

@@ -671,8 +671,8 @@ void RenderableBillboardsCloud::renderLabels(const RenderData& data, const glm::
scale = 306391534.73091 * PARSEC;
break;
}
for (const auto pair : _labelData) {
for (const std::pair<glm::vec3, std::string>& pair : _labelData) {
//glm::vec3 scaledPos(_transformationMatrix * glm::dvec4(pair.first, 1.0));
glm::vec3 scaledPos(pair.first);
scaledPos *= scale;
@@ -690,8 +690,7 @@ void RenderableBillboardsCloud::renderLabels(const RenderData& data, const glm::
_renderOption.value(),
"%s",
pair.second.c_str());
}
}
}
void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) {

View File

@@ -235,15 +235,15 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f)
//, _pointColor(ColorInfo, glm::vec3(1.f, 0.4f, 0.2f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(1.0f, 1.0f, 1.0f))
, _drawLabels(DrawLabelInfo, false)
, _textColor(
TextColorInfo,
glm::vec4(1.0f, 1.0, 1.0f, 1.f),
glm::vec4(0.f),
glm::vec4(1.f)
)
, _textSize(TextSizeInfo, 8.0, 0.5, 24.0)
, _textSize(TextSizeInfo, 8.0, 0.5, 24.0)
, _drawElements(DrawElementsInfo, true)
, _drawLabels(DrawLabelInfo, false)
, _renderOption(RenderOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
, _program(nullptr)
, _fontRenderer(nullptr)
@@ -251,10 +251,8 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
, _speckFile("")
, _labelFile("")
, _unit(Parsec)
, _nValuesPerAstronomicalObject(0)
, _nValuesPerAstronomicalObject(0)
{
using File = ghoul::filesystem::File;
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
@@ -382,7 +380,6 @@ void RenderableDUMeshes::initialize() {
bool success = loadData();
if (!success) {
throw ghoul::RuntimeError("Error loading data");
return;
}
createMeshes();
@@ -400,7 +397,7 @@ void RenderableDUMeshes::initialize() {
}
void RenderableDUMeshes::deinitialize() {
for (auto pair : _renderingMeshesMap) {
for (const std::pair<int, RenderingMesh>& pair : _renderingMeshesMap) {
for (int i = 0; i < pair.second.numU; ++i) {
glDeleteVertexArrays(1, &pair.second.vaoArray[i]);
glDeleteBuffers(1, &pair.second.vboArray[i]);
@@ -414,8 +411,10 @@ void RenderableDUMeshes::deinitialize() {
}
}
void RenderableDUMeshes::renderMeshes(const RenderData& data, const glm::dmat4& modelViewMatrix,
const glm::dmat4& projectionMatrix) {
void RenderableDUMeshes::renderMeshes(const RenderData&,
const glm::dmat4& modelViewMatrix,
const glm::dmat4& projectionMatrix)
{
// Saving current OpenGL state
GLboolean blendEnabled = glIsEnabled(GL_BLEND);
GLenum blendEquationRGB;
@@ -514,7 +513,7 @@ void RenderableDUMeshes::renderLabels(const RenderData& data, const glm::dmat4&
break;
}
for (const auto pair : _labelData) {
for (const std::pair<glm::vec3, std::string>& pair : _labelData) {
//glm::vec3 scaledPos(_transformationMatrix * glm::dvec4(pair.first, 1.0));
glm::vec3 scaledPos(pair.first);
scaledPos *= scale;

View File

@@ -154,7 +154,7 @@ private:
glm::dmat4 _transformationMatrix;
std::unordered_map<int, glm::vec3> _meshColorMap;
std::unordered_map<int, RenderingMesh> _renderingMeshesMap;
std::unordered_map<int, RenderingMesh> _renderingMeshesMap;
};

View File

@@ -278,8 +278,6 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
, _sluminosity(1.f)
, _transformationMatrix(glm::dmat4(1.0))
{
using File = ghoul::filesystem::File;
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
@@ -431,7 +429,6 @@ void RenderablePlanesCloud::initialize() {
bool success = loadData();
if (!success) {
throw ghoul::RuntimeError("Error loading data");
return;
}
createPlanes();
@@ -468,8 +465,10 @@ void RenderablePlanesCloud::deinitialize() {
}
}
void RenderablePlanesCloud::renderPlanes(const RenderData& data, const glm::dmat4& modelViewMatrix,
const glm::dmat4& projectionMatrix) {
void RenderablePlanesCloud::renderPlanes(const RenderData&,
const glm::dmat4& modelViewMatrix,
const glm::dmat4& projectionMatrix)
{
// Saving current OpenGL state
GLboolean blendEnabled = glIsEnabled(GL_BLEND);
GLenum blendEquationRGB;
@@ -580,7 +579,7 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data, const glm::dmat
break;
}
for (const auto pair : _labelData) {
for (const std::pair<glm::vec3, std::string>& pair : _labelData) {
//glm::vec3 scaledPos(_transformationMatrix * glm::dvec4(pair.first, 1.0));
glm::vec3 scaledPos(pair.first);
scaledPos *= scale;

View File

@@ -168,6 +168,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layeradjustment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layergroup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layergroupid.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layermanager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layerrendersettings.cpp

View File

@@ -221,6 +221,8 @@ int loadWMSCapabilities(lua_State* L) {
std::move(globe),
std::move(url)
);
return 0;
}
int removeWMSServer(lua_State* L) {

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* Copyright (c) 2014-2017 *
* *
* 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 *
@@ -22,54 +22,48 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
#include <modules/globebrowsing/rendering/layer/layergroupid.h>
in vec2 vs_st;
in vec4 vs_normal;
in vec4 vs_position;
namespace openspace::globebrowsing::layergroupid {
uniform vec4 campos;
uniform vec4 objpos;
uniform vec3 sun_pos;
uniform bool _performShading = true;
uniform float transparency;
uniform int shadows;
uniform float time;
uniform sampler2D texture1;
Fragment getFragment() {
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse = texture(texture1, vs_st);
Fragment frag;
if (_performShading) {
vec3 n = normalize(vs_normal.xyz);
vec3 l_pos = vec3(sun_pos); // sun.
vec3 l_dir = normalize(l_pos - objpos.xyz);
float intensity = min(max(5 * dot(n,l_dir), 0.0), 1);
// float shine = 0.0001;
const vec4 specular = vec4(0.5);
vec4 ambient = vec4(0.0, 0.0, 0.0, transparency);
/*
if(intensity > 0.f){
// halfway vector
vec3 h = normalize(l_dir + e);
// specular factor
float intSpec = max(dot(h,n),0.0);
spec = specular * pow(intSpec, shine);
TypeID getTypeIDFromTypeString(const std::string& typeString) {
for (int i = 0; i < NUM_LAYER_TYPES; ++i) {
if (typeString == LAYER_TYPE_NAMES[i]) {
return static_cast<TypeID>(i);
}
*/
diffuse = max(intensity * diffuse, ambient);
}
frag.color.rgb = diffuse.rgb;
frag.color.a = transparency;
frag.depth = depth;
return frag;
return TypeID::Unknown;
}
layergroupid::GroupID getGroupIDFromName(const std::string& layerGroupName) {
for (int i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) {
if (layerGroupName == layergroupid::LAYER_GROUP_NAMES[i]) {
return static_cast<layergroupid::GroupID>(i);
}
}
return GroupID::Unknown;
}
layergroupid::AdjustmentTypeID getAdjustmentTypeIDFromName(
const std::string& adjustmentTypeName)
{
for (int i = 0; i < layergroupid::NUM_ADJUSTMENT_TYPES; ++i) {
if (adjustmentTypeName == layergroupid::ADJUSTMENT_TYPE_NAMES[i]) {
return static_cast<layergroupid::AdjustmentTypeID>(i);
}
}
return AdjustmentTypeID::None;
}
layergroupid::BlendModeID getBlendModeIDFromName(
const std::string& blendModeName)
{
for (int i = 0; i < layergroupid::NUM_BLEND_MODES; ++i) {
if (blendModeName == layergroupid::BLEND_MODE_NAMES[i]) {
return static_cast<layergroupid::BlendModeID>(i);
}
}
return BlendModeID::Normal;
}
} // namespace openspace::globebrowsing::layergroupid

View File

@@ -110,45 +110,15 @@ enum class BlendModeID {
Color = 4,
};
static TypeID getTypeIDFromTypeString(std::string typeString) {
for (int i = 0; i < NUM_LAYER_TYPES; ++i) {
if (typeString == LAYER_TYPE_NAMES[i]) {
return static_cast<TypeID>(i);
}
}
return TypeID::Unknown;
}
TypeID getTypeIDFromTypeString(const std::string& typeString);
static layergroupid::GroupID getGroupIDFromName(std::string layerGroupName) {
for (int i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) {
if (layerGroupName == layergroupid::LAYER_GROUP_NAMES[i]) {
return static_cast<layergroupid::GroupID>(i);
}
}
return GroupID::Unknown;
}
layergroupid::GroupID getGroupIDFromName(const std::string& layerGroupName);
static layergroupid::AdjustmentTypeID getAdjustmentTypeIDFromName(
std::string adjustmentTypeName)
{
for (int i = 0; i < layergroupid::NUM_ADJUSTMENT_TYPES; ++i) {
if (adjustmentTypeName == layergroupid::ADJUSTMENT_TYPE_NAMES[i]) {
return static_cast<layergroupid::AdjustmentTypeID>(i);
}
}
return AdjustmentTypeID::None;
}
layergroupid::AdjustmentTypeID getAdjustmentTypeIDFromName(
const std::string& adjustmentTypeName);
static layergroupid::BlendModeID getBlendModeIDFromName(
std::string blendModeName)
{
for (int i = 0; i < layergroupid::NUM_BLEND_MODES; ++i) {
if (blendModeName == layergroupid::BLEND_MODE_NAMES[i]) {
return static_cast<layergroupid::BlendModeID>(i);
}
}
return BlendModeID::Normal;
}
layergroupid::BlendModeID getBlendModeIDFromName(
const std::string& blendModeName);
} // namespace openspace::globebrowsing::layergroupid

View File

@@ -162,19 +162,25 @@ openspace.globebrowsing.parseInfoFile = function (file)
local dir = openspace.directoryForPath(file)
dofile(file)
local color = {
Name = Name,
Description = Description or "",
FilePath = dir .. '/' .. ColorFile,
BlendMode = "Color"
}
local color = nil
if ColorFile then
color = {
Name = Name,
Description = Description or "",
FilePath = dir .. '/' .. ColorFile,
BlendMode = "Color"
}
end
local height = {
Name = Name,
Description = Description or "",
FilePath = dir .. '/' .. HeightFile,
TilePixelSize = 90
}
local height = nil
if HeightFile then
local height = {
Name = Name,
Description = Description or "",
FilePath = dir .. '/' .. HeightFile,
TilePixelSize = 90
}
end
return color, height
end
@@ -186,8 +192,12 @@ openspace.globebrowsing.addBlendingLayersFromDirectory = function (dir, node_nam
if file:find('.info') then
c, h = openspace.globebrowsing.parseInfoFile(file)
openspace.globebrowsing.addLayer(node_name, "ColorLayers", c)
openspace.globebrowsing.addLayer(node_name, "HeightLayers", h)
if c then
openspace.globebrowsing.addLayer(node_name, "ColorLayers", c)
end
if h then
openspace.globebrowsing.addLayer(node_name, "HeightLayers", h)
end
end
end
end

View File

@@ -41,7 +41,7 @@ namespace openspace::globebrowsing {
/**
* Function for passing GDAL error messages to the GHOUL logging system.
*/
static void gdalErrorHandler(CPLErr eErrClass, int errNo, const char* msg);
void gdalErrorHandler(CPLErr eErrClass, int errNo, const char* msg);
/**
* Singleton class interfacing with global GDAL functions.

View File

@@ -64,7 +64,6 @@ void GuiGlobeBrowsingComponent::render() {
using Layer = GlobeBrowsingModule::Layer;
bool e = _isEnabled;
e = e;
ImGui::Begin("Globe Browsing", &e, WindowSize, 0.5f);
_isEnabled = e;

View File

@@ -47,7 +47,7 @@ namespace {
openspace::MissionPhase::Trace t = mission.phaseTrace(currentTime, 0);
int treeOption = t.empty() ? 0 : ImGuiTreeNodeFlags_DefaultOpen;
if (ImGui::TreeNodeEx(("%s" + missionHashname).c_str(), treeOption, mission.name().c_str())) {
if (ImGui::TreeNodeEx(("%s" + missionHashname).c_str(), treeOption, "%s", mission.name().c_str())) {
if (!mission.description().empty()) {
ImGui::Text("%s", mission.description().c_str());
}

View File

@@ -147,8 +147,8 @@ namespace openspace::gui {
GuiPropertyComponent::GuiPropertyComponent(std::string name, UseTreeLayout useTree, IsTopLevelWindow topLevel)
: GuiComponent(std::move(name))
, _useTreeLayout(useTree)
, _isTopLevel(topLevel)
, _currentUseTreeLayout(useTree)
, _isTopLevel(topLevel)
{}
void GuiPropertyComponent::setSource(SourceFunction function) {

View File

@@ -139,10 +139,12 @@ void GuiSpaceTimeComponent::render() {
CaptionText("Time Controls");
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f);
ImGui::Text("Current Date: %s", OsEng.timeManager().time().UTC().c_str());
constexpr int BufferSize = 256;
static char Buffer[BufferSize];
bool dateChanged = ImGui::InputText(
"Date",
"Change Date",
Buffer,
BufferSize,
ImGuiInputTextFlags_EnterReturnsTrue
@@ -207,8 +209,26 @@ void GuiSpaceTimeComponent::render() {
incrementTime(-1);
}
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 55.f);
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 15.f);
bool nowDay = ImGui::Button("Now");
if (nowDay) {
std::string nowTime = Time::now().UTC();
// UTC returns a string of the type YYYY MMM DDTHH:mm:ss.xxx
// setTime doesn't like the T in it and wants a space instead
nowTime[11] = ' ';
OsEng.scriptEngine().queueScript(
"openspace.time.setTime(\"" + nowTime + "\")",
scripting::ScriptEngine::RemoteScripting::Yes
);
}
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 15.f);
bool plusDay = ImGui::Button("+Day");
if (plusDay) {
@@ -262,13 +282,6 @@ void GuiSpaceTimeComponent::render() {
);
}
auto setDeltaTime = [](std::chrono::seconds dt) {
OsEng.scriptEngine().queueScript(
"openspace.time.setDeltaTime(" + std::to_string(dt.count()) + ")",
scripting::ScriptEngine::RemoteScripting::Yes
);
};
bool minusDs = ImGui::Button("-1d/s");
if (minusDs) {
OsEng.scriptEngine().queueScript(

View File

@@ -274,8 +274,10 @@ bool RenderableConstellationBounds::loadVertexFile() {
std::string fileName = absPath(_vertexFilename);
std::ifstream file;
file.exceptions(std::ifstream::goodbit);
file.open(fileName);
if (!file.good()) {
return false;
}
ConstellationBound currentBound;
currentBound.constellationAbbreviation = "";

View File

@@ -36,7 +36,6 @@ out vec4 vs_position;
uniform mat4 modelViewProjectionTransform;
void main() {
vs_st = in_st;

View File

@@ -78,6 +78,7 @@ return {
KeyboardShortcuts = "${DOCUMENTATION}/KeyboardMapping.html",
Documentation = "${DOCUMENTATION}/Documentation.html",
FactoryDocumentation = "${DOCUMENTATION}/FactoryDocumentation.html",
LicenseDocumentation = "${DOCUMENTATION}/License.html",
-- CheckOpenGLState = true,
-- LogEachOpenGLCall = true,

View File

@@ -1,5 +1,7 @@
mark_interesting_nodes = function(nodes)
for _, n in pairs(nodes) do
openspace.addTag(n, "GUI.Interesting")
if openspace.hasSceneGraphNode(n) then
openspace.addTag(n, "GUI.Interesting")
end
end
end

View File

@@ -24,7 +24,6 @@
#version __CONTEXT__
#include "floatoperations.glsl"
#include <#{fragmentPath}>

View File

@@ -22,7 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
void getEntry(inout vec3 entryPos, inout float entryDepth) {
entryPos = cameraPosInRaycaster;
entryDepth = 0;

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
#version __CONTEXT__
in vec2 in_position;

View File

@@ -133,6 +133,8 @@ set(OPENSPACE_SOURCE
${OPENSPACE_BASE_DIR}/src/scene/scene.cpp
${OPENSPACE_BASE_DIR}/src/scene/scene_doc.inl
${OPENSPACE_BASE_DIR}/src/scene/scene_lua.inl
${OPENSPACE_BASE_DIR}/src/scene/scenelicense.cpp
${OPENSPACE_BASE_DIR}/src/scene/scenelicensewriter.cpp
${OPENSPACE_BASE_DIR}/src/scene/sceneloader.cpp
${OPENSPACE_BASE_DIR}/src/scene/scenemanager.cpp
${OPENSPACE_BASE_DIR}/src/scene/scenegraphnode.cpp
@@ -290,6 +292,8 @@ set(OPENSPACE_HEADER
${OPENSPACE_BASE_DIR}/include/openspace/scene/rotation.h
${OPENSPACE_BASE_DIR}/include/openspace/scene/scale.h
${OPENSPACE_BASE_DIR}/include/openspace/scene/scene.h
${OPENSPACE_BASE_DIR}/include/openspace/scene/scenelicense.h
${OPENSPACE_BASE_DIR}/include/openspace/scene/scenelicensewriter.h
${OPENSPACE_BASE_DIR}/include/openspace/scene/sceneloader.h
${OPENSPACE_BASE_DIR}/include/openspace/scene/scenemanager.h
${OPENSPACE_BASE_DIR}/include/openspace/scene/scenegraphnode.h

View File

@@ -30,6 +30,8 @@
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/invariants.h>
#include <ghoul/logging/logmanager.h>
#include <fstream>
namespace {
@@ -158,6 +160,12 @@ std::string escapedJson(const std::string& text) {
case '\\':
jsonString += "\\\\";
break;
case '\n':
jsonString += "\\\\n";
break;
case '\r':
jsonString += "\\r";
break;
default:
jsonString += c;
}

View File

@@ -58,6 +58,7 @@ const string ConfigurationManager::KeyPropertyDocumentation = "PropertyDocumenta
const string ConfigurationManager::KeyKeyboardShortcuts = "KeyboardShortcuts";
const string ConfigurationManager::KeyDocumentation = "Documentation";
const string ConfigurationManager::KeyFactoryDocumentation = "FactoryDocumentation";
const string ConfigurationManager::KeySceneLicenseDocumentation = "LicenseDocumentation";
const string ConfigurationManager::KeyConfigScene = "Scene";
const string ConfigurationManager::KeyConfigTasksRoot = "TasksRoot";

View File

@@ -200,6 +200,14 @@ documentation::Documentation ConfigurationManager::Documentation() {
"created in the current application configuration. Any previous file in this "
"location will be silently overritten."
},
{
ConfigurationManager::KeySceneLicenseDocumentation,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing the scene license "
"information. Any previous file in this location will be silently "
"overwritten."
},
{
ConfigurationManager::KeyLauncher,
new TableVerifier({

View File

@@ -48,6 +48,7 @@
#include <openspace/scene/scene.h>
#include <openspace/scene/rotation.h>
#include <openspace/scene/scale.h>
#include <openspace/scene/scenelicense.h>
#include <openspace/scene/translation.h>
#include <openspace/scene/scenemanager.h>
@@ -164,7 +165,6 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
}
, _scheduledSceneSwitch(false)
, _scenePath("")
, _runTime(0.0)
, _shutdown({false, 0.f, 0.f})
, _isFirstRenderingFirstFrame(true)
{
@@ -320,23 +320,17 @@ void OpenSpaceEngine::create(int argc, char** argv,
ConfigurationManager::KeyPerSceneCache
);
std::string cacheFolder = absPath("${CACHE}");
if (hasCacheCommandline) {
cacheFolder = commandlineArgumentPlaceholders.cacheFolder;
// @CLEANUP: Why is this commented out? ---abock
//FileSys.registerPathToken(
// "${CACHE}",
// commandlineArgumentPlaceholders.cacheFolder,
// ghoul::filesystem::FileSystem::Override::Yes
//);
}
if (hasCacheConfiguration) {
std::string scene = _engine->configurationManager().value<std::string>(
ConfigurationManager::KeyConfigScene
);
cacheFolder += "-" + ghoul::filesystem::File(scene).baseName();
}
if (hasCacheCommandline || hasCacheConfiguration) {
if (hasCacheCommandline) {
cacheFolder = commandlineArgumentPlaceholders.cacheFolder;
}
if (hasCacheConfiguration) {
std::string scene = _engine->configurationManager().value<std::string>(
ConfigurationManager::KeyConfigScene
);
cacheFolder += "-" + ghoul::filesystem::File(scene).baseName();
}
LINFO("Old cache: " << absPath("${CACHE}"));
LINFO("New cache: " << cacheFolder);
FileSys.registerPathToken(
@@ -347,8 +341,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
}
// Create directories that doesn't exist
auto tokens = FileSys.tokens();
for (const std::string& token : tokens) {
for (const std::string& token : FileSys.tokens()) {
if (!FileSys.directoryExists(token)) {
std::string p = absPath(token);
FileSys.createDirectory(p, ghoul::filesystem::FileSystem::Recursive::Yes);
@@ -377,9 +370,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
}
// Create the cachemanager
FileSys.createCacheManager(
absPath("${" + ConfigurationManager::KeyCache + "}"), CacheVersion
);
FileSys.createCacheManager(cacheFolder, CacheVersion);
// Register the provided shader directories
ghoul::opengl::ShaderPreprocessor::addIncludePath(absPath("${SHADERS}"));
@@ -445,7 +436,7 @@ void OpenSpaceEngine::initialize() {
glbinding::Binding::useCurrentContext();
glbinding::Binding::initialize();
// clear the screen so the user don't have to see old buffer contents from the
// clear the screen so the user doesn't have to see old buffer contents from the
// graphics card
LDEBUG("Clearing all Windows");
_windowWrapper->clearAllWindows(glm::vec4(0.f, 0.f, 0.f, 1.f));
@@ -645,6 +636,15 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) {
);
}
if (configurationManager().hasKey(ConfigurationManager::KeySceneLicenseDocumentation))
{
scene->writeSceneLicenseDocumentation(
absPath(configurationManager().value<std::string>(
ConfigurationManager::KeySceneLicenseDocumentation
))
);
}
// If a PropertyDocumentationFile was specified, generate it now.
if (configurationManager().hasKey(ConfigurationManager::KeyPropertyDocumentation)) {
scene->writeDocumentation(
@@ -902,10 +902,11 @@ void OpenSpaceEngine::initializeGL() {
}
LTRACE("OpenSpaceEngine::initializeGL::Console::initialize(end)");
const std::string key = ConfigurationManager::KeyOpenGLDebugContext;
if (_configurationManager->hasKey(key)) {
if (_configurationManager->hasKey(ConfigurationManager::KeyOpenGLDebugContext)) {
LTRACE("OpenSpaceEngine::initializeGL::DebugContext(begin)");
ghoul::Dictionary dict = _configurationManager->value<ghoul::Dictionary>(key);
ghoul::Dictionary dict = _configurationManager->value<ghoul::Dictionary>(
ConfigurationManager::KeyOpenGLDebugContext
);
bool debug = dict.value<bool>(ConfigurationManager::PartActivate);
// Debug output is not available before 4.3
@@ -925,7 +926,6 @@ void OpenSpaceEngine::initializeGL() {
setDebugOutput(DebugOutput(debug), SynchronousOutput(synchronous));
if (dict.hasKey(ConfigurationManager::PartFilterIdentifier)) {
ghoul::Dictionary filterDict = dict.value<ghoul::Dictionary>(
ConfigurationManager::PartFilterIdentifier
@@ -1102,20 +1102,9 @@ void OpenSpaceEngine::initializeGL() {
LINFO("Finished initializing OpenGL");
LINFO("IsUsingSwapGroups: " << _windowWrapper->isUsingSwapGroups());
LINFO("IsSwapGroupMaster: " << _windowWrapper->isSwapGroupMaster());
LTRACE("OpenSpaceEngine::initializeGL(end)");
}
double OpenSpaceEngine::runTime() {
return _runTime;
}
void OpenSpaceEngine::setRunTime(double d) {
_runTime = d;
}
void OpenSpaceEngine::preSynchronization() {
LTRACE("OpenSpaceEngine::preSynchronization(begin)");
FileSys.triggerFilesystemEvents();
@@ -1226,7 +1215,7 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix,
func();
}
if (_shutdown.inShutdown) {
if (isGuiWindow && _shutdown.inShutdown) {
_renderEngine->renderShutdownInformation(_shutdown.timer, _shutdown.waitTime);
}
@@ -1399,19 +1388,17 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
&luascriptfunctions::addTag,
"string, string",
"Adds a tag (second argument) to a scene graph node (first argument)"
},
{
"removeTag",
&luascriptfunctions::removeTag,
"string, string",
"Removes a tag (second argument) from a scene graph node (first argument)"
}
}
};
}
void OpenSpaceEngine::enableBarrier() {
_windowWrapper->setBarrier(true);
}
void OpenSpaceEngine::disableBarrier() {
_windowWrapper->setBarrier(false);
}
// Registers a callback for a specific CallbackOption
void OpenSpaceEngine::registerModuleCallback(OpenSpaceEngine::CallbackOption option,
std::function<void()> function)
@@ -1445,7 +1432,7 @@ void OpenSpaceEngine::registerModuleCallback(OpenSpaceEngine::CallbackOption opt
throw ghoul::MissingCaseException();
}
}
void OpenSpaceEngine::registerModuleKeyboardCallback(
std::function<bool (Key, KeyModifier, KeyAction)> function)
{

View File

@@ -176,7 +176,31 @@ int addTag(lua_State* L) {
return luaL_error(L, "Unknown scene graph node type '%s'", uri.c_str());
}
node->addTag(tag);
node->addTag(std::move(tag));
return 0;
}
/**
* \ingroup LuaScripts
* removeTag():
* Removes a tag from a SceneGraphNode
*/
int removeTag(lua_State* L) {
const int nArguments = lua_gettop(L);
if (nArguments != 2) {
return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments);
}
const std::string uri = lua_tostring(L, -2);
const std::string tag = lua_tostring(L, -1);
SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(uri);
if (!node) {
return luaL_error(L, "Unknown scene graph node type '%s'", uri.c_str());
}
node->removeTag(tag);
return 0;
}

View File

@@ -64,7 +64,7 @@ SGCTWindowWrapper::SGCTWindowWrapper()
setEyeSeparationDistance(_eyeSeparation);
});
}
void SGCTWindowWrapper::terminate() {
sgct::Engine::instance()->terminate();
}
@@ -72,7 +72,7 @@ void SGCTWindowWrapper::terminate() {
void SGCTWindowWrapper::setBarrier(bool enabled) {
sgct::SGCTWindow::setBarrier(enabled);
}
void SGCTWindowWrapper::setSynchronization(bool enabled) {
sgct_core::ClusterManager::instance()->setUseIgnoreSync(enabled);
}
@@ -90,7 +90,7 @@ void SGCTWindowWrapper::clearAllWindows(const glm::vec4& clearColor) {
bool SGCTWindowWrapper::windowHasResized() const {
return sgct::Engine::instance()->getCurrentWindowPtr()->isWindowResized();
}
double SGCTWindowWrapper::averageDeltaTime() const {
return sgct::Engine::instance()->getAvgDt();
}
@@ -98,7 +98,11 @@ double SGCTWindowWrapper::averageDeltaTime() const {
double SGCTWindowWrapper::deltaTime() const {
return sgct::Engine::instance()->getDt();
}
double SGCTWindowWrapper::applicationTime() const {
return sgct::Engine::getTime();
}
glm::vec2 SGCTWindowWrapper::mousePosition() const {
int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId();
double posX, posY;
@@ -157,7 +161,7 @@ glm::ivec2 SGCTWindowWrapper::currentDrawBufferResolution() const {
}
throw WindowWrapperException("No viewport available");
}
glm::vec2 SGCTWindowWrapper::dpiScaling() const {
return glm::vec2(
sgct::Engine::instance()->getCurrentWindowPtr()->getXScale(),
@@ -168,7 +172,7 @@ glm::vec2 SGCTWindowWrapper::dpiScaling() const {
int SGCTWindowWrapper::currentNumberOfAaSamples() const {
return sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfAASamples();
}
bool SGCTWindowWrapper::isRegularRendering() const {
sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr();
std::size_t nViewports = w->getNumberOfViewports();
@@ -194,7 +198,7 @@ bool SGCTWindowWrapper::isGuiWindow() const {
GuiWindowTag
);
}
bool SGCTWindowWrapper::isMaster() const {
return sgct::Engine::instance()->isMaster();
}
@@ -206,7 +210,7 @@ bool SGCTWindowWrapper::isSwapGroupMaster() const {
bool SGCTWindowWrapper::isUsingSwapGroups() const {
return sgct::Engine::instance()->getCurrentWindowPtr()->isUsingSwapGroups();
}
glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const {
return sgct::Engine::instance()->getCurrentModelViewProjectionMatrix();
}
@@ -214,7 +218,7 @@ glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const {
glm::mat4 SGCTWindowWrapper::modelMatrix() const {
return sgct::Engine::instance()->getModelMatrix();
}
void SGCTWindowWrapper::setNearFarClippingPlane(float nearPlane, float farPlane) {
sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane);
}
@@ -225,39 +229,33 @@ void SGCTWindowWrapper::setEyeSeparationDistance(float distance) {
glm::ivec4 SGCTWindowWrapper::viewportPixelCoordinates() const {
int x1, xSize, y1, ySize;
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(x1,
y1,
xSize,
ySize);
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(
x1,
y1,
xSize,
ySize
);
return glm::ivec4(x1, xSize, y1, ySize);
}
bool SGCTWindowWrapper::isExternalControlConnected() const {
return sgct::Engine::instance()->isExternalControlConnected();
}
void SGCTWindowWrapper::sendMessageToExternalControl(const std::vector<char>& message) const {
sgct::Engine::instance()->sendMessageToExternalControl(
message.data(),
static_cast<int>(message.size())
);
}
bool SGCTWindowWrapper::isSimpleRendering() const {
return (sgct::Engine::instance()->getCurrentRenderTarget() != sgct::Engine::NonLinearBuffer);
}
void SGCTWindowWrapper::takeScreenshot(bool applyWarping) const {
sgct::SGCTSettings::instance()->setCaptureFromBackBuffer(applyWarping);
sgct::Engine::instance()->takeScreenshot();
}
//void forEachWindow(std::function<void (void)> function) {
// size_t n = sgct::Engine::instance()->getNumberOfWindows();
// for (size_t i = 0; i < n; ++i)
// function();
//}
} // namespace openspace
} // namespace openspace

View File

@@ -92,19 +92,23 @@ double WindowWrapper::averageDeltaTime() const {
double WindowWrapper::deltaTime() const {
return 0.0;
}
double WindowWrapper::applicationTime() const {
return 0.0;
}
glm::vec2 WindowWrapper::mousePosition() const {
return glm::vec2(0.f);
}
uint32_t WindowWrapper::mouseButtons(int) const {
return uint32_t(0);
}
glm::ivec2 WindowWrapper::currentWindowSize() const {
return glm::ivec2(0);
}
glm::ivec2 WindowWrapper::currentWindowResolution() const {
return currentWindowSize();
}
@@ -153,11 +157,11 @@ glm::mat4 WindowWrapper::viewProjectionMatrix() const {
glm::mat4 WindowWrapper::modelMatrix() const {
return glm::mat4(1.f);
}
void WindowWrapper::setNearFarClippingPlane(float, float) {}
void WindowWrapper::setEyeSeparationDistance(float) {}
glm::ivec4 WindowWrapper::viewportPixelCoordinates() const {
return glm::ivec4(
0,
@@ -166,19 +170,19 @@ glm::ivec4 WindowWrapper::viewportPixelCoordinates() const {
currentWindowResolution().y
);
}
bool WindowWrapper::isExternalControlConnected() const {
return false;
}
void WindowWrapper::sendMessageToExternalControl(const std::vector<char>&) const {
}
bool WindowWrapper::isSimpleRendering() const {
return true;
}
void WindowWrapper::takeScreenshot(bool) const {}
} // namespace openspace

View File

@@ -138,7 +138,7 @@ std::string KeyBindingManager::generateJson() const {
}
return jsonString;
}
}
scripting::LuaLibrary KeyBindingManager::luaLibrary() {
return {

View File

@@ -25,6 +25,7 @@
#include <openspace/interaction/keyframenavigator.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/scene/scene.h>
#include <openspace/util/camera.h>
@@ -37,7 +38,7 @@
namespace openspace::interaction {
void KeyframeNavigator::updateCamera(Camera& camera) {
double now = OsEng.runTime();
double now = OsEng.windowWrapper().applicationTime();
if (_cameraPoseTimeline.nKeyframes() == 0) {
return;

View File

@@ -587,7 +587,7 @@ void ParallelConnection::initializationMessageReceived(){
double ParallelConnection::calculateBufferedKeyframeTime(double originalTime) {
std::lock_guard<std::mutex> latencyLock(_latencyMutex);
double timeDiff = OsEng.runTime() - originalTime;
double timeDiff = OsEng.windowWrapper().applicationTime() - originalTime;
if (_latencyDiffs.size() == 0) {
_initialTimeDiff = timeDiff;
}
@@ -1084,7 +1084,7 @@ void ParallelConnection::preSynchronization() {
if (OsEng.timeManager().time().timeJumped()) {
_timeJumped = true;
}
double now = OsEng.runTime();
double now = OsEng.windowWrapper().applicationTime();
if (_lastCameraKeyframeTimestamp + _cameraKeyframeInterval < now) {
sendCameraKeyframe();
@@ -1156,7 +1156,7 @@ void ParallelConnection::sendCameraKeyframe() {
kf._focusNode = focusNode->name();
// Timestamp as current runtime of OpenSpace instance
kf._timestamp = OsEng.runTime();
kf._timestamp = OsEng.windowWrapper().applicationTime();
// Create a buffer for the keyframe
std::vector<char> buffer;
@@ -1180,7 +1180,7 @@ void ParallelConnection::sendTimeKeyframe() {
kf._time = time.j2000Seconds();
// Timestamp as current runtime of OpenSpace instance
kf._timestamp = OsEng.runTime();
kf._timestamp = OsEng.windowWrapper().applicationTime();
// Create a buffer for the keyframe
std::vector<char> buffer;

View File

@@ -130,10 +130,10 @@ void PerformanceManager::destroyGlobalSharedMemory() {
sharedMemory.releaseLock();
}
PerformanceManager::PerformanceManager()
PerformanceManager::PerformanceManager(std::string loggingDirectory, std::string prefix)
: _loggingEnabled(false)
, _logDir(absPath("${BASE_PATH}"))
, _prefix("PM-")
, _logDir(absPath(std::move(loggingDirectory)))
, _prefix(std::move(prefix))
, _ext("log")
, _performanceMemory(nullptr)
, _tick(0)

View File

@@ -34,14 +34,6 @@ namespace openspace::properties {
namespace {
const char* _loggerCat = "PropertyOwner";
bool propertyLess(Property* lhs, Property* rhs) {
return lhs->identifier() < rhs->identifier();
}
bool subOwnerLess(PropertyOwner* lhs, PropertyOwner* rhs) {
return lhs->name() < rhs->name();
}
} // namespace
@@ -290,4 +282,11 @@ void PropertyOwner::addTag(std::string tag) {
_tags.push_back(std::move(tag));
}
void PropertyOwner::removeTag(const std::string& tag) {
_tags.erase(
std::remove(_tags.begin(), _tags.end(), tag),
_tags.end()
);
}
} // namespace openspace::properties

View File

@@ -218,7 +218,7 @@ RenderEngine::RenderEngine()
, _scene(nullptr)
, _raycasterManager(nullptr)
, _deferredcasterManager(nullptr)
, _performanceMeasurements(PerformanceInfo)
, _doPerformanceMeasurements(PerformanceInfo)
, _performanceManager(nullptr)
, _renderer(nullptr)
, _rendererImplementation(RendererImplementation::Invalid)
@@ -244,35 +244,41 @@ RenderEngine::RenderEngine()
, _nAaSamples(AaSamplesInfo, 8, 1, 16)
, _frameNumber(0)
{
_performanceMeasurements.onChange([this]() {
if (_performanceMeasurements) {
_doPerformanceMeasurements.onChange([this](){
if (_doPerformanceMeasurements) {
if (!_performanceManager) {
_performanceManager = std::make_unique<performance::PerformanceManager>();
const std::string KeyLogDir = ConfigurationManager::KeyLogging + "." + ConfigurationManager::PartLogDir;
std::string loggingDir = "${BASE_PATH}";
const std::string KeyDir = ConfigurationManager::KeyLogging + "." + ConfigurationManager::PartLogDir;
if (OsEng.configurationManager().hasKey(KeyDir)) {
loggingDir = OsEng.configurationManager().value<std::string>(KeyDir);
}
std::string prefix = "PM-";
const std::string KeyPrefix = ConfigurationManager::KeyLogging + "." + ConfigurationManager::PartLogPerformancePrefix;
if (OsEng.configurationManager().hasKeyAndValue<std::string>(KeyLogDir)) {
_performanceManager->logDir(OsEng.configurationManager().value<std::string>(KeyLogDir));
}
if (OsEng.configurationManager().hasKeyAndValue<std::string>(KeyPrefix)) {
_performanceManager->prefix(OsEng.configurationManager().value<std::string>(KeyPrefix));
if (OsEng.configurationManager().hasKey(KeyPrefix)) {
prefix = OsEng.configurationManager().value<std::string>(KeyPrefix);
}
_performanceManager = std::make_unique<performance::PerformanceManager>(
loggingDir,
prefix
);
}
}
});
addProperty(_performanceMeasurements);
else {
_performanceManager = nullptr;
}
_frametimeType.addOption(
static_cast<int>(FrametimeType::DtTimeAvg),
"Average Deltatime"
);
_frametimeType.addOption(
static_cast<int>(FrametimeType::FPS),
"Frames per second"
);
_frametimeType.addOption(
static_cast<int>(FrametimeType::FPSAvg),
"Average frames per second"
);
});
addProperty(_doPerformanceMeasurements);
_frametimeType.addOptions({
{ static_cast<int>(FrametimeType::DtTimeAvg), "Average Deltatime" },
{ static_cast<int>(FrametimeType::FPS), "Frames per second" },
{ static_cast<int>(FrametimeType::FPSAvg), "Average frames per second" },
{ static_cast<int>(FrametimeType::None), "None" }
});
addProperty(_frametimeType);
addProperty(_showDate);
@@ -318,9 +324,6 @@ RenderEngine::RenderEngine()
addProperty(_disableMasterRendering);
}
/**
* Destructor
*/
RenderEngine::~RenderEngine() {}
void RenderEngine::setRendererFromString(const std::string& renderingMethod) {
@@ -347,7 +350,7 @@ void RenderEngine::initialize() {
std::string renderingMethod = DefaultRenderingMethod;
// If the user specified a rendering method that he would like to use, use that
auto& confManager = OsEng.configurationManager();
ConfigurationManager& confManager = OsEng.configurationManager();
if (confManager.hasKeyAndValue<std::string>(KeyRenderingMethod)) {
renderingMethod = confManager.value<std::string>(KeyRenderingMethod);
}
@@ -414,7 +417,7 @@ void RenderEngine::initializeGL() {
// set the close clip plane and the far clip plane to extreme values while in
// development
OsEng.windowWrapper().setNearFarClippingPlane(0.001f, 10000.f);
OsEng.windowWrapper().setNearFarClippingPlane(0.001f, 1000.f);
try {
const float fontSizeBig = 50.f;
@@ -440,7 +443,7 @@ void RenderEngine::initializeGL() {
}
void RenderEngine::deinitialize() {
for (std::shared_ptr<ScreenSpaceRenderable> ssr : _screenSpaceRenderables) {
for (std::shared_ptr<ScreenSpaceRenderable>& ssr : _screenSpaceRenderables) {
ssr->deinitialize();
}
@@ -566,9 +569,9 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat
_camera->sgctInternal.setViewMatrix(viewMatrix * sceneMatrix);
}
_camera->sgctInternal.setProjectionMatrix(projectionMatrix);
if (!(wrapper.isMaster() && _disableMasterRendering) && !wrapper.isGuiWindow()) {
bool masterEnabled = wrapper.isMaster() ? !_disableMasterRendering : true;
if (masterEnabled && !wrapper.isGuiWindow() && _globalBlackOutFactor > 0.f) {
_renderer->render(_globalBlackOutFactor, _performanceManager != nullptr);
}
@@ -585,9 +588,9 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat
RenderFont(*_fontBig, penPosition, "%i", _frameNumber);
}
_frameNumber++;
++_frameNumber;
for (std::shared_ptr<ScreenSpaceRenderable>& ssr : _screenSpaceRenderables) {
if (ssr->isEnabled() && ssr->isReady()) {
ssr->render();
@@ -610,7 +613,6 @@ void RenderEngine::renderShutdownInformation(float timer, float fullTime) {
fontResolution().x - size.boundingBox.x - 10,
fontResolution().y - size.boundingBox.y
);
// penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
@@ -785,7 +787,6 @@ void RenderEngine::setRendererData(const ghoul::Dictionary& data) {
}
}
/**
* Set resolve data
* Called from the renderer, whenever it needs to update
@@ -853,7 +854,6 @@ scripting::LuaLibrary RenderEngine::luaLibrary() {
"number",
""
},
//also temporary @JK
{
"fadeOut",
&luascriptfunctions::fadeOut,
@@ -887,7 +887,7 @@ performance::PerformanceManager* RenderEngine::performanceManager() {
void RenderEngine::registerScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s)
{
s->initialize();
_screenSpaceRenderables.push_back(s);
_screenSpaceRenderables.push_back(std::move(s));
}
void RenderEngine::unregisterScreenSpaceRenderable(
@@ -905,7 +905,7 @@ void RenderEngine::unregisterScreenSpaceRenderable(
}
}
void RenderEngine::unregisterScreenSpaceRenderable(std::string name) {
void RenderEngine::unregisterScreenSpaceRenderable(const std::string& name){
std::shared_ptr<ScreenSpaceRenderable> s = screenSpaceRenderable(name);
if (s) {
unregisterScreenSpaceRenderable(s);
@@ -913,14 +913,22 @@ void RenderEngine::unregisterScreenSpaceRenderable(std::string name) {
}
std::shared_ptr<ScreenSpaceRenderable> RenderEngine::screenSpaceRenderable(
std::string name)
const std::string& name)
{
for (auto s : _screenSpaceRenderables) {
if (s->name() == name) {
return s;
auto it = std::find_if(
_screenSpaceRenderables.begin(),
_screenSpaceRenderables.end(),
[name](const std::shared_ptr<ScreenSpaceRenderable>& s) {
return s->name() == name;
}
);
if (it != _screenSpaceRenderables.end()) {
return *it;
}
else {
return nullptr;
}
return nullptr;
}
std::vector<ScreenSpaceRenderable*> RenderEngine::screenSpaceRenderables() const {
@@ -935,7 +943,7 @@ std::vector<ScreenSpaceRenderable*> RenderEngine::screenSpaceRenderables() const
}
RenderEngine::RendererImplementation RenderEngine::rendererFromString(
const std::string& impl)
const std::string& impl) const
{
const std::map<std::string, RenderEngine::RendererImplementation> RenderingMethods = {
{ "ABuffer", RendererImplementation::ABuffer },
@@ -966,40 +974,39 @@ std::string RenderEngine::progressToStr(int size, double t) {
}
void RenderEngine::renderInformation() {
// TODO: Adjust font_size properly when using retina screen
using ghoul::fontrendering::RenderFont;
if (_fontDate) {
glm::vec2 penPosition = glm::vec2(
10.f,
fontResolution().y
//OsEng.windowWrapper().viewportPixelCoordinates().w
glm::vec2 penPosition = glm::vec2(
10.f,
fontResolution().y
);
// If the console is opened, move all text downwards
penPosition.y -= OsEng.console().currentHeight();
if (_showDate && _fontDate) {
penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
penPosition,
"Date: %s",
OsEng.timeManager().time().UTC().c_str()
);
}
else {
penPosition.y -= _fontInfo->height();
}
if (_showInfo && _fontInfo) {
RenderFontCr(
*_fontInfo,
penPosition,
"Simulation increment (s): %.3f",
OsEng.timeManager().time().deltaTime()
);
penPosition.y -= OsEng.console().currentHeight();
if (_showDate && _fontDate) {
penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
penPosition,
"Date: %s",
OsEng.timeManager().time().UTC().c_str()
);
}
else {
penPosition.y -= _fontInfo->height();
}
if (_showInfo && _fontInfo) {
RenderFontCr(
*_fontInfo,
penPosition,
"Simulation increment (s): %.3f",
OsEng.timeManager().time().deltaTime()
);
FrametimeType frametimeType = FrametimeType(_frametimeType.value());
switch (frametimeType) {
FrametimeType frametimeType = FrametimeType(_frametimeType.value());
switch (frametimeType) {
case FrametimeType::DtTimeAvg:
RenderFontCr(
*_fontInfo,
@@ -1024,15 +1031,7 @@ void RenderEngine::renderInformation() {
1.0 / OsEng.windowWrapper().averageDeltaTime()
);
break;
default:
RenderFontCr(
*_fontInfo,
penPosition,
"Avg. Frametime: %.5f",
OsEng.windowWrapper().averageDeltaTime()
);
break;
}
}
ParallelConnection::Status status = OsEng.parallelConnection().status();
size_t nConnections = OsEng.parallelConnection().nConnections();
@@ -1074,275 +1073,278 @@ void RenderEngine::renderInformation() {
}
}
if (connectionInfo != "") {
RenderFontCr(
*_fontInfo,
penPosition,
connectionInfo.c_str()
);
}
if (!connectionInfo.empty()) {
RenderFontCr(
*_fontInfo,
penPosition,
connectionInfo.c_str()
);
}
#ifdef OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS_ENABLED
bool hasNewHorizons = scene()->sceneGraphNode("NewHorizons");
double currentTime = OsEng.timeManager().time().j2000Seconds();
bool hasNewHorizons = scene()->sceneGraphNode("NewHorizons");
double currentTime = OsEng.timeManager().time().j2000Seconds();
//if (MissionManager::ref().hasCurrentMission()) {
//if (MissionManager::ref().hasCurrentMission()) {
// const Mission& mission = MissionManager::ref().currentMission();
// const Mission& mission = MissionManager::ref().currentMission();
// if (mission.phases().size() > 0) {
// static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
// //static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
// static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
// static const glm::vec4 missionProgressColor = currentMissionColor;// (0.4, 1.0, 1.0, 1);
// // static const glm::vec4 currentLeafMissionColor = missionProgressColor;
// static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
// if (mission.phases().size() > 0) {
// static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
// //static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
// static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
// static const glm::vec4 missionProgressColor = currentMissionColor;// (0.4, 1.0, 1.0, 1);
// // static const glm::vec4 currentLeafMissionColor = missionProgressColor;
// static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
// // Add spacing
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, " ");
// // Add spacing
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, " ");
// auto phaseTrace = mission.phaseTrace(currentTime);
// auto phaseTrace = mission.phaseTrace(currentTime);
// if (phaseTrace.size()) {
// const MissionPhase& phase = phaseTrace.back().get();
// std::string title = "Current Mission Phase: " + phase.name();
// RenderFontCr(*_fontInfo, penPosition, missionProgressColor, title.c_str());
// double remaining = phase.timeRange().end - currentTime;
// float t = static_cast<float>(1.0 - remaining / phase.timeRange().duration());
// std::string progress = progressToStr(25, t);
// //RenderFontCr(*_fontInfo, penPosition, missionProgressColor,
// // "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
// }
// else {
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor, "Next Mission:");
// double remaining = mission.timeRange().start - currentTime;
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor,
// "%.0f s", remaining);
// }
// if (phaseTrace.size()) {
// const MissionPhase& phase = phaseTrace.back().get();
// std::string title = "Current Mission Phase: " + phase.name();
// RenderFontCr(*_fontInfo, penPosition, missionProgressColor, title.c_str());
// double remaining = phase.timeRange().end - currentTime;
// float t = static_cast<float>(1.0 - remaining / phase.timeRange().duration());
// std::string progress = progressToStr(25, t);
// //RenderFontCr(*_fontInfo, penPosition, missionProgressColor,
// // "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
// }
// else {
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor, "Next Mission:");
// double remaining = mission.timeRange().start - currentTime;
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor,
// "%.0f s", remaining);
// }
// bool showAllPhases = false;
// bool showAllPhases = false;
// typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
// std::stack<PhaseWithDepth> S;
// int pixelIndentation = 20;
// S.push({ &mission, 0 });
// while (!S.empty()) {
// const MissionPhase* phase = S.top().first;
// int depth = S.top().second;
// S.pop();
// typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
// std::stack<PhaseWithDepth> S;
// int pixelIndentation = 20;
// S.push({ &mission, 0 });
// while (!S.empty()) {
// const MissionPhase* phase = S.top().first;
// int depth = S.top().second;
// S.pop();
// bool isCurrentPhase = phase->timeRange().includes(currentTime);
// bool isCurrentPhase = phase->timeRange().includes(currentTime);
// penPosition.x += depth * pixelIndentation;
// if (isCurrentPhase) {
// double remaining = phase->timeRange().end - currentTime;
// float t = static_cast<float>(1.0 - remaining / phase->timeRange().duration());
// std::string progress = progressToStr(25, t);
// RenderFontCr(*_fontInfo, penPosition, currentMissionColor,
// "%s %s %.1f %%",
// phase->name().c_str(),
// progress.c_str(),
// t * 100
// );
// }
// else {
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, phase->name().c_str());
// }
// penPosition.x -= depth * pixelIndentation;
// penPosition.x += depth * pixelIndentation;
// if (isCurrentPhase) {
// double remaining = phase->timeRange().end - currentTime;
// float t = static_cast<float>(1.0 - remaining / phase->timeRange().duration());
// std::string progress = progressToStr(25, t);
// RenderFontCr(*_fontInfo, penPosition, currentMissionColor,
// "%s %s %.1f %%",
// phase->name().c_str(),
// progress.c_str(),
// t * 100
// );
// }
// else {
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, phase->name().c_str());
// }
// penPosition.x -= depth * pixelIndentation;
// if (isCurrentPhase || showAllPhases) {
// // phases are sorted increasingly by start time, and will be popped
// // last-in-first-out from the stack, so add them in reversed order.
// int indexLastPhase = static_cast<int>(phase->phases().size()) - 1;
// for (int i = indexLastPhase; 0 <= i; --i) {
// S.push({ &phase->phases()[i], depth + 1 });
// }
// }
// }
// }
// }
// if (isCurrentPhase || showAllPhases) {
// // phases are sorted increasingly by start time, and will be popped
// // last-in-first-out from the stack, so add them in reversed order.
// int indexLastPhase = static_cast<int>(phase->phases().size()) - 1;
// for (int i = indexLastPhase; 0 <= i; --i) {
// S.push({ &phase->phases()[i], depth + 1 });
// }
// }
// }
// }
// }
if (openspace::ImageSequencer::ref().isReady()) {
penPosition.y -= 25.f;
if (openspace::ImageSequencer::ref().isReady()) {
penPosition.y -= 25.f;
glm::vec4 targetColor(0.00, 0.75, 1.00, 1);
glm::vec4 targetColor(0.00, 0.75, 1.00, 1);
if (hasNewHorizons) {
try {
double lt;
glm::dvec3 p =
SpiceManager::ref().targetPosition("PLUTO", "NEW HORIZONS", "GALACTIC", {}, currentTime, lt);
psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
float a, b;
glm::dvec3 radii;
SpiceManager::ref().getValue("PLUTO", "RADII", radii);
a = static_cast<float>(radii.x);
b = static_cast<float>(radii.y);
float radius = (a + b) / 2.f;
float distToSurf = glm::length(nhPos.vec3()) - radius;
if (hasNewHorizons) {
try {
double lt;
glm::dvec3 p =
SpiceManager::ref().targetPosition("PLUTO", "NEW HORIZONS", "GALACTIC", {}, currentTime, lt);
psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
float a, b;
glm::dvec3 radii;
SpiceManager::ref().getValue("PLUTO", "RADII", radii);
a = static_cast<float>(radii.x);
b = static_cast<float>(radii.y);
float radius = (a + b) / 2.f;
float distToSurf = glm::length(nhPos.vec3()) - radius;
RenderFont(*_fontInfo,
penPosition,
"Distance to Pluto: % .1f (KM)",
distToSurf
);
penPosition.y -= _fontInfo->height();
}
catch (...) {
// @CLEANUP: This is bad as it will discard all exceptions
// without telling us about it! ---abock
}
RenderFont(*_fontInfo,
penPosition,
"Distance to Pluto: % .1f (KM)",
distToSurf
);
penPosition.y -= _fontInfo->height();
}
catch (...) {
// @CLEANUP: This is bad as it will discard all exceptions
// without telling us about it! ---abock
}
}
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - currentTime;
float t = static_cast<float>(1.0 - remaining / openspace::ImageSequencer::ref().getIntervalLength());
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - currentTime;
float t = static_cast<float>(1.0 - remaining / openspace::ImageSequencer::ref().getIntervalLength());
std::string str = SpiceManager::ref().dateFromEphemerisTime(
ImageSequencer::ref().getNextCaptureTime(),
"YYYY MON DD HR:MN:SC"
std::string str = SpiceManager::ref().dateFromEphemerisTime(
ImageSequencer::ref().getNextCaptureTime(),
"YYYY MON DD HR:MN:SC"
);
glm::vec4 active(0.6, 1, 0.00, 1);
glm::vec4 brigther_active(0.9, 1, 0.75, 1);
glm::vec4 active(0.6, 1, 0.00, 1);
glm::vec4 brigther_active(0.9, 1, 0.75, 1);
if (remaining > 0) {
if (remaining > 0) {
std::string progress = progressToStr(25, t);
brigther_active *= (1 - t);
std::string progress = progressToStr(25, t);
brigther_active *= (1 - t);
RenderFontCr(*_fontInfo,
penPosition,
active * t + brigther_active,
"Next instrument activity:"
RenderFontCr(*_fontInfo,
penPosition,
active * t + brigther_active,
"Next instrument activity:"
);
RenderFontCr(*_fontInfo,
penPosition,
active * t + brigther_active,
"%.0f s %s %.1f %%",
remaining, progress.c_str(), t * 100
RenderFontCr(*_fontInfo,
penPosition,
active * t + brigther_active,
"%.0f s %s %.1f %%",
remaining, progress.c_str(), t * 100
);
RenderFontCr(*_fontInfo,
penPosition,
active,
"Data acquisition time: %s",
str.c_str()
RenderFontCr(*_fontInfo,
penPosition,
active,
"Data acquisition time: %s",
str.c_str()
);
}
std::pair<double, std::string> nextTarget = ImageSequencer::ref().getNextTarget();
std::pair<double, std::string> currentTarget = ImageSequencer::ref().getCurrentTarget();
}
std::pair<double, std::string> nextTarget = ImageSequencer::ref().getNextTarget();
std::pair<double, std::string> currentTarget = ImageSequencer::ref().getCurrentTarget();
if (currentTarget.first > 0.0) {
int timeleft = static_cast<int>(nextTarget.first - currentTime);
if (currentTarget.first > 0.0) {
int timeleft = static_cast<int>(nextTarget.first - currentTime);
int hour = timeleft / 3600;
int second = timeleft % 3600;
int minute = second / 60;
second = second % 60;
int hour = timeleft / 3600;
int second = timeleft % 3600;
int minute = second / 60;
second = second % 60;
std::string hh, mm, ss;
std::string hh, mm, ss;
if (hour < 10)
hh.append("0");
if (minute < 10)
mm.append("0");
if (second < 10)
ss.append("0");
if (hour < 10)
hh.append("0");
if (minute < 10)
mm.append("0");
if (second < 10)
ss.append("0");
hh.append(std::to_string(hour));
mm.append(std::to_string(minute));
ss.append(std::to_string(second));
hh.append(std::to_string(hour));
mm.append(std::to_string(minute));
ss.append(std::to_string(second));
RenderFontCr(*_fontInfo,
penPosition,
targetColor,
"Data acquisition adjacency: [%s:%s:%s]",
hh.c_str(), mm.c_str(), ss.c_str()
RenderFontCr(*_fontInfo,
penPosition,
targetColor,
"Data acquisition adjacency: [%s:%s:%s]",
hh.c_str(), mm.c_str(), ss.c_str()
);
#if 0
// Why is it (2) in the original? ---abock
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(0);
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(2);
std::string space;
glm::vec4 color;
size_t isize = incidentTargets.second.size();
for (size_t p = 0; p < isize; p++) {
double t = static_cast<double>(p + 1) / static_cast<double>(isize + 1);
t = (p > isize / 2) ? 1 - t : t;
t += 0.3;
color = (p == isize / 2) ? targetColor : glm::vec4(t, t, t, 1);
RenderFont(*_fontInfo,
penPosition,
color,
"%s%s",
space.c_str(), incidentTargets.second[p].c_str()
);
for (int k = 0; k < incidentTargets.second[p].size() + 2; k++)
space += " ";
}
#endif
penPosition.y -= _fontInfo->height();
// Why is it (2) in the original? ---abock
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(0);
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(2);
std::string space;
glm::vec4 color;
size_t isize = incidentTargets.second.size();
for (size_t p = 0; p < isize; p++) {
double t = static_cast<double>(p + 1) / static_cast<double>(isize + 1);
t = (p > isize / 2) ? 1 - t : t;
t += 0.3;
color = (p == isize / 2) ? targetColor : glm::vec4(t, t, t, 1);
std::map<std::string, bool> activeMap = ImageSequencer::ref().getActiveInstruments();
glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1);
glm::vec4 notFiring(0.5, 0.5, 0.5, 1);
RenderFontCr(*_fontInfo,
RenderFont(*_fontInfo,
penPosition,
active,
"Active Instruments:"
color,
"%s%s",
space.c_str(), incidentTargets.second[p].c_str()
);
for (int k = 0; k < incidentTargets.second[p].size() + 2; k++)
space += " ";
}
#endif
penPosition.y -= _fontInfo->height();
std::map<std::string, bool> activeMap = ImageSequencer::ref().getActiveInstruments();
glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1);
glm::vec4 notFiring(0.5, 0.5, 0.5, 1);
RenderFontCr(*_fontInfo,
penPosition,
active,
"Active Instruments:"
);
for (auto m : activeMap) {
if (m.second == false) {
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"| |"
);
RenderFontCr(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" %5s",
m.first.c_str()
);
for (auto m : activeMap) {
if (m.second == false) {
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"| |"
);
RenderFontCr(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" %5s",
m.first.c_str()
);
}
else {
}
else {
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"|"
);
if (m.first == "NH_LORRI") {
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"|"
);
if (m.first == "NH_LORRI") {
RenderFont(*_fontInfo,
penPosition,
firing,
" + "
);
}
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" |"
);
RenderFontCr(*_fontInfo,
penPosition,
active,
" %5s",
m.first.c_str()
firing,
" + "
);
}
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" |"
);
RenderFontCr(*_fontInfo,
penPosition,
active,
" %5s",
m.first.c_str()
);
}
}
}
#endif
}
#endif
}
}
@@ -1366,9 +1368,6 @@ void RenderEngine::renderVersionInformation() {
OPENSPACE_GIT_COMMIT
);
FR::defaultRenderer().render(
*_fontInfo,
glm::vec2(
@@ -1407,11 +1406,11 @@ void RenderEngine::renderScreenLog() {
_log->removeExpiredEntries();
const int max = 10;
const int category_length = 20;
const int msg_length = 140;
const int categoryLength = 20;
const int messageLength = 140;
std::chrono::seconds fade(5);
auto entries = _log->entries();
const std::vector<ScreenLog::LogEntry>& entries = _log->entries();
auto lastEntries =
entries.size() > max ?
std::make_pair(entries.rbegin(), entries.rbegin() + max) :
@@ -1431,65 +1430,62 @@ void RenderEngine::renderScreenLog() {
auto d = (diff - ttf).count();
auto t = static_cast<float>(d) / static_cast<float>(fade.count());
float p = 0.8f - t;
alpha = (p <= 0.f) ? 0.f : pow(p, 0.3f);
alpha = (p <= 0.f) ? 0.f : pow(p, 0.4f);
}
// Since all log entries are ordered, once one exceeds alpha, all have
if (alpha <= 0.0)
if (alpha <= 0.0) {
break;
}
const std::string lvl = "(" + ghoul::logging::stringFromLevel(e->level) + ")";
const std::string& message = e->message.substr(0, msg_length);
const std::string& message = e->message.substr(0, messageLength);
nr += std::count(message.begin(), message.end(), '\n');
const glm::vec4 White(0.9f, 0.9f, 0.9f, 1.0f);
const glm::vec4 white(0.9f, 0.9f, 0.9f, alpha);
RenderFont(
*_fontLog,
glm::vec2(10.f, _fontLog->pointSize() * nr * 2),
White * alpha,
"%-14s %s%s", // Format
e->timeString.c_str(), // Time string
e->category.substr(0, category_length).c_str(), // Category string
e->category.length() > 20 ? "..." : ""); // Pad category with "..."
const glm::vec4 Red(1.f, 0.f, 0.f, 1.f);
const glm::vec4 Yellow(1.f, 1.f, 0.f, 1.f);
const glm::vec4 Green(0.f, 1.f, 0.f, 1.f);
const glm::vec4 Blue(0.f, 0.f, 1.f, 1.f);
white,
"%-14s %s%s",
e->timeString.c_str(),
e->category.substr(0, categoryLength).c_str(),
e->category.length() > 20 ? "..." : "");
glm::vec4 color(glm::uninitialize);
switch (e->level) {
case ghoul::logging::LogLevel::Debug:
color = Green;
break;
case ghoul::logging::LogLevel::Warning:
color = Yellow;
break;
case ghoul::logging::LogLevel::Error:
color = Red;
break;
case ghoul::logging::LogLevel::Fatal:
color = Blue;
break;
default:
color = White;
break;
case ghoul::logging::LogLevel::Debug:
color = glm::vec4(0.f, 1.f, 0.f, alpha);
break;
case ghoul::logging::LogLevel::Warning:
color = glm::vec4(1.f, 1.f, 0.f, alpha);
break;
case ghoul::logging::LogLevel::Error:
color = glm::vec4(1.f, 0.f, 0.f, alpha);
break;
case ghoul::logging::LogLevel::Fatal:
color = glm::vec4(0.3f, 0.3f, 0.85f, alpha);
break;
default:
color = white;
break;
}
// const float font_with_light = 5;
RenderFont(
*_fontLog,
glm::vec2(10 + 39 * _fontLog->pointSize(), _fontLog->pointSize() * nr * 2),
color * alpha,
"%s", // Format
lvl.c_str()); // Pad category with "..." if exceeds category_length
color,
"%s",
lvl.c_str()
);
RenderFont(*_fontLog,
glm::vec2(10 + 53 * _fontLog->pointSize(), _fontLog->pointSize() * nr * 2),
White * alpha,
"%s", // Format
message.c_str()); // Pad category with "..." if exceeds category_length
white,
"%s",
message.c_str()
);
++nr;
}
}
@@ -1497,22 +1493,9 @@ void RenderEngine::renderScreenLog() {
std::vector<Syncable*> RenderEngine::getSyncables() {
if (_camera) {
return _camera->getSyncables();
} else {
return {};
}
else {
return std::vector<Syncable*>();
}
}
void RenderEngine::sortScreenspaceRenderables() {
std::sort(
_screenSpaceRenderables.begin(),
_screenSpaceRenderables.end(),
[](const std::shared_ptr<ScreenSpaceRenderable>& j,
const std::shared_ptr<ScreenSpaceRenderable>& i)
{
return i->depth() > j->depth();
}
);
}
}// namespace openspace

View File

@@ -34,8 +34,6 @@
#include <openspace/util/factorymanager.h>
namespace {
const char* _loggerCat = "ScreenSpaceRenderable";
const char* KeyType = "Type";
const char* KeyTag = "Tag";
const float PlaneDepth = -2.f;

View File

@@ -72,12 +72,17 @@ std::unique_ptr<Scale> Scale::createFromDictionary(const ghoul::Dictionary& dict
Scale::Scale()
: properties::PropertyOwner({ "Scale" })
, _scale(1.0)
{}
bool Scale::initialize() {
return true;
}
double Scale::scaleValue() const {
return _scale;
}
void Scale::update(const UpdateData&) {}
} // namespace openspace

View File

@@ -139,6 +139,10 @@ void Scene::removeNode(SceneGraphNode* node, UpdateDependencies updateDeps) {
}
}
void Scene::addSceneLicense(SceneLicense license) {
_licenses.push_back(std::move(license));
}
void Scene::updateDependencies() {
sortTopologically();
}
@@ -272,6 +276,11 @@ const std::vector<SceneGraphNode*>& Scene::allSceneGraphNodes() const {
return _topologicallySortedNodes;
}
void Scene::writeSceneLicenseDocumentation(const std::string& path) const {
SceneLicenseWriter writer(_licenses);
writer.writeDocumentation(path);
}
std::string Scene::generateJson() const {
std::function<std::string(properties::PropertyOwner*)> createJson =
[&createJson](properties::PropertyOwner* owner) -> std::string
@@ -407,6 +416,13 @@ scripting::LuaLibrary Scene::luaLibrary() {
&luascriptfunctions::removeSceneGraphNode,
"string",
"Removes the SceneGraphNode identified by name"
},
{
"hasSceneGraphNode",
&luascriptfunctions::hasSceneGraphNode,
"string",
"Checks whether the specifies SceneGraphNode is present in the current "
"scene"
}
}
};

View File

@@ -390,4 +390,16 @@ int removeSceneGraphNode(lua_State* L) {
return 1;
}
int hasSceneGraphNode(lua_State* L) {
int nArguments = lua_gettop(L);
SCRIPT_CHECK_ARGUMENTS("removeSceneGraphNode", L, 1, nArguments);
std::string nodeName = luaL_checkstring(L, -1);
SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(nodeName);
lua_pushboolean(L, node != nullptr);
return 1;
}
} // namespace openspace::luascriptfunctions

View File

@@ -0,0 +1,94 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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/scenelicense.h>
#include <openspace/openspace.h>
#include <openspace/documentation/verifier.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/dictionary.h>
#include <fstream>
#include <sstream>
namespace {
const char* LicenseKeyName = "Name";
const char* LicenseKeyAttribution = "Attribution";
const char* LicenseKeyUrl = "URL";
const char* LicenseKeyLicenseText = "License";
} // namespace
namespace openspace {
documentation::Documentation SceneLicense::Documentation() {
using namespace documentation;
return {
"License Information",
"core_license",
{
{
LicenseKeyName,
new StringVerifier,
Optional::No,
"A short, descriptive name for the license employed for this node."
},
{
LicenseKeyAttribution,
new StringVerifier,
Optional::No,
"The organization that shall be attributed to the licensed content."
},
{
LicenseKeyUrl,
new StringVerifier,
Optional::Yes,
"The URL pointing to the original license."
},
{
LicenseKeyLicenseText,
new StringVerifier,
Optional::No,
"The full text of the license agreements."
}
}
};
}
SceneLicense::SceneLicense(const ghoul::Dictionary& dictionary, std::string m)
: module(std::move(m))
{
ghoul_assert(!module.empty(), "Module name must not be empty");
documentation::testSpecificationAndThrow(Documentation(), dictionary, "SceneLicense");
name = dictionary.value<std::string>(LicenseKeyName);
attribution = dictionary.value<std::string>(LicenseKeyAttribution);
dictionary.getValue(LicenseKeyUrl, url);
licenseText = dictionary.value<std::string>(LicenseKeyLicenseText);
}
} // namespace openspace

View File

@@ -0,0 +1,82 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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/scenelicensewriter.h>
#include <sstream>
namespace {
const char* MainTemplateFilename = "${OPENSPACE_DATA}/web/scenelicense/main.hbs";
const char* SceneLicenseTemplateFilename = "${OPENSPACE_DATA}/web/scenelicense/scenelicense.hbs";
const char* JsFilename = "${OPENSPACE_DATA}/web/scenelicense/script.js";
} // namespace
namespace openspace {
SceneLicenseWriter::SceneLicenseWriter(const std::vector<SceneLicense>& licenses)
: DocumentationGenerator(
"Documentation",
"sceneLicenses",
{
{ "sceneLicenseTemplate", SceneLicenseTemplateFilename },
{ "mainTemplate", MainTemplateFilename }
},
JsFilename
)
, _licenses(licenses)
{}
std::string SceneLicenseWriter::generateJson() const {
std::stringstream json;
json << "[";
for (const SceneLicense& license : _licenses) {
json << "{";
json << "\"module\": \"" << escapedJson(license.module) << "\", ";
json << "\"name\": \"" << escapedJson(license.name) << "\", ";
json << "\"attribution\": \"" << escapedJson(license.attribution) << "\", ";
json << "\"url\": \"" << escapedJson(license.url) << "\", ";
json << "\"licenseText\": \"" << escapedJson(license.licenseText) << "\"";
json << "}";
if (&license != &(_licenses.back())) {
json << ",";
}
}
json << "]";
std::string jsonString = "";
for (const char& c : json.str()) {
if (c == '\'') {
jsonString += "\\'";
} else {
jsonString += c;
}
}
return jsonString;
}
} // namespace openspace

View File

@@ -40,6 +40,7 @@ namespace {
const char* KeyPathScene = "ScenePath";
const char* KeyModules = "Modules";
const char* ModuleExtension = ".mod";
const char* LicenseExtension = ".license";
//const char* KeyPathModule = "ModulePath";
//const char* RootNodeName = "Root";
@@ -97,6 +98,7 @@ std::unique_ptr<Scene> SceneLoader::loadScene(const std::string& path) {
std::vector<std::string> keys = moduleDictionary.keys();
std::vector<SceneLoader::LoadedNode> allNodes;
std::vector<SceneLicense> allLicenses;
{
// Inside loadDirectory the working directory is changed (for now), so we need
@@ -112,8 +114,19 @@ std::unique_ptr<Scene> SceneLoader::loadScene(const std::string& path) {
std::replace(fullName.begin(), fullName.end(), '/', FileSys.PathSeparator);
std::string path = FileSys.pathByAppendingComponent(modulesPath, fullName);
std::vector<SceneLoader::LoadedNode> nodes = loadDirectory(path, state);
std::move(nodes.begin(), nodes.end(), std::back_inserter(allNodes));
std::pair<std::vector<SceneLoader::LoadedNode>, std::vector<SceneLicense>>
nodes = loadDirectory(path, state);
std::move(
nodes.first.begin(),
nodes.first.end(),
std::back_inserter(allNodes)
);
std::move(
nodes.second.begin(),
nodes.second.end(),
std::back_inserter(allLicenses)
);
}
}
@@ -125,6 +138,10 @@ std::unique_ptr<Scene> SceneLoader::loadScene(const std::string& path) {
addLoadedNodes(*scene, std::move(allNodes));
for (SceneLicense& l : allLicenses) {
scene->addSceneLicense(std::move(l));
}
ghoul::Dictionary cameraDictionary;
sceneDictionary.getValue(KeyCamera, cameraDictionary);
LoadedCamera loadedCamera = loadCamera(cameraDictionary);
@@ -145,7 +162,8 @@ std::unique_ptr<Scene> SceneLoader::loadScene(const std::string& path) {
return scene;
}
std::vector<SceneGraphNode*> SceneLoader::importDirectory(Scene& scene, const std::string& path) {
std::pair<std::vector<SceneGraphNode*>, std::vector<SceneLicense>>
SceneLoader::importDirectory(Scene& scene, const std::string& path) {
lua_State* state = ghoul::lua::createNewLuaState();
OnExit(
// Delete the Lua state at the end of the scope, no matter what.
@@ -156,9 +174,11 @@ std::vector<SceneGraphNode*> SceneLoader::importDirectory(Scene& scene, const st
std::string absDirectoryPath = absPath(path);
ghoul::filesystem::Directory oldDirectory = FileSys.currentDirectory();
std::vector<SceneLoader::LoadedNode> nodes = loadDirectory(path, state);
std::pair<std::vector<SceneLoader::LoadedNode>, std::vector<SceneLicense>>
nodes = loadDirectory(path, state);
FileSys.setCurrentDirectory(oldDirectory);
return addLoadedNodes(scene, std::move(nodes));
return { addLoadedNodes(scene, std::move(nodes.first)), nodes.second };
}
SceneGraphNode* SceneLoader::importNodeDictionary(Scene& scene, const ghoul::Dictionary& dict) {
@@ -198,14 +218,15 @@ SceneLoader::LoadedCamera SceneLoader::loadCamera(const ghoul::Dictionary& camer
}
std::vector<SceneLoader::LoadedNode> SceneLoader::loadDirectory(
std::pair<std::vector<SceneLoader::LoadedNode>, std::vector<SceneLicense>>
SceneLoader::loadDirectory(
const std::string& path,
lua_State* luaState)
{
std::string::size_type pos = path.find_last_of(FileSys.PathSeparator);
if (pos == std::string::npos) {
LERROR("Error parsing directory name '" << path << "'");
return std::vector<SceneLoader::LoadedNode>();
return {};
}
std::string moduleName = path.substr(pos + 1);
std::string moduleFile = FileSys.pathByAppendingComponent(path, moduleName) + ModuleExtension;
@@ -218,9 +239,18 @@ std::vector<SceneLoader::LoadedNode> SceneLoader::loadDirectory(
FileSys.setCurrentDirectory(ghoul::filesystem::Directory(path));
// We have a module file, so it is a direct include.
return loadModule(moduleFile, luaState);
std::vector<SceneLoader::LoadedNode> nodes = loadModule(moduleFile, luaState);
std::vector<SceneLicense> licenses;
std::string licenseFile = FileSys.pathByAppendingComponent(path, moduleName) + LicenseExtension;
if (FileSys.fileExists(licenseFile)) {
licenses = loadLicense(licenseFile, moduleName);
}
return { std::move(nodes), licenses };
} else {
std::vector<SceneLoader::LoadedNode> allLoadedNodes;
std::vector<SceneLicense> allLicenses;
// If we do not have a module file, we have to include all subdirectories.
using ghoul::filesystem::Directory;
using std::string;
@@ -230,14 +260,25 @@ std::vector<SceneLoader::LoadedNode> SceneLoader::loadDirectory(
if (!FileSys.directoryExists(directoryPath)) {
LERROR("The directory " << directoryPath << " does not exist.");
return std::vector<SceneLoader::LoadedNode>();
return {};
}
for (const string& subdirectory : directory.readDirectories()) {
std::vector<SceneLoader::LoadedNode> loadedNodes = loadDirectory(subdirectory, luaState);
std::move(loadedNodes.begin(), loadedNodes.end(), std::back_inserter(allLoadedNodes));
std::pair<std::vector<SceneLoader::LoadedNode>, std::vector<SceneLicense>>
loadedNodes = loadDirectory(subdirectory, luaState);
std::move(
loadedNodes.first.begin(),
loadedNodes.first.end(),
std::back_inserter(allLoadedNodes)
);
std::move(
loadedNodes.second.begin(),
loadedNodes.second.end(),
std::back_inserter(allLicenses)
);
}
return allLoadedNodes;
return { std::move(allLoadedNodes), std::move(allLicenses) };
}
}
@@ -309,6 +350,19 @@ std::vector<SceneLoader::LoadedNode> SceneLoader::loadModule(const std::string&
return loadedNodes;
}
std::vector<SceneLicense> SceneLoader::loadLicense(const std::string& path, std::string module) {
ghoul::Dictionary licenseDictionary;
try {
ghoul::lua::loadDictionaryFromFile(path, licenseDictionary);
} catch (const ghoul::lua::LuaRuntimeException& e) {
LERRORC(e.component, e.message);
return {};
}
SceneLicense license(licenseDictionary, module);
return { license };
}
std::vector<SceneGraphNode*> SceneLoader::addLoadedNodes(Scene& scene, std::vector<SceneLoader::LoadedNode>&& loadedNodes) {
std::map<std::string, SceneGraphNode*> existingNodes = scene.nodesByName();
std::map<std::string, SceneGraphNode*> addedNodes;

View File

@@ -73,6 +73,7 @@ std::unique_ptr<Translation> Translation::createFromDictionary(
Translation::Translation()
: properties::PropertyOwner({ "Translation" })
, _positionValue(glm::dvec3(0.0))
{}
bool Translation::initialize() {
@@ -81,6 +82,10 @@ bool Translation::initialize() {
void Translation::update(const UpdateData&) {}
glm::dvec3 Translation::position() const {
return _positionValue;
}
glm::dvec3 Translation::position(double time) {
update({
{},

View File

@@ -42,7 +42,7 @@ namespace openspace {
std::vector<std::unique_ptr<Task>> TaskLoader::tasksFromDictionary(const ghoul::Dictionary& tasksDictionary) {
std::vector<std::unique_ptr<Task>> tasks;
std::vector<std::string> keys = tasksDictionary.keys();
for (const std::string key : keys) {
for (const std::string& key : keys) {
std::string taskName;
ghoul::Dictionary subTask;
if (tasksDictionary.getValue(key, taskName)) {
@@ -52,7 +52,7 @@ std::vector<std::unique_ptr<Task>> TaskLoader::tasksFromDictionary(const ghoul::
} else if (tasksDictionary.getValue(key, subTask)) {
std::string taskType = subTask.value<std::string>("Type");
std::unique_ptr<Task> task = Task::createFromDictionary(subTask);
if (task == nullptr) {
if (!task) {
LERROR("Failed to create a Task object of type '" << taskType << "'");
}
tasks.push_back(std::move(task));

View File

@@ -23,7 +23,9 @@
****************************************************************************************/
#include <openspace/util/timemanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/network/parallelconnection.h>
#include <openspace/util/timeline.h>
@@ -45,7 +47,7 @@ void TimeManager::preSynchronization(double dt) {
}
void TimeManager::consumeKeyframes(double dt) {
double now = OsEng.runTime();
double now = OsEng.windowWrapper().applicationTime();
const std::deque<Keyframe<Time>>& keyframes = _timeline.keyframes();
auto firstFutureKeyframe = std::lower_bound(keyframes.begin(), keyframes.end(), now, &compareKeyframeTimeWithTime);
@@ -114,10 +116,10 @@ void TimeManager::consumeKeyframes(double dt) {
double parameter = (t1 - t0) / (t2 - t0);
double y0 = time().j2000Seconds();
double yPrime0 = time().deltaTime();
// double yPrime0 = time().deltaTime();
double y2 = nextTime.j2000Seconds();
double yPrime2 = nextTime.deltaTime();
// double yPrime2 = nextTime.deltaTime();
double y1 = (1 - parameter) * y0 + parameter * y2;
double y1Prime = (y1 - y0) / dt;

View File

@@ -26,9 +26,6 @@
#include <openspace/util/spicemanager.h>
#include <ghoul/logging/logmanager.h>
#define _USE_MATH_DEFINES
#include <math.h>
namespace {
const char* _loggerCat = "TransformationManager";
} // namespace
@@ -53,9 +50,10 @@ TransformationManager::~TransformationManager(){
#endif
}
glm::dmat3 TransformationManager::kameleonTransformationMatrix(std::string from,
std::string to,
double ephemerisTime) const
glm::dmat3 TransformationManager::kameleonTransformationMatrix(
[[maybe_unused]] const std::string& from,
[[maybe_unused]] const std::string& to,
[[maybe_unused]] double ephemerisTime) const
{
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
ccmc::Position in0 = {1.f, 0.f, 0.f};
@@ -80,9 +78,10 @@ glm::dmat3 TransformationManager::kameleonTransformationMatrix(std::string from,
#endif
}
glm::dmat3 TransformationManager::frameTransformationMatrix(std::string from,
std::string to,
double ephemerisTime) const
glm::dmat3 TransformationManager::frameTransformationMatrix(
[[maybe_unused]] const std::string& from,
[[maybe_unused]] const std::string& to,
[[maybe_unused]] double ephemerisTime) const
{
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
auto fromit = _kameleonFrames.find(from);

View File

@@ -30,17 +30,19 @@ function (handle_applications)
list(REMOVE_ITEM appDirs ".DS_Store")
message(STATUS "Configuration application")
# First create all of the options for the applications. In case that one of the
# applications fail to include later, we still want all of them listed
foreach (app ${appDirs})
set(app_dir "${OPENSPACE_APPS_DIR}/${app}")
string(TOUPPER ${app} upper_app)
option(OPENSPACE_APPLICATION_${upper_app} "${app} Application" OFF)
get_application_attribute_default(${app_dir} is_default_application)
if (${is_default_application})
option(OPENSPACE_APPLICATION_${upper_app} "Build ${app} application" ${is_default_application})
endif ()
option(OPENSPACE_APPLICATION_${upper_app} "Build ${app} application" ${is_default_application})
endforeach ()
foreach (app ${appDirs})
set(app_dir "${OPENSPACE_APPS_DIR}/${app}")
string(TOUPPER ${app} upper_app)
if (OPENSPACE_APPLICATION_${upper_app})
message(STATUS "Adding application ${app}")
add_subdirectory(${app_dir})