mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 04:30:09 -05:00
Merge branch 'develop' into feature/milkyway
This commit is contained in:
@@ -179,7 +179,7 @@ bool OpenSpaceEngine::create(int argc, char** argv,
|
||||
|
||||
// Create the cachemanager
|
||||
FileSys.createCacheManager(absPath("${" + constants::configurationmanager::keyCache + "}"));
|
||||
_engine->_console.loadHistory();
|
||||
_engine->_console.initialize();
|
||||
|
||||
// Register the provided shader directories
|
||||
ghoul::opengl::ShaderObject::addIncludePath("${SHADERS}");
|
||||
@@ -208,7 +208,7 @@ bool OpenSpaceEngine::create(int argc, char** argv,
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::destroy() {
|
||||
|
||||
_engine->_console.deinitialize();
|
||||
delete _engine;
|
||||
ghoul::systemcapabilities::SystemCapabilities::deinitialize();
|
||||
FactoryManager::deinitialize();
|
||||
@@ -498,7 +498,7 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
_interactionHandler.update(dt);
|
||||
_interactionHandler.lockControls();
|
||||
|
||||
//Time::ref().advanceTime(dt);
|
||||
Time::ref().advanceTime(dt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+63
-187
@@ -29,6 +29,7 @@
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/filesystem/cachemanager.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/clipboard.h>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@@ -39,108 +40,6 @@
|
||||
namespace {
|
||||
const std::string _loggerCat = "LuaConsole";
|
||||
const std::string historyFile = "ConsoleHistory";
|
||||
|
||||
#if !defined(WIN32)
|
||||
// Dangerus as fuck (if malicious input)
|
||||
bool exec(const std::string& cmd, std::string& value)
|
||||
{
|
||||
FILE* pipe = popen(cmd.c_str(), "r");
|
||||
if (!pipe)
|
||||
return false;
|
||||
|
||||
const int buffer_size = 1024;
|
||||
char buffer[buffer_size];
|
||||
value = "";
|
||||
while (!feof(pipe))
|
||||
{
|
||||
if (fgets(buffer, buffer_size, pipe) != NULL)
|
||||
{
|
||||
value += buffer;
|
||||
}
|
||||
}
|
||||
pclose(pipe);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Put this functio nsomewhere appropriate
|
||||
// get text from clipboard
|
||||
std::string getClipboardText() {
|
||||
#if defined(WIN32)
|
||||
// Try opening the clipboard
|
||||
if (!OpenClipboard(nullptr))
|
||||
return "";
|
||||
|
||||
// Get handle of clipboard object for ANSI text
|
||||
HANDLE hData = GetClipboardData(CF_TEXT);
|
||||
if (hData == nullptr)
|
||||
return "";
|
||||
|
||||
// Lock the handle to get the actual text pointer
|
||||
char * pszText = static_cast<char*>(GlobalLock(hData));
|
||||
if (pszText == nullptr)
|
||||
return "";
|
||||
|
||||
// Save text in a string class instance
|
||||
std::string text(pszText);
|
||||
|
||||
// Release the lock
|
||||
GlobalUnlock(hData);
|
||||
|
||||
// Release the clipboard
|
||||
CloseClipboard();
|
||||
|
||||
text.erase(std::remove(text.begin(), text.end(), '\r'), text.end());
|
||||
return text;
|
||||
#elif defined(__APPLE__)
|
||||
std::string text;
|
||||
if (exec("pbpaste", text))
|
||||
return text.substr(0, text.length() - 1);
|
||||
return ""; // remove a line ending
|
||||
#else
|
||||
std::string text;
|
||||
if (exec("xclip -o -sel c -f", text))
|
||||
return text.substr(0, text.length() - 1);
|
||||
return ""; // remove a line ending
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: Put this function somewhere appropriate
|
||||
// set text to clipboard
|
||||
bool setClipboardText(std::string text)
|
||||
{
|
||||
#if defined(WIN32)
|
||||
char *ptrData = nullptr;
|
||||
HANDLE hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, text.length() + 1);
|
||||
|
||||
ptrData = (char*)GlobalLock(hData);
|
||||
memcpy(ptrData, text.c_str(), text.length() + 1);
|
||||
|
||||
GlobalUnlock(hData);
|
||||
|
||||
if (!OpenClipboard(nullptr))
|
||||
return false;
|
||||
|
||||
if (!EmptyClipboard())
|
||||
return false;
|
||||
|
||||
SetClipboardData(CF_TEXT, hData);
|
||||
|
||||
CloseClipboard();
|
||||
|
||||
return true;
|
||||
#elif defined(__APPLE__)
|
||||
std::stringstream cmd;
|
||||
cmd << "echo \"" << text << "\" | pbcopy";
|
||||
std::string buf;
|
||||
return exec(cmd.str(), buf);
|
||||
#else
|
||||
std::stringstream cmd;
|
||||
cmd << "echo \"" << text << "\" | xclip -i -sel c -f";
|
||||
std::string buf;
|
||||
return exec(cmd.str(), buf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -202,77 +101,74 @@ LuaConsole::LuaConsole()
|
||||
}
|
||||
|
||||
LuaConsole::~LuaConsole() {
|
||||
std::ofstream file(absPath(_filename), std::ios::binary | std::ios::out);
|
||||
if (file.is_open()) {
|
||||
size_t n = _commandsHistory.size();
|
||||
file.write(reinterpret_cast<const char*>(&n), sizeof(size_t));
|
||||
for (const std::string& s : _commandsHistory) {
|
||||
size_t length = s.length();
|
||||
file.write(reinterpret_cast<const char*>(&length), sizeof(size_t));
|
||||
file.write(s.c_str(), sizeof(char)*length);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LuaConsole::loadHistory() {
|
||||
FileSys.cacheManager()->getCachedFile(historyFile, "", _filename, true);
|
||||
|
||||
std::ifstream file(absPath(_filename), std::ios::binary | std::ios::in);
|
||||
if (file.is_open()) {
|
||||
size_t n;
|
||||
void LuaConsole::initialize() {
|
||||
FileSys.cacheManager()->getCachedFile(historyFile, "", _filename, true);
|
||||
|
||||
file.read(reinterpret_cast<char*>(&n), sizeof(size_t));
|
||||
std::ifstream file(absPath(_filename), std::ios::binary | std::ios::in);
|
||||
if (file.good()) {
|
||||
int64_t nCommands;
|
||||
file.read(reinterpret_cast<char*>(&nCommands), sizeof(int64_t));
|
||||
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
size_t length;
|
||||
file.read(reinterpret_cast<char*>(&length), sizeof(size_t));
|
||||
char* tmp = new char[length + 1];
|
||||
file.read(tmp, sizeof(char)*length);
|
||||
tmp[length] = '\0';
|
||||
_commandsHistory.emplace_back(tmp);
|
||||
delete[] tmp;
|
||||
}
|
||||
file.close();
|
||||
_commands = _commandsHistory;
|
||||
}
|
||||
_commands.push_back("");
|
||||
_activeCommand = _commands.size() - 1;
|
||||
for (size_t i = 0; i < nCommands; ++i) {
|
||||
int64_t length;
|
||||
file.read(reinterpret_cast<char*>(&length), sizeof(int64_t));
|
||||
char* tmp = new char[length + 1];
|
||||
file.read(tmp, sizeof(char)*length);
|
||||
tmp[length] = '\0';
|
||||
_commandsHistory.emplace_back(tmp);
|
||||
delete[] tmp;
|
||||
}
|
||||
file.close();
|
||||
_commands = _commandsHistory;
|
||||
}
|
||||
else
|
||||
LERROR("Could not open file '" << absPath(_filename) << "' for reading history");
|
||||
_commands.push_back("");
|
||||
_activeCommand = _commands.size() - 1;
|
||||
|
||||
}
|
||||
|
||||
void LuaConsole::deinitialize() {
|
||||
std::ofstream file(absPath(_filename), std::ios::binary | std::ios::out);
|
||||
if (file.good()) {
|
||||
int64_t nCommands = _commandsHistory.size();
|
||||
file.write(reinterpret_cast<const char*>(&nCommands), sizeof(int64_t));
|
||||
for (const std::string& s : _commandsHistory) {
|
||||
int64_t length = s.length();
|
||||
file.write(reinterpret_cast<const char*>(&length), sizeof(int64_t));
|
||||
file.write(s.c_str(), length);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void LuaConsole::keyboardCallback(int key, int action) {
|
||||
if (action == SGCT_PRESS || action == SGCT_REPEAT) {
|
||||
const size_t windowIndex = sgct::Engine::instance()->getFocusedWindowIndex();
|
||||
const bool mod_CONTROL = sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_LEFT_CONTROL) ||
|
||||
const bool modifierControl = sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_LEFT_CONTROL) ||
|
||||
sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_RIGHT_CONTROL);
|
||||
const bool mod_SHIFT = sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_LEFT_SHIFT) ||
|
||||
const bool modifierShift = sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_LEFT_SHIFT) ||
|
||||
sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_RIGHT_SHIFT);
|
||||
|
||||
// Paste from clipboard
|
||||
if (key == SGCT_KEY_V) {
|
||||
if (mod_CONTROL) {
|
||||
addToCommand(getClipboardText());
|
||||
}
|
||||
}
|
||||
if (modifierControl && (key == SGCT_KEY_V))
|
||||
addToCommand(ghoul::clipboardText());
|
||||
|
||||
// Copy to clipboard
|
||||
if (key == SGCT_KEY_C) {
|
||||
if (mod_CONTROL) {
|
||||
setClipboardText(_commands.at(_activeCommand));
|
||||
}
|
||||
}
|
||||
if (modifierControl && (key == SGCT_KEY_C))
|
||||
ghoul::setClipboardText(_commands.at(_activeCommand));
|
||||
|
||||
// Go to the previous character
|
||||
if (key == SGCT_KEY_LEFT) {
|
||||
if (_inputPosition > 0)
|
||||
_inputPosition -= 1;
|
||||
}
|
||||
if ((key == SGCT_KEY_LEFT) && (_inputPosition > 0))
|
||||
--_inputPosition;
|
||||
|
||||
// Go to the next character
|
||||
if (key == SGCT_KEY_RIGHT) {
|
||||
if (_inputPosition < _commands.at(_activeCommand).length())
|
||||
++_inputPosition;
|
||||
}
|
||||
if ((key == SGCT_KEY_RIGHT) && _inputPosition < _commands.at(_activeCommand).length())
|
||||
++_inputPosition;
|
||||
|
||||
// Go to previous command
|
||||
if (key == SGCT_KEY_UP) {
|
||||
@@ -297,36 +193,28 @@ void LuaConsole::keyboardCallback(int key, int action) {
|
||||
}
|
||||
|
||||
// Remove character after _inputPosition
|
||||
if (key == SGCT_KEY_DELETE) {
|
||||
if (_inputPosition <= _commands.at(_activeCommand).size()) {
|
||||
_commands.at(_activeCommand).erase(_inputPosition, 1);
|
||||
}
|
||||
}
|
||||
if ((key == SGCT_KEY_DELETE) && (_inputPosition <= _commands.at(_activeCommand).size()))
|
||||
_commands.at(_activeCommand).erase(_inputPosition, 1);
|
||||
|
||||
// Go to the beginning of command string
|
||||
if (key == SGCT_KEY_HOME) {
|
||||
if (key == SGCT_KEY_HOME)
|
||||
_inputPosition = 0;
|
||||
}
|
||||
|
||||
// Go to the end of command string
|
||||
if (key == SGCT_KEY_END) {
|
||||
if (key == SGCT_KEY_END)
|
||||
_inputPosition = _commands.at(_activeCommand).size();
|
||||
}
|
||||
|
||||
if (key == SGCT_KEY_ENTER) {
|
||||
|
||||
// SHIFT+ENTER == new line
|
||||
if (mod_SHIFT) {
|
||||
if (modifierShift)
|
||||
addToCommand("\n");
|
||||
}
|
||||
// CTRL+ENTER == Debug print the command
|
||||
else if (mod_CONTROL) {
|
||||
else if (modifierControl) {
|
||||
LDEBUG("Active command from next line:\n" << _commands.at(_activeCommand));
|
||||
}
|
||||
// ENTER == run lua script
|
||||
else {
|
||||
if (_commands.at(_activeCommand) != "") {
|
||||
|
||||
OsEng.scriptEngine().runScript(_commands.at(_activeCommand));
|
||||
if (!_commandsHistory.empty() &&
|
||||
_commands.at(_activeCommand) != _commandsHistory.at(_commandsHistory.size() - 1))
|
||||
@@ -334,24 +222,19 @@ void LuaConsole::keyboardCallback(int key, int action) {
|
||||
else if (_commandsHistory.empty())
|
||||
_commandsHistory.push_back(_commands.at(_activeCommand));
|
||||
|
||||
_commands = _commandsHistory;
|
||||
_commands.push_back("");
|
||||
_activeCommand = _commands.size() - 1;
|
||||
_inputPosition = 0;
|
||||
setVisible(false);
|
||||
}
|
||||
else {
|
||||
_commands = _commandsHistory;
|
||||
_commands.push_back("");
|
||||
setVisible(false);
|
||||
}
|
||||
_commands = _commandsHistory;
|
||||
_commands.push_back("");
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LuaConsole::charCallback(unsigned int codepoint) {
|
||||
if (codepoint == ignoreCodepoint())
|
||||
if (codepoint == commandInputButton())
|
||||
return;
|
||||
|
||||
#ifndef WIN32
|
||||
@@ -407,18 +290,10 @@ void LuaConsole::render() {
|
||||
Freetype::print(font, 10.0f + font_size*0.5f, startY - (font_size)*(n + 1)*3.0f / 2.0f, green, ss.str().c_str(), "^");
|
||||
}
|
||||
|
||||
unsigned int LuaConsole::commandInputButton(){
|
||||
// Button left of 1 and abobe TAB
|
||||
#ifdef WIN32
|
||||
return SGCT_KEY_BACKSLASH;
|
||||
#else
|
||||
unsigned int LuaConsole::commandInputButton() {
|
||||
// Button left of 1 and above TAB
|
||||
// How to deal with different keyboard languages? ---abock
|
||||
return SGCT_KEY_GRAVE_ACCENT;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned int LuaConsole::ignoreCodepoint() {
|
||||
// Correesponding codepoint for commandInputButton()
|
||||
return 167;
|
||||
}
|
||||
|
||||
void LuaConsole::addToCommand(std::string c) {
|
||||
@@ -491,4 +366,5 @@ scripting::ScriptEngine::LuaLibrary LuaConsole::luaLibrary() {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -40,7 +40,11 @@
|
||||
#include <sgct.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderablePlanet";
|
||||
const std::string _loggerCat = "RenderablePlanet";
|
||||
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyGeometry = "Geometry";
|
||||
const std::string keyShading = "PerformShading";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -51,6 +55,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
, _programObject(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _geometry(nullptr)
|
||||
, _performShading("performShading", "Perform Shading", true)
|
||||
{
|
||||
std::string name;
|
||||
bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
|
||||
@@ -63,15 +68,14 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
"RenderablePlanet need the '"<<constants::scenegraph::keyPathModule<<"' be specified");
|
||||
|
||||
ghoul::Dictionary geometryDictionary;
|
||||
success = dictionary.getValue(
|
||||
constants::renderableplanet::keyGeometry, geometryDictionary);
|
||||
success = dictionary.getValue(keyGeometry, geometryDictionary);
|
||||
if (success) {
|
||||
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
|
||||
geometryDictionary.setValue(constants::scenegraph::keyPathModule, path);
|
||||
_geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary);
|
||||
}
|
||||
|
||||
dictionary.getValue(constants::renderableplanet::keyFrame, _target);
|
||||
dictionary.getValue(keyFrame, _target);
|
||||
|
||||
// TODO: textures need to be replaced by a good system similar to the geometry as soon
|
||||
// as the requirements are fixed (ab)
|
||||
@@ -84,6 +88,14 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
|
||||
addProperty(_colorTexturePath);
|
||||
_colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
|
||||
|
||||
if (dictionary.hasKeyAndValue<bool>(keyShading)) {
|
||||
bool shading;
|
||||
dictionary.getValue(keyShading, shading);
|
||||
_performShading = shading;
|
||||
}
|
||||
|
||||
addProperty(_performShading);
|
||||
}
|
||||
|
||||
RenderablePlanet::~RenderablePlanet() {
|
||||
@@ -147,6 +159,8 @@ void RenderablePlanet::render(const RenderData& data)
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
|
||||
_programObject->setUniform("_performShading", _performShading);
|
||||
|
||||
// Bind texture
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
|
||||
@@ -51,6 +51,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
|
||||
, _size(glm::vec2(1,1))
|
||||
, _origin(Origin::Center)
|
||||
, _shader(nullptr)
|
||||
, _programIsDirty(false)
|
||||
, _texture(nullptr)
|
||||
, _quad(0)
|
||||
, _vertexPositionBuffer(0)
|
||||
@@ -133,7 +134,13 @@ bool RenderablePlane::initialize() {
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
|
||||
OsEng.ref().configurationManager().getValue("PlaneProgram", _shader);
|
||||
// Plane program
|
||||
_shader = ghoul::opengl::ProgramObject::Build("Plane",
|
||||
"${SHADERS}/modules/plane/plane_vs.glsl",
|
||||
"${SHADERS}/modules/plane/plane_fs.glsl");
|
||||
if (!_shader)
|
||||
return false;
|
||||
_shader->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; });
|
||||
|
||||
loadTexture();
|
||||
|
||||
@@ -147,6 +154,7 @@ bool RenderablePlane::deinitialize() {
|
||||
_vertexPositionBuffer = 0;
|
||||
if(_texture)
|
||||
delete _texture;
|
||||
delete _shader;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -176,10 +184,13 @@ void RenderablePlane::render(const RenderData& data) {
|
||||
}
|
||||
|
||||
void RenderablePlane::update(const UpdateData& data) {
|
||||
if (_programIsDirty) {
|
||||
_shader->rebuildFromFile();
|
||||
_programIsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderablePlane::loadTexture()
|
||||
{
|
||||
void RenderablePlane::loadTexture() {
|
||||
LDEBUG("loadTexture");
|
||||
if (_texturePath.value() != "") {
|
||||
LDEBUG("loadTexture2");
|
||||
|
||||
@@ -132,7 +132,7 @@ void RenderableTrail::render(const RenderData& data) {
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
|
||||
_programObject->setUniform("color", _lineColor);
|
||||
_programObject->setUniform("nVertices", unsigned int(_vertexArray.size()));
|
||||
_programObject->setUniform("nVertices", static_cast<unsigned int>(_vertexArray.size()));
|
||||
_programObject->setUniform("lineFade", _lineFade);
|
||||
|
||||
glBindVertexArray(_vaoID);
|
||||
@@ -166,7 +166,9 @@ void RenderableTrail::update(const UpdateData& data) {
|
||||
int nValues = floor(deltaTime / _increment);
|
||||
|
||||
// Update the floating current time
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", data.time, pscPos, pscVel, lightTime);
|
||||
// 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);
|
||||
pscPos[3] += 3; // KM to M
|
||||
_vertexArray[0] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
|
||||
|
||||
@@ -175,13 +177,13 @@ void RenderableTrail::update(const UpdateData& data) {
|
||||
// close to 1
|
||||
|
||||
// But you never know
|
||||
nValues = std::min(nValues, int(_vertexArray.size()));
|
||||
nValues = std::min(nValues, int(_vertexArray.size() - 1));
|
||||
//LINFO(nValues);
|
||||
std::vector<TrailVBOLayout> tmp = _vertexArray;
|
||||
|
||||
for (int i = nValues; i > 0; --i) {
|
||||
double et = _oldTime + i * _increment;
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", et, pscPos, pscVel, lightTime);
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", et, pscPos, pscVel, lightTime);
|
||||
pscPos[3] += 3;
|
||||
_vertexArray[i] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
|
||||
}
|
||||
@@ -217,7 +219,7 @@ void RenderableTrail::fullYearSweep(double time) {
|
||||
psc pscPos, pscVel;
|
||||
_vertexArray.resize(segments+2);
|
||||
for (int i = 0; i < segments+2; i++){
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", time, pscPos, pscVel, lightTime);
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", time, pscPos, pscVel, lightTime);
|
||||
pscPos[3] += 3;
|
||||
|
||||
_vertexArray[i] = {pscPos[0], pscPos[1], pscPos[2], pscPos[3]};
|
||||
|
||||
@@ -476,18 +476,40 @@ bool RenderableStars::saveCachedFile(const std::string& file) const {
|
||||
|
||||
void RenderableStars::createDataSlice(ColorOption option) {
|
||||
_slicedData.clear();
|
||||
|
||||
// This is only temporary until the scalegraph is in place ---abock
|
||||
float minDistance = std::numeric_limits<float>::max();
|
||||
float maxDistance = -std::numeric_limits<float>::max();
|
||||
|
||||
for (size_t i = 0; i < _fullData.size(); i+=_nValuesPerStar) {
|
||||
float distLy = _fullData[i + 6];
|
||||
//if (distLy < 20.f) {
|
||||
minDistance = std::min(minDistance, distLy);
|
||||
maxDistance = std::max(maxDistance, distLy);
|
||||
//}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < _fullData.size(); i+=_nValuesPerStar) {
|
||||
psc position = PowerScaledCoordinate::CreatePowerScaledCoordinate(
|
||||
_fullData[i + 0],
|
||||
_fullData[i + 1],
|
||||
_fullData[i + 2]
|
||||
);
|
||||
// This is only temporary until the scalegraph is in place. It places all stars
|
||||
// on a sphere with a small variation in the distance to account for blending
|
||||
// issues ---abock
|
||||
glm::vec3 p = glm::vec3(_fullData[i + 0], _fullData[i + 1], _fullData[i + 2]);
|
||||
if (p != glm::vec3(0.f))
|
||||
p = glm::normalize(p);
|
||||
|
||||
float distLy = _fullData[i + 6];
|
||||
float normalizedDist = (distLy - minDistance) / (maxDistance - minDistance);
|
||||
float distance = 18.f - normalizedDist / 1.f ;
|
||||
|
||||
|
||||
psc position = psc(glm::vec4(p, distance));
|
||||
|
||||
// Convert parsecs -> meter
|
||||
PowerScaledScalar parsecsToMetersFactor = PowerScaledScalar(0.308567758f, 17.f);
|
||||
position[0] *= parsecsToMetersFactor[0];
|
||||
position[1] *= parsecsToMetersFactor[0];
|
||||
position[2] *= parsecsToMetersFactor[0];
|
||||
position[3] += parsecsToMetersFactor[1];
|
||||
//PowerScaledScalar parsecsToMetersFactor = PowerScaledScalar(0.308567758f, 17.f);
|
||||
//position[0] *= parsecsToMetersFactor[0];
|
||||
//position[1] *= parsecsToMetersFactor[0];
|
||||
//position[2] *= parsecsToMetersFactor[0];
|
||||
//position[3] += parsecsToMetersFactor[1];
|
||||
|
||||
switch (option) {
|
||||
case ColorOption::Color:
|
||||
@@ -503,7 +525,8 @@ void RenderableStars::createDataSlice(ColorOption option) {
|
||||
|
||||
layout.value.bvColor = _fullData[i + 3];
|
||||
layout.value.luminance = _fullData[i + 4];
|
||||
layout.value.absoluteMagnitude = _fullData[i + 5];
|
||||
//layout.value.absoluteMagnitude = _fullData[i + 5];
|
||||
layout.value.absoluteMagnitude = _fullData[i + 6];
|
||||
|
||||
_slicedData.insert(_slicedData.end(),
|
||||
layout.data.begin(),
|
||||
|
||||
@@ -190,15 +190,6 @@ bool SceneGraph::initialize()
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager().setValue("GridProgram", tmpProgram);
|
||||
|
||||
// Plane program
|
||||
tmpProgram = ProgramObject::Build("Plane",
|
||||
"${SHADERS}/plane_vs.glsl",
|
||||
"${SHADERS}/plane_fs.glsl");
|
||||
if (!tmpProgram) return false;
|
||||
tmpProgram->setProgramObjectCallback(cb);
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager().setValue("PlaneProgram", tmpProgram);
|
||||
|
||||
// Done building shaders
|
||||
double elapsed = std::chrono::duration_cast<second_>(clock_::now()-beginning).count();
|
||||
LINFO("Time to load scene graph shaders: " << elapsed << " seconds");
|
||||
|
||||
@@ -209,8 +209,10 @@ bool ScriptEngine::initialize() {
|
||||
}
|
||||
|
||||
void ScriptEngine::deinitialize() {
|
||||
lua_close(_state);
|
||||
_state = nullptr;
|
||||
if (_state) {
|
||||
lua_close(_state);
|
||||
_state = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEngine::addLibrary(LuaLibrary library) {
|
||||
|
||||
Reference in New Issue
Block a user