From c8da82509863c5c8b9cef47a54d12c644ce3c928 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 18 Apr 2016 15:14:59 +0200 Subject: [PATCH] Rename ImageSequencer2 to ImageSequencer --- modules/base/ephemeris/spiceephemeris.cpp | 4 +- modules/base/rendering/renderablemodel.cpp | 8 +- modules/newhorizons/newhorizonsmodule.cpp | 2 +- .../rendering/renderablecrawlingline.cpp | 4 +- .../newhorizons/rendering/renderablefov.cpp | 6 +- .../rendering/renderablemodelprojection.cpp | 8 +- .../rendering/renderableplaneprojection.cpp | 4 +- .../rendering/renderableplanetprojection.cpp | 14 +- modules/newhorizons/util/imagesequencer.cpp | 516 +++--- modules/newhorizons/util/imagesequencer.h | 284 +-- src/rendering/renderengine.cpp | 1604 ++++++++--------- 11 files changed, 1227 insertions(+), 1227 deletions(-) diff --git a/modules/base/ephemeris/spiceephemeris.cpp b/modules/base/ephemeris/spiceephemeris.cpp index 588607897c..d597ea96a4 100644 --- a/modules/base/ephemeris/spiceephemeris.cpp +++ b/modules/base/ephemeris/spiceephemeris.cpp @@ -84,9 +84,9 @@ void SpiceEphemeris::update(const UpdateData& data) { double lightTime = 0.0; glm::dvec3 position = SpiceManager::ref().targetPosition(_targetName, _originName, "GALACTIC", {}, data.time, lightTime); - //double interval = openspace::ImageSequencer2::ref().getIntervalLength(); + //double interval = openspace::ImageSequencer::ref().getIntervalLength(); //if (_ghosting == "TRUE" && interval > 60){ - // double _time = openspace::ImageSequencer2::ref().getNextCaptureTime(); + // double _time = openspace::ImageSequencer::ref().getNextCaptureTime(); // SpiceManager::ref().getTargetPosition(_targetName, _originName, // "GALACTIC", "NONE", _time, position, lightTime); //} diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index f5a282e5b1..f3953a4896 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -234,10 +234,10 @@ void RenderableModel::update(const UpdateData& data) { double _time = data.time; //if (_isGhost){ - // futureTime = openspace::ImageSequencer2::ref().getNextCaptureTime(); - // double remaining = openspace::ImageSequencer2::ref().getNextCaptureTime() - data.time; - // double interval = openspace::ImageSequencer2::ref().getIntervalLength(); - // double t = 1.f - remaining / openspace::ImageSequencer2::ref().getIntervalLength(); + // futureTime = openspace::ImageSequencer::ref().getNextCaptureTime(); + // double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - data.time; + // double interval = openspace::ImageSequencer::ref().getIntervalLength(); + // double t = 1.f - remaining / openspace::ImageSequencer::ref().getIntervalLength(); // if (interval > 60) { // if (t < 0.8) // _fading = static_cast(t); diff --git a/modules/newhorizons/newhorizonsmodule.cpp b/modules/newhorizons/newhorizonsmodule.cpp index 5daadd11d2..466439e989 100644 --- a/modules/newhorizons/newhorizonsmodule.cpp +++ b/modules/newhorizons/newhorizonsmodule.cpp @@ -51,7 +51,7 @@ NewHorizonsModule::NewHorizonsModule() {} void NewHorizonsModule::internalInitialize() { - ImageSequencer2::initialize(); + ImageSequencer::initialize(); FactoryManager::ref().addFactory(std::make_unique>()); FactoryManager::ref().addFactory(std::make_unique>()); diff --git a/modules/newhorizons/rendering/renderablecrawlingline.cpp b/modules/newhorizons/rendering/renderablecrawlingline.cpp index 2b63e17383..063262723b 100644 --- a/modules/newhorizons/rendering/renderablecrawlingline.cpp +++ b/modules/newhorizons/rendering/renderablecrawlingline.cpp @@ -186,8 +186,8 @@ void RenderableCrawlingLine::update(const UpdateData& data) { _positions[TargetPosition] = target; - if (ImageSequencer2::ref().isReady()) { - _imageSequenceTime = ImageSequencer2::ref().instrumentActiveTime(_instrumentName); + if (ImageSequencer::ref().isReady()) { + _imageSequenceTime = ImageSequencer::ref().instrumentActiveTime(_instrumentName); _drawLine = _imageSequenceTime != -1.f; } } diff --git a/modules/newhorizons/rendering/renderablefov.cpp b/modules/newhorizons/rendering/renderablefov.cpp index f2131c3da8..889a5acf00 100644 --- a/modules/newhorizons/rendering/renderablefov.cpp +++ b/modules/newhorizons/rendering/renderablefov.cpp @@ -421,7 +421,7 @@ void RenderableFov::fovSurfaceIntercept(bool H[], std::vector bounds // This method is purely cosmetics, can very well be removed // but be sure to set colors somewhere. void RenderableFov::computeColors() { - double t2 = (openspace::ImageSequencer2::ref().getNextCaptureTime()); + double t2 = (openspace::ImageSequencer::ref().getNextCaptureTime()); double diff = (t2 - _time); float t = 0.0; float interpolationStart = 7.0; //seconds before @@ -551,8 +551,8 @@ void RenderableFov::render(const RenderData& data) { _programObject->setUniform("ModelTransform", glm::mat4(1)); setPscUniforms(*_programObject.get(), data.camera, data.position); - if (openspace::ImageSequencer2::ref().isReady()) - _drawFOV = ImageSequencer2::ref().instrumentActive(_instrumentID); + if (openspace::ImageSequencer::ref().isReady()) + _drawFOV = ImageSequencer::ref().instrumentActive(_instrumentID); if (_drawFOV){ // update only when time progresses. diff --git a/modules/newhorizons/rendering/renderablemodelprojection.cpp b/modules/newhorizons/rendering/renderablemodelprojection.cpp index c50363f19a..0030eaabd5 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.cpp +++ b/modules/newhorizons/rendering/renderablemodelprojection.cpp @@ -168,7 +168,7 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di dictionary.getValue(keyTranslation, translationDictionary); if (_sequenceType == sequenceTypeImage) { parser = new LabelParser(name, _sequenceSource, translationDictionary); - openspace::ImageSequencer2::ref().runSequenceParser(parser); + openspace::ImageSequencer::ref().runSequenceParser(parser); } } @@ -351,9 +351,9 @@ void RenderableModelProjection::update(const UpdateData& data) { _time = data.time; - if (openspace::ImageSequencer2::ref().isReady() && _performProjection) { - openspace::ImageSequencer2::ref().updateSequencer(_time); - _capture = openspace::ImageSequencer2::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID); + if (openspace::ImageSequencer::ref().isReady() && _performProjection) { + openspace::ImageSequencer::ref().updateSequencer(_time); + _capture = openspace::ImageSequencer::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID); } // set spice-orientation in accordance to timestamp diff --git a/modules/newhorizons/rendering/renderableplaneprojection.cpp b/modules/newhorizons/rendering/renderableplaneprojection.cpp index 5cd01ad5c9..cdbd73dc50 100644 --- a/modules/newhorizons/rendering/renderableplaneprojection.cpp +++ b/modules/newhorizons/rendering/renderableplaneprojection.cpp @@ -130,7 +130,7 @@ bool RenderablePlaneProjection::deinitialize() { } void RenderablePlaneProjection::render(const RenderData& data) { - bool active = ImageSequencer2::ref().instrumentActive(_instrument); + bool active = ImageSequencer::ref().instrumentActive(_instrument); if (!_hasImage || (_moving && !active)) return; @@ -165,7 +165,7 @@ void RenderablePlaneProjection::update(const UpdateData& data) { double time = data.time; - const Image img = openspace::ImageSequencer2::ref().getLatestImageForInstrument(_instrument); + const Image img = openspace::ImageSequencer::ref().getLatestImageForInstrument(_instrument); if (img.path == "") return; diff --git a/modules/newhorizons/rendering/renderableplanetprojection.cpp b/modules/newhorizons/rendering/renderableplanetprojection.cpp index 4e1a67cfd0..46f343e699 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.cpp +++ b/modules/newhorizons/rendering/renderableplanetprojection.cpp @@ -194,20 +194,20 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& _projectorID, translationDictionary, _potentialTargets); - openspace::ImageSequencer2::ref().runSequenceParser(parser); + openspace::ImageSequencer::ref().runSequenceParser(parser); } else if (_sequenceType == sequenceTypeImage) { parser = new LabelParser(name, _sequenceSource, translationDictionary); - openspace::ImageSequencer2::ref().runSequenceParser(parser); + openspace::ImageSequencer::ref().runSequenceParser(parser); } else if (_sequenceType == sequenceTypeHybrid) { //first read labels parser = new LabelParser(name, _sequenceSource, translationDictionary); - openspace::ImageSequencer2::ref().runSequenceParser(parser); + openspace::ImageSequencer::ref().runSequenceParser(parser); std::string _eventFile; bool foundEventFile = dictionary.getValue("Projection.EventFile", _eventFile); @@ -219,7 +219,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& _projectorID, translationDictionary, _potentialTargets); - openspace::ImageSequencer2::ref().runSequenceParser(parser); + openspace::ImageSequencer::ref().runSequenceParser(parser); } else{ LWARNING("No eventfile has been provided, please check modfiles"); @@ -561,9 +561,9 @@ void RenderablePlanetProjection::update(const UpdateData& data){ _time = Time::ref().currentTime(); _capture = false; - if (openspace::ImageSequencer2::ref().isReady() && _performProjection){ - openspace::ImageSequencer2::ref().updateSequencer(_time); - _capture = openspace::ImageSequencer2::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID); + if (openspace::ImageSequencer::ref().isReady() && _performProjection){ + openspace::ImageSequencer::ref().updateSequencer(_time); + _capture = openspace::ImageSequencer::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID); } if (_fboProgramObject && _fboProgramObject->isDirty()) { diff --git a/modules/newhorizons/util/imagesequencer.cpp b/modules/newhorizons/util/imagesequencer.cpp index 1f334c562a..5c5a96c7e8 100644 --- a/modules/newhorizons/util/imagesequencer.cpp +++ b/modules/newhorizons/util/imagesequencer.cpp @@ -38,179 +38,179 @@ #include namespace { -const std::string _loggerCat = "ImageSequencer2"; +const std::string _loggerCat = "ImageSequencer"; } namespace openspace { -ImageSequencer2* ImageSequencer2::_instance = nullptr; +ImageSequencer* ImageSequencer::_instance = nullptr; -ImageSequencer2::ImageSequencer2() +ImageSequencer::ImageSequencer() : _hasData(false) {} -ImageSequencer2& ImageSequencer2::ref() { - assert(_instance != nullptr); - return *_instance; +ImageSequencer& ImageSequencer::ref() { + assert(_instance != nullptr); + return *_instance; } -void ImageSequencer2::initialize() { - assert(_instance == nullptr); - _instance = new ImageSequencer2; +void ImageSequencer::initialize() { + assert(_instance == nullptr); + _instance = new ImageSequencer; _instance->_defaultCaptureImage = absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder_blank.png"); } -void ImageSequencer2::deinitialize() { - delete _instance; - _instance = nullptr; +void ImageSequencer::deinitialize() { + delete _instance; + _instance = nullptr; } -bool ImageSequencer2::isReady(){ - return _hasData; +bool ImageSequencer::isReady(){ + return _hasData; } -void ImageSequencer2::updateSequencer(double time){ - if (Time::ref().timeJumped() && Time::ref().deltaTime() == 0){ - Time::ref().setDeltaTime(0.1); - } // Time is not properly updated when time jump with dt = 0 +void ImageSequencer::updateSequencer(double time){ + if (Time::ref().timeJumped() && Time::ref().deltaTime() == 0){ + Time::ref().setDeltaTime(0.1); + } // Time is not properly updated when time jump with dt = 0 - if (_currentTime != time){ - _previousTime = _currentTime; - _currentTime = time; - } + if (_currentTime != time){ + _previousTime = _currentTime; + _currentTime = time; + } } -std::pair ImageSequencer2::getNextTarget(){ - auto compareTime = [](const std::pair &a, - const std::pair &b)->bool{ - return a.first < b.first; - }; - std::pair findEqualToThis; - findEqualToThis.first = _currentTime; - auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime); +std::pair ImageSequencer::getNextTarget(){ + auto compareTime = [](const std::pair &a, + const std::pair &b)->bool{ + return a.first < b.first; + }; + std::pair findEqualToThis; + findEqualToThis.first = _currentTime; + auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime); - if (it != _targetTimes.end() && it != _targetTimes.begin()) - return (*it); + if (it != _targetTimes.end() && it != _targetTimes.begin()) + return (*it); else return std::make_pair(0.0, ""); } -std::pair ImageSequencer2::getCurrentTarget(){ - auto compareTime = [](const std::pair &a, - const std::pair &b)->bool{ - return a.first < b.first; - }; - std::pair findEqualToThis; - findEqualToThis.first = _currentTime; - auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime); +std::pair ImageSequencer::getCurrentTarget(){ + auto compareTime = [](const std::pair &a, + const std::pair &b)->bool{ + return a.first < b.first; + }; + std::pair findEqualToThis; + findEqualToThis.first = _currentTime; + auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime); - if (it != _targetTimes.end() && it != _targetTimes.begin()){ - return *std::prev(it); - } + if (it != _targetTimes.end() && it != _targetTimes.begin()){ + return *std::prev(it); + } else return std::make_pair(0.0, "No Target"); } -std::pair> ImageSequencer2::getIncidentTargetList(int range){ - std::pair> incidentTargets; +std::pair> ImageSequencer::getIncidentTargetList(int range){ + std::pair> incidentTargets; - auto compareTime = [](const std::pair &a, - const std::pair &b)->bool{ - return a.first < b.first; - }; - // what to look for - std::pair findEqualToThis; - findEqualToThis.first = _currentTime; - auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime); - - if (it != _targetTimes.end() && it != _targetTimes.begin()){ - // move the iterator to the first element of the range - std::advance(it, -(range + 1)); + auto compareTime = [](const std::pair &a, + const std::pair &b)->bool{ + return a.first < b.first; + }; + // what to look for + std::pair findEqualToThis; + findEqualToThis.first = _currentTime; + auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime); + + if (it != _targetTimes.end() && it != _targetTimes.begin()){ + // move the iterator to the first element of the range + std::advance(it, -(range + 1)); - // now extract incident range - for (int i = 0; i < 2 * range + 1; i++){ - incidentTargets.first = it->first; - incidentTargets.second.push_back(it->second); - it++; - if (it == _targetTimes.end()) - break; - } - } + // now extract incident range + for (int i = 0; i < 2 * range + 1; i++){ + incidentTargets.first = it->first; + incidentTargets.second.push_back(it->second); + it++; + if (it == _targetTimes.end()) + break; + } + } - return incidentTargets; + return incidentTargets; } -double ImageSequencer2::getIntervalLength(){ - double upcoming = getNextCaptureTime(); - if (_nextCapture != upcoming){ - _nextCapture = upcoming; - _intervalLength = upcoming - _currentTime; - } - return _intervalLength; +double ImageSequencer::getIntervalLength(){ + double upcoming = getNextCaptureTime(); + if (_nextCapture != upcoming){ + _nextCapture = upcoming; + _intervalLength = upcoming - _currentTime; + } + return _intervalLength; } -double ImageSequencer2::getNextCaptureTime(){ - auto compareTime = [](const double &a, const double &b)->bool{ - return a < b; - }; - double nextCaptureTime = 0; - auto it = std::lower_bound(_captureProgression.begin(), _captureProgression.end(), _currentTime, compareTime); - if (it != _captureProgression.end()) - nextCaptureTime = *it; +double ImageSequencer::getNextCaptureTime(){ + auto compareTime = [](const double &a, const double &b)->bool{ + return a < b; + }; + double nextCaptureTime = 0; + auto it = std::lower_bound(_captureProgression.begin(), _captureProgression.end(), _currentTime, compareTime); + if (it != _captureProgression.end()) + nextCaptureTime = *it; - return nextCaptureTime; + return nextCaptureTime; } -const Image ImageSequencer2::getLatestImageForInstrument(const std::string _instrumentID){ - auto it = _latestImages.find(_instrumentID); - if (it != _latestImages.end()) - return _latestImages[_instrumentID]; - else { - Image dummyImage = { 0, 0, "", std::vector(), "", false }; - return dummyImage; - } +const Image ImageSequencer::getLatestImageForInstrument(const std::string _instrumentID){ + auto it = _latestImages.find(_instrumentID); + if (it != _latestImages.end()) + return _latestImages[_instrumentID]; + else { + Image dummyImage = { 0, 0, "", std::vector(), "", false }; + return dummyImage; + } } -std::map ImageSequencer2::getActiveInstruments(){ - // first set all instruments to off - for (auto i : _switchingMap) - _switchingMap[i.first] = false; - // go over the filetranslation map - for (const auto &key : _fileTranslation){ - // for each spice-instrument - for (const auto &instrumentID : key.second->getTranslation()){ - // check if the spice-instrument is active - if (instrumentActive(instrumentID)){ - // go over switching map - for (const auto &instrument : _switchingMap){ - // if instrument is present in switching map - if (instrumentID == instrument.first){ - // set as active - _switchingMap[instrumentID] = true; - } - } - } - } - } - // return entire map, seen in GUI. - return _switchingMap; +std::map ImageSequencer::getActiveInstruments(){ + // first set all instruments to off + for (auto i : _switchingMap) + _switchingMap[i.first] = false; + // go over the filetranslation map + for (const auto &key : _fileTranslation){ + // for each spice-instrument + for (const auto &instrumentID : key.second->getTranslation()){ + // check if the spice-instrument is active + if (instrumentActive(instrumentID)){ + // go over switching map + for (const auto &instrument : _switchingMap){ + // if instrument is present in switching map + if (instrumentID == instrument.first){ + // set as active + _switchingMap[instrumentID] = true; + } + } + } + } + } + // return entire map, seen in GUI. + return _switchingMap; } -bool ImageSequencer2::instrumentActive(std::string instrumentID){ - for (auto i : _instrumentTimes){ - //check if this instrument is in range - if (i.second.inRange(_currentTime)){ - //if so, then get the corresponding spiceID - std::vector spiceIDs = _fileTranslation[i.first]->getTranslation(); - //check which specific subinstrument is firing - for (auto s : spiceIDs){ - if (s == instrumentID){ - return true; - } - } - } - } - return false; +bool ImageSequencer::instrumentActive(std::string instrumentID){ + for (auto i : _instrumentTimes){ + //check if this instrument is in range + if (i.second.inRange(_currentTime)){ + //if so, then get the corresponding spiceID + std::vector spiceIDs = _fileTranslation[i.first]->getTranslation(); + //check which specific subinstrument is firing + for (auto s : spiceIDs){ + if (s == instrumentID){ + return true; + } + } + } + } + return false; } -float ImageSequencer2::instrumentActiveTime(const std::string& instrumentID) const { +float ImageSequencer::instrumentActiveTime(const std::string& instrumentID) const { for (auto i : _instrumentTimes){ //check if this instrument is in range if (i.second.inRange(_currentTime)){ @@ -227,154 +227,154 @@ float ImageSequencer2::instrumentActiveTime(const std::string& instrumentID) con return -1.f; } -bool ImageSequencer2::getImagePaths(std::vector& captures, - std::string projectee, - std::string instrumentRequest){ +bool ImageSequencer::getImagePaths(std::vector& captures, + std::string projectee, + std::string instrumentRequest){ - // check if this instance is either in range or - // a valid candidate to recieve data - if (!instrumentActive(instrumentRequest) && !Time::ref().timeJumped()) return false; + // check if this instance is either in range or + // a valid candidate to recieve data + if (!instrumentActive(instrumentRequest) && !Time::ref().timeJumped()) return false; - //if (!Time::ref().timeJumped() && projectee == getCurrentTarget().second) - if (_subsetMap[projectee]._range.inRange(_currentTime) || - _subsetMap[projectee]._range.inRange(_previousTime)){ - auto compareTime = [](const Image &a, - const Image &b)->bool{ - return a.startTime < b.startTime; - }; - // for readability we store the iterators - auto begin = _subsetMap[projectee]._subset.begin(); - auto end = _subsetMap[projectee]._subset.end(); - - // create temporary storage - std::vector captureTimes; - // what to look for - Image findPrevious, findCurrent; - findPrevious.startTime = _previousTime; - findCurrent.startTime = _currentTime; + //if (!Time::ref().timeJumped() && projectee == getCurrentTarget().second) + if (_subsetMap[projectee]._range.inRange(_currentTime) || + _subsetMap[projectee]._range.inRange(_previousTime)){ + auto compareTime = [](const Image &a, + const Image &b)->bool{ + return a.startTime < b.startTime; + }; + // for readability we store the iterators + auto begin = _subsetMap[projectee]._subset.begin(); + auto end = _subsetMap[projectee]._subset.end(); + + // create temporary storage + std::vector captureTimes; + // what to look for + Image findPrevious, findCurrent; + findPrevious.startTime = _previousTime; + findCurrent.startTime = _currentTime; - // find the two iterators that correspond to the latest time jump - auto curr = std::lower_bound(begin, end, findCurrent , compareTime); - auto prev = std::lower_bound(begin, end, findPrevious, compareTime); - - if (curr != begin && curr != end && prev != begin && prev != end && prev < curr){ + // find the two iterators that correspond to the latest time jump + auto curr = std::lower_bound(begin, end, findCurrent , compareTime); + auto prev = std::lower_bound(begin, end, findPrevious, compareTime); + + if (curr != begin && curr != end && prev != begin && prev != end && prev < curr){ if (curr->startTime >= prev->startTime){ - std::copy_if(prev, curr, back_inserter(captureTimes), - [instrumentRequest](const Image& i) { - return i.activeInstruments[0] == instrumentRequest; - }); + std::copy_if(prev, curr, back_inserter(captureTimes), + [instrumentRequest](const Image& i) { + return i.activeInstruments[0] == instrumentRequest; + }); - //std::reverse(captureTimes.begin(), captureTimes.end()); - captures = captureTimes; + //std::reverse(captureTimes.begin(), captureTimes.end()); + captures = captureTimes; if (!captures.empty()) - _latestImages[captures.back().activeInstruments.front()] = captures.back(); + _latestImages[captures.back().activeInstruments.front()] = captures.back(); - return true; + return true; } - } - } - return false; + } + } + return false; } -void ImageSequencer2::sortData(){ - auto targetComparer = [](const std::pair &a, - const std::pair &b)->bool{ - return a.first < b.first; - }; - auto imageComparer = [](const Image &a, const Image &b)->bool{ - return a.startTime < b.startTime; - }; +void ImageSequencer::sortData(){ + auto targetComparer = [](const std::pair &a, + const std::pair &b)->bool{ + return a.first < b.first; + }; + auto imageComparer = [](const Image &a, const Image &b)->bool{ + return a.startTime < b.startTime; + }; - std::sort(_targetTimes.begin(), _targetTimes.end(), targetComparer); - std::stable_sort(_captureProgression.begin(), _captureProgression.end()); + std::sort(_targetTimes.begin(), _targetTimes.end(), targetComparer); + std::stable_sort(_captureProgression.begin(), _captureProgression.end()); - for (auto sub : _subsetMap){ - std::sort(_subsetMap[sub.first]._subset.begin(), - _subsetMap[sub.first]._subset.end(), imageComparer); - } + for (auto sub : _subsetMap){ + std::sort(_subsetMap[sub.first]._subset.begin(), + _subsetMap[sub.first]._subset.end(), imageComparer); + } } -void ImageSequencer2::runSequenceParser(SequenceParser* parser){ - bool parserComplete = parser->create(); - if (parserComplete){ - // get new data - std::map translations = parser->getTranslation(); // in1 - std::map imageData = parser->getSubsetMap(); // in2 - std::vector> instrumentTimes = parser->getIstrumentTimes(); //in3 - std::vector> targetTimes = parser->getTargetTimes(); //in4 - std::vector captureProgression = parser->getCaptureProgression(); //in5 +void ImageSequencer::runSequenceParser(SequenceParser* parser){ + bool parserComplete = parser->create(); + if (parserComplete){ + // get new data + std::map translations = parser->getTranslation(); // in1 + std::map imageData = parser->getSubsetMap(); // in2 + std::vector> instrumentTimes = parser->getIstrumentTimes(); //in3 + std::vector> targetTimes = parser->getTargetTimes(); //in4 + std::vector captureProgression = parser->getCaptureProgression(); //in5 - // check for sanity - if (translations.empty() || imageData.empty() || instrumentTimes.empty() || targetTimes.empty() || captureProgression.empty()) - return; + // check for sanity + if (translations.empty() || imageData.empty() || instrumentTimes.empty() || targetTimes.empty() || captureProgression.empty()) + return; - // append data - _fileTranslation.insert(translations.begin(), translations.end()); - for (auto it : imageData){ - if (_subsetMap.find(it.first) == _subsetMap.end()) { - // if key not exist yet - add sequence data for key (target) - _subsetMap.insert(it); - } else { - std::string key = it.first; - std::vector &source = it.second._subset; // prediction - std::vector &destination = _subsetMap[key]._subset; // imagery + // append data + _fileTranslation.insert(translations.begin(), translations.end()); + for (auto it : imageData){ + if (_subsetMap.find(it.first) == _subsetMap.end()) { + // if key not exist yet - add sequence data for key (target) + _subsetMap.insert(it); + } else { + std::string key = it.first; + std::vector &source = it.second._subset; // prediction + std::vector &destination = _subsetMap[key]._subset; // imagery - // simple search function - double min = 10; - auto findMin = [&](std::vector &vector)->double{ - for (int i = 1; i < vector.size(); i++){ - double e = abs(vector[i].startTime - vector[i - 1].startTime); - if (e < min){ - min = e; - } - } - return min; - }; - - // find the smallest separation of images in time - double epsilon; - epsilon = findMin(source); - epsilon = findMin(destination); - // set epsilon as 1% smaller than min - epsilon -= min*0.01; - - // IFF images have same time as mission planned capture, erase that event from - // 'predicted event file' (mission-playbook) - std::vector tmp; - for (int i = 0; i < source.size(); i++){ - for (int j = 0; j < destination.size(); j++){ - double diff = abs(source[i].startTime - destination[j].startTime); - if (diff < epsilon){ - source.erase(source.begin() + i); - } - } - } - // pad image data with predictions (ie - where no actual images, add placeholder) - _subsetMap[key]._subset.insert(_subsetMap[key]._subset.end(), source.begin(), source.end()); - } - } + // simple search function + double min = 10; + auto findMin = [&](std::vector &vector)->double{ + for (int i = 1; i < vector.size(); i++){ + double e = abs(vector[i].startTime - vector[i - 1].startTime); + if (e < min){ + min = e; + } + } + return min; + }; + + // find the smallest separation of images in time + double epsilon; + epsilon = findMin(source); + epsilon = findMin(destination); + // set epsilon as 1% smaller than min + epsilon -= min*0.01; + + // IFF images have same time as mission planned capture, erase that event from + // 'predicted event file' (mission-playbook) + std::vector tmp; + for (int i = 0; i < source.size(); i++){ + for (int j = 0; j < destination.size(); j++){ + double diff = abs(source[i].startTime - destination[j].startTime); + if (diff < epsilon){ + source.erase(source.begin() + i); + } + } + } + // pad image data with predictions (ie - where no actual images, add placeholder) + _subsetMap[key]._subset.insert(_subsetMap[key]._subset.end(), source.begin(), source.end()); + } + } - _instrumentTimes.insert(_instrumentTimes.end(), instrumentTimes.begin(), instrumentTimes.end()); - _targetTimes.insert(_targetTimes.end(), targetTimes.begin(), targetTimes.end()); - _captureProgression.insert(_captureProgression.end(), captureProgression.begin(), captureProgression.end()); + _instrumentTimes.insert(_instrumentTimes.end(), instrumentTimes.begin(), instrumentTimes.end()); + _targetTimes.insert(_targetTimes.end(), targetTimes.begin(), targetTimes.end()); + _captureProgression.insert(_captureProgression.end(), captureProgression.begin(), captureProgression.end()); - // sorting of data _not_ optional - sortData(); + // sorting of data _not_ optional + sortData(); - // extract payload from _fileTranslation - for (auto t : _fileTranslation){ - if (t.second->getDecoderType() == "CAMERA" || - t.second->getDecoderType() == "SCANNER"){ - std::vector spiceIDs = t.second->getTranslation(); - for (auto id : spiceIDs){ - _switchingMap[id] = false; - } - } - } - _hasData = true; - } - else - LERROR("One of more sequence loads failed; please check mod files"); + // extract payload from _fileTranslation + for (auto t : _fileTranslation){ + if (t.second->getDecoderType() == "CAMERA" || + t.second->getDecoderType() == "SCANNER"){ + std::vector spiceIDs = t.second->getTranslation(); + for (auto id : spiceIDs){ + _switchingMap[id] = false; + } + } + } + _hasData = true; + } + else + LERROR("One or more sequence loads failed; please check mod files"); } } // namespace openspace diff --git a/modules/newhorizons/util/imagesequencer.h b/modules/newhorizons/util/imagesequencer.h index 8bc8c9d252..d34e1ebd79 100644 --- a/modules/newhorizons/util/imagesequencer.h +++ b/modules/newhorizons/util/imagesequencer.h @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __ImageSequencer2_H__ -#define __ImageSequencer2_H__ +#ifndef __IMAGESEQUENCER_H__ +#define __IMAGESEQUENCER_H__ // open space includes #include @@ -36,170 +36,170 @@ #include namespace openspace { - /** - * The ImageSequencer singleton main function is to manage the timekeeping and - * distribution of large image data-sets across all openspace renderable instances, - * both for past and future unmanned-spacecraft missions. To load the instance with - * data the client must provide a parser inherited from the abstract base class - * SequenceParser. Hence, there is no restriction imposed on data input, whether its - * data in the form of existing images or in the form of a planned observation schedule. - * Notably, in order for the sequencer to function the client must provide or write a - * parser that fills the ImageSequencers private members. - * \see SequenceParser - * \see ImageSequencer2::runSequenceParser(SequenceParser* parser) - * std::map - */ -class ImageSequencer2 { + /** + * The ImageSequencer singleton main function is to manage the timekeeping and + * distribution of large image data-sets across all openspace renderable instances, + * both for past and future unmanned-spacecraft missions. To load the instance with + * data the client must provide a parser inherited from the abstract base class + * SequenceParser. Hence, there is no restriction imposed on data input, whether its + * data in the form of existing images or in the form of a planned observation schedule. + * Notably, in order for the sequencer to function the client must provide or write a + * parser that fills the ImageSequencers private members. + * \see SequenceParser + * \see ImageSequencer::runSequenceParser(SequenceParser* parser) + * std::map + */ +class ImageSequencer { public: - ImageSequencer2(); - /** - * Singelton instantiation - */ - static ImageSequencer2* _instance; - /** - * Returns the reference to the singleton ImageSequencer object that must have been - * initialized by a call to the initialize method earlier. - * \return The ImageSequencer singleton - */ - static ImageSequencer2& ref(); - /** - * Initializer that initializes the static member. - */ - static void initialize(); - /** - * Deinitializes that deinitializes the static member. - */ - static void deinitialize(); - /** - * Returns true if sequencer has been loaded with data. - */ - bool isReady(); + ImageSequencer(); + /** + * Singelton instantiation + */ + static ImageSequencer* _instance; + /** + * Returns the reference to the singleton ImageSequencer object that must have been + * initialized by a call to the initialize method earlier. + * \return The ImageSequencer singleton + */ + static ImageSequencer& ref(); + /** + * Initializer that initializes the static member. + */ + static void initialize(); + /** + * Deinitializes that deinitializes the static member. + */ + static void deinitialize(); + /** + * Returns true if sequencer has been loaded with data. + */ + bool isReady(); - /** - * Updates sequencer with current time. This is used internally for keeping - * track of both current simulation time and the time of the previously rendered frame. - */ - void updateSequencer(double time); - /** - * Runs parser and recieves the datastructures filled by it. - * \see SequenceParser - */ - void runSequenceParser(SequenceParser* parser); + /** + * Updates sequencer with current time. This is used internally for keeping + * track of both current simulation time and the time of the previously rendered frame. + */ + void updateSequencer(double time); + /** + * Runs parser and recieves the datastructures filled by it. + * \see SequenceParser + */ + void runSequenceParser(SequenceParser* parser); - /** - * Retrieves the next upcoming target in time. - */ - std::pair getNextTarget(); + /** + * Retrieves the next upcoming target in time. + */ + std::pair getNextTarget(); - /** - * Retrieves the most current target in time. - */ - std::pair getCurrentTarget(); + /** + * Retrieves the most current target in time. + */ + std::pair getCurrentTarget(); - /** - * Retrieves current target and (in the list) adjacent targets, the number to retrieve is user set - */ - std::pair> getIncidentTargetList(int range = 2); + /** + * Retrieves current target and (in the list) adjacent targets, the number to retrieve is user set + */ + std::pair> getIncidentTargetList(int range = 2); - /** - * Retrieves the next upcoming time of image capture. - */ - double getNextCaptureTime(); + /** + * Retrieves the next upcoming time of image capture. + */ + double getNextCaptureTime(); - /** - * Retrieves the time interval length between the current time and an upcoming capture. - */ - double getIntervalLength(); + /** + * Retrieves the time interval length between the current time and an upcoming capture. + */ + double getIntervalLength(); - /* - * Returns a map with key instrument names whose value indicate whether - * an instrument is active or not. - */ - std::map getActiveInstruments(); + /* + * Returns a map with key instrument names whose value indicate whether + * an instrument is active or not. + */ + std::map getActiveInstruments(); - /* - * Retrieves the relevant data from a specific subset based on the what instance - * makes the request. If an instance is not registered in the class then the singleton - * returns false and no projections will occur. - */ - bool getImagePaths(std::vector& captures, - std::string projectee, - std::string instrumentRequest); + /* + * Retrieves the relevant data from a specific subset based on the what instance + * makes the request. If an instance is not registered in the class then the singleton + * returns false and no projections will occur. + */ + bool getImagePaths(std::vector& captures, + std::string projectee, + std::string instrumentRequest); - /* - * returns true if instrumentID is within a capture range. - */ - bool instrumentActive(std::string instrumentID); + /* + * returns true if instrumentID is within a capture range. + */ + bool instrumentActive(std::string instrumentID); float instrumentActiveTime(const std::string& instrumentID) const; - /* - * returns latest captured image - */ - const Image getLatestImageForInstrument(const std::string _instrumentID); + /* + * returns latest captured image + */ + const Image getLatestImageForInstrument(const std::string _instrumentID); private: - void sortData(); - - /* - * _fileTranslation handles any types of ambiguities between the data and - * spice/openspace -calls. This map is composed of a key that is a string in - * the data to be translated and a Decoder that holds the corresponding - * translation provided through a modfile. - * \see Decoder - * \see (projection mod files) - */ - std::map _fileTranslation; + void sortData(); + + /* + * _fileTranslation handles any types of ambiguities between the data and + * spice/openspace -calls. This map is composed of a key that is a string in + * the data to be translated and a Decoder that holds the corresponding + * translation provided through a modfile. + * \see Decoder + * \see (projection mod files) + */ + std::map _fileTranslation; - /* - * This is the main container of image data. The key is the target name, - * the value is a subset of images. - * \see SequenceParser - */ - std::map _subsetMap; + /* + * This is the main container of image data. The key is the target name, + * the value is a subset of images. + * \see SequenceParser + */ + std::map _subsetMap; - /* - * In order for the simulation to know when to turn on/off any instrument within - * all instruments in the spacecraft payload, the key is the data-file given - * instrument name. - */ - std::map _switchingMap; + /* + * In order for the simulation to know when to turn on/off any instrument within + * all instruments in the spacecraft payload, the key is the data-file given + * instrument name. + */ + std::map _switchingMap; - /* - * This datastructure holds the specific times when the spacecraft switches from - * observing one inertial body to the next. This happens a lot in such missions - * and the coupling of target with specific time is usually therefore not 1:1. - */ - std::vector> _targetTimes; + /* + * This datastructure holds the specific times when the spacecraft switches from + * observing one inertial body to the next. This happens a lot in such missions + * and the coupling of target with specific time is usually therefore not 1:1. + */ + std::vector> _targetTimes; - /* - * Holds the time ranges of each instruments on and off periods. An instrument - * rendering class may ask the ImageSequencer whether or not it - */ - std::vector> _instrumentTimes; + /* + * Holds the time ranges of each instruments on and off periods. An instrument + * rendering class may ask the ImageSequencer whether or not it + */ + std::vector> _instrumentTimes; - /* - * Each consecutive images capture time, for easier traversal. - */ - std::vector _captureProgression; + /* + * Each consecutive images capture time, for easier traversal. + */ + std::vector _captureProgression; - // current simulation time - double _currentTime; - // simulation time of previous frame - double _previousTime; - // time between current simulation time and an upcoming capture - double _intervalLength; - // next consecutive capture in time - double _nextCapture; - // default capture image - std::string _defaultCaptureImage; + // current simulation time + double _currentTime; + // simulation time of previous frame + double _previousTime; + // time between current simulation time and an upcoming capture + double _intervalLength; + // next consecutive capture in time + double _nextCapture; + // default capture image + std::string _defaultCaptureImage; - std::map _latestImages; - // if no data, no run - bool _hasData; + std::map _latestImages; + // if no data, no run + bool _hasData; }; } // namespace openspace -#endif // __ImageSequencer2_H__ +#endif // __IMAGESEQUENCER_H__ diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index f26fc24f90..c14dbe8565 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -86,7 +86,7 @@ #include "renderengine_lua.inl" namespace { - const std::string _loggerCat = "RenderEngine"; + const std::string _loggerCat = "RenderEngine"; const std::string KeyRenderingMethod = "RenderingMethod"; std::chrono::seconds ScreenLogTimeToLive(15); @@ -97,26 +97,26 @@ namespace { namespace openspace { const std::string RenderEngine::PerformanceMeasurementSharedData = - "OpenSpacePerformanceMeasurementSharedData"; + "OpenSpacePerformanceMeasurementSharedData"; const std::string RenderEngine::KeyFontMono = "Mono"; const std::string RenderEngine::KeyFontLight = "Light"; RenderEngine::RenderEngine() - : _mainCamera(nullptr) - , _sceneGraph(nullptr) - , _renderer(nullptr) + : _mainCamera(nullptr) + , _sceneGraph(nullptr) + , _renderer(nullptr) , _rendererImplementation(RendererImplementation::Invalid) - , _log(nullptr) - , _showInfo(true) - , _showLog(true) - , _takeScreenshot(false) - , _doPerformanceMeasurements(false) - , _performanceMemory(nullptr) - , _globalBlackOutFactor(1.f) - , _fadeDuration(2.f) - , _currentFadeTime(0.f) - , _fadeDirection(0) + , _log(nullptr) + , _showInfo(true) + , _showLog(true) + , _takeScreenshot(false) + , _doPerformanceMeasurements(false) + , _performanceMemory(nullptr) + , _globalBlackOutFactor(1.f) + , _fadeDuration(2.f) + , _currentFadeTime(0.f) + , _fadeDirection(0) // , _sgctRenderStatisticsVisible(false) { _onScreenInformation = { @@ -127,20 +127,20 @@ RenderEngine::RenderEngine() } RenderEngine::~RenderEngine() { - delete _sceneGraph; - _sceneGraph = nullptr; + delete _sceneGraph; + _sceneGraph = nullptr; - delete _mainCamera; - delete _performanceMemory; - delete _raycasterManager; + delete _mainCamera; + delete _performanceMemory; + delete _raycasterManager; - if (ghoul::SharedMemory::exists(PerformanceMeasurementSharedData)) - ghoul::SharedMemory::remove(PerformanceMeasurementSharedData); + if (ghoul::SharedMemory::exists(PerformanceMeasurementSharedData)) + ghoul::SharedMemory::remove(PerformanceMeasurementSharedData); } bool RenderEngine::deinitialize() { - _sceneGraph->clearSceneGraph(); - return true; + _sceneGraph->clearSceneGraph(); + return true; } void RenderEngine::setRendererFromString(const std::string& renderingMethod) { @@ -149,7 +149,7 @@ void RenderEngine::setRendererFromString(const std::string& renderingMethod) { std::unique_ptr newRenderer = nullptr; switch (_rendererImplementation) { case RendererImplementation::Framebuffer: - newRenderer = std::make_unique(); + newRenderer = std::make_unique(); break; case RendererImplementation::ABuffer: newRenderer = std::make_unique(); @@ -169,7 +169,7 @@ bool RenderEngine::initialize() { if (OsEng.configurationManager().hasKeyAndValue(KeyRenderingMethod)) { renderingMethod = OsEng.configurationManager().value(KeyRenderingMethod); - } else { + } else { using Version = ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version; // The default rendering method has a requirement of OpenGL 4.3, so if we are @@ -182,13 +182,13 @@ bool RenderEngine::initialize() { _raycasterManager = new RaycasterManager(); - LINFO("Seting renderer from string: " << renderingMethod); - setRendererFromString(renderingMethod); + LINFO("Seting renderer from string: " << renderingMethod); + setRendererFromString(renderingMethod); - // init camera and set temporary position and scaling - _mainCamera = new Camera(); - _mainCamera->setScaling(glm::vec2(1.0, -8.0)); - _mainCamera->setPosition(psc(0.f, 0.f, 1.499823f, 11.f)); + // init camera and set temporary position and scaling + _mainCamera = new Camera(); + _mainCamera->setScaling(glm::vec2(1.0, -8.0)); + _mainCamera->setPosition(psc(0.f, 0.f, 1.499823f, 11.f)); OsEng.interactionHandler().setCamera(_mainCamera); if (_renderer) { @@ -209,15 +209,15 @@ bool RenderEngine::initialize() { ghoul::io::TextureReader::ref().addReader(std::make_shared()); - return true; + return true; } bool RenderEngine::initializeGL() { - // TODO: Fix the power scaled coordinates in such a way that these - // values can be set to more realistic values + // TODO: Fix the power scaled coordinates in such a way that these + // values can be set to more realistic values - // set the close clip plane and the far clip plane to extreme values while in - // development + // set the close clip plane and the far clip plane to extreme values while in + // development OsEng.windowWrapper().setNearFarClippingPlane(0.001f, 1000.f); @@ -241,28 +241,28 @@ bool RenderEngine::initializeGL() { // sgct::Engine::instance()->setNearAndFarClippingPlanes(0.001f, 1000.0f); - // sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f, 30.0f); + // sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f, 30.0f); - // calculating the maximum field of view for the camera, used to - // determine visibility of objects in the scene graph + // calculating the maximum field of view for the camera, used to + // determine visibility of objects in the scene graph /* if (sgct::Engine::instance()->getCurrentRenderTarget() == sgct::Engine::NonLinearBuffer) { - // fisheye mode, looking upwards to the "dome" - glm::vec4 upDirection(0, 1, 0, 0); + // fisheye mode, looking upwards to the "dome" + glm::vec4 upDirection(0, 1, 0, 0); - // get the tilt and rotate the view - const float tilt = wPtr->getFisheyeTilt(); - glm::mat4 tiltMatrix - = glm::rotate(glm::mat4(1.0f), tilt, glm::vec3(1.0f, 0.0f, 0.0f)); - const glm::vec4 viewdir = tiltMatrix * upDirection; + // get the tilt and rotate the view + const float tilt = wPtr->getFisheyeTilt(); + glm::mat4 tiltMatrix + = glm::rotate(glm::mat4(1.0f), tilt, glm::vec3(1.0f, 0.0f, 0.0f)); + const glm::vec4 viewdir = tiltMatrix * upDirection; - // set the tilted view and the FOV - _mainCamera->setCameraDirection(glm::vec3(viewdir[0], viewdir[1], viewdir[2])); - _mainCamera->setMaxFov(wPtr->getFisheyeFOV()); - _mainCamera->setLookUpVector(glm::vec3(0.0, 1.0, 0.0)); - } - else {*/ - // get corner positions, calculating the forth to easily calculate center - + // set the tilted view and the FOV + _mainCamera->setCameraDirection(glm::vec3(viewdir[0], viewdir[1], viewdir[2])); + _mainCamera->setMaxFov(wPtr->getFisheyeFOV()); + _mainCamera->setLookUpVector(glm::vec3(0.0, 1.0, 0.0)); + } + else {*/ + // get corner positions, calculating the forth to easily calculate center + // glm::vec3 corners[4]; // sgct::SGCTWindow* wPtr = sgct::Engine::instance()->getWindowPtr(0); // sgct_core::BaseViewport* vp = wPtr->getViewport(0); @@ -274,36 +274,36 @@ bool RenderEngine::initializeGL() { // corners[3] = glm::vec3(corners[2][0], corners[0][1], corners[2][2]); // // const glm::vec3 center = (corners[0] + corners[1] + corners[2] + corners[3]); - //// - //const glm::vec3 eyePosition = sgct_core::ClusterManager::instance()->getDefaultUserPtr()->getPos(); - ////// get viewdirection, stores the direction in the camera, used for culling - //const glm::vec3 viewdir = glm::normalize(eyePosition - center); + //// + //const glm::vec3 eyePosition = sgct_core::ClusterManager::instance()->getDefaultUserPtr()->getPos(); + ////// get viewdirection, stores the direction in the camera, used for culling + //const glm::vec3 viewdir = glm::normalize(eyePosition - center); //const glm::vec3 upVector = corners[0] - corners[1]; - //_mainCamera->setCameraDirection(glm::normalize(-viewdir)); + //_mainCamera->setCameraDirection(glm::normalize(-viewdir)); _mainCamera->setCameraDirection(glm::vec3(0.f, 0.f, -1.f)); - //_mainCamera->setLookUpVector(glm::normalize(upVector)); + //_mainCamera->setLookUpVector(glm::normalize(upVector)); _mainCamera->setLookUpVector(glm::vec3(0.f, 1.f, 0.f)); - // set the initial fov to be 0.0 which means everything will be culled - //float maxFov = 0.0f; + // set the initial fov to be 0.0 which means everything will be culled + //float maxFov = 0.0f; float maxFov = std::numeric_limits::max(); - //// for each corner - //for (int i = 0; i < 4; ++i) { - // // calculate radians to corner - // glm::vec3 dir = glm::normalize(eyePosition - corners[i]); - // float radsbetween = acos(glm::dot(viewdir, dir)) - // / (glm::length(viewdir) * glm::length(dir)); + //// for each corner + //for (int i = 0; i < 4; ++i) { + // // calculate radians to corner + // glm::vec3 dir = glm::normalize(eyePosition - corners[i]); + // float radsbetween = acos(glm::dot(viewdir, dir)) + // / (glm::length(viewdir) * glm::length(dir)); - // // the angle to a corner is larger than the current maxima - // if (radsbetween > maxFov) { - // maxFov = radsbetween; - // } - //} - _mainCamera->setMaxFov(maxFov); + // // the angle to a corner is larger than the current maxima + // if (radsbetween > maxFov) { + // maxFov = radsbetween; + // } + //} + _mainCamera->setMaxFov(maxFov); //} LINFO("Initializing Log"); @@ -312,128 +312,128 @@ bool RenderEngine::initializeGL() { ghoul::logging::LogManager::ref().addLog(std::move(log)); LINFO("Finished initializing GL"); - return true; + return true; } void RenderEngine::preSynchronization() { - if (_mainCamera) - _mainCamera->preSynchronization(); + if (_mainCamera) + _mainCamera->preSynchronization(); } void RenderEngine::postSynchronizationPreDraw() { - //temporary fade funtionality - if (_fadeDirection != 0) { - if (_currentFadeTime > _fadeDuration){ - _fadeDirection = 0; - _globalBlackOutFactor = fminf(1.f, fmaxf(0.f, _globalBlackOutFactor)); - } - else { - if (_fadeDirection < 0) - _globalBlackOutFactor = glm::smoothstep(1.f, 0.f, _currentFadeTime / _fadeDuration); - else - _globalBlackOutFactor = glm::smoothstep(0.f, 1.f, _currentFadeTime / _fadeDuration); + //temporary fade funtionality + if (_fadeDirection != 0) { + if (_currentFadeTime > _fadeDuration){ + _fadeDirection = 0; + _globalBlackOutFactor = fminf(1.f, fmaxf(0.f, _globalBlackOutFactor)); + } + else { + if (_fadeDirection < 0) + _globalBlackOutFactor = glm::smoothstep(1.f, 0.f, _currentFadeTime / _fadeDuration); + else + _globalBlackOutFactor = glm::smoothstep(0.f, 1.f, _currentFadeTime / _fadeDuration); _currentFadeTime += static_cast(OsEng.windowWrapper().averageDeltaTime()); - } - } + } + } - if (_mainCamera) - _mainCamera->postSynchronizationPreDraw(); + if (_mainCamera) + _mainCamera->postSynchronizationPreDraw(); - bool windowResized = OsEng.windowWrapper().windowHasResized(); + bool windowResized = OsEng.windowWrapper().windowHasResized(); - if (windowResized) { - glm::ivec2 res = OsEng.windowWrapper().currentDrawBufferResolution(); - _renderer->setResolution(res); - ghoul::fontrendering::FontRenderer::defaultRenderer().setWindowSize(glm::vec2(res)); - } + if (windowResized) { + glm::ivec2 res = OsEng.windowWrapper().currentDrawBufferResolution(); + _renderer->setResolution(res); + ghoul::fontrendering::FontRenderer::defaultRenderer().setWindowSize(glm::vec2(res)); + } - // converts the quaternion used to rotation matrices + // converts the quaternion used to rotation matrices if (_mainCamera) _mainCamera->compileViewRotationMatrix(); - // update and evaluate the scene starting from the root node - _sceneGraph->update({ - Time::ref().currentTime(), + // update and evaluate the scene starting from the root node + _sceneGraph->update({ + Time::ref().currentTime(), Time::ref().timeJumped(), - Time::ref().deltaTime(), - _doPerformanceMeasurements - }); - _sceneGraph->evaluate(_mainCamera); + Time::ref().deltaTime(), + _doPerformanceMeasurements + }); + _sceneGraph->evaluate(_mainCamera); - _renderer->update(); + _renderer->update(); - for (auto program : _programs) { - if (program->isDirty()) { - program->rebuildFromFile(); - } - } + for (auto program : _programs) { + if (program->isDirty()) { + program->rebuildFromFile(); + } + } - //Allow focus node to update camera (enables camera-following) - //FIX LATER: THIS CAUSES MASTER NODE TO BE ONE FRAME AHEAD OF SLAVES - //if (const SceneGraphNode* node = OsEng.ref().interactionHandler().focusNode()){ - //node->updateCamera(_mainCamera); - //} + //Allow focus node to update camera (enables camera-following) + //FIX LATER: THIS CAUSES MASTER NODE TO BE ONE FRAME AHEAD OF SLAVES + //if (const SceneGraphNode* node = OsEng.ref().interactionHandler().focusNode()){ + //node->updateCamera(_mainCamera); + //} } void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) { - _mainCamera->setViewMatrix(viewMatrix); - _mainCamera->setProjectionMatrix(projectionMatrix); + _mainCamera->setViewMatrix(viewMatrix); + _mainCamera->setProjectionMatrix(projectionMatrix); - if (!(OsEng.isMaster() && _disableMasterRendering)) { + if (!(OsEng.isMaster() && _disableMasterRendering)) { _renderer->render(_globalBlackOutFactor, _doPerformanceMeasurements); - } + } - // Print some useful information on the master viewport - if (OsEng.isMaster() && OsEng.windowWrapper().isSimpleRendering()) { - if (_showInfo) { - renderInformation(); - } - if (_showLog) { - renderScreenLog(); - } - } + // Print some useful information on the master viewport + if (OsEng.isMaster() && OsEng.windowWrapper().isSimpleRendering()) { + if (_showInfo) { + renderInformation(); + } + if (_showLog) { + renderScreenLog(); + } + } } void RenderEngine::postDraw() { if (Time::ref().timeJumped()) Time::ref().setTimeJumped(false); - if (_takeScreenshot) { + if (_takeScreenshot) { OsEng.windowWrapper().takeScreenshot(); - _takeScreenshot = false; - } + _takeScreenshot = false; + } - if (_doPerformanceMeasurements) - storePerformanceMeasurements(); + if (_doPerformanceMeasurements) + storePerformanceMeasurements(); } void RenderEngine::takeScreenshot() { - _takeScreenshot = true; + _takeScreenshot = true; } void RenderEngine::toggleInfoText(bool b) { - _showInfo = b; + _showInfo = b; } Scene* RenderEngine::scene() { - // TODO custom assert (ticket #5) - assert(_sceneGraph); - return _sceneGraph; + // TODO custom assert (ticket #5) + assert(_sceneGraph); + return _sceneGraph; } RaycasterManager& RenderEngine::raycasterManager() { - return *_raycasterManager; + return *_raycasterManager; } void RenderEngine::setSceneGraph(Scene* sceneGraph) { - _sceneGraph = sceneGraph; + _sceneGraph = sceneGraph; } void RenderEngine::serialize(SyncBuffer* syncBuffer) { - if (_mainCamera){ - _mainCamera->serialize(syncBuffer); - } + if (_mainCamera){ + _mainCamera->serialize(syncBuffer); + } syncBuffer->encode(_onScreenInformation._node); @@ -443,9 +443,9 @@ void RenderEngine::serialize(SyncBuffer* syncBuffer) { } void RenderEngine::deserialize(SyncBuffer* syncBuffer) { - if (_mainCamera){ - _mainCamera->deserialize(syncBuffer); - } + if (_mainCamera){ + _mainCamera->deserialize(syncBuffer); + } syncBuffer->decode(_onScreenInformation._node); syncBuffer->decode(_onScreenInformation._position.x); syncBuffer->decode(_onScreenInformation._position.y); @@ -454,11 +454,11 @@ void RenderEngine::deserialize(SyncBuffer* syncBuffer) { } Camera* RenderEngine::camera() const { - return _mainCamera; + return _mainCamera; } Renderer* RenderEngine::renderer() const { - return _renderer.get(); + return _renderer.get(); } RenderEngine::RendererImplementation RenderEngine::rendererImplementation() const { @@ -466,91 +466,91 @@ RenderEngine::RendererImplementation RenderEngine::rendererImplementation() cons } float RenderEngine::globalBlackOutFactor() { - return _globalBlackOutFactor; + return _globalBlackOutFactor; } void RenderEngine::setGlobalBlackOutFactor(float opacity) { - _globalBlackOutFactor = opacity; + _globalBlackOutFactor = opacity; } void RenderEngine::startFading(int direction, float fadeDuration) { - _fadeDirection = direction; - _fadeDuration = fadeDuration; - _currentFadeTime = 0.f; + _fadeDirection = direction; + _fadeDuration = fadeDuration; + _currentFadeTime = 0.f; } /** * Build a program object for rendering with the used renderer */ std::unique_ptr RenderEngine::buildRenderProgram( - std::string name, - std::string vsPath, - std::string fsPath, - const ghoul::Dictionary& data) { + std::string name, + std::string vsPath, + std::string fsPath, + const ghoul::Dictionary& data) { - ghoul::Dictionary dict = data; + ghoul::Dictionary dict = data; // set path to the current renderer's main fragment shader - dict.setValue("rendererData", _rendererData); + dict.setValue("rendererData", _rendererData); // parameterize the main fragment shader program with specific contents. // fsPath should point to a shader file defining a Fragment getFragment() function // instead of a void main() setting glFragColor, glFragDepth, etc. dict.setValue("fragmentPath", fsPath); std::unique_ptr program = ghoul::opengl::ProgramObject::Build( - name, - vsPath, - RenderFsPath, - dict); + name, + vsPath, + RenderFsPath, + dict); if (program) { _programs.push_back(program.get()); } - return program; + return program; } /** * Build a program object for rendering with the used renderer */ std::unique_ptr RenderEngine::buildRenderProgram( - std::string name, - std::string vsPath, - std::string fsPath, - std::string csPath, - const ghoul::Dictionary& data) { + std::string name, + std::string vsPath, + std::string fsPath, + std::string csPath, + const ghoul::Dictionary& data) { - ghoul::Dictionary dict = data; - dict.setValue("rendererData", _rendererData); + ghoul::Dictionary dict = data; + dict.setValue("rendererData", _rendererData); // parameterize the main fragment shader program with specific contents. // fsPath should point to a shader file defining a Fragment getFragment() function // instead of a void main() setting glFragColor, glFragDepth, etc. dict.setValue("fragmentPath", fsPath); - std::unique_ptr program = ghoul::opengl::ProgramObject::Build( - name, - vsPath, - RenderFsPath, - csPath, - dict); + std::unique_ptr program = ghoul::opengl::ProgramObject::Build( + name, + vsPath, + RenderFsPath, + csPath, + dict); if (program) { _programs.push_back(program.get()); } - return program; + return program; } void RenderEngine::removeRenderProgram(const std::unique_ptr& program) { - ghoul::opengl::ProgramObject* ptr = program.get(); + ghoul::opengl::ProgramObject* ptr = program.get(); auto it = std::find( - _programs.begin(), - _programs.end(), - ptr - ); + _programs.begin(), + _programs.end(), + ptr + ); - if (it != _programs.end()) { - _programs.erase(it); - } + if (it != _programs.end()) { + _programs.erase(it); + } } /** @@ -559,120 +559,120 @@ void RenderEngine::removeRenderProgram(const std::unique_ptrdictionary(); - dict.setValue("rendererData", _rendererData); - program->setDictionary(dict); - } + _rendererData = data; + for (auto program : _programs) { + ghoul::Dictionary dict = program->dictionary(); + dict.setValue("rendererData", _rendererData); + program->setDictionary(dict); + } } /** * Set renderer */ void RenderEngine::setRenderer(std::unique_ptr renderer) { - glm::ivec2 res = OsEng.windowWrapper().currentDrawBufferResolution(); + glm::ivec2 res = OsEng.windowWrapper().currentDrawBufferResolution(); - if (_renderer) { - _renderer->deinitialize(); - } + if (_renderer) { + _renderer->deinitialize(); + } - _renderer = std::move(renderer); + _renderer = std::move(renderer); _renderer->setResolution(res); - _renderer->initialize(); + _renderer->initialize(); _renderer->setCamera(_mainCamera); _renderer->setScene(_sceneGraph); } scripting::ScriptEngine::LuaLibrary RenderEngine::luaLibrary() { - return { - "", - { - { - "takeScreenshot", - &luascriptfunctions::takeScreenshot, - "", - "Renders the current image to a file on disk" - }, - { - "setRenderer", - &luascriptfunctions::setRenderer, - "string", - "Sets the renderer (ABuffer or FrameBuffer)" - }, - { - "showRenderInformation", - &luascriptfunctions::showRenderInformation, - "bool", - "Toggles the showing of render information on-screen text" - }, - { - "setPerformanceMeasurement", - &luascriptfunctions::setPerformanceMeasurement, - "bool", - "Sets the performance measurements" - }, - { - "fadeIn", - &luascriptfunctions::fadeIn, - "number", - "", + return { + "", + { + { + "takeScreenshot", + &luascriptfunctions::takeScreenshot, + "", + "Renders the current image to a file on disk" + }, + { + "setRenderer", + &luascriptfunctions::setRenderer, + "string", + "Sets the renderer (ABuffer or FrameBuffer)" + }, + { + "showRenderInformation", + &luascriptfunctions::showRenderInformation, + "bool", + "Toggles the showing of render information on-screen text" + }, + { + "setPerformanceMeasurement", + &luascriptfunctions::setPerformanceMeasurement, + "bool", + "Sets the performance measurements" + }, + { + "fadeIn", + &luascriptfunctions::fadeIn, + "number", + "", true - }, - //also temporary @JK - { - "fadeOut", - &luascriptfunctions::fadeOut, - "number", - "", + }, + //also temporary @JK + { + "fadeOut", + &luascriptfunctions::fadeOut, + "number", + "", true - }, - }, - }; + }, + }, + }; } void RenderEngine::setPerformanceMeasurements(bool performanceMeasurements) { - _doPerformanceMeasurements = performanceMeasurements; + _doPerformanceMeasurements = performanceMeasurements; } bool RenderEngine::doesPerformanceMeasurements() const { - return _doPerformanceMeasurements; + return _doPerformanceMeasurements; } void RenderEngine::storePerformanceMeasurements() { - const int8_t Version = 0; - const int nValues = 250; - const int lengthName = 256; - const int maxValues = 256; + const int8_t Version = 0; + const int nValues = 250; + const int lengthName = 256; + const int maxValues = 256; - struct PerformanceLayout { - int8_t version; - int32_t nValuesPerEntry; - int32_t nEntries; - int32_t maxNameLength; - int32_t maxEntries; + struct PerformanceLayout { + int8_t version; + int32_t nValuesPerEntry; + int32_t nEntries; + int32_t maxNameLength; + int32_t maxEntries; - struct PerformanceLayoutEntry { - char name[lengthName]; - float renderTime[nValues]; - float updateRenderable[nValues]; - float updateEphemeris[nValues]; + struct PerformanceLayoutEntry { + char name[lengthName]; + float renderTime[nValues]; + float updateRenderable[nValues]; + float updateEphemeris[nValues]; - int32_t currentRenderTime; - int32_t currentUpdateRenderable; - int32_t currentUpdateEphemeris; - }; + int32_t currentRenderTime; + int32_t currentUpdateRenderable; + int32_t currentUpdateEphemeris; + }; - PerformanceLayoutEntry entries[maxValues]; - }; + PerformanceLayoutEntry entries[maxValues]; + }; - const int nNodes = static_cast(scene()->allSceneGraphNodes().size()); - if (!_performanceMemory) { + const int nNodes = static_cast(scene()->allSceneGraphNodes().size()); + if (!_performanceMemory) { - // Compute the total size - const int totalSize = sizeof(int8_t) + 4 * sizeof(int32_t) + - maxValues * sizeof(PerformanceLayout::PerformanceLayoutEntry); - LINFO("Create shared memory of " << totalSize << " bytes"); + // Compute the total size + const int totalSize = sizeof(int8_t) + 4 * sizeof(int32_t) + + maxValues * sizeof(PerformanceLayout::PerformanceLayoutEntry); + LINFO("Create shared memory of " << totalSize << " bytes"); try { ghoul::SharedMemory::remove(PerformanceMeasurementSharedData); @@ -681,52 +681,52 @@ void RenderEngine::storePerformanceMeasurements() { LINFOC(e.component, e.what()); } - ghoul::SharedMemory::create(PerformanceMeasurementSharedData, totalSize); - _performanceMemory = new ghoul::SharedMemory(PerformanceMeasurementSharedData); + ghoul::SharedMemory::create(PerformanceMeasurementSharedData, totalSize); + _performanceMemory = new ghoul::SharedMemory(PerformanceMeasurementSharedData); void* ptr = _performanceMemory->memory(); - PerformanceLayout* layout = reinterpret_cast(ptr); - layout->version = Version; - layout->nValuesPerEntry = nValues; - layout->nEntries = nNodes; - layout->maxNameLength = lengthName; - layout->maxEntries = maxValues; + PerformanceLayout* layout = reinterpret_cast(ptr); + layout->version = Version; + layout->nValuesPerEntry = nValues; + layout->nEntries = nNodes; + layout->maxNameLength = lengthName; + layout->maxEntries = maxValues; - memset(layout->entries, 0, maxValues * sizeof(PerformanceLayout::PerformanceLayoutEntry)); + memset(layout->entries, 0, maxValues * sizeof(PerformanceLayout::PerformanceLayoutEntry)); - for (int i = 0; i < nNodes; ++i) { - SceneGraphNode* node = scene()->allSceneGraphNodes()[i]; + for (int i = 0; i < nNodes; ++i) { + SceneGraphNode* node = scene()->allSceneGraphNodes()[i]; - memset(layout->entries[i].name, 0, lengthName); + memset(layout->entries[i].name, 0, lengthName); #ifdef _MSC_VER strcpy_s(layout->entries[i].name, node->name().length() + 1, node->name().c_str()); #else strcpy(layout->entries[i].name, node->name().c_str()); #endif - layout->entries[i].currentRenderTime = 0; - layout->entries[i].currentUpdateRenderable = 0; - layout->entries[i].currentUpdateEphemeris = 0; - } - } + layout->entries[i].currentRenderTime = 0; + layout->entries[i].currentUpdateRenderable = 0; + layout->entries[i].currentUpdateEphemeris = 0; + } + } void* ptr = _performanceMemory->memory(); - PerformanceLayout* layout = reinterpret_cast(ptr); - _performanceMemory->acquireLock(); - for (int i = 0; i < nNodes; ++i) { - SceneGraphNode* node = scene()->allSceneGraphNodes()[i]; - SceneGraphNode::PerformanceRecord r = node->performanceRecord(); - PerformanceLayout::PerformanceLayoutEntry& entry = layout->entries[i]; + PerformanceLayout* layout = reinterpret_cast(ptr); + _performanceMemory->acquireLock(); + for (int i = 0; i < nNodes; ++i) { + SceneGraphNode* node = scene()->allSceneGraphNodes()[i]; + SceneGraphNode::PerformanceRecord r = node->performanceRecord(); + PerformanceLayout::PerformanceLayoutEntry& entry = layout->entries[i]; - entry.renderTime[entry.currentRenderTime] = r.renderTime / 1000.f; - entry.updateEphemeris[entry.currentUpdateEphemeris] = r.updateTimeEphemeris / 1000.f; - entry.updateRenderable[entry.currentUpdateRenderable] = r.updateTimeRenderable / 1000.f; + entry.renderTime[entry.currentRenderTime] = r.renderTime / 1000.f; + entry.updateEphemeris[entry.currentUpdateEphemeris] = r.updateTimeEphemeris / 1000.f; + entry.updateRenderable[entry.currentUpdateRenderable] = r.updateTimeRenderable / 1000.f; - entry.currentRenderTime = (entry.currentRenderTime + 1) % nValues; - entry.currentUpdateEphemeris = (entry.currentUpdateEphemeris + 1) % nValues; - entry.currentUpdateRenderable = (entry.currentUpdateRenderable + 1) % nValues; - } - _performanceMemory->releaseLock(); + entry.currentRenderTime = (entry.currentRenderTime + 1) % nValues; + entry.currentUpdateEphemeris = (entry.currentUpdateEphemeris + 1) % nValues; + entry.currentUpdateRenderable = (entry.currentUpdateRenderable + 1) % nValues; + } + _performanceMemory->releaseLock(); } // This method is temporary and will be removed once the scalegraph is in effect ---abock @@ -734,52 +734,52 @@ void RenderEngine::changeViewPoint(std::string origin) { SceneGraphNode* solarSystemBarycenterNode = scene()->sceneGraphNode("SolarSystemBarycenter"); SceneGraphNode* plutoBarycenterNode = scene()->sceneGraphNode("PlutoBarycenter"); SceneGraphNode* newHorizonsNode = scene()->sceneGraphNode("NewHorizons"); - SceneGraphNode* newHorizonsPathNodeJ = scene()->sceneGraphNode("NewHorizonsPathJupiter"); - SceneGraphNode* newHorizonsPathNodeP = scene()->sceneGraphNode("NewHorizonsPathPluto"); + SceneGraphNode* newHorizonsPathNodeJ = scene()->sceneGraphNode("NewHorizonsPathJupiter"); + SceneGraphNode* newHorizonsPathNodeP = scene()->sceneGraphNode("NewHorizonsPathPluto"); // SceneGraphNode* cg67pNode = scene()->sceneGraphNode("67P"); // SceneGraphNode* rosettaNode = scene()->sceneGraphNode("Rosetta"); - RenderablePath* nhPath; + RenderablePath* nhPath; SceneGraphNode* jupiterBarycenterNode = scene()->sceneGraphNode("JupiterBarycenter"); - //SceneGraphNode* newHorizonsGhostNode = scene()->sceneGraphNode("NewHorizonsGhost"); - //SceneGraphNode* dawnNode = scene()->sceneGraphNode("Dawn"); - //SceneGraphNode* vestaNode = scene()->sceneGraphNode("Vesta"); + //SceneGraphNode* newHorizonsGhostNode = scene()->sceneGraphNode("NewHorizonsGhost"); + //SceneGraphNode* dawnNode = scene()->sceneGraphNode("Dawn"); + //SceneGraphNode* vestaNode = scene()->sceneGraphNode("Vesta"); // if (solarSystemBarycenterNode == nullptr || plutoBarycenterNode == nullptr || - //jupiterBarycenterNode == nullptr) { - // LERROR("Necessary nodes does not exist"); - //return; + //jupiterBarycenterNode == nullptr) { + // LERROR("Necessary nodes does not exist"); + //return; // } if (origin == "Pluto") { - if (newHorizonsPathNodeP) { - Renderable* R = newHorizonsPathNodeP->renderable(); - newHorizonsPathNodeP->setParent(plutoBarycenterNode); - nhPath = static_cast(R); - nhPath->calculatePath("PLUTO BARYCENTER"); - } + if (newHorizonsPathNodeP) { + Renderable* R = newHorizonsPathNodeP->renderable(); + newHorizonsPathNodeP->setParent(plutoBarycenterNode); + nhPath = static_cast(R); + nhPath->calculatePath("PLUTO BARYCENTER"); + } - plutoBarycenterNode->setParent(scene()->sceneGraphNode("SolarSystem")); - plutoBarycenterNode->setEphemeris(new StaticEphemeris); - - solarSystemBarycenterNode->setParent(plutoBarycenterNode); - newHorizonsNode->setParent(plutoBarycenterNode); - //newHorizonsGhostNode->setParent(plutoBarycenterNode); + plutoBarycenterNode->setParent(scene()->sceneGraphNode("SolarSystem")); + plutoBarycenterNode->setEphemeris(new StaticEphemeris); + + solarSystemBarycenterNode->setParent(plutoBarycenterNode); + newHorizonsNode->setParent(plutoBarycenterNode); + //newHorizonsGhostNode->setParent(plutoBarycenterNode); - //dawnNode->setParent(plutoBarycenterNode); - //vestaNode->setParent(plutoBarycenterNode); + //dawnNode->setParent(plutoBarycenterNode); + //vestaNode->setParent(plutoBarycenterNode); - //newHorizonsTrailNode->setParent(plutoBarycenterNode); - ghoul::Dictionary solarDictionary = - { - { std::string("Type"), std::string("Spice") }, - { std::string("Body"), std::string("SUN") }, - { std::string("Reference"), std::string("GALACTIC") }, - { std::string("Observer"), std::string("PLUTO BARYCENTER") }, - { std::string("Kernels"), ghoul::Dictionary() } - }; + //newHorizonsTrailNode->setParent(plutoBarycenterNode); + ghoul::Dictionary solarDictionary = + { + { std::string("Type"), std::string("Spice") }, + { std::string("Body"), std::string("SUN") }, + { std::string("Reference"), std::string("GALACTIC") }, + { std::string("Observer"), std::string("PLUTO BARYCENTER") }, + { std::string("Kernels"), ghoul::Dictionary() } + }; ghoul::Dictionary jupiterDictionary = { @@ -799,13 +799,13 @@ void RenderEngine::changeViewPoint(std::string origin) { { std::string("Kernels"), ghoul::Dictionary() } }; - solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary)); - jupiterBarycenterNode->setEphemeris(new SpiceEphemeris(jupiterDictionary)); + solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary)); + jupiterBarycenterNode->setEphemeris(new SpiceEphemeris(jupiterDictionary)); newHorizonsNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); - //newHorizonsTrailNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); + //newHorizonsTrailNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); - //ghoul::Dictionary dawnDictionary = + //ghoul::Dictionary dawnDictionary = //{ // { std::string("Type"), std::string("Spice") }, // { std::string("Body"), std::string("DAWN") }, @@ -814,42 +814,42 @@ void RenderEngine::changeViewPoint(std::string origin) { // { std::string("Kernels"), ghoul::Dictionary() } //}; //dawnNode->setEphemeris(new SpiceEphemeris(dawnDictionary)); - // - //ghoul::Dictionary vestaDictionary = - //{ - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("VESTA") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("PLUTO BARYCENTER") }, - // { std::string("Kernels"), ghoul::Dictionary() } - //}; - //vestaNode->setEphemeris(new SpiceEphemeris(vestaDictionary)); + // + //ghoul::Dictionary vestaDictionary = + //{ + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("VESTA") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("PLUTO BARYCENTER") }, + // { std::string("Kernels"), ghoul::Dictionary() } + //}; + //vestaNode->setEphemeris(new SpiceEphemeris(vestaDictionary)); - - //ghoul::Dictionary newHorizonsGhostDictionary = - //{ - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("NEW HORIZONS") }, - // { std::string("EphmerisGhosting"), std::string("TRUE") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("PLUTO BARYCENTER") }, - // { std::string("Kernels"), ghoul::Dictionary() } - //}; - //newHorizonsGhostNode->setEphemeris(new SpiceEphemeris(newHorizonsGhostDictionary)); - + + //ghoul::Dictionary newHorizonsGhostDictionary = + //{ + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("NEW HORIZONS") }, + // { std::string("EphmerisGhosting"), std::string("TRUE") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("PLUTO BARYCENTER") }, + // { std::string("Kernels"), ghoul::Dictionary() } + //}; + //newHorizonsGhostNode->setEphemeris(new SpiceEphemeris(newHorizonsGhostDictionary)); + return; } if (origin == "Sun") { - solarSystemBarycenterNode->setParent(scene()->sceneGraphNode("SolarSystem")); + solarSystemBarycenterNode->setParent(scene()->sceneGraphNode("SolarSystem")); - plutoBarycenterNode->setParent(solarSystemBarycenterNode); - jupiterBarycenterNode->setParent(solarSystemBarycenterNode); - newHorizonsNode->setParent(solarSystemBarycenterNode); - //newHorizonsGhostNode->setParent(solarSystemBarycenterNode); + plutoBarycenterNode->setParent(solarSystemBarycenterNode); + jupiterBarycenterNode->setParent(solarSystemBarycenterNode); + newHorizonsNode->setParent(solarSystemBarycenterNode); + //newHorizonsGhostNode->setParent(solarSystemBarycenterNode); - //newHorizonsTrailNode->setParent(solarSystemBarycenterNode); - //dawnNode->setParent(solarSystemBarycenterNode); - //vestaNode->setParent(solarSystemBarycenterNode); + //newHorizonsTrailNode->setParent(solarSystemBarycenterNode); + //dawnNode->setParent(solarSystemBarycenterNode); + //vestaNode->setParent(solarSystemBarycenterNode); ghoul::Dictionary plutoDictionary = { @@ -881,232 +881,232 @@ void RenderEngine::changeViewPoint(std::string origin) { { std::string("Kernels"), ghoul::Dictionary() } }; newHorizonsNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); - //newHorizonsTrailNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); + //newHorizonsTrailNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); - //ghoul::Dictionary dawnDictionary = - //{ - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("DAWN") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("SUN") }, - // { std::string("Kernels"), ghoul::Dictionary() } - //}; - //dawnNode->setEphemeris(new SpiceEphemeris(dawnDictionary)); - // - //ghoul::Dictionary vestaDictionary = - //{ - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("VESTA") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("SUN") }, - // { std::string("Kernels"), ghoul::Dictionary() } - //}; - //vestaNode->setEphemeris(new SpiceEphemeris(vestaDictionary)); - - - //ghoul::Dictionary newHorizonsGhostDictionary = - //{ - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("NEW HORIZONS") }, - // { std::string("EphmerisGhosting"), std::string("TRUE") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("JUPITER BARYCENTER") }, - // { std::string("Kernels"), ghoul::Dictionary() } - //}; - //newHorizonsGhostNode->setEphemeris(new SpiceEphemeris(newHorizonsGhostDictionary)); - + //ghoul::Dictionary dawnDictionary = + //{ + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("DAWN") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("SUN") }, + // { std::string("Kernels"), ghoul::Dictionary() } + //}; + //dawnNode->setEphemeris(new SpiceEphemeris(dawnDictionary)); + // + //ghoul::Dictionary vestaDictionary = + //{ + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("VESTA") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("SUN") }, + // { std::string("Kernels"), ghoul::Dictionary() } + //}; + //vestaNode->setEphemeris(new SpiceEphemeris(vestaDictionary)); + + + //ghoul::Dictionary newHorizonsGhostDictionary = + //{ + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("NEW HORIZONS") }, + // { std::string("EphmerisGhosting"), std::string("TRUE") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("JUPITER BARYCENTER") }, + // { std::string("Kernels"), ghoul::Dictionary() } + //}; + //newHorizonsGhostNode->setEphemeris(new SpiceEphemeris(newHorizonsGhostDictionary)); + return; } if (origin == "Jupiter") { - if (newHorizonsPathNodeJ) { - Renderable* R = newHorizonsPathNodeJ->renderable(); - newHorizonsPathNodeJ->setParent(jupiterBarycenterNode); - nhPath = static_cast(R); - nhPath->calculatePath("JUPITER BARYCENTER"); - } + if (newHorizonsPathNodeJ) { + Renderable* R = newHorizonsPathNodeJ->renderable(); + newHorizonsPathNodeJ->setParent(jupiterBarycenterNode); + nhPath = static_cast(R); + nhPath->calculatePath("JUPITER BARYCENTER"); + } - jupiterBarycenterNode->setParent(scene()->sceneGraphNode("SolarSystem")); - jupiterBarycenterNode->setEphemeris(new StaticEphemeris); + jupiterBarycenterNode->setParent(scene()->sceneGraphNode("SolarSystem")); + jupiterBarycenterNode->setEphemeris(new StaticEphemeris); - solarSystemBarycenterNode->setParent(jupiterBarycenterNode); - newHorizonsNode->setParent(jupiterBarycenterNode); - //newHorizonsTrailNode->setParent(jupiterBarycenterNode); + solarSystemBarycenterNode->setParent(jupiterBarycenterNode); + newHorizonsNode->setParent(jupiterBarycenterNode); + //newHorizonsTrailNode->setParent(jupiterBarycenterNode); - //dawnNode->setParent(jupiterBarycenterNode); - //vestaNode->setParent(jupiterBarycenterNode); + //dawnNode->setParent(jupiterBarycenterNode); + //vestaNode->setParent(jupiterBarycenterNode); - ghoul::Dictionary solarDictionary = - { - { std::string("Type"), std::string("Spice") }, - { std::string("Body"), std::string("SUN") }, - { std::string("Reference"), std::string("GALACTIC") }, - { std::string("Observer"), std::string("JUPITER BARYCENTER") }, - { std::string("Kernels"), ghoul::Dictionary() } - }; + ghoul::Dictionary solarDictionary = + { + { std::string("Type"), std::string("Spice") }, + { std::string("Body"), std::string("SUN") }, + { std::string("Reference"), std::string("GALACTIC") }, + { std::string("Observer"), std::string("JUPITER BARYCENTER") }, + { std::string("Kernels"), ghoul::Dictionary() } + }; - ghoul::Dictionary plutoDictionary = - { - { std::string("Type"), std::string("Spice") }, - { std::string("Body"), std::string("PlUTO BARYCENTER") }, - { std::string("Reference"), std::string("GALACTIC") }, - { std::string("Observer"), std::string("JUPITER BARYCENTER") }, - { std::string("Kernels"), ghoul::Dictionary() } - }; + ghoul::Dictionary plutoDictionary = + { + { std::string("Type"), std::string("Spice") }, + { std::string("Body"), std::string("PlUTO BARYCENTER") }, + { std::string("Reference"), std::string("GALACTIC") }, + { std::string("Observer"), std::string("JUPITER BARYCENTER") }, + { std::string("Kernels"), ghoul::Dictionary() } + }; - ghoul::Dictionary newHorizonsDictionary = - { - { std::string("Type"), std::string("Spice") }, - { std::string("Body"), std::string("NEW HORIZONS") }, - { std::string("Reference"), std::string("GALACTIC") }, - { std::string("Observer"), std::string("JUPITER BARYCENTER") }, - { std::string("Kernels"), ghoul::Dictionary() } - }; - solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary)); - plutoBarycenterNode->setEphemeris(new SpiceEphemeris(plutoDictionary)); - newHorizonsNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); - //newHorizonsGhostNode->setParent(jupiterBarycenterNode); - //newHorizonsTrailNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); + ghoul::Dictionary newHorizonsDictionary = + { + { std::string("Type"), std::string("Spice") }, + { std::string("Body"), std::string("NEW HORIZONS") }, + { std::string("Reference"), std::string("GALACTIC") }, + { std::string("Observer"), std::string("JUPITER BARYCENTER") }, + { std::string("Kernels"), ghoul::Dictionary() } + }; + solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary)); + plutoBarycenterNode->setEphemeris(new SpiceEphemeris(plutoDictionary)); + newHorizonsNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); + //newHorizonsGhostNode->setParent(jupiterBarycenterNode); + //newHorizonsTrailNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); - //ghoul::Dictionary dawnDictionary = - //{ - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("DAWN") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("JUPITER BARYCENTER") }, - // { std::string("Kernels"), ghoul::Dictionary() } - //}; - //dawnNode->setEphemeris(new SpiceEphemeris(dawnDictionary)); - // - //ghoul::Dictionary vestaDictionary = - //{ - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("VESTA") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("JUPITER BARYCENTER") }, - // { std::string("Kernels"), ghoul::Dictionary() } - //}; - //vestaNode->setEphemeris(new SpiceEphemeris(vestaDictionary)); + //ghoul::Dictionary dawnDictionary = + //{ + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("DAWN") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("JUPITER BARYCENTER") }, + // { std::string("Kernels"), ghoul::Dictionary() } + //}; + //dawnNode->setEphemeris(new SpiceEphemeris(dawnDictionary)); + // + //ghoul::Dictionary vestaDictionary = + //{ + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("VESTA") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("JUPITER BARYCENTER") }, + // { std::string("Kernels"), ghoul::Dictionary() } + //}; + //vestaNode->setEphemeris(new SpiceEphemeris(vestaDictionary)); - - //ghoul::Dictionary newHorizonsGhostDictionary = - //{ - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("NEW HORIZONS") }, - // { std::string("EphmerisGhosting"), std::string("TRUE") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("JUPITER BARYCENTER") }, - // { std::string("Kernels"), ghoul::Dictionary() } - //}; - //newHorizonsGhostNode->setEphemeris(new SpiceEphemeris(newHorizonsGhostDictionary)); - //newHorizonsGhostNode->setParent(jupiterBarycenterNode); + + //ghoul::Dictionary newHorizonsGhostDictionary = + //{ + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("NEW HORIZONS") }, + // { std::string("EphmerisGhosting"), std::string("TRUE") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("JUPITER BARYCENTER") }, + // { std::string("Kernels"), ghoul::Dictionary() } + //}; + //newHorizonsGhostNode->setEphemeris(new SpiceEphemeris(newHorizonsGhostDictionary)); + //newHorizonsGhostNode->setParent(jupiterBarycenterNode); - + return; } - //if (origin == "Vesta") { - // - // vestaNode->setParent(scene()->sceneGraphNode("SolarSystem")); - // vestaNode->setEphemeris(new StaticEphemeris); - // - // solarSystemBarycenterNode->setParent(vestaNode); - // newHorizonsNode->setParent(vestaNode); - // - // dawnNode->setParent(vestaNode); - // plutoBarycenterNode->setParent(vestaNode); - // - // - // ghoul::Dictionary plutoDictionary = - // { - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("PLUTO BARYCENTER") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("VESTA") }, - // { std::string("Kernels"), ghoul::Dictionary() } - // }; - // ghoul::Dictionary solarDictionary = - // { - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("SUN") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("VESTA") }, - // { std::string("Kernels"), ghoul::Dictionary() } - // }; - // - // ghoul::Dictionary jupiterDictionary = - // { - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("JUPITER BARYCENTER") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("VESTA") }, - // { std::string("Kernels"), ghoul::Dictionary() } - // }; - // - // solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary)); - // plutoBarycenterNode->setEphemeris(new SpiceEphemeris(plutoDictionary)); - // jupiterBarycenterNode->setEphemeris(new SpiceEphemeris(jupiterDictionary)); - // - // ghoul::Dictionary newHorizonsDictionary = - // { - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("NEW HORIZONS") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("VESTA") }, - // { std::string("Kernels"), ghoul::Dictionary() } - // }; - // newHorizonsNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); - // - // ghoul::Dictionary dawnDictionary = - // { - // { std::string("Type"), std::string("Spice") }, - // { std::string("Body"), std::string("DAWN") }, - // { std::string("Reference"), std::string("GALACTIC") }, - // { std::string("Observer"), std::string("VESTA") }, - // { std::string("Kernels"), ghoul::Dictionary() } - // }; - // dawnNode->setEphemeris(new SpiceEphemeris(dawnDictionary)); - // vestaNode->setEphemeris(new StaticEphemeris); - // - // return; - //} + //if (origin == "Vesta") { + // + // vestaNode->setParent(scene()->sceneGraphNode("SolarSystem")); + // vestaNode->setEphemeris(new StaticEphemeris); + // + // solarSystemBarycenterNode->setParent(vestaNode); + // newHorizonsNode->setParent(vestaNode); + // + // dawnNode->setParent(vestaNode); + // plutoBarycenterNode->setParent(vestaNode); + // + // + // ghoul::Dictionary plutoDictionary = + // { + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("PLUTO BARYCENTER") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("VESTA") }, + // { std::string("Kernels"), ghoul::Dictionary() } + // }; + // ghoul::Dictionary solarDictionary = + // { + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("SUN") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("VESTA") }, + // { std::string("Kernels"), ghoul::Dictionary() } + // }; + // + // ghoul::Dictionary jupiterDictionary = + // { + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("JUPITER BARYCENTER") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("VESTA") }, + // { std::string("Kernels"), ghoul::Dictionary() } + // }; + // + // solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary)); + // plutoBarycenterNode->setEphemeris(new SpiceEphemeris(plutoDictionary)); + // jupiterBarycenterNode->setEphemeris(new SpiceEphemeris(jupiterDictionary)); + // + // ghoul::Dictionary newHorizonsDictionary = + // { + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("NEW HORIZONS") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("VESTA") }, + // { std::string("Kernels"), ghoul::Dictionary() } + // }; + // newHorizonsNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary)); + // + // ghoul::Dictionary dawnDictionary = + // { + // { std::string("Type"), std::string("Spice") }, + // { std::string("Body"), std::string("DAWN") }, + // { std::string("Reference"), std::string("GALACTIC") }, + // { std::string("Observer"), std::string("VESTA") }, + // { std::string("Kernels"), ghoul::Dictionary() } + // }; + // dawnNode->setEphemeris(new SpiceEphemeris(dawnDictionary)); + // vestaNode->setEphemeris(new StaticEphemeris); + // + // return; + //} - if (origin == "67P") { - SceneGraphNode* rosettaNode = scene()->sceneGraphNode("Rosetta"); - SceneGraphNode* cgNode = scene()->sceneGraphNode("67P"); - //jupiterBarycenterNode->setParent(solarSystemBarycenterNode); - //plutoBarycenterNode->setParent(solarSystemBarycenterNode); - solarSystemBarycenterNode->setParent(cgNode); - rosettaNode->setParent(cgNode); - - ghoul::Dictionary solarDictionary = - { - { std::string("Type"), std::string("Spice") }, - { std::string("Body"), std::string("SUN") }, - { std::string("Reference"), std::string("GALACTIC") }, - { std::string("Observer"), std::string("CHURYUMOV-GERASIMENKO") }, - { std::string("Kernels"), ghoul::Dictionary() } - }; - solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary)); - - ghoul::Dictionary rosettaDictionary = - { - { std::string("Type"), std::string("Spice") }, - { std::string("Body"), std::string("ROSETTA") }, - { std::string("Reference"), std::string("GALACTIC") }, - { std::string("Observer"), std::string("CHURYUMOV-GERASIMENKO") }, - { std::string("Kernels"), ghoul::Dictionary() } - }; - - cgNode->setParent(scene()->sceneGraphNode("SolarSystem")); - rosettaNode->setEphemeris(new SpiceEphemeris(rosettaDictionary)); - cgNode->setEphemeris(new StaticEphemeris); - - return; - - } + if (origin == "67P") { + SceneGraphNode* rosettaNode = scene()->sceneGraphNode("Rosetta"); + SceneGraphNode* cgNode = scene()->sceneGraphNode("67P"); + //jupiterBarycenterNode->setParent(solarSystemBarycenterNode); + //plutoBarycenterNode->setParent(solarSystemBarycenterNode); + solarSystemBarycenterNode->setParent(cgNode); + rosettaNode->setParent(cgNode); + + ghoul::Dictionary solarDictionary = + { + { std::string("Type"), std::string("Spice") }, + { std::string("Body"), std::string("SUN") }, + { std::string("Reference"), std::string("GALACTIC") }, + { std::string("Observer"), std::string("CHURYUMOV-GERASIMENKO") }, + { std::string("Kernels"), ghoul::Dictionary() } + }; + solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary)); + + ghoul::Dictionary rosettaDictionary = + { + { std::string("Type"), std::string("Spice") }, + { std::string("Body"), std::string("ROSETTA") }, + { std::string("Reference"), std::string("GALACTIC") }, + { std::string("Observer"), std::string("CHURYUMOV-GERASIMENKO") }, + { std::string("Kernels"), ghoul::Dictionary() } + }; + + cgNode->setParent(scene()->sceneGraphNode("SolarSystem")); + rosettaNode->setEphemeris(new SpiceEphemeris(rosettaDictionary)); + cgNode->setEphemeris(new StaticEphemeris); + + return; + + } LFATAL("This function is being misused with an argument of '" << origin << "'"); } @@ -1128,46 +1128,46 @@ RenderEngine::RendererImplementation RenderEngine::rendererFromString(const std: } void RenderEngine::renderInformation() { - // TODO: Adjust font_size properly when using retina screen - const float fontSizeMono = 10.f; - const float fontSizeTime = 15.f; + // TODO: Adjust font_size properly when using retina screen + const float fontSizeMono = 10.f; + const float fontSizeTime = 15.f; - using Font = ghoul::fontrendering::Font; - using ghoul::fontrendering::RenderFont; + using Font = ghoul::fontrendering::Font; + using ghoul::fontrendering::RenderFont; - if (_showInfo && _fontDate && _fontInfo) { - double currentTime = Time::ref().currentTime(); + if (_showInfo && _fontDate && _fontInfo) { + double currentTime = Time::ref().currentTime(); - glm::vec2 penPosition = glm::vec2( - 10.f, - OsEng.windowWrapper().viewportPixelCoordinates().w - ); - penPosition.y -= _fontDate->height(); + glm::vec2 penPosition = glm::vec2( + 10.f, + OsEng.windowWrapper().viewportPixelCoordinates().w + ); + penPosition.y -= _fontDate->height(); - RenderFontCr(*_fontDate, - penPosition, - "Date: %s", - Time::ref().currentTimeUTC().c_str() - ); + RenderFontCr(*_fontDate, + penPosition, + "Date: %s", + Time::ref().currentTimeUTC().c_str() + ); - RenderFontCr(*_fontInfo, - penPosition, - "Simulation increment (s): %.0f", - Time::ref().deltaTime() - ); + RenderFontCr(*_fontInfo, + penPosition, + "Simulation increment (s): %.0f", + Time::ref().deltaTime() + ); - RenderFontCr(*_fontInfo, - penPosition, - "Avg. Frametime: %.5f", - OsEng.windowWrapper().averageDeltaTime() - ); + RenderFontCr(*_fontInfo, + penPosition, + "Avg. Frametime: %.5f", + OsEng.windowWrapper().averageDeltaTime() + ); #ifdef OPENSPACE_MODULE_NEWHORIZONS_ENABLED - if (openspace::ImageSequencer2::ref().isReady()) { - penPosition.y -= 25.f; + if (openspace::ImageSequencer::ref().isReady()) { + penPosition.y -= 25.f; - glm::vec4 targetColor(0.00, 0.75, 1.00, 1); + glm::vec4 targetColor(0.00, 0.75, 1.00, 1); try { double lt; @@ -1192,243 +1192,243 @@ void RenderEngine::renderInformation() { } catch (...) {} - double remaining = openspace::ImageSequencer2::ref().getNextCaptureTime() - currentTime; - float t = static_cast(1.0 - remaining / openspace::ImageSequencer2::ref().getIntervalLength()); - std::string progress = "|"; - int g = static_cast((t * 24) + 1); - g = std::max(g, 0); - for (int i = 0; i < g; i++) - progress.append("-"); - progress.append(">"); - for (int i = 0; i < 25 - g; i++) - progress.append(" "); + double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - currentTime; + float t = static_cast(1.0 - remaining / openspace::ImageSequencer::ref().getIntervalLength()); + std::string progress = "|"; + int g = static_cast((t * 24) + 1); + g = std::max(g, 0); + for (int i = 0; i < g; i++) + progress.append("-"); + progress.append(">"); + for (int i = 0; i < 25 - g; i++) + progress.append(" "); - std::string str = SpiceManager::ref().dateFromEphemerisTime( - ImageSequencer2::ref().getNextCaptureTime(), - "YYYY MON DD HR:MN:SC" - ); + std::string str = SpiceManager::ref().dateFromEphemerisTime( + ImageSequencer::ref().getNextCaptureTime(), + "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); + glm::vec4 active(0.6, 1, 0.00, 1); + glm::vec4 brigther_active(0.9, 1, 0.75, 1); - progress.append("|"); - if (remaining > 0) { - brigther_active *= (1 - t); + progress.append("|"); + if (remaining > 0) { + brigther_active *= (1 - t); - RenderFontCr(*_fontInfo, - penPosition, - active * t + brigther_active, - "Next instrument activity:" - ); + RenderFontCr(*_fontInfo, + penPosition, + active * t + brigther_active, + "Next instrument activity:" + ); - RenderFontCr(*_fontInfo, - penPosition, - active * t + brigther_active, - "%.0f s %s %.1f %%", - remaining, progress.c_str(), t * 100 - ); + RenderFontCr(*_fontInfo, + penPosition, + active * t + brigther_active, + "%.0f s %s %.1f %%", + remaining, progress.c_str(), t * 100 + ); - RenderFontCr(*_fontInfo, - penPosition, - active, - "Data acquisition time: %s", - str.c_str() - ); - } - std::pair nextTarget = ImageSequencer2::ref().getNextTarget(); - std::pair currentTarget = ImageSequencer2::ref().getCurrentTarget(); + RenderFontCr(*_fontInfo, + penPosition, + active, + "Data acquisition time: %s", + str.c_str() + ); + } + std::pair nextTarget = ImageSequencer::ref().getNextTarget(); + std::pair currentTarget = ImageSequencer::ref().getCurrentTarget(); - if (currentTarget.first > 0.0) { - int timeleft = static_cast(nextTarget.first - currentTime); + if (currentTarget.first > 0.0) { + int timeleft = static_cast(nextTarget.first - currentTime); - int hour = timeleft / 3600; - int second = timeleft % 3600; - int minute = second / 60; - second = second % 60; + int hour = timeleft / 3600; + int second = timeleft % 3600; + int minute = second / 60; + second = second % 60; - std::string hh, mm, ss, coundtown; + std::string hh, mm, ss, coundtown; - if (hour < 10) hh.append("0"); - if (minute < 10) mm.append("0"); - if (second < 10) ss.append("0"); + if (hour < 10) hh.append("0"); + if (minute < 10) mm.append("0"); + if (second < 10) ss.append("0"); - hh.append(std::to_string(hour)); - mm.append(std::to_string(minute)); - ss.append(std::to_string(second)); + hh.append(std::to_string(hour)); + mm.append(std::to_string(minute)); + ss.append(std::to_string(second)); - RenderFontCr(*_fontInfo, - penPosition, - targetColor, - "Data acquisition adjacency: [%s:%s:%s]", - hh.c_str(), mm.c_str(), ss.c_str() - ); + RenderFontCr(*_fontInfo, + penPosition, + targetColor, + "Data acquisition adjacency: [%s:%s:%s]", + hh.c_str(), mm.c_str(), ss.c_str() + ); - std::pair> incidentTargets = ImageSequencer2::ref().getIncidentTargetList(2); - std::string space; - glm::vec4 color; - size_t isize = incidentTargets.second.size(); - for (size_t p = 0; p < isize; p++) { - double t = static_cast(p + 1) / static_cast(isize + 1); - t = (p > isize / 2) ? 1 - t : t; - t += 0.3; - color = (p == isize / 2) ? targetColor : glm::vec4(t, t, t, 1); + std::pair> incidentTargets = ImageSequencer::ref().getIncidentTargetList(2); + std::string space; + glm::vec4 color; + size_t isize = incidentTargets.second.size(); + for (size_t p = 0; p < isize; p++) { + double t = static_cast(p + 1) / static_cast(isize + 1); + t = (p > isize / 2) ? 1 - t : t; + t += 0.3; + color = (p == isize / 2) ? targetColor : glm::vec4(t, t, t, 1); - RenderFont(*_fontInfo, - penPosition, - color, - "%s%s", - space.c_str(), incidentTargets.second[p].c_str() - ); + RenderFont(*_fontInfo, + penPosition, + color, + "%s%s", + space.c_str(), incidentTargets.second[p].c_str() + ); - for (int k = 0; k < incidentTargets.second[p].size() + 2; k++) - space += " "; - } - penPosition.y -= _fontInfo->height(); + for (int k = 0; k < incidentTargets.second[p].size() + 2; k++) + space += " "; + } + penPosition.y -= _fontInfo->height(); - std::map activeMap = ImageSequencer2::ref().getActiveInstruments(); - glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1); - glm::vec4 notFiring(0.5, 0.5, 0.5, 1); + std::map activeMap = ImageSequencer::ref().getActiveInstruments(); + glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1); + glm::vec4 notFiring(0.5, 0.5, 0.5, 1); - RenderFontCr(*_fontInfo, - penPosition, - active, - "Active Instruments:" - ); + RenderFontCr(*_fontInfo, + penPosition, + active, + "Active Instruments:" + ); - for (auto t : activeMap) { - if (t.second == false) { - RenderFont(*_fontInfo, - penPosition, - glm::vec4(0.3, 0.3, 0.3, 1), - "| |" - ); - RenderFontCr(*_fontInfo, - penPosition, - glm::vec4(0.3, 0.3, 0.3, 1), - " %5s", - t.first.c_str() - ); + for (auto t : activeMap) { + if (t.second == false) { + RenderFont(*_fontInfo, + penPosition, + glm::vec4(0.3, 0.3, 0.3, 1), + "| |" + ); + RenderFontCr(*_fontInfo, + penPosition, + glm::vec4(0.3, 0.3, 0.3, 1), + " %5s", + t.first.c_str() + ); - } - else { - RenderFont(*_fontInfo, - penPosition, - glm::vec4(0.3, 0.3, 0.3, 1), - "|" - ); - if (t.first == "NH_LORRI") { - RenderFont(*_fontInfo, - penPosition, - firing, - " + " - ); - } - RenderFont(*_fontInfo, - penPosition, - glm::vec4(0.3, 0.3, 0.3, 1), - " |" - ); - RenderFontCr(*_fontInfo, - penPosition, - active, - " %5s", - t.first.c_str() - ); - } - } - } - } + } + else { + RenderFont(*_fontInfo, + penPosition, + glm::vec4(0.3, 0.3, 0.3, 1), + "|" + ); + if (t.first == "NH_LORRI") { + RenderFont(*_fontInfo, + penPosition, + firing, + " + " + ); + } + RenderFont(*_fontInfo, + penPosition, + glm::vec4(0.3, 0.3, 0.3, 1), + " |" + ); + RenderFontCr(*_fontInfo, + penPosition, + active, + " %5s", + t.first.c_str() + ); + } + } + } + } #endif - } + } } void RenderEngine::renderScreenLog() { - _log->removeExpiredEntries(); + _log->removeExpiredEntries(); - const int max = 10; - const int category_length = 20; - const int msg_length = 140; - std::chrono::seconds fade(5); + const int max = 10; + const int category_length = 20; + const int msg_length = 140; + std::chrono::seconds fade(5); - auto entries = _log->entries(); - auto lastEntries = entries.size() > max ? std::make_pair(entries.rbegin(), entries.rbegin() + max) : std::make_pair(entries.rbegin(), entries.rend()); + auto entries = _log->entries(); + auto lastEntries = entries.size() > max ? std::make_pair(entries.rbegin(), entries.rbegin() + max) : std::make_pair(entries.rbegin(), entries.rend()); - // if (entries.size() > max) + // if (entries.size() > max) - //ScreenLog::const_range ScreenLog::last(size_t n) { - // if (_entries.size() > n) { - // return std::make_pair(_entries.rbegin(), _entries.rbegin() + n); - // } else { - // return std::make_pair(_entries.rbegin(), _entries.rend()); - // } - //} + //ScreenLog::const_range ScreenLog::last(size_t n) { + // if (_entries.size() > n) { + // return std::make_pair(_entries.rbegin(), _entries.rbegin() + n); + // } else { + // return std::make_pair(_entries.rbegin(), _entries.rend()); + // } + //} - // auto entries = _log->last(max); + // auto entries = _log->last(max); - const glm::vec4 white(0.9, 0.9, 0.9, 1); - const glm::vec4 red(1, 0, 0, 1); - const glm::vec4 yellow(1, 1, 0, 1); - const glm::vec4 green(0, 1, 0, 1); - const glm::vec4 blue(0, 0, 1, 1); + const glm::vec4 white(0.9, 0.9, 0.9, 1); + const glm::vec4 red(1, 0, 0, 1); + const glm::vec4 yellow(1, 1, 0, 1); + const glm::vec4 green(0, 1, 0, 1); + const glm::vec4 blue(0, 0, 1, 1); - size_t nr = 1; - auto now = std::chrono::steady_clock::now(); - for (auto& it = lastEntries.first; it != lastEntries.second; ++it) { - const ScreenLog::LogEntry* e = &(*it); + size_t nr = 1; + auto now = std::chrono::steady_clock::now(); + for (auto& it = lastEntries.first; it != lastEntries.second; ++it) { + const ScreenLog::LogEntry* e = &(*it); - std::chrono::duration diff = now - e->timeStamp; + std::chrono::duration diff = now - e->timeStamp; - float alpha = 1; - std::chrono::duration ttf = ScreenLogTimeToLive - fade; - if (diff > ttf) { - auto d = (diff - ttf).count(); - auto t = static_cast(d) / static_cast(fade.count()); - float p = 0.8f - t; - alpha = (p <= 0.f) ? 0.f : pow(p, 0.3f); - } + float alpha = 1; + std::chrono::duration ttf = ScreenLogTimeToLive - fade; + if (diff > ttf) { + auto d = (diff - ttf).count(); + auto t = static_cast(d) / static_cast(fade.count()); + float p = 0.8f - t; + alpha = (p <= 0.f) ? 0.f : pow(p, 0.3f); + } - // Since all log entries are ordered, once one exceeds alpha, all have - if (alpha <= 0.0) - break; + // Since all log entries are ordered, once one exceeds alpha, all have + if (alpha <= 0.0) + break; - const std::string lvl = "(" + ghoul::logging::LogManager::stringFromLevel(e->level) + ")"; - const std::string& message = e->message.substr(0, msg_length); - nr += std::count(message.begin(), message.end(), '\n'); + const std::string lvl = "(" + ghoul::logging::LogManager::stringFromLevel(e->level) + ")"; + const std::string& message = e->message.substr(0, msg_length); + nr += std::count(message.begin(), message.end(), '\n'); - RenderFont(*_fontLog, - glm::vec2(10.f, _fontLog->pointSize() * nr * 2), - white * alpha, - "%-14s %s%s", // Format - e->timeString.c_str(), // Time string - e->category.substr(0, category_length).c_str(), // Category string (up to category_length) - e->category.length() > 20 ? "..." : ""); // Pad category with "..." if exceeds category_length + RenderFont(*_fontLog, + glm::vec2(10.f, _fontLog->pointSize() * nr * 2), + white * alpha, + "%-14s %s%s", // Format + e->timeString.c_str(), // Time string + e->category.substr(0, category_length).c_str(), // Category string (up to category_length) + e->category.length() > 20 ? "..." : ""); // Pad category with "..." if exceeds category_length - glm::vec4 color = white; - if (e->level == ghoul::logging::LogManager::LogLevel::Debug) - color = green; - if (e->level == ghoul::logging::LogManager::LogLevel::Warning) - color = yellow; - if (e->level == ghoul::logging::LogManager::LogLevel::Error) - color = red; - if (e->level == ghoul::logging::LogManager::LogLevel::Fatal) - color = blue; + glm::vec4 color = white; + if (e->level == ghoul::logging::LogManager::LogLevel::Debug) + color = green; + if (e->level == ghoul::logging::LogManager::LogLevel::Warning) + color = yellow; + if (e->level == ghoul::logging::LogManager::LogLevel::Error) + color = red; + if (e->level == ghoul::logging::LogManager::LogLevel::Fatal) + color = blue; - // const float font_with_light = 5; - RenderFont(*_fontLog, - glm::vec2(static_cast(10 + 39 * _fontLog->pointSize()), _fontLog->pointSize() * nr * 2), - color * alpha, - "%s", // Format - lvl.c_str()); // Pad category with "..." if exceeds category_length + // const float font_with_light = 5; + RenderFont(*_fontLog, + glm::vec2(static_cast(10 + 39 * _fontLog->pointSize()), _fontLog->pointSize() * nr * 2), + color * alpha, + "%s", // Format + lvl.c_str()); // Pad category with "..." if exceeds category_length - RenderFont(*_fontLog, - glm::vec2(static_cast(10 + 53 * _fontLog->pointSize()), _fontLog->pointSize() * nr * 2), - white * alpha, - "%s", // Format - message.c_str()); // Pad category with "..." if exceeds category_length - ++nr; - } + RenderFont(*_fontLog, + glm::vec2(static_cast(10 + 53 * _fontLog->pointSize()), _fontLog->pointSize() * nr * 2), + white * alpha, + "%s", // Format + message.c_str()); // Pad category with "..." if exceeds category_length + ++nr; + } } }// namespace openspace