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
+6 -5
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
+9
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(),
};
@@ -38,7 +38,6 @@
namespace {
const char* KeyName = "Name";
const char* KeyUrl = "URL";
static const openspace::properties::Property::PropertyInfo TexturePathInfo = {
"TexturePath",
+133
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
@@ -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__
+119
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
@@ -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,19 +22,33 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
#ifndef __OPENSPACE_MODULE_BASE___LUASCALE___H__
#define __OPENSPACE_MODULE_BASE___LUASCALE___H__
in vec4 vs_positionScreenSpace;
in vec4 vs_pointColor;
#include <openspace/scene/scale.h>
#include <openspace/properties/stringproperty.h>
Fragment getFragment() {
if (vs_pointColor.a < 0.01) {
discard;
}
Fragment frag;
frag.color = vs_pointColor;
frag.depth = vs_positionScreenSpace.w;
return frag;
}
#include <ghoul/lua/luastate.h>
namespace openspace {
namespace documentation { struct Documentation; }
class LuaScale : public Scale {
public:
LuaScale();
LuaScale(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___LUASCALE___H__
+2 -4
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
-2
View File
@@ -38,8 +38,6 @@ public:
StaticScale();
StaticScale(const ghoul::Dictionary& dictionary);
double scaleValue() const override;
static documentation::Documentation Documentation();
private:
-1
View File
@@ -29,7 +29,6 @@ in float vs_screenSpaceDepth;
uniform sampler2D texture1;
Fragment getFragment() {
Fragment frag;
-63
View File
@@ -1,63 +0,0 @@
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScaling_vs.hglsl"
in vec4 in_point_position;
out vec4 vs_positionScreenSpace;
out vec4 vs_pointColor;
uniform vec3 color;
uniform mat4 modelViewTransform;
uniform mat4 projectionTransform;
uniform int pointSteps;
void main() {
vec4 positionCameraSpace = modelViewTransform * in_point_position;
vec4 positionClipSpace = projectionTransform * positionCameraSpace;
vs_positionScreenSpace = z_normalization(positionClipSpace);
gl_Position = vs_positionScreenSpace;
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;
}
// 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);
vs_pointColor.a = maximumDistance / (distanceToCamera / 100.0);
}
+141
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
@@ -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,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/powerScalingMath.hglsl"
#include <${SHADERS_GENERATED}/constants.hglsl>:notrack
#include <openspace/scene/translation.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/filesystem/file.h>
#include <ghoul/lua/luastate.h>
uniform mat4 projection;
uniform mat4 ViewProjection;
#include <memory>
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)
);
namespace openspace {
namespace documentation { struct Documentation; }
class LuaTranslation : public Translation {
public:
LuaTranslation();
LuaTranslation(const ghoul::Dictionary& dictionary);
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;
}
}
virtual void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
private:
properties::StringProperty _luaScriptFile;
ghoul::lua::LuaState _state;
std::unique_ptr<ghoul::filesystem::File> _fileHandle;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___LUATRANSLATION___H__
@@ -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
@@ -38,8 +38,6 @@ public:
StaticTranslation();
StaticTranslation(const ghoul::Dictionary& dictionary);
virtual glm::dvec3 position() const override;
static documentation::Documentation Documentation();
private:
@@ -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&) {
@@ -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;
@@ -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;
};
@@ -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;
+1
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
@@ -221,6 +221,8 @@ int loadWMSCapabilities(lua_State* L) {
std::move(globe),
std::move(url)
);
return 0;
}
int removeWMSServer(lua_State* L) {
@@ -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
@@ -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
+24 -14
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
@@ -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.
@@ -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;
+1 -1
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());
}
+1 -1
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) {
+23 -10
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(
@@ -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 = "";
-1
View File
@@ -36,7 +36,6 @@ out vec4 vs_position;
uniform mat4 modelViewProjectionTransform;
void main() {
vs_st = in_st;