mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-11 15:58:45 -05:00
Merge branch 'plutoViz' of openspace.itn.liu.se:/openspace into plutoViz
Conflicts: ext/ghoul
This commit is contained in:
@@ -75,7 +75,7 @@ public:
|
||||
bool initializeGL();
|
||||
void preSynchronization();
|
||||
void postSynchronizationPreDraw();
|
||||
void render();
|
||||
void render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
|
||||
void postDraw();
|
||||
void keyboardCallback(int key, int action);
|
||||
void charCallback(unsigned int codepoint);
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
bool initializeGL();
|
||||
void postSynchronizationPreDraw();
|
||||
void preSynchronization();
|
||||
void render();
|
||||
void render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
|
||||
void postDraw();
|
||||
|
||||
void takeScreenshot();
|
||||
|
||||
36
include/openspace/scripting/script_helper.h
Normal file
36
include/openspace/scripting/script_helper.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* 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 __SCRIPT_HELPER_H__
|
||||
#define __SCRIPT_HELPER_H__
|
||||
|
||||
#define SCRIPT_CHECK_ARGUMENTS(__stack__, __reqArg__, __realArg__) \
|
||||
if (__realArg__ != __reqArg__) { \
|
||||
LERROR(ghoul::lua::errorLocation(__stack__) << "Expected " << __reqArg__ << \
|
||||
" arguments, got " << __realArg__); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
|
||||
#endif // __SCRIPT_HELPER_H__
|
||||
@@ -96,9 +96,10 @@ private:
|
||||
//sync variables
|
||||
std::mutex _mutex;
|
||||
std::vector<std::string> _queuedScripts;
|
||||
std::vector<std::string> _receivedScripts;
|
||||
std::string _currentSyncedScript;
|
||||
};
|
||||
|
||||
|
||||
} // namespace scripting
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
46
openspace.cfg
Normal file
46
openspace.cfg
Normal file
@@ -0,0 +1,46 @@
|
||||
return {
|
||||
Paths = {
|
||||
SGCT = "${BASE_PATH}/config/sgct",
|
||||
SCRIPTS = "${BASE_PATH}/scripts",
|
||||
SHADERS = "${BASE_PATH}/shaders",
|
||||
SHADERS_GENERATED = "${SHADERS}/generated",
|
||||
OPENSPACE_DATA = "${BASE_PATH}/openspace-data",
|
||||
TESTDIR = "${BASE_PATH}/src/tests",
|
||||
CONFIG = "${BASE_PATH}/config",
|
||||
CACHE = "${BASE_PATH}/cache",
|
||||
FONTS = "${OPENSPACE_DATA}/fonts",
|
||||
PLUTO_KERNELS = "${OPENSPACE_DATA}/spice/Pluto",
|
||||
JP_KERNELS = "${OPENSPACE_DATA}/spice/JP_KERNELS"
|
||||
},
|
||||
SpiceKernel = {
|
||||
Time = "${OPENSPACE_DATA}/spice/naif0010.tls",
|
||||
LeapSecond = "${OPENSPACE_DATA}/spice/pck00010.tpc",
|
||||
NewHorizons = "${OPENSPACE_DATA}/spice/nhmeta.tm"
|
||||
},
|
||||
Fonts = {
|
||||
Mono = "${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf",
|
||||
Light = "${FONTS}/Roboto/Roboto-Regular.ttf"
|
||||
},
|
||||
StartupScripts = {
|
||||
"${SCRIPTS}/default_startup.lua"
|
||||
},
|
||||
SettingsScripts = {
|
||||
"${SCRIPTS}/default_settings.lua"
|
||||
},
|
||||
Logging = {
|
||||
LogLevel = "Debug",
|
||||
ImmediateFlush = true,
|
||||
Logs = {
|
||||
{ Type = "HTML", FileName = "${BASE_PATH}/log.html", Append = false }
|
||||
}
|
||||
},
|
||||
LuaDocumentationFile = {
|
||||
Type = "text",
|
||||
File = "${BASE_PATH}/LuaScripting.txt"
|
||||
},
|
||||
SGCTConfig = "${SGCT}/single.xml",
|
||||
--SGCTConfig = "${SGCT}/single_fisheye.xml",
|
||||
--SGCTConfig = "${SGCT}/two_nodes.xml",
|
||||
--SGCTConfig = "${SGCT}/single_sbs_stereo.xml",
|
||||
Scene = "${OPENSPACE_DATA}/scene/default_michal.scene",
|
||||
}
|
||||
@@ -567,8 +567,8 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::render() {
|
||||
_renderEngine->render();
|
||||
void OpenSpaceEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) {
|
||||
_renderEngine->render(projectionMatrix, viewMatrix);
|
||||
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
// If currently writing a command, render it to screen
|
||||
@@ -576,7 +576,7 @@ void OpenSpaceEngine::render() {
|
||||
if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering() && _console->isVisible()) {
|
||||
_console->render();
|
||||
}
|
||||
|
||||
|
||||
if (_gui->isEnabled())
|
||||
_gui->endFrame();
|
||||
}
|
||||
|
||||
@@ -162,7 +162,10 @@ void mainPostSyncPreDrawFunc()
|
||||
|
||||
void mainRenderFunc()
|
||||
{
|
||||
OsEng.render();
|
||||
glm::mat4 userMatrix = glm::translate(glm::mat4(1.f), _sgctEngine->getUserPtr()->getPos());
|
||||
glm::mat4 viewMatrix = _sgctEngine->getActiveViewMatrix() * userMatrix;
|
||||
glm::mat4 projectionMatrix = _sgctEngine->getActiveProjectionMatrix();
|
||||
OsEng.render(projectionMatrix, viewMatrix);
|
||||
}
|
||||
|
||||
void mainPostDrawFunc()
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/configurationmanager.h>
|
||||
#include <sgct.h>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
@@ -56,7 +57,6 @@ namespace {
|
||||
const std::string keyInstrumentNear = "Instrument.Near";
|
||||
const std::string keyInstrumentFar = "Instrument.Far";
|
||||
const std::string keySequenceDir = "Projection.Sequence";
|
||||
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyGeometry = "Geometry";
|
||||
const std::string keyShading = "PerformShading";
|
||||
@@ -144,8 +144,9 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
|
||||
bool loaded = openspace::ImageSequencer::ref().loadSequence(_sequenceDir);
|
||||
if (!loaded) LDEBUG(name + " did not load sequence " + _sequenceDir + " check mod file path");
|
||||
*/
|
||||
openspace::ImageSequencer::ref().parsePlaybook("C:/Users/michal/playbook", "txt");
|
||||
//openspace::ImageSequencer::ref().parsePlaybook("C:/Users/michal/playbook", "txt");
|
||||
//openspace::ImageSequencer::ref().parsePlaybook("C:/Users/joaki56/Desktop/ProjectionsOfInterest/playbook", "txt");
|
||||
openspace::ImageSequencer::ref().parsePlaybook(absPath("${OPENSPACE_DATA}/playbook.csv"), "csv");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ bool RenderableFov::initialize(){
|
||||
bool completeSuccess = true;
|
||||
if (_programObject == nullptr)
|
||||
completeSuccess &= OsEng.ref().configurationManager()->getValue("FovProgram", _programObject);
|
||||
completeSuccess &= OsEng.ref().configurationManager()->getValue("EphemerisProgram", _programObject);
|
||||
|
||||
allocateData();
|
||||
sendToGPU();
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace openspace {
|
||||
|
||||
}
|
||||
|
||||
void RenderEngine::render()
|
||||
void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix)
|
||||
{
|
||||
// We need the window pointer
|
||||
sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr();
|
||||
@@ -375,21 +375,19 @@ namespace openspace {
|
||||
= sgct_core::ClusterManager::instance()->getUserPtr()->getPos();
|
||||
#endif
|
||||
//@CHECK does the dome disparity disappear if this line disappears? ---abock
|
||||
const glm::mat4 view
|
||||
= glm::translate(glm::mat4(1.0),
|
||||
eyePosition); // make sure the eye is in the center
|
||||
_mainCamera->setViewProjectionMatrix(
|
||||
sgct::Engine::instance()->getActiveModelViewProjectionMatrix() * view);
|
||||
|
||||
_mainCamera->setModelMatrix(
|
||||
sgct::Engine::instance()->getModelMatrix());
|
||||
//const glm::mat4 view
|
||||
// = glm::translate(glm::mat4(1.0),
|
||||
// eyePosition); // make sure the eye is in the center
|
||||
//
|
||||
|
||||
_mainCamera->setViewMatrix(
|
||||
sgct::Engine::instance()->getActiveViewMatrix()* view);
|
||||
viewMatrix );
|
||||
|
||||
_mainCamera->setProjectionMatrix(
|
||||
sgct::Engine::instance()->getActiveProjectionMatrix());
|
||||
projectionMatrix);
|
||||
|
||||
//Is this really necessary to store?
|
||||
_mainCamera->setViewProjectionMatrix(projectionMatrix * viewMatrix);
|
||||
|
||||
// render the scene starting from the root node
|
||||
if (!_visualizeABuffer) {
|
||||
@@ -435,21 +433,21 @@ namespace openspace {
|
||||
|
||||
// GUI PRINT
|
||||
// Using a macro to shorten line length and increase readability
|
||||
#define PrintText(i, format, size, ...) Freetype::print(font, size, static_cast<float>(startY - font_size_mono * i * 2), format, __VA_ARGS__);
|
||||
#define PrintText(i, format, ...) Freetype::print(font, 10.f, static_cast<float>(startY - font_size_mono * i * 2), format, __VA_ARGS__);
|
||||
#define PrintColorText(i, format, size, color, ...) Freetype::print(font, size, static_cast<float>(startY - font_size_mono * i * 2), color, format, __VA_ARGS__);
|
||||
|
||||
|
||||
int i = 0;
|
||||
|
||||
PrintText(i++, "Date: %s", 20, Time::ref().currentTimeUTC().c_str());
|
||||
PrintText(i++, "Avg. Frametime: %.5f", 10, sgct::Engine::instance()->getAvgDt());
|
||||
PrintText(i++, "Drawtime: %.5f", 10, sgct::Engine::instance()->getDrawTime());
|
||||
PrintText(i++, "Frametime: %.5f", 10, sgct::Engine::instance()->getDt());
|
||||
PrintText(i++, "Origin: (% .5f, % .5f, % .5f, % .5f)", 10, origin[0], origin[1], origin[2], origin[3]);
|
||||
PrintText(i++, "Cam pos: (% .5f, % .5f, % .5f, % .5f)", 10, position[0], position[1], position[2], position[3]);
|
||||
PrintText(i++, "View dir: (% .5f, % .5f, % .5f)", 10, viewdirection[0], viewdirection[1], viewdirection[2]);
|
||||
PrintText(i++, "Cam->origin: (% .15f, % .4f)", 10, pssl[0], pssl[1]);
|
||||
PrintText(i++, "Scaling: (% .5f, % .5f)", 10, scaling[0], scaling[1]);
|
||||
PrintText(i++, "Date: %s", Time::ref().currentTimeUTC().c_str());
|
||||
PrintText(i++, "Avg. Frametime: %.5f", sgct::Engine::instance()->getAvgDt());
|
||||
PrintText(i++, "Drawtime: %.5f", sgct::Engine::instance()->getDrawTime());
|
||||
PrintText(i++, "Frametime: %.5f", sgct::Engine::instance()->getDt());
|
||||
PrintText(i++, "Origin: (% .5f, % .5f, % .5f, % .5f)", origin[0], origin[1], origin[2], origin[3]);
|
||||
PrintText(i++, "Cam pos: (% .5f, % .5f, % .5f, % .5f)", position[0], position[1], position[2], position[3]);
|
||||
PrintText(i++, "View dir: (% .5f, % .5f, % .5f)", viewdirection[0], viewdirection[1], viewdirection[2]);
|
||||
PrintText(i++, "Cam->origin: (% .15f, % .4f)", pssl[0], pssl[1]);
|
||||
PrintText(i++, "Scaling: (% .5f, % .5f)", scaling[0], scaling[1]);
|
||||
|
||||
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - Time::ref().currentTime();
|
||||
double t = 0.0;
|
||||
|
||||
@@ -179,7 +179,7 @@ void RenderableStars::render(const RenderData& data) {
|
||||
// is done twice? ---abock
|
||||
glm::vec2 scaling = glm::vec2(1, -19);
|
||||
|
||||
glm::mat4 modelMatrix = data.camera.modelMatrix();
|
||||
glm::mat4 modelMatrix = glm::mat4(1.0);
|
||||
glm::mat4 viewMatrix = data.camera.viewMatrix();
|
||||
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scenegraph/scenegraphnode.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/scripting/script_helper.h>
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/time.h>
|
||||
|
||||
@@ -69,24 +70,29 @@ namespace luascriptfunctions {
|
||||
* with the type the denoted Property expects
|
||||
*/
|
||||
int property_setValue(lua_State* L) {
|
||||
using ghoul::lua::luaTypeToString;
|
||||
static const std::string _loggerCat = "property_setValue";
|
||||
using ghoul::lua::errorLocation;
|
||||
using ghoul::lua::luaTypeToString;
|
||||
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 2)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments);
|
||||
SCRIPT_CHECK_ARGUMENTS(L, 2, nArguments);
|
||||
|
||||
std::string uri = luaL_checkstring(L, -2);
|
||||
const int type = lua_type(L, -1);
|
||||
|
||||
openspace::properties::Property* prop = property(uri);
|
||||
if (!prop)
|
||||
return luaL_error(L, "Property with URL '%s' could not be found", uri.c_str());
|
||||
if (!prop) {
|
||||
LERROR(errorLocation(L) << "Property with URI '" << uri << "' was not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (type != prop->typeLua())
|
||||
return luaL_error(L, "Property '%s' does not accept input of type '%s'. \
|
||||
Requested type: '%s'", uri.c_str(),
|
||||
luaTypeToString(type).c_str(),
|
||||
luaTypeToString(prop->typeLua()).c_str());
|
||||
|
||||
if (type != prop->typeLua()) {
|
||||
LERROR(errorLocation(L) << "Property '" << uri <<
|
||||
"' does not accept input of type '" << luaTypeToString(type) <<
|
||||
"'. Requested type: '" << luaTypeToString(prop->typeLua()) << "'");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
prop->setLua(L);
|
||||
|
||||
@@ -100,15 +106,19 @@ int property_setValue(lua_State* L) {
|
||||
* be passed to the setPropertyValue method.
|
||||
*/
|
||||
int property_getValue(lua_State* L) {
|
||||
static const std::string _loggerCat = "property_getValue";
|
||||
using ghoul::lua::errorLocation;
|
||||
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 1)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
|
||||
SCRIPT_CHECK_ARGUMENTS(L, 1, nArguments);
|
||||
|
||||
std::string uri = luaL_checkstring(L, -1);
|
||||
|
||||
openspace::properties::Property* prop = property(uri);
|
||||
if (!prop)
|
||||
return luaL_error(L, "Property with URL '%s' could not be found", uri.c_str());
|
||||
if (!prop) {
|
||||
LERROR(errorLocation(L) << "Property with URL '" << uri << "' was not found");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
prop->getLua(L);
|
||||
return 1;
|
||||
@@ -121,9 +131,10 @@ int property_getValue(lua_State* L) {
|
||||
* be passed to the setPropertyValue method.
|
||||
*/
|
||||
int loadScene(lua_State* L) {
|
||||
static const std::string _loggerCat = "loadScene";
|
||||
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 1)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
|
||||
SCRIPT_CHECK_ARGUMENTS(L, 1, nArguments);
|
||||
|
||||
std::string sceneFile = luaL_checkstring(L, -1);
|
||||
|
||||
@@ -173,7 +184,6 @@ bool SceneGraph::initialize()
|
||||
tmpProgram->setProgramObjectCallback(cb);
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager()->setValue("fboPassProgram", tmpProgram);
|
||||
|
||||
// projection program
|
||||
tmpProgram = ProgramObject::Build("projectiveProgram",
|
||||
"${SHADERS}/projectiveTexture_vs.glsl",
|
||||
|
||||
@@ -612,13 +612,21 @@ void ScriptEngine::serialize(SyncBuffer* syncBuffer){
|
||||
|
||||
void ScriptEngine::deserialize(SyncBuffer* syncBuffer){
|
||||
syncBuffer->decode(_currentSyncedScript);
|
||||
|
||||
if (!_currentSyncedScript.empty()){
|
||||
_mutex.lock();
|
||||
_receivedScripts.push_back(_currentSyncedScript);
|
||||
_mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEngine::postSynchronizationPreDraw(){
|
||||
if (!_currentSyncedScript.empty()){
|
||||
runScript(_currentSyncedScript);
|
||||
_currentSyncedScript.clear();
|
||||
_mutex.lock();
|
||||
if (!_receivedScripts.empty()){
|
||||
runScript(_receivedScripts.back());
|
||||
_receivedScripts.pop_back();
|
||||
}
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
void ScriptEngine::preSynchronization(){
|
||||
@@ -628,6 +636,9 @@ void ScriptEngine::preSynchronization(){
|
||||
if (!_queuedScripts.empty()){
|
||||
_currentSyncedScript = _queuedScripts.back();
|
||||
_queuedScripts.pop_back();
|
||||
|
||||
//Not really a received script but the master also needs to run the script...
|
||||
_receivedScripts.push_back(_currentSyncedScript);
|
||||
}
|
||||
|
||||
_mutex.unlock();
|
||||
|
||||
@@ -158,9 +158,10 @@ bool replace(std::string& str, const std::string& from, const std::string& to) {
|
||||
}
|
||||
|
||||
bool ImageSequencer::parsePlaybook(const std::string& dir, const std::string& type, std::string year){
|
||||
ghoul::filesystem::Directory playbookDir(dir, true);
|
||||
std::vector<std::string> dirlist = playbookDir.read(true, false);
|
||||
for (auto path : dirlist){
|
||||
//ghoul::filesystem::Directory playbookDir(dir, true);
|
||||
//std::vector<std::string> dirlist = playbookDir.read(true, false);
|
||||
//for (auto path : dirlist){
|
||||
std::string path = dir;
|
||||
if (size_t position = path.find_last_of(".") + 1){
|
||||
if (position != std::string::npos){
|
||||
ghoul::filesystem::File currentFile(path);
|
||||
@@ -185,7 +186,7 @@ bool ImageSequencer::parsePlaybook(const std::string& dir, const std::string& ty
|
||||
timestr = year + " " + timestr;
|
||||
|
||||
openspace::SpiceManager::ref().getETfromDate(timestr, et);
|
||||
std::string defaultImagePath = dir + "/placeholder.png";
|
||||
std::string defaultImagePath = absPath("${OPENSPACE_DATA}/placeholder.png");
|
||||
createImage(et, et + shutter, defaultImagePath);
|
||||
}
|
||||
} while (!file.eof());
|
||||
@@ -224,7 +225,7 @@ bool ImageSequencer::parsePlaybook(const std::string& dir, const std::string& ty
|
||||
openspace::SpiceManager::ref().getDateFromET(et, str);
|
||||
std::cout << str << std::endl;
|
||||
*/
|
||||
std::string defaultImagePath = dir + "/placeholder.png";
|
||||
std::string defaultImagePath = absPath("${OPENSPACE_DATA}/placeholder.png");
|
||||
createImage(et, et + shutter, defaultImagePath);
|
||||
}
|
||||
} while (!file.eof());
|
||||
@@ -232,7 +233,7 @@ bool ImageSequencer::parsePlaybook(const std::string& dir, const std::string& ty
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
return true; // add check
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user