diff --git a/include/openspace/rendering/renderablecrawlingline.h b/include/openspace/rendering/renderablecrawlingline.h index 080dc38428..a7979b2e0a 100644 --- a/include/openspace/rendering/renderablecrawlingline.h +++ b/include/openspace/rendering/renderablecrawlingline.h @@ -49,8 +49,10 @@ private: std::string _source; std::string _target; std::string _referenceFrame; + glm::vec3 _lineColor; psc _positions[2]; + int _frameCounter; bool _drawLine; float _imageSequenceTime; diff --git a/include/openspace/rendering/renderableplaneprojection.h b/include/openspace/rendering/renderableplaneprojection.h index c2fc6ce19a..d65d123d4c 100644 --- a/include/openspace/rendering/renderableplaneprojection.h +++ b/include/openspace/rendering/renderableplaneprojection.h @@ -68,7 +68,7 @@ namespace openspace { private: void loadTexture(); - void updatePlane(const Image* img, double currentTime); + void updatePlane(const Image img, double currentTime); std::string findClosestTarget(double currentTime); void setTarget(std::string body); diff --git a/include/openspace/util/constants.h b/include/openspace/util/constants.h index 1ed613a4af..e29df4932d 100644 --- a/include/openspace/util/constants.h +++ b/include/openspace/util/constants.h @@ -96,6 +96,7 @@ namespace renderableplaneprojection { const std::string keyTexture = "Texture"; const std::string keyName = "Name"; const std::string galacticFrame = "GALACTIC"; + const double REALLY_FAR = 99999999999; } // namespace renderableplaneprojection namespace renderablestars { diff --git a/include/openspace/util/imagesequencer2.h b/include/openspace/util/imagesequencer2.h index dfbbc8921e..37b1f857d2 100644 --- a/include/openspace/util/imagesequencer2.h +++ b/include/openspace/util/imagesequencer2.h @@ -139,7 +139,7 @@ public: /* * returns latest captured image */ - const Image* getLatestImageForInstrument(const std::string _instrumentID); + const Image getLatestImageForInstrument(const std::string _instrumentID); private: void sortData(); @@ -196,7 +196,7 @@ private: // default capture image std::string _defaultCaptureImage; - Image* _latestImage; + Image _latestImage; // if no data, no run bool _hasData; }; diff --git a/scripts/bind_keys.lua b/scripts/bind_keys.lua index f5f92e23cc..6340812048 100644 --- a/scripts/bind_keys.lua +++ b/scripts/bind_keys.lua @@ -15,6 +15,28 @@ openspace.bindKey("PRINT_SCREEN", "openspace.takeScreenshot()") openspace.bindKey("SPACE", "openspace.time.togglePause()") -- Bookmarks for the New Horizons encounter +openspace.bindKey("1", "openspace.time.setDeltaTime(1)") +openspace.bindKey("2", "openspace.time.setDeltaTime(5)") +openspace.bindKey("3", "openspace.time.setDeltaTime(10)") +openspace.bindKey("4", "openspace.time.setDeltaTime(30)") +openspace.bindKey("5", "openspace.time.setDeltaTime(60)") +openspace.bindKey("6", "openspace.time.setDeltaTime(120)") +openspace.bindKey("7", "openspace.time.setDeltaTime(360)") +openspace.bindKey("8", "openspace.time.setDeltaTime(540)") +openspace.bindKey("9", "openspace.time.setDeltaTime(720)") + +openspace.bindKey("a", "openspace.setOrigin('NewHorizons')") +openspace.bindKey("s", "openspace.setOrigin('PlutoProjection')") +openspace.bindKey("d", "openspace.setOrigin('Charon')") +openspace.bindKey("z", "openspace.setOrigin('JupiterProjection')") +openspace.bindKey("x", "openspace.setOrigin('Europa')") + + +openspace.bindKey("g", "openspace.time.setTime('2007-02-28T11:40:00.00'); openspace.time.setDeltaTime(1);") + +openspace.bindKey("h", "openspace.time.setTime('2015-07-14T09:00:00.00'); openspace.time.setDeltaTime(1); openspace.changeCoordinateSystem('Pluto'); openspace.printInfo('Changing Viewpoint to Pluto-in-center');") + +--[[ openspace.bindKey("1", "openspace.time.setTime('2007-02-27T16:40:00.00'); openspace.time.setDeltaTime(10)") openspace.bindKey("2", "openspace.time.setTime('2015-07-14T10:50:00.00'); openspace.time.setDeltaTime(10)") openspace.bindKey("3", "openspace.time.setTime('2015-07-14T11:22:00.00'); openspace.time.setDeltaTime(1)") @@ -22,6 +44,7 @@ openspace.bindKey("4", "openspace.time.setTime('2015-07-14T11:36:40.00'); opensp openspace.bindKey("5", "openspace.time.setTime('2015-07-14T11:48:43.00'); openspace.time.setDeltaTime(1)") openspace.bindKey("6", "openspace.time.setTime('2015-07-14T12:04:35.00'); openspace.time.setDeltaTime(1)") openspace.bindKey("7", "openspace.time.setTime('2015-07-14T15:02:46.00'); openspace.time.setDeltaTime(100)") +]]-- openspace.bindKey("q", "local b = openspace.getPropertyValue('SunMarker.renderable.enabled'); openspace.setPropertyValue('SunMarker.renderable.enabled', not b)") openspace.bindKey("e", "local b = openspace.getPropertyValue('EarthMarker.renderable.enabled'); openspace.setPropertyValue('EarthMarker.renderable.enabled', not b)") diff --git a/shaders/modules/crawlingline/crawlingline_fs.glsl b/shaders/modules/crawlingline/crawlingline_fs.glsl index ab40cbc7b6..f6c31a0d96 100644 --- a/shaders/modules/crawlingline/crawlingline_fs.glsl +++ b/shaders/modules/crawlingline/crawlingline_fs.glsl @@ -26,7 +26,7 @@ uniform vec4 campos; uniform vec4 objpos; - +uniform vec3 color; uniform float _alpha; in vec4 vs_position; @@ -39,7 +39,7 @@ void main() { vec4 position = vs_position; float depth = pscDepth(position); // vec4 diffuse = texture(texture1, vs_st); - vec4 diffuse = vec4(1.0); + vec4 diffuse = vec4(color, 1.0); diffuse.a = _alpha; ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth); addToBuffer(frag); diff --git a/shaders/projectiveTexture_fs.glsl b/shaders/projectiveTexture_fs.glsl index f222cceeb1..d62a5ccffa 100644 --- a/shaders/projectiveTexture_fs.glsl +++ b/shaders/projectiveTexture_fs.glsl @@ -60,7 +60,7 @@ void main() //vec3 e = normalize(camdir); vec3 l_pos = sun_pos; // sun. vec3 l_dir = normalize(l_pos-objpos.xyz); - float terminatorBright = 0.1; + float terminatorBright = 0.4; float intensity = min(max(5*dot(n,l_dir), terminatorBright), 1); float shine = 0.0001; diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index 6017ebb36e..edd0f9e14e 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -886,7 +886,7 @@ void InteractionHandler::keyboardCallback(int key, int action) { const float dt = static_cast(_deltaTime); if (action == SGCT_PRESS || action == SGCT_REPEAT) { - if (key == SGCT_KEY_S) { + /*if (key == SGCT_KEY_S) { glm::vec3 euler(speed * dt, 0.0, 0.0); glm::quat rot = glm::quat(euler); orbitDelta(rot); @@ -911,7 +911,7 @@ void InteractionHandler::keyboardCallback(int key, int action) { } if (key == SGCT_KEY_X) { Time::ref().advanceTime(-sgct::Engine::instance()->getDt()); - } + }*/ if (key == 262) { glm::vec3 euler(0.0, speed * dt*0.4, 0.0); glm::quat rot = glm::quat(euler); diff --git a/src/rendering/renderablecrawlingline.cpp b/src/rendering/renderablecrawlingline.cpp index 718ccab666..125e9c4b5a 100644 --- a/src/rendering/renderablecrawlingline.cpp +++ b/src/rendering/renderablecrawlingline.cpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace { const std::string _loggerCat = "RenderableCrawlingLine"; @@ -36,6 +37,7 @@ namespace { const std::string KeyTarget = "Target"; const std::string KeyInstrument = "Instrument"; const std::string KeyReferenceFrame = "Frame"; + const std::string keyColor = "RGB"; static const int SourcePosition = 0; static const int TargetPosition = 1; @@ -55,6 +57,12 @@ RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictiona dictionary.getValue(KeyTarget, _target); dictionary.getValue(KeyInstrument, _instrumentName); dictionary.getValue(KeyReferenceFrame, _referenceFrame); + + + if (dictionary.hasKeyAndValue(keyColor)) + dictionary.getValue(keyColor, _lineColor); + else + _lineColor = glm::vec3(1); } bool RenderableCrawlingLine::isReady() const { @@ -67,6 +75,7 @@ bool RenderableCrawlingLine::isReady() const { } bool RenderableCrawlingLine::initialize() { + _frameCounter = 0; bool completeSuccess = true; _program = ghoul::opengl::ProgramObject::Build("RenderableCrawlingLine", "${SHADERS}/modules/crawlingline/crawlingline_vs.glsl", @@ -100,9 +109,9 @@ bool RenderableCrawlingLine::deinitialize(){ } void RenderableCrawlingLine::render(const RenderData& data) { - if (_drawLine) { + if (_drawLine) { _program->activate(); - + _frameCounter++; // fetch data psc currentPosition = data.position; psc campos = data.camera.position(); @@ -114,20 +123,20 @@ void RenderableCrawlingLine::render(const RenderData& data) { _program->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); _program->setUniform("ModelTransform", transform); - static const float CutoffValue = 0.15f; - float alpha; - if (_imageSequenceTime < 0.5f) - alpha = std::min(_imageSequenceTime / CutoffValue, 1.f); - else - alpha = std::min((1.f - _imageSequenceTime) / CutoffValue, 1.f); + int frame = _frameCounter % 20; + float fadingFactor = static_cast(sin((frame * pi_c()) / 20)); + float alpha = 0.6f + fadingFactor*0.4f; + + glLineWidth(2.f); _program->setUniform("_alpha", alpha); + _program->setUniform("color", _lineColor); setPscUniforms(_program, &data.camera, data.position); glBindVertexArray(_vao); glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(psc) * 2, _positions); - //glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(psc), _positions, GL_DYNAMIC_DRAW); + glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); @@ -139,20 +148,27 @@ void RenderableCrawlingLine::render(const RenderData& data) { } void RenderableCrawlingLine::update(const UpdateData& data) { - double t; - //_positions[SourcePosition][0] = 0.f; - //_positions[SourcePosition][1] = 0.f; - //_positions[SourcePosition][2] = 0.f; - //_positions[SourcePosition][3] = 0.f; - // - //_positions[TargetPosition][0] = 0.f; - //_positions[TargetPosition][1] = 0.f; - //_positions[TargetPosition][2] = 0.f; - //_positions[TargetPosition][3] = 0.f; - SpiceManager::ref().getTargetPosition(_source, "SUN", _referenceFrame, "NONE", data.time, _positions[SourcePosition], t); - _positions[SourcePosition][3] += 3; - SpiceManager::ref().getTargetPosition(_target, "SUN", _referenceFrame, "NONE", data.time, _positions[TargetPosition], t); - _positions[TargetPosition][3] += 3; + glm::dmat3 transformMatrix = glm::dmat3(1); + openspace::SpiceManager::ref().getPositionTransformMatrix(_source, _referenceFrame, data.time, transformMatrix); + + glm::mat4 tmp = glm::mat4(1); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++){ + tmp[i][j] = static_cast(transformMatrix[i][j]); + } + } + + _positions[SourcePosition] = PowerScaledCoordinate::CreatePowerScaledCoordinate(0, 0, 0); + + std::string shape, instrument; + std::vector bounds; + glm::dvec3 boresight; + + bool found = openspace::SpiceManager::ref().getFieldOfView(_source, shape, instrument, boresight, bounds); + glm::vec4 target(boresight[0], boresight[1], boresight[2], 14); + target = tmp * target; + + _positions[TargetPosition] = target; if (ImageSequencer2::ref().isReady()) { _imageSequenceTime = ImageSequencer2::ref().instrumentActiveTime(_instrumentName); diff --git a/src/rendering/renderableplaneprojection.cpp b/src/rendering/renderableplaneprojection.cpp index 7dec5a2e9b..57c85fb131 100644 --- a/src/rendering/renderableplaneprojection.cpp +++ b/src/rendering/renderableplaneprojection.cpp @@ -144,17 +144,16 @@ void RenderablePlaneProjection::update(const UpdateData& data) { double time = data.time; - const Image* img = openspace::ImageSequencer2::ref().getLatestImageForInstrument(_instrument); + const Image img = openspace::ImageSequencer2::ref().getLatestImageForInstrument(_instrument); openspace::SpiceManager::ref().getPositionTransformMatrix(_target.frame, galacticFrame, time, _stateMatrix); std::string tex = _texturePath; - - if (_moving || _planeIsDirty) + if (img.path != "" && (_moving || _planeIsDirty)) updatePlane(img, time); - else if (img != nullptr && img->path != tex) { - time = img->startTime; + else if (img.path != "" && img.path != tex) { + time = img.startTime; updatePlane(img, time); } @@ -186,7 +185,7 @@ void RenderablePlaneProjection::loadTexture() { } } -void RenderablePlaneProjection::updatePlane(const Image* img, double currentTime) { +void RenderablePlaneProjection::updatePlane(const Image img, double currentTime) { std::string shape, frame; std::vector bounds; @@ -194,10 +193,10 @@ void RenderablePlaneProjection::updatePlane(const Image* img, double currentTime std::string target = "JUPITER"; //default if (!_moving) { - // target = findClosestTarget(currentTime); + target = findClosestTarget(currentTime); } - if (img != nullptr) - target = img->target; + if (img.path != "") + target = img.target; setTarget(target); @@ -252,8 +251,8 @@ void RenderablePlaneProjection::updatePlane(const Image* img, double currentTime glEnableVertexAttribArray(1); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast(sizeof(GLfloat) * 4)); - if (!_moving && img != nullptr) { - _texturePath = img->path; + if (!_moving && img.path != "") { + _texturePath = img.path; loadTexture(); } } @@ -295,7 +294,7 @@ std::string RenderablePlaneProjection::findClosestTarget(double currentTime) { std::string targetBody; bool hasBody, found = false; - PowerScaledScalar min = PowerScaledScalar::CreatePSS(9999999999999); + PowerScaledScalar min = PowerScaledScalar::CreatePSS(REALLY_FAR); PowerScaledScalar distance = PowerScaledScalar::CreatePSS(0.0); std::string closestTarget = ""; diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 0b63d8bfd1..b95c091955 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -540,43 +540,46 @@ namespace openspace { int line = 0; - PrintText(line++, "Date: %s", Time::ref().currentTimeUTC().c_str()); - + //PrintText(line++, "Date: %s", Time::ref().currentTimeUTC().c_str()); + PrintColorTextArg(line++, "Date: %s", 10, glm::vec4(1), Time::ref().currentTimeUTC().c_str()); + glm::vec4 targetColor(0.00, 0.75, 1.00, 1); + double dt = Time::ref().deltaTime(); + PrintColorTextArg(line++, "Simulation increment (s): %.0f", 10, glm::vec4(1), dt); PrintText(line++, "Avg. Frametime: %.5f", sgct::Engine::instance()->getAvgDt()); - PrintText(line++, "Drawtime: %.5f", sgct::Engine::instance()->getDrawTime()); - PrintText(line++, "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]); - */ + + //PrintText(line++, "Drawtime: %.5f", sgct::Engine::instance()->getDrawTime()); + //PrintText(line++, "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]); if (openspace::ImageSequencer2::ref().isReady()) { double remaining = openspace::ImageSequencer2::ref().getNextCaptureTime() - currentTime; double t = 1.f - remaining / openspace::ImageSequencer2::ref().getIntervalLength(); std::string progress = "|"; - int g = ((t)* 30) + 1; + int g = ((t)* 24) + 1; for (int i = 0; i < g; i++) progress.append("-"); progress.append(">"); - for (int i = 0; i < 31 - g; i++) + for (int i = 0; i < 25 - g; i++) progress.append(" "); std::string str = ""; - openspace::SpiceManager::ref().getDateFromET(openspace::ImageSequencer2::ref().getNextCaptureTime(), str); + openspace::SpiceManager::ref().getDateFromET(openspace::ImageSequencer2::ref().getNextCaptureTime(), str, "YYYY MON DD HR:MN:SC"); + + glm::vec4 active(0.6, 1, 0.00, 1); + glm::vec4 brigther_active(0.9, 1, 0.75, 1); progress.append("|"); if (remaining > 0){ - glm::vec4 g1(0, t, 0, 1); - glm::vec4 g2(1 - t); - PrintColorText(line++, "Next projection in:", 10, g1 + g2); - PrintColorTextArg(line++, "%.0f sec %s %.1f %%", 10, g1 + g2, remaining, progress.c_str(), t * 100); + brigther_active *= (1 - t); + PrintColorText(line++, "Next instrument activity:", 10, active*t + brigther_active); + PrintColorTextArg(line++, "%.0f s %s %.1f %%", 10, active*t + brigther_active, remaining, progress.c_str(), t * 100); + PrintColorTextArg(line++, "Data acquisition time: %s", 10, active, str.c_str()); + } - glm::vec4 w(1); - PrintColorTextArg(line++, "Ucoming capture : %s", 10, w, str.c_str()); - std::pair nextTarget = ImageSequencer2::ref().getNextTarget(); std::pair currentTarget = ImageSequencer2::ref().getCurrentTarget(); @@ -598,9 +601,7 @@ namespace openspace { mm.append(std::to_string(minute)); ss.append(std::to_string(second)); - - glm::vec4 b2(1.00, 0.51, 0.00, 1); - PrintColorTextArg(line++, "Switching observation focus in : [%s:%s:%s]", 10, b2, hh.c_str(), mm.c_str(), ss.c_str()); + PrintColorTextArg(line++, "Data acquisition adjacency: [%s:%s:%s]", 10, targetColor, hh.c_str(), mm.c_str(), ss.c_str()); std::pair> incidentTargets = ImageSequencer2::ref().getIncidentTargetList(2); std::string space; @@ -610,18 +611,17 @@ namespace openspace { double t = (double)(p + 1) / (double)(isize + 1); t = (p > isize / 2) ? 1 - t : t; t += 0.3; - color = (p == isize / 2) ? glm::vec4(1.00, 0.51, 0.00, 1) : glm::vec4(t, t, t, 1); + color = (p == isize / 2) ? targetColor : glm::vec4(t, t, t, 1); PrintColorTextArg(line, "%s%s", 10, color, space.c_str(), incidentTargets.second[p].c_str()); - for (int k = 0; k < 10; k++) + for (int k = 0; k < incidentTargets.second[p].size() + 2; k++) space += " "; } line++; std::map activeMap = ImageSequencer2::ref().getActiveInstruments(); - glm::vec4 active(0.58, 1, 0.00, 1); glm::vec4 firing(0.58-t, 1-t, 1-t, 1); glm::vec4 notFiring(0.5, 0.5, 0.5, 1); - PrintColorText(line++, "Active Instruments : ", 10, active); + PrintColorText(line++, "Active Instruments: ", 10, active); for (auto t : activeMap){ if (t.second == false){ PrintColorText(line, "| |", 10, glm::vec4(0.3, 0.3, 0.3, 1)); diff --git a/src/util/imagesequencer2.cpp b/src/util/imagesequencer2.cpp index b2e172ec7a..8e0225d930 100644 --- a/src/util/imagesequencer2.cpp +++ b/src/util/imagesequencer2.cpp @@ -47,7 +47,7 @@ ImageSequencer2* ImageSequencer2::_instance = nullptr; ImageSequencer2::ImageSequencer2() : _hasData(false), -_latestImage(nullptr), +_latestImage(), _defaultCaptureImage(absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder_blank.png")) {} @@ -159,8 +159,8 @@ double ImageSequencer2::getNextCaptureTime(){ return nextCaptureTime; } -const Image* ImageSequencer2::getLatestImageForInstrument(const std::string _instrumentID){ - +const Image ImageSequencer2::getLatestImageForInstrument(const std::string _instrumentID){ + return _latestImage; } @@ -269,7 +269,7 @@ bool ImageSequencer2::getImagePaths(std::vector& captures, std::reverse(captureTimes.begin(), captureTimes.end()); captures = captureTimes; if (!captures.empty()) - _latestImage = &captures.back(); + _latestImage = captures.back(); return true; }