mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-10 13:41:45 -06:00
Merge branch 'plutoViz' into feature/stars
This commit is contained in:
@@ -59,7 +59,8 @@ public:
|
||||
|
||||
static bool isInitialized();
|
||||
bool initialize();
|
||||
|
||||
bool isMaster();
|
||||
void setMaster(bool master);
|
||||
static bool findConfiguration(std::string& filename);
|
||||
|
||||
// Guaranteed to return a valid pointer
|
||||
@@ -110,6 +111,7 @@ private:
|
||||
LuaConsole* _console;
|
||||
gui::GUI* _gui;
|
||||
double _dt;
|
||||
bool _isMaster;
|
||||
|
||||
SyncBuffer* _syncBuffer;
|
||||
};
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
void loadTexture();
|
||||
void allocateData();
|
||||
void insertPoint(std::vector<float>& arr, psc& p, glm::vec4& c);
|
||||
void insertPoint(std::vector<float>& arr, psc p, glm::vec4 c);
|
||||
void fovProjection(bool H[], std::vector<glm::dvec3> bounds);
|
||||
|
||||
psc orthogonalProjection(glm::dvec3 camvec);
|
||||
|
||||
@@ -73,6 +73,9 @@ public:
|
||||
|
||||
void serialize(SyncBuffer* syncBuffer);
|
||||
void deserialize(SyncBuffer* syncBuffer);
|
||||
|
||||
float globalOpacity();
|
||||
void setGlobalOpacity(float opacity);
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
@@ -84,6 +87,12 @@ public:
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
|
||||
// This is a temporary method to change the origin of the coordinate system ---abock
|
||||
void changeViewPoint(std::string origin);
|
||||
|
||||
//temporaray fade functionality
|
||||
void startFading(int direction, float fadeDuration);
|
||||
|
||||
private:
|
||||
void storePerformanceMeasurements();
|
||||
|
||||
@@ -101,6 +110,11 @@ private:
|
||||
|
||||
void generateGlslConfig();
|
||||
|
||||
float _globalOpactity;
|
||||
float _fadeDuration;
|
||||
float _currentFadeTime;
|
||||
int _fadeDirection;
|
||||
|
||||
bool _visualizeABuffer;
|
||||
ABufferVisualizer* _visualizer;
|
||||
};
|
||||
|
||||
@@ -85,6 +85,12 @@ public:
|
||||
const Renderable* renderable() const;
|
||||
Renderable* renderable();
|
||||
|
||||
// @TODO Remove once the scalegraph is in effect ---abock
|
||||
void setEphemeris(Ephemeris* eph) {
|
||||
delete _ephemeris;
|
||||
_ephemeris = eph;
|
||||
}
|
||||
|
||||
private:
|
||||
bool sphereInsideFrustum(const psc& s_pos, const PowerScaledScalar& s_rad, const Camera* camera);
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
|
||||
openspace.clearKeys()
|
||||
|
||||
function setEarthAsOrigin()
|
||||
openspace.setOrigin('Earth')
|
||||
end
|
||||
|
||||
interaction_speed = 2.75
|
||||
|
||||
-- Key Bindings
|
||||
@@ -14,6 +9,10 @@ openspace.bindKey("f3", "openspace.setPerformanceMeasurement(false)")
|
||||
openspace.bindKey("f4", "openspace.takeScreenshot()")
|
||||
openspace.bindKey("f5", "loadKeyBindings()")
|
||||
|
||||
openspace.bindKey("f9", "openspace.changeViewPointToPluto(); openspace.printInfo('Changing Viewpoint to Pluto-in-center');");
|
||||
openspace.bindKey("f10", "openspace.changeViewPointToSun(); openspace.printInfo('Changing Viewpoint to Sun-in-center');");
|
||||
|
||||
|
||||
openspace.bindKey("T", "openspace.distance(-interaction_speed * openspace.dt(), 6.0)")
|
||||
openspace.bindKey("G", "openspace.distance(interaction_speed * openspace.dt(), 6.0)")
|
||||
openspace.bindKey("Y", "openspace.distance(-interaction_speed * openspace.dt(), 10.0)")
|
||||
|
||||
36
shaders/postFX_fs.glsl
Normal file
36
shaders/postFX_fs.glsl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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 430
|
||||
|
||||
in vec2 UV;
|
||||
out vec4 Color;
|
||||
|
||||
uniform sampler2D Tex;
|
||||
uniform float Opacity;
|
||||
|
||||
void main()
|
||||
{
|
||||
Color = texture(Tex, UV) * Opacity;
|
||||
}
|
||||
36
shaders/postFX_vs.glsl
Normal file
36
shaders/postFX_vs.glsl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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 430
|
||||
|
||||
layout (location = 0) in vec2 TexCoords;
|
||||
layout (location = 1) in vec3 Position;
|
||||
|
||||
out vec2 UV;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(Position, 1.0);
|
||||
UV = TexCoords;
|
||||
}
|
||||
@@ -93,6 +93,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName)
|
||||
, _console(new LuaConsole)
|
||||
, _gui(new gui::GUI)
|
||||
, _syncBuffer(nullptr)
|
||||
, _isMaster(false)
|
||||
{
|
||||
SpiceManager::initialize();
|
||||
Time::initialize();
|
||||
@@ -530,9 +531,17 @@ bool OpenSpaceEngine::initializeGL() {
|
||||
return success;
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::isMaster(){
|
||||
return _isMaster;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::setMaster(bool master){
|
||||
_isMaster = master;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::preSynchronization() {
|
||||
FileSys.triggerFilesystemEvents();
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
if (_isMaster) {
|
||||
//const double dt = sgct::Engine::instance()->getDt();
|
||||
const double dt = sgct::Engine::instance()->getAvgDt();
|
||||
|
||||
@@ -552,7 +561,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
_scriptEngine->postSynchronizationPreDraw();
|
||||
_renderEngine->postSynchronizationPreDraw();
|
||||
|
||||
if (sgct::Engine::instance()->isMaster() && _gui->isEnabled()) {
|
||||
if (_isMaster && _gui->isEnabled()) {
|
||||
double posX, posY;
|
||||
sgct::Engine::instance()->getMousePos(0, &posX, &posY);
|
||||
|
||||
@@ -571,10 +580,10 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
void OpenSpaceEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) {
|
||||
_renderEngine->render(projectionMatrix, viewMatrix);
|
||||
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
if (_isMaster) {
|
||||
// If currently writing a command, render it to screen
|
||||
sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr();
|
||||
if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering() && _console->isVisible()) {
|
||||
if (_isMaster && !w->isUsingFisheyeRendering() && _console->isVisible()) {
|
||||
_console->render();
|
||||
}
|
||||
|
||||
@@ -584,14 +593,14 @@ void OpenSpaceEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::postDraw() {
|
||||
if (sgct::Engine::instance()->isMaster())
|
||||
if (_isMaster)
|
||||
//_interactionHandler.unlockControls();
|
||||
|
||||
_renderEngine->postDraw();
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::keyboardCallback(int key, int action) {
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
bool isConsumed = _gui->keyCallback(key, action);
|
||||
if (isConsumed)
|
||||
@@ -611,7 +620,7 @@ void OpenSpaceEngine::keyboardCallback(int key, int action) {
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::charCallback(unsigned int codepoint) {
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
bool isConsumed = _gui->charCallback(codepoint);
|
||||
if (isConsumed)
|
||||
@@ -625,7 +634,7 @@ void OpenSpaceEngine::charCallback(unsigned int codepoint) {
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mouseButtonCallback(int key, int action) {
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
bool isConsumed = _gui->mouseButtonCallback(key, action);
|
||||
if (isConsumed && action != SGCT_RELEASE)
|
||||
@@ -637,13 +646,13 @@ void OpenSpaceEngine::mouseButtonCallback(int key, int action) {
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mousePositionCallback(int x, int y) {
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
if (_isMaster) {
|
||||
_interactionHandler->mousePositionCallback(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mouseScrollWheelCallback(int pos) {
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
bool isConsumed = _gui->mouseWheelCallback(pos);
|
||||
if (isConsumed)
|
||||
|
||||
54
src/main.cpp
54
src/main.cpp
@@ -23,8 +23,9 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logging>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <sgct.h>
|
||||
|
||||
sgct::Engine* _sgctEngine;
|
||||
@@ -45,6 +46,12 @@ void mainDecodeFun();
|
||||
void mainExternalControlCallback(const char * receivedChars, int size);
|
||||
void mainLogCallback(const char* msg);
|
||||
|
||||
//temporary post-FX functions, TODO make a more permanent solution to this @JK
|
||||
void postFXPass();
|
||||
void setupPostFX();
|
||||
GLint _postFXTexLoc;
|
||||
GLint _postFXOpacityLoc;
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "main";
|
||||
}
|
||||
@@ -109,6 +116,9 @@ int main(int argc, char** argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
//is this node the master? (must be set after call to _sgctEngine->init())
|
||||
OsEng.ref().setMaster(_sgctEngine->isMaster());
|
||||
|
||||
// Main loop
|
||||
LDEBUG("Starting rendering loop");
|
||||
_sgctEngine->render();
|
||||
@@ -136,6 +146,9 @@ void mainInitFunc()
|
||||
std::cin.ignore(100);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
//temporary post-FX solution, TODO add a more permanent solution @JK
|
||||
setupPostFX();
|
||||
}
|
||||
|
||||
void mainPreSyncFunc()
|
||||
@@ -155,9 +168,9 @@ void mainRenderFunc()
|
||||
glm::mat4 userMatrix = glm::translate(glm::mat4(1.f), _sgctEngine->getDefaultUserPtr()->getPos());
|
||||
glm::mat4 sceneMatrix = _sgctEngine->getModelMatrix();
|
||||
glm::mat4 viewMatrix = _sgctEngine->getActiveViewMatrix() * userMatrix;
|
||||
|
||||
|
||||
//dont shift nav-direction on master, makes it very tricky to navigate @JK
|
||||
if (!_sgctEngine->isMaster()){
|
||||
if (!OsEng.ref().isMaster()){
|
||||
viewMatrix = viewMatrix * sceneMatrix;
|
||||
}
|
||||
|
||||
@@ -172,39 +185,39 @@ void mainPostDrawFunc()
|
||||
|
||||
void mainExternalControlCallback(const char* receivedChars, int size)
|
||||
{
|
||||
if (_sgctEngine->isMaster())
|
||||
if (OsEng.ref().isMaster())
|
||||
OsEng.externalControlCallback(receivedChars, size, 0);
|
||||
}
|
||||
|
||||
void mainKeyboardCallback(int key, int action)
|
||||
{
|
||||
if (_sgctEngine->isMaster())
|
||||
if (OsEng.ref().isMaster())
|
||||
OsEng.keyboardCallback(key, action);
|
||||
}
|
||||
|
||||
void mainMouseButtonCallback(int key, int action)
|
||||
{
|
||||
if (_sgctEngine->isMaster())
|
||||
if (OsEng.ref().isMaster())
|
||||
OsEng.mouseButtonCallback(key, action);
|
||||
}
|
||||
|
||||
void mainMousePosCallback(double x, double y)
|
||||
{
|
||||
// TODO use float instead
|
||||
if (_sgctEngine->isMaster())
|
||||
if (OsEng.ref().isMaster())
|
||||
OsEng.mousePositionCallback(static_cast<int>(x), static_cast<int>(y));
|
||||
}
|
||||
|
||||
void mainMouseScrollCallback(double posX, double posY)
|
||||
{
|
||||
// TODO use float instead
|
||||
if (_sgctEngine->isMaster())
|
||||
if (OsEng.ref().isMaster())
|
||||
OsEng.mouseScrollWheelCallback(static_cast<int>(posY));
|
||||
}
|
||||
|
||||
void mainCharCallback(unsigned int codepoint) {
|
||||
|
||||
if (_sgctEngine->isMaster())
|
||||
if (OsEng.ref().isMaster())
|
||||
OsEng.charCallback(codepoint);
|
||||
}
|
||||
|
||||
@@ -222,4 +235,27 @@ void mainLogCallback(const char* msg){
|
||||
std::string message = msg;
|
||||
// Remove the trailing \n that is passed along
|
||||
LINFOC("SGCT", message.substr(0, std::max<size_t>(message.size() - 1, 0)));
|
||||
}
|
||||
|
||||
void postFXPass(){
|
||||
glUniform1i(_postFXTexLoc, 0);
|
||||
if (OsEng.isMaster()){
|
||||
glUniform1f(_postFXOpacityLoc, 1.f);
|
||||
}
|
||||
else{
|
||||
glUniform1f(_postFXOpacityLoc, OsEng.ref().renderEngine()->globalOpacity());
|
||||
}
|
||||
}
|
||||
|
||||
void setupPostFX(){
|
||||
sgct::PostFX fx[1];
|
||||
sgct::ShaderProgram *shader;
|
||||
fx[0].init("OpacityControl", absPath("${SHADERS}/postFX_vs.glsl"), absPath("${SHADERS}/postFX_fs.glsl"));
|
||||
fx[0].setUpdateUniformsFunction(postFXPass);
|
||||
shader = fx[0].getShaderProgram();
|
||||
shader->bind();
|
||||
_postFXTexLoc = shader->getUniformLocation("Tex");
|
||||
_postFXOpacityLoc = shader->getUniformLocation("Opacity");
|
||||
shader->unbind();
|
||||
_sgctEngine->addPostFX(fx[0]);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
dictionary.getValue(keyFrame, _frame);
|
||||
|
||||
bool b1 = dictionary.getValue(keyBody, _target);
|
||||
assert(b1 == true);
|
||||
//assert(b1 == true);
|
||||
|
||||
// TODO: textures need to be replaced by a good system similar to the geometry as soon
|
||||
// as the requirements are fixed (ab)
|
||||
|
||||
@@ -184,7 +184,7 @@ void RenderableFov::sendToGPU(){
|
||||
}
|
||||
// various helper methods
|
||||
|
||||
void RenderableFov::insertPoint(std::vector<float>& arr, psc& p, glm::vec4& c){
|
||||
void RenderableFov::insertPoint(std::vector<float>& arr, psc p, glm::vec4 c){
|
||||
for (int i = 0; i < 4; i++){
|
||||
arr.push_back(p[i]);
|
||||
}
|
||||
@@ -197,10 +197,10 @@ void RenderableFov::insertPoint(std::vector<float>& arr, psc& p, glm::vec4& c){
|
||||
psc RenderableFov::pscInterpolate(psc p0, psc p1, float t){
|
||||
assert(t >= 0 && t <= 1);
|
||||
float t2 = (1.f - t);
|
||||
return PowerScaledCoordinate::PowerScaledCoordinate(t2*p0[0] + t*p1[0],
|
||||
t2*p0[1] + t*p1[1],
|
||||
t2*p0[2] + t*p1[2],
|
||||
t2*p0[3] + t*p1[3]);
|
||||
return PowerScaledCoordinate(t2*p0[0] + t*p1[0],
|
||||
t2*p0[1] + t*p1[1],
|
||||
t2*p0[2] + t*p1[2],
|
||||
t2*p0[3] + t*p1[3]);
|
||||
}
|
||||
glm::dvec3 RenderableFov::interpolate(glm::dvec3 p0, glm::dvec3 p1, float t){
|
||||
assert(t >= 0 && t <= 1);
|
||||
@@ -278,13 +278,14 @@ void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds){
|
||||
glm::dvec3 interpolated;
|
||||
glm::dvec3 current;
|
||||
glm::dvec3 next;
|
||||
glm::vec4 tmp(1);
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
int k = (i + 1 > 3) ? 0 : i + 1;
|
||||
current = bounds[i];
|
||||
next = bounds[k];
|
||||
if (H[i] == false){ // If point is non-interceptive, project it.
|
||||
insertPoint(_varray2, orthogonalProjection(current), glm::vec4(1));
|
||||
insertPoint(_varray2, orthogonalProjection(current), tmp);
|
||||
}
|
||||
if (H[i] == true && H[i + 1] == false){ // current point is interceptive, next is not
|
||||
// find outer most point for interpolation
|
||||
|
||||
@@ -170,7 +170,7 @@ void RenderableTrail::update(const UpdateData& data) {
|
||||
// Update the floating current time
|
||||
// Is 'CN+S' correct? It has to be chosen to be the same as in SpiceEphemeris, but
|
||||
// unsure if it is correct ---abock
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", data.time, pscPos, pscVel, lightTime);
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", data.time, pscPos, pscVel, lightTime);
|
||||
pscPos[3] += 3; // KM to M
|
||||
_vertexArray[0] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
|
||||
|
||||
|
||||
@@ -57,6 +57,10 @@
|
||||
#include <fstream>
|
||||
#include <sgct.h>
|
||||
|
||||
// These are temporary ---abock
|
||||
#include <openspace/scenegraph/spiceephemeris.h>
|
||||
#include <openspace/scenegraph/staticephemeris.h>
|
||||
|
||||
// ABuffer defines
|
||||
#define ABUFFER_FRAMEBUFFER 0
|
||||
#define ABUFFER_SINGLE_LINKED 1
|
||||
@@ -80,6 +84,22 @@ namespace openspace {
|
||||
|
||||
namespace luascriptfunctions {
|
||||
|
||||
int changeToPlutoViewPoint(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 0)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
OsEng.renderEngine()->changeViewPoint("Pluto");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int changeToSunViewPoint(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 0)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
OsEng.renderEngine()->changeViewPoint("Sun");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* takeScreenshot():
|
||||
@@ -140,6 +160,37 @@ namespace openspace {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* fadeIn(float):
|
||||
* start a global fadein over (float) seconds
|
||||
*/
|
||||
int fadeIn(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 1)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
|
||||
|
||||
double t = luaL_checknumber(L, -1);
|
||||
|
||||
OsEng.renderEngine()->startFading(1, t);
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* fadeIn(float):
|
||||
* start a global fadeout over (float) seconds
|
||||
*/
|
||||
int fadeOut(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 1)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
|
||||
|
||||
double t = luaL_checknumber(L, -1);
|
||||
|
||||
OsEng.renderEngine()->startFading(-1, t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace luascriptfunctions
|
||||
|
||||
|
||||
@@ -155,6 +206,11 @@ namespace openspace {
|
||||
, _performanceMemory(nullptr)
|
||||
, _visualizeABuffer(false)
|
||||
, _visualizer(nullptr)
|
||||
, _globalOpactity(1.f)
|
||||
, _fadeDuration(2.f)
|
||||
, _currentFadeTime(0.f)
|
||||
, _fadeDirection(0)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@@ -307,6 +363,24 @@ namespace openspace {
|
||||
|
||||
void RenderEngine::postSynchronizationPreDraw()
|
||||
{
|
||||
//temporary fade funtionality
|
||||
if (_fadeDirection != 0){
|
||||
if (_currentFadeTime > _fadeDuration){
|
||||
_fadeDirection = 0;
|
||||
_globalOpactity = fminf(1.f, fmaxf(0.f, _globalOpactity));
|
||||
}
|
||||
else{
|
||||
|
||||
if (_fadeDirection < 0){
|
||||
_globalOpactity = glm::smoothstep(1.f, 0.f, _currentFadeTime / _fadeDuration);
|
||||
}
|
||||
else{
|
||||
_globalOpactity = glm::smoothstep(0.f, 1.f, _currentFadeTime / _fadeDuration);
|
||||
}
|
||||
_currentFadeTime += static_cast<float>(sgct::Engine::instance()->getAvgDt());
|
||||
}
|
||||
}
|
||||
|
||||
if (_mainCamera){
|
||||
_mainCamera->postSynchronizationPreDraw();
|
||||
}
|
||||
@@ -396,7 +470,7 @@ namespace openspace {
|
||||
#if 1
|
||||
|
||||
// Print some useful information on the master viewport
|
||||
if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering()) {
|
||||
if (OsEng.ref().isMaster() && !w->isUsingFisheyeRendering()) {
|
||||
|
||||
// TODO: Adjust font_size properly when using retina screen
|
||||
const int font_size_mono = 10;
|
||||
@@ -587,6 +661,20 @@ namespace openspace {
|
||||
return _abuffer;
|
||||
}
|
||||
|
||||
float RenderEngine::globalOpacity(){
|
||||
return _globalOpactity;
|
||||
}
|
||||
|
||||
void RenderEngine::setGlobalOpacity(float opacity){
|
||||
_globalOpactity = opacity;
|
||||
}
|
||||
|
||||
void RenderEngine::startFading(int direction, float fadeDuration){
|
||||
_fadeDirection = direction;
|
||||
_fadeDuration = fadeDuration;
|
||||
_currentFadeTime = 0.f;
|
||||
}
|
||||
|
||||
void RenderEngine::generateGlslConfig() {
|
||||
LDEBUG("Generating GLSLS config, expect shader recompilation");
|
||||
int xSize = sgct::Engine::instance()->getActiveWindowPtr()->getXFramebufferResolution();;
|
||||
@@ -648,7 +736,34 @@ namespace openspace {
|
||||
&luascriptfunctions::setPerformanceMeasurement,
|
||||
"bool",
|
||||
"Sets the performance measurements"
|
||||
}
|
||||
},
|
||||
// These are temporary ---abock
|
||||
{
|
||||
"changeViewPointToPluto",
|
||||
&luascriptfunctions::changeToPlutoViewPoint,
|
||||
"",
|
||||
""
|
||||
},
|
||||
{
|
||||
"changeViewPointToSun",
|
||||
&luascriptfunctions::changeToSunViewPoint,
|
||||
"",
|
||||
""
|
||||
},
|
||||
//also temporary @JK
|
||||
{
|
||||
"fadeIn",
|
||||
&luascriptfunctions::fadeIn,
|
||||
"number",
|
||||
""
|
||||
},
|
||||
//also temporary @JK
|
||||
{
|
||||
"fadeOut",
|
||||
&luascriptfunctions::fadeOut,
|
||||
"number",
|
||||
""
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -738,4 +853,43 @@ namespace openspace {
|
||||
_performanceMemory->releaseLock();
|
||||
}
|
||||
|
||||
// This method is temporary and will be removed once the scalegraph is in effect ---abock
|
||||
void RenderEngine::changeViewPoint(std::string origin) {
|
||||
SceneGraphNode* solarSystemBarycenterNode = sceneGraph()->sceneGraphNode("SolarSystemBarycenter");
|
||||
SceneGraphNode* plutoBarycenterNode = sceneGraph()->sceneGraphNode("PlutoBarycenter");
|
||||
|
||||
if (origin == "Pluto") {
|
||||
ghoul::Dictionary solarDictionary =
|
||||
{
|
||||
{ std::string("Type"), std::string("Spice") },
|
||||
{ std::string("Body") , std::string("PLUTO BARYCENTER") },
|
||||
{ std::string("Reference"), std::string("ECLIPJ2000") },
|
||||
{ std::string("Observer") , std::string("SUN") },
|
||||
{ std::string("Kernels") , ghoul::Dictionary() }
|
||||
};
|
||||
ghoul::Dictionary t;
|
||||
t.setValue("Position", glm::vec4(1.f, 0.f, 0.f, 12.f));
|
||||
solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary));
|
||||
plutoBarycenterNode->setEphemeris(new StaticEphemeris);
|
||||
return;
|
||||
}
|
||||
if (origin == "Sun") {
|
||||
ghoul::Dictionary plutoDictionary =
|
||||
{
|
||||
{ std::string("Type"), std::string("Spice") },
|
||||
{ std::string("Body"), std::string("PLUTO BARYCENTER") },
|
||||
{ std::string("Reference"), std::string("ECLIPJ2000") },
|
||||
{ std::string("Observer"), std::string("SUN") },
|
||||
{ std::string("Kernels"), ghoul::Dictionary() }
|
||||
};
|
||||
|
||||
solarSystemBarycenterNode->setEphemeris(new StaticEphemeris);
|
||||
plutoBarycenterNode->setEphemeris(new SpiceEphemeris(plutoDictionary));
|
||||
|
||||
return;
|
||||
}
|
||||
ghoul_assert(false, "??");
|
||||
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
|
||||
@@ -52,8 +52,6 @@ SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
|
||||
|
||||
ghoul::Dictionary kernels;
|
||||
dictionary.getValue(keyKernels, kernels);
|
||||
if (kernels.size() == 0)
|
||||
_kernelsLoadedSuccessfully = false;
|
||||
for (size_t i = 1; i <= kernels.size(); ++i) {
|
||||
std::string kernel;
|
||||
bool success = kernels.getValue(std::to_string(i), kernel);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace openspace {
|
||||
using namespace constants::staticephemeris;
|
||||
|
||||
StaticEphemeris::StaticEphemeris(const ghoul::Dictionary& dictionary)
|
||||
: _position(0.1f, 0.f, 0.f, 0.f)
|
||||
: _position(0.f, 0.f, 0.f, 0.f)
|
||||
{
|
||||
const bool hasPosition = dictionary.hasKeyAndValue<glm::vec4>(keyPosition);
|
||||
if (hasPosition) {
|
||||
|
||||
@@ -260,15 +260,19 @@ void ScriptEngine::addLibrary(LuaLibrary library) {
|
||||
}
|
||||
|
||||
bool ScriptEngine::runScript(const std::string& script) {
|
||||
if (script.empty())
|
||||
return false;
|
||||
if (script.empty()){
|
||||
LWARNING("Script was empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
int status = luaL_loadstring(_state, script.c_str());
|
||||
if (status != LUA_OK) {
|
||||
LERROR("Error loading script: '" << lua_tostring(_state, -1) << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
//LDEBUG("Executing script");
|
||||
LDEBUG("Executing script");
|
||||
LINFO(script);
|
||||
if (lua_pcall(_state, 0, LUA_MULTRET, 0)) {
|
||||
LERROR("Error executing script: " << lua_tostring(_state, -1));
|
||||
return false;
|
||||
@@ -608,6 +612,7 @@ bool ScriptEngine::writeDocumentation(const std::string& filename, const std::st
|
||||
|
||||
void ScriptEngine::serialize(SyncBuffer* syncBuffer){
|
||||
syncBuffer->encode(_currentSyncedScript);
|
||||
_currentSyncedScript.clear();
|
||||
}
|
||||
|
||||
void ScriptEngine::deserialize(SyncBuffer* syncBuffer){
|
||||
|
||||
Reference in New Issue
Block a user