From 84ba9b150397bf4be9d1df3ea1175971beca8cf3 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 1 Jul 2015 17:55:06 +0200 Subject: [PATCH 1/4] Set correct default scene file --- apps/Launcher/mainwindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/Launcher/mainwindow.cpp b/apps/Launcher/mainwindow.cpp index 115b823dd1..c186e6c36c 100644 --- a/apps/Launcher/mainwindow.cpp +++ b/apps/Launcher/mainwindow.cpp @@ -197,6 +197,9 @@ void MainWindow::initialize() { _sceneFiles.insert(i.fileName(), i.absoluteFilePath()); _scenes->addItem(i.fileName()); } + + _scenes->setCurrentText("default.scene"); + _syncWidget->setSceneFiles(_sceneFiles); } From c205c720c696813e5c5044962faf3c24fb386950 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 1 Jul 2015 17:55:26 +0200 Subject: [PATCH 2/4] Removal of the old imagesequencer --- modules/newhorizons/CMakeLists.txt | 10 +- modules/newhorizons/util/imagesequencer.cpp | 545 -------------------- modules/newhorizons/util/imagesequencer.h | 140 ----- 3 files changed, 4 insertions(+), 691 deletions(-) delete mode 100644 modules/newhorizons/util/imagesequencer.cpp delete mode 100644 modules/newhorizons/util/imagesequencer.h diff --git a/modules/newhorizons/CMakeLists.txt b/modules/newhorizons/CMakeLists.txt index 6b9cd1d8b7..5ee0503ec1 100644 --- a/modules/newhorizons/CMakeLists.txt +++ b/modules/newhorizons/CMakeLists.txt @@ -32,11 +32,10 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanetprojection.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableshadowcylinder.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometryprojection.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodelprojection.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodelprojection.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/writeToTexture.h ${CMAKE_CURRENT_SOURCE_DIR}/util/decoder.h ${CMAKE_CURRENT_SOURCE_DIR}/util/hongkangparser.h - ${CMAKE_CURRENT_SOURCE_DIR}/util/imagesequencer.h ${CMAKE_CURRENT_SOURCE_DIR}/util/imagesequencer2.h ${CMAKE_CURRENT_SOURCE_DIR}/util/instrumentdecoder.h ${CMAKE_CURRENT_SOURCE_DIR}/util/labelparser.h @@ -54,10 +53,9 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanetprojection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableshadowcylinder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometryprojection.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodelprojection.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodelprojection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/decoder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/hongkangparser.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/util/imagesequencer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/imagesequencer2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/instrumentdecoder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/labelparser.cpp @@ -74,9 +72,9 @@ set(SHADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fov_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/projectiveTexture_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/projectiveTexture_vs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/projectionPass_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/projectionPass_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/projectionPass_vs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/modelShader_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/modelShader_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/modelShader_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/terminatorshadow_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/terminatorshadow_vs.glsl diff --git a/modules/newhorizons/util/imagesequencer.cpp b/modules/newhorizons/util/imagesequencer.cpp deleted file mode 100644 index dbcc2dc767..0000000000 --- a/modules/newhorizons/util/imagesequencer.cpp +++ /dev/null @@ -1,545 +0,0 @@ -/***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014 * -* * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this * -* software and associated documentation files (the "Software"), to deal in the Software * -* without restriction, including without limitation the rights to use, copy, modify, * -* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * -* permit persons to whom the Software is furnished to do so, subject to the following * -* conditions: * -* * -* The above copyright notice and this permission notice shall be included in all copies * -* or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * -* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * -* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * -* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * -* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * -* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * -****************************************************************************************/ - -// open space includes -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace { -const std::string _loggerCat = "ImageSequencer"; -} - -namespace openspace { - -ImageSequencer* ImageSequencer::_sequencer = nullptr; - -struct ImageParams{ - double startTime; - std::string path; - std::string activeInstrument; - std::string target; - bool projected; -}; - - - -std::vector> _timeStamps; -void createImage(std::vector& vec, double t1, std::string instrument, std::string target, std::string path = "dummypath"); - -auto imageComparer = [](const ImageParams &a, const ImageParams &b)->bool{ - return a.startTime < b.startTime; -}; - - -std::vector::iterator binary_find(std::vector::iterator begin, - std::vector::iterator end, - const ImageParams &val, - bool(*imageComparer)(const ImageParams &a, const ImageParams &b)){ - // Finds the lower bound in at most log(last - first) + 1 comparisons - std::vector::iterator it = std::lower_bound(begin, end, val, imageComparer); - if (it != begin){ - return it; - } - return end; -} - -ImageSequencer::ImageSequencer() - : _nextCapture(-1.0) - , _currentTime(-1.0) - , _sequenceIDs(0) - , _defaultCaptureImage(absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder_blank.png")) - , _targetsAdded(false) -{} - - -ImageSequencer& ImageSequencer::ref() { - assert(_sequencer != nullptr); - return *_sequencer; -} -void ImageSequencer::initialize() { - assert(_sequencer == nullptr); - _sequencer = new ImageSequencer; -} - -void ImageSequencer::deinitialize() { - delete _sequencer; - _sequencer = nullptr; -} - -void ImageSequencer::setSequenceId(int& id){ - id = _sequenceIDs; - _sequenceIDs++; -} - -void ImageSequencer::addSequenceObserver(int sequenceID, std::string name, std::vector payload){ - if (sequenceID >= 0){ - _observers.insert(std::make_pair(sequenceID, name)); - _instruments.insert(std::make_pair(name, payload)); - } -} - -void ImageSequencer::registerTargets(std::vector& potential){ - for (auto p : potential){ - if (_projectableTargets.find(p) == _projectableTargets.end()){ - _projectableTargets[p] = _currentTime; - } - } -} - -void ImageSequencer::update(double time){ - _currentTime = time; - static bool time_initialized; - - if (!time_initialized){ - for (auto &it : _projectableTargets) { - it.second = _currentTime; - assert(it.second > 0.0); - } - time_initialized = true; - } -} - -void createImage(std::vector& vec, double t1, std::string instrument, std::string target, std::string path) { - // insert - ImageParams image; - image.startTime = t1; - image.path = path; - image.activeInstrument = instrument; - image.target = target; - image.projected = false; - - vec.push_back(image); -} - -double ImageSequencer::getNextCaptureTime(){ - return _nextCapture; -} -double ImageSequencer::nextCaptureTime(double time, int sequenceID){ - if (time < _nextCapture) return _nextCapture; - auto it = binary_find(_timeStamps[sequenceID].begin(), _timeStamps[sequenceID].end(), { time, "", "", "", false }, imageComparer); - if (it == _timeStamps[sequenceID].end()) return _nextCapture; - - return it->startTime; -} - -std::string ImageSequencer::findActiveInstrument(double time, int sequenceID){ - auto it = binary_find(_timeStamps[sequenceID].begin(), _timeStamps[sequenceID].end(), { time, "", "", "",false }, imageComparer); - if ((it == _timeStamps[sequenceID].end())){ - _activeInstrument = "Not found, incufficient playbook-data"; - }else{ - _activeInstrument = std::prev(it)->activeInstrument; - } - - return _activeInstrument; -} - -void ImageSequencer::augumentSequenceWithTargets(int sequenceID){ - if (!_targetsAdded){ - // if there is an registered observer for this sequence - if (_observers.count(sequenceID) > 0) { - // find observer - std::string observer = _observers.at(sequenceID); - // find its instruments - std::map >::iterator it2 = _instruments.find(observer); - if (it2 != _instruments.end()){ - std::string _targetFOV; - bool _withinFOV; - // for each image taken - for (std::vector::iterator image = _timeStamps[sequenceID].begin(); image != _timeStamps[sequenceID].end(); ++image) { - // traverse potential targets... - for (auto t : _projectableTargets){ - // ... and potential instruments - for (auto i : it2->second){ - //register precisely which target is being projected to upon image-capture - bool success = openspace::SpiceManager::ref().targetWithinFieldOfView( - i, // Instrumnet - t.first, // projectables - observer, // new horizons - "ELLIPSOID", - "NONE", - image->startTime, - _withinFOV); - //if (!_withinFOV) image->target = "VOID"; - if (success && _withinFOV){ - image->target = t.first; - //once we find it abort search, break the loop. - break; - } - } - } - } - }else{ - LERROR("Spacecraft payload not provided, cannot write playbook"); - } - } - else{ - LERROR("Did not find observing spacecraft for sequence, cannot write playbook"); - } - _targetsAdded = true; - } -} - -bool ImageSequencer::getImagePath(std::vector>& _imageTimes, int sequenceID, std::string projectee, bool withinFOV){ - /*if (withinFOV && !Time::ref().timeJumped()){ - getSingleImage(_imageTimes, sequenceID, projectee); - }else{*/ - getMultipleImages(_imageTimes, sequenceID, projectee); - //} - return true; -} - -bool ImageSequencer::getMultipleImages(std::vector>& _imageTimes, int sequenceID, std::string projectee){ - double previousTime; - std::map::iterator it = _projectableTargets.find(projectee); - if (it != _projectableTargets.end()){ - previousTime = it->second; - it->second = _currentTime; - } - auto it1 = binary_find(_timeStamps[sequenceID].begin(), _timeStamps[sequenceID].end(), { previousTime, "", "", "", false }, imageComparer); - auto it2 = binary_find(_timeStamps[sequenceID].begin(), _timeStamps[sequenceID].end(), { _currentTime, "", "", "", false }, imageComparer); - - if (it1 != _timeStamps[sequenceID].end() && it2 != _timeStamps[sequenceID].end() && it1 != it2){ - std::transform(it1, it2, std::back_inserter(_imageTimes), - [](const ImageParams& i) { - return std::make_pair(i.startTime, i.path); - }); - } - std::reverse(_imageTimes.begin(), _imageTimes.end()); - - double upcoming = nextCaptureTime(_currentTime, sequenceID); - if (_nextCapture != upcoming){ - _nextCapture = upcoming; - _intervalLength = upcoming - _currentTime; - } - - return true; -} - -bool ImageSequencer::getSingleImage(std::vector>& _imageTimes, int sequenceID, std::string projectee){ - - auto bfind = [](std::vector::iterator begin, - std::vector::iterator end, - const ImageParams &val, - bool(*imageComparer)(const ImageParams &a, const ImageParams &b))->std::vector::iterator{ - // Finds the lower bound in at most log(last - first) + 1 comparisons - std::vector::iterator it = std::lower_bound(begin, end, val, imageComparer); - if (it != begin){ - return std::prev(it); - } - return end; - }; - - auto it = bfind(_timeStamps[sequenceID].begin(), _timeStamps[sequenceID].end(), { _currentTime, "", "", "", false }, imageComparer); - - if (it != _timeStamps[sequenceID].end() && !it->projected){ - it->projected = true; - _imageTimes.push_back(std::make_pair(it->startTime, it->path)); - } - - double upcoming = nextCaptureTime(_currentTime, sequenceID); - if (_nextCapture != upcoming){ - _nextCapture = upcoming; - _intervalLength = upcoming - _currentTime; - } - - return true; -} -/* -bool ImageSequencer::getImagePath(std::vector>& _imageTimes, int sequenceID, std::string projectee, bool closedInterval){ - double t = _currentTime; - - double ptime; - std::map::iterator it = _previous.find(projectee); - if (it != _previous.end()){ - ptime = it->second; - it->second = _currentTime; - } - - while (t > ptime){ - auto binary_find = [](std::vector::iterator begin, - std::vector::iterator end, - const ImageParams &val, - bool(*imageComparer)(const ImageParams &a, const ImageParams &b))->std::vector::iterator{ - // Finds the lower bound in at most log(last - first) + 1 comparisons - std::vector::iterator it = std::lower_bound(begin, end, val, imageComparer); - if (it != begin){ - return std::prev(it); - } - return end; - }; - - auto it = binary_find(_timeStamps[sequenceID].begin(), _timeStamps[sequenceID].end(), { t, 0, "", "", false }, imageComparer); - - if (it == _timeStamps[sequenceID].end() || it->startTime < ptime) break; - - if (!it->projected || it != _timeStamps[sequenceID].end()){ - _imageTimes.push_back(std::make_pair(it->startTime, it->path)); - } - t = it->startTime - 1; - //it->projected = true; - } - std::reverse(_imageTimes.begin(), _imageTimes.end()); - - double upcoming = nextCaptureTime(_currentTime, sequenceID); - if (_nextCapture != upcoming){ - _nextCapture = upcoming; - _intervalLength = upcoming - _currentTime; - } - - return true; -}*/ -/* -bool ImageSequencer::getImagePath(double& currentTime, std::string& path, bool closedInterval){ - auto binary_find = [](std::vector::iterator begin, - std::vector::iterator end, - const ImageParams &val, - bool(*imageComparer)(const ImageParams &a, const ImageParams &b))->std::vector::iterator{ - // Finds the lower bound in at most log(last - first) + 1 comparisons - std::vector::iterator it = std::lower_bound(begin, end, val, imageComparer); - if (it != begin){ - return std::prev(it); - } - return end; - }; - - auto it = binary_find(_timeStamps.begin(), _timeStamps.end(), { currentTime, 0, "", "", false }, imageComparer); - //check [start, stop] - if (closedInterval && (it == _timeStamps.end() || it->stopTime < currentTime || it->projected)){ - return false; - }else if (!closedInterval && (it == _timeStamps.end() || it->projected)){ - return false; - } - - double upcoming = nextCaptureTime(currentTime); - if (_nextCapture != upcoming){ - _nextCapture = upcoming; - _intervalLength = upcoming - currentTime; - } - - it->projected = true; - path = it->path; - currentTime = it->startTime; - - return true; -} - -bool ImageSequencer::sequenceReset(){ - for (auto image : _timeStamps){ - image.projected = false; - } - return true; -} -*/ - -// ----------------- LOAD-DATA RELATED STUFF -------------------------------------- - -bool replace(std::string& str, const std::string& from, const std::string& to) { - size_t start_pos = str.find(from); - if (start_pos == std::string::npos) - return false; - str.replace(start_pos, from.length(), to); - return true; -} - -double ImageSequencer::getMissionElapsedTime(std::string timestr){ - std::string::size_type sz; // alias of size_t - double met = std::stod(timestr, &sz); - double diff; - double et; - //met ref time. - openspace::SpiceManager::ref().getETfromDate("2015-07-14T11:50:00.00", et); - - diff = std::abs(met - _metRef); - if (met > _metRef){ - et += diff; - } - else if (met < _metRef){ - et -= diff; - } - return et; -} - -bool ImageSequencer::parsePlaybookFile(const std::string& fileName, int& sequenceID, std::string year) { - setSequenceId(sequenceID); - std::vector tmp; - - if (size_t position = fileName.find_last_of(".") + 1){ - if (position != std::string::npos){ - std::string extension = ghoul::filesystem::File(fileName).fileExtension(); -#ifdef BACKUP_PLAYBOOK // Comma separated playbook in case we dont recieve updates from kang. - if (extension == "csv"){ // comma separated playbook - std::cout << "USING COMMA SEPARATED TIMELINE V9F" << std::endl; - - std::string cachedFile = ""; - FileSys.cacheManager()->getCachedFile(fileName, cachedFile, true); - - bool hasCachedFile = FileSys.fileExists(cachedFile); - if (hasCachedFile) { - std::ifstream file(cachedFile); - if (!file.good()) - LERROR("Error loading cached playbook '" << cachedFile << "'"); - else { - do { - std::string line; - std::getline(file, line); - - std::stringstream s(line); - - double start, end; - std::string path; - - s >> start; - s >> end; - - std::getline(s, path); - createImage(start, end, _defaultCaptureImage); - } while (!file.eof()); - } - } else { - std::ifstream file(fileName); - if (!file.good()) LERROR("Failed to open csv file '" << fileName << "'"); - - std::string timestr = ""; - double shutter = 0.01; - double et; - do{ - std::getline(file, timestr); - auto pos = timestr.find("LORRI image started"); - if (pos != std::string::npos){ - timestr = timestr.substr(timestr.find_first_of(",") + 1); - timestr = timestr.substr(0, timestr.find_first_of(",")); - - replace(timestr, " ", "::"); - timestr = year + " " + timestr; - - openspace::SpiceManager::ref().getETfromDate(timestr, et); - createImage(et, et + shutter, _defaultCaptureImage); - } - } while (!file.eof()); - - std::sort(_timeStamps.begin(), _timeStamps.end(), imageComparer); - - std::ofstream cachedFileStream(cachedFile); - cachedFileStream << std::setprecision(64); - if (cachedFileStream.good()) { - for (const ImageParams& i : _timeStamps) - cachedFileStream << i.startTime << "\t" << i.stopTime << "\t" << i.path << std::endl; - } - - } - } -#endif - if (extension == "txt"){// Hong Kang. pre-parsed playbook - LINFO("Using Preparsed Playbook V9H"); - std::ifstream file(fileName); - if (!file.good()) LERROR("Failed to open txt file '" << fileName << "'"); - - std::string timestr = ""; - double et; - - //@TODO: change similar to renderableFOV - std::string instruments[3] = { "LORRI", "RALPH_LEISA", "MVIC" }; - std::string id[3] = { "NH_LORRI", "NH_RALPH_LEISA", "MVIC" }; - int isize = sizeof(instruments) / sizeof(instruments[0]); - - do{ - std::getline(file, timestr); - for (int i = 0; i < isize; i++){ - auto pos = timestr.find(instruments[i]); - if (pos != std::string::npos){ - timestr = timestr.substr(24, 9); - et = getMissionElapsedTime(timestr); - createImage(tmp, et, id[i], "", _defaultCaptureImage); - std::sort(tmp.begin(), tmp.end(), imageComparer); - } - } - } while (!file.eof()); - } - - } - } - _timeStamps.push_back(tmp); - return true; -} - -bool ImageSequencer::loadSequence(const std::string& dir, int& sequenceID) { - setSequenceId(sequenceID); - std::vector tmp; - - ghoul::filesystem::Directory sequenceDir(dir, true); - std::vector sequencePaths = sequenceDir.read(true, false); // check inputs - for (auto path : sequencePaths){ - if (size_t position = path.find_last_of(".") + 1){ - if (position != std::string::npos){ - ghoul::filesystem::File currentFile(path); - std::string extension = currentFile.fileExtension(); - - if (extension == "lbl"){ // discovered header file - std::ifstream file(currentFile.path()); - - if (!file.good()) LERROR("Failed to open label file '" << currentFile.path() << "'"); - - // open up label files - std::string line = ""; - std::string specsOfInterest = "START_TIME"; // can be extended - double timestamp= 0.0; - bool found = false; - do { - std::getline(file, line); - auto pos = line.find(specsOfInterest); - if (pos != std::string::npos){ - std::string time = line.substr(line.find("=") + 2); - time.erase(std::remove(time.begin(), time.end(), ' '), time.end()); - openspace::SpiceManager::ref().getETfromDate(time, timestamp); - } - if (timestamp != 0.0){ - found = true; - std::string ext = "jpg"; - path.replace(path.begin() + position, path.end(), ext); - bool fileExists = FileSys.fileExists(path); - if (fileExists) { - createImage(tmp, timestamp, "NH_LORRI", "", path); /// fix active instrument! - std::sort(tmp.begin(), tmp.end(), imageComparer); - } - } - } while (!file.eof() && found == false); - } - } - } - } - _timeStamps.push_back(tmp); - return !_timeStamps.empty(); -} - -} // namespace openspace diff --git a/modules/newhorizons/util/imagesequencer.h b/modules/newhorizons/util/imagesequencer.h deleted file mode 100644 index 8dad22159c..0000000000 --- a/modules/newhorizons/util/imagesequencer.h +++ /dev/null @@ -1,140 +0,0 @@ -/***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014 * -* * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this * -* software and associated documentation files (the "Software"), to deal in the Software * -* without restriction, including without limitation the rights to use, copy, modify, * -* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * -* permit persons to whom the Software is furnished to do so, subject to the following * -* conditions: * -* * -* The above copyright notice and this permission notice shall be included in all copies * -* or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * -* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * -* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * -* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * -* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * -* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * -****************************************************************************************/ - -#ifndef __IMAGESEQUENCER_H__ -#define __IMAGESEQUENCER_H__ - -// open space includes -#include -#include -#include -#include -#include - -namespace openspace { - -class ImageSequencer { -public: - ImageSequencer(); - /** - * Singelton instantiation - */ - static ImageSequencer& ref(); - static void initialize(); - static void deinitialize(); - - /** - * Updates current time and initializes the previous time member - */ - void update(double initTime); - - /** - * When the a projectable class loads its sequence it also has to request an ID - * which is set by reference and returned to the projectable. This ID is later - * used to access whatever data ImageSequencer loads. - */ - void setSequenceId(int& id); - - //bool sequenceReset(); - - /** - * Based on sequenceID and unique projectee name, the ImageSequencer determines which subset of data is to be filled to _imageTimes - * which can be used in a projecable class for projections. - */ - bool getImagePath(std::vector>& _imageTimes, int sequenceID, std::string projectee, bool withinFOV); - - /* - * Returns the time until next capture in seconds. - * - */ - double getNextCaptureTime(); - - /* - * Returns the time until next capture in seconds. - */ - double getIntervalLength(){ return _intervalLength; }; - - /* - * Returns next active instrument - */ - std::string& getActiveInstrument(){ return _activeInstrument; }; - - /* - * Performs search to find next consective instrument thats active - */ - std::string findActiveInstrument(double time, int sequenceID); - - /* - * Performs search to find next consecutive projection image. - */ - double nextCaptureTime(double _time, int sequenceID); - - /* - * Load (from *.fit converted) jpg image sequence based on corresponding *.lbl header files - */ - bool loadSequence(const std::string& dir, int& sequenceID); - /* - * Load sequence file of either *.csv type (excel) or preparsed *.txt type - */ - bool parsePlaybook(const std::string& dir, const std::string& type, std::string year = "2015"); - bool parsePlaybookFile(const std::string& fileName, int& sequenceID, std::string year = "2015"); - /* - * These three methods augment the playbook - */ - void augumentSequenceWithTargets(int sequenceID); - void addSequenceObserver(int sequenceID, std::string name, std::vector payload); - void registerTargets(std::vector& potential); - - - static ImageSequencer* _sequencer; - -protected: - - bool getMultipleImages(std::vector>& _imageTimes, int sequenceID, std::string projectee); - bool getSingleImage(std::vector>& _imageTimes, int sequenceID, std::string projectee); - -private: - - double getMissionElapsedTime(std::string timestr); - - std::map _projectableTargets; - std::map _observers; - std::map > _instruments; - - double _nextCapture; - double _intervalLength; - double _metRef = 299180517; - double _currentTime; - int _sequenceIDs; - - std::string _defaultCaptureImage; - std::string _activeInstrument; - - bool _targetsAdded; - -}; - -} // namespace openspace - -#endif // __IMAGESEQUENCER_H__ \ No newline at end of file From 8f88ead11327bde654cdd3a3fd2e1fff8723f303 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 1 Jul 2015 17:55:41 +0200 Subject: [PATCH 3/4] Remove crashing error from imagesequencer2 --- modules/newhorizons/util/imagesequencer2.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/newhorizons/util/imagesequencer2.cpp b/modules/newhorizons/util/imagesequencer2.cpp index 385efeaaec..31435afb82 100644 --- a/modules/newhorizons/util/imagesequencer2.cpp +++ b/modules/newhorizons/util/imagesequencer2.cpp @@ -374,9 +374,8 @@ void ImageSequencer2::runSequenceParser(SequenceParser* parser){ } _hasData = true; } - else{ - ghoul_assert(parserComplete, "one or more sequence loads failed, please check mod files. "); - } + else + LERROR("One of more sequence loads failed; please check mod files"); } } // namespace openspace From 40c42ff7720aba0cf0f748329d0d8ad1a6c0cd87 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 1 Jul 2015 17:56:51 +0200 Subject: [PATCH 4/4] Fix the scaling of renderablemodel by making the magnification a floatproperty --- data | 2 +- modules/base/rendering/modelgeometry.cpp | 12 +++- modules/base/rendering/modelgeometry.h | 70 ++++++++++--------- modules/base/rendering/renderablemodel.cpp | 2 + modules/base/rendering/wavefrontgeometry.cpp | 2 +- modules/base/rendering/wavefrontgeometry.h | 24 +++---- modules/base/shaders/model_vs.glsl | 12 ++-- .../newhorizons/shaders/modelShader_vs.glsl | 17 +++-- 8 files changed, 80 insertions(+), 61 deletions(-) diff --git a/data b/data index 3860dfdac4..fa00aaa0c2 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 3860dfdac47e63729ec6addd9e09c00d6382ad02 +Subproject commit fa00aaa0c244e8e5709877a344c3007d2244e9ec diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index e29e3adaf8..155b34e76a 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -66,6 +66,7 @@ ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dict ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) : _parent(nullptr) + , _magnification("magnification", "Magnification", 0.f, 0.f, 10.f) , _mode(GL_TRIANGLES) { setName("ModelGeometry"); @@ -74,9 +75,8 @@ ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) bool success = dictionary.getValue(keyName, name); ghoul_assert(success, "Name tag was not present"); - success = dictionary.getValue(keySize, _magnification); - if (!success) - _magnification = 0; // if not set, models will be 1:1 (earlier 1:1000) @AA + if (dictionary.hasKeyAndValue(keySize)) + _magnification = static_cast(dictionary.value(keySize)); success = dictionary.getValue(keyObjFile, _file); if (!success) { @@ -88,6 +88,8 @@ ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) if (!FileSys.fileExists(_file, true)) LERROR("Could not load OBJ file '" << _file << "': File not found"); + + addProperty(_magnification); } ModelGeometry::~ModelGeometry() { @@ -246,5 +248,9 @@ bool ModelGeometry::getIndices(std::vector* indexList) { return !(indexList->empty()); } +void ModelGeometry::setUniforms(ghoul::opengl::ProgramObject& program) { + program.setUniform("_magnification", _magnification); +} + } // namespace modelgeometry } // namespace openspace diff --git a/modules/base/rendering/modelgeometry.h b/modules/base/rendering/modelgeometry.h index c49b7b36f5..6293d5f43f 100644 --- a/modules/base/rendering/modelgeometry.h +++ b/modules/base/rendering/modelgeometry.h @@ -26,52 +26,56 @@ #define __MODELGEOMETRY_H__ #include + +#include #include #include namespace openspace { - namespace modelgeometry { +namespace modelgeometry { - class ModelGeometry : public properties::PropertyOwner { - public: - static ModelGeometry* createFromDictionary(const ghoul::Dictionary& dictionary); +class ModelGeometry : public properties::PropertyOwner { +public: + static ModelGeometry* createFromDictionary(const ghoul::Dictionary& dictionary); - struct Vertex { - GLfloat location[4]; - GLfloat tex[2]; - GLfloat normal[3]; - }; + struct Vertex { + GLfloat location[4]; + GLfloat tex[2]; + GLfloat normal[3]; + }; - ModelGeometry(const ghoul::Dictionary& dictionary); - virtual ~ModelGeometry(); - virtual bool initialize(Renderable* parent); - virtual void deinitialize(); - void render(); - virtual bool loadModel(const std::string& filename) = 0; - void changeRenderMode(const GLenum mode); - bool getVertices(std::vector* vertexList); - bool getIndices(std::vector* indexList); + ModelGeometry(const ghoul::Dictionary& dictionary); + virtual ~ModelGeometry(); + virtual bool initialize(Renderable* parent); + virtual void deinitialize(); + void render(); + virtual bool loadModel(const std::string& filename) = 0; + void changeRenderMode(const GLenum mode); + bool getVertices(std::vector* vertexList); + bool getIndices(std::vector* indexList); - protected: - Renderable* _parent; + virtual void setUniforms(ghoul::opengl::ProgramObject& program); - bool loadObj(const std::string& filename); - bool loadCachedFile(const std::string& filename); - bool saveCachedFile(const std::string& filename); - float _magnification; +protected: + Renderable* _parent; - GLuint _vaoID; - GLuint _vbo; - GLuint _ibo; - GLenum _mode; + bool loadObj(const std::string& filename); + bool loadCachedFile(const std::string& filename); + bool saveCachedFile(const std::string& filename); + properties::FloatProperty _magnification; - std::vector _vertices; - std::vector _indices; - std::string _file; - }; + GLuint _vaoID; + GLuint _vbo; + GLuint _ibo; + GLenum _mode; - } // namespace modelgeometry + std::vector _vertices; + std::vector _indices; + std::string _file; +}; + +} // namespace modelgeometry } // namespace openspace #endif // __MODELGEOMETRY_H__ diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 8151fb54af..5c5c00aa6f 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -196,6 +196,8 @@ void RenderableModel::render(const RenderData& data) { _programObject->setUniform("_performShading", _performShading); + _geometry->setUniforms(*_programObject); + if (_performFade && _fading > 0.f){ _fading = _fading - 0.01f; } diff --git a/modules/base/rendering/wavefrontgeometry.cpp b/modules/base/rendering/wavefrontgeometry.cpp index 999e43bbbd..092a1bae10 100644 --- a/modules/base/rendering/wavefrontgeometry.cpp +++ b/modules/base/rendering/wavefrontgeometry.cpp @@ -97,7 +97,7 @@ bool WavefrontGeometry::loadModel(const std::string& filename) { _vertices[j + currentPosition].location[0] = tmp[0]; _vertices[j + currentPosition].location[1] = tmp[1]; _vertices[j + currentPosition].location[2] = tmp[2]; - _vertices[j + currentPosition].location[3] = tmp[3] + _magnification; + _vertices[j + currentPosition].location[3] = tmp[3]; _vertices[j + currentPosition].normal[0] = shapes[i].mesh.normals[3 * j + 0]; _vertices[j + currentPosition].normal[1] = shapes[i].mesh.normals[3 * j + 1]; diff --git a/modules/base/rendering/wavefrontgeometry.h b/modules/base/rendering/wavefrontgeometry.h index 07c01b9a73..d068c27a34 100644 --- a/modules/base/rendering/wavefrontgeometry.h +++ b/modules/base/rendering/wavefrontgeometry.h @@ -29,23 +29,23 @@ namespace openspace { - class RenderableModel; - class RenderableModelProjection; +class RenderableModel; +class RenderableModelProjection; - namespace modelgeometry { +namespace modelgeometry { - class WavefrontGeometry : public ModelGeometry { - public: - WavefrontGeometry(const ghoul::Dictionary& dictionary); + class WavefrontGeometry : public ModelGeometry { + public: + WavefrontGeometry(const ghoul::Dictionary& dictionary); - bool initialize(Renderable* parent) override; - void deinitialize() override; + bool initialize(Renderable* parent) override; + void deinitialize() override; - private: - bool loadModel(const std::string& filename); - }; + private: + bool loadModel(const std::string& filename); + }; - } // namespace modelgeometry +} // namespace modelgeometry } // namespace openspace #endif // __WAVEFRONTOBJECT_H__ diff --git a/modules/base/shaders/model_vs.glsl b/modules/base/shaders/model_vs.glsl index 13f3025471..338160f233 100644 --- a/modules/base/shaders/model_vs.glsl +++ b/modules/base/shaders/model_vs.glsl @@ -27,6 +27,8 @@ uniform mat4 ViewProjection; uniform mat4 ModelTransform; +uniform float _magnification; + layout(location = 0) in vec4 in_position; //in vec3 in_position; layout(location = 1) in vec2 in_st; @@ -39,13 +41,15 @@ out float s; #include "PowerScaling/powerScaling_vs.hglsl" -void main() -{ +void main() { + vec4 pos = in_position; + pos.w += _magnification; + // set variables vs_st = in_st; //vs_stp = in_position.xyz; - vs_position = in_position; - vec4 tmp = in_position; + vs_position = pos; + vec4 tmp = pos; // this is wrong for the normal. The normal transform is the transposed inverse of the model transform vs_normal = normalize(ModelTransform * vec4(in_normal,0)); diff --git a/modules/newhorizons/shaders/modelShader_vs.glsl b/modules/newhorizons/shaders/modelShader_vs.glsl index 26b63bd914..6ae3ac64ea 100644 --- a/modules/newhorizons/shaders/modelShader_vs.glsl +++ b/modules/newhorizons/shaders/modelShader_vs.glsl @@ -34,26 +34,29 @@ layout(location = 2) in vec3 in_normal; uniform vec3 boresight; +uniform float _magnification; + out vec2 vs_st; out vec4 vs_normal; out vec4 vs_position; out float s; - - out vec4 ProjTexCoord; + + #include "PowerScaling/powerScaling_vs.hglsl" -void main(){ +void main() { + vec4 pos = in_position; + pos.w += _magnification; vs_st = in_st; - vs_position = in_position; - vec4 tmp = in_position; - //tmp[3] += _magnification for runtime alteration of model size @AA + vs_position = pos; + vec4 tmp = pos; vs_normal = normalize(ModelTransform * vec4(in_normal,0)); vec4 position = pscTransform(tmp, ModelTransform); vs_position = tmp; - vec4 raw_pos = psc_to_meter(in_position, scaling); + vec4 raw_pos = psc_to_meter(pos, scaling); ProjTexCoord = ProjectorMatrix * ModelTransform * raw_pos; position = ViewProjection * position; gl_Position = z_normalization(position);