diff --git a/include/openspace/rendering/planets/renderableplanetprojection.h b/include/openspace/rendering/planets/renderableplanetprojection.h index b35013b02f..4137e0f640 100644 --- a/include/openspace/rendering/planets/renderableplanetprojection.h +++ b/include/openspace/rendering/planets/renderableplanetprojection.h @@ -88,11 +88,11 @@ private: glm::mat4 _projectorMatrix; // spice - std::string _sequenceFile; std::string _instrumentID; std::string _projectorID; std::string _projecteeID; std::string _aberration; + std::vector _potentialTargets; // @TODO copy-n-paste from renderablefov float _fovy; float _aspectRatio; float _nearPlane; diff --git a/include/openspace/rendering/renderablefov.h b/include/openspace/rendering/renderablefov.h index edbb0da1ca..409b4e0bcc 100644 --- a/include/openspace/rendering/renderablefov.h +++ b/include/openspace/rendering/renderablefov.h @@ -88,6 +88,7 @@ public: std::string _method; std::string _aberrationCorrection; std::string _fovTarget; + std::vector _potentialTargets; glm::dvec3 ipoint, ivec; glm::dvec3 _previousHalf; diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index 2a384e8954..943b8afb47 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -192,6 +192,7 @@ private: double _time; ///< The time stored as the number of seconds past the J2000 epoch double _dt; bool _timeJumped; + bool _jockeHasToFixThisLater; //shared copies double _sharedTime; diff --git a/include/openspace/util/updatestructures.h b/include/openspace/util/updatestructures.h index ccac2bc0a0..2e6900d3d9 100644 --- a/include/openspace/util/updatestructures.h +++ b/include/openspace/util/updatestructures.h @@ -36,6 +36,7 @@ struct InitializeData { struct UpdateData { double time; + //bool isTimeJump; double delta; bool doPerformanceMeasurement; }; diff --git a/openspace-data b/openspace-data index 96c0274c57..cfae9b614a 160000 --- a/openspace-data +++ b/openspace-data @@ -1 +1 @@ -Subproject commit 96c0274c57d312792d12edb3a54ac3a623c03269 +Subproject commit cfae9b614adb4b12bed03faae425a3031a907722 diff --git a/scripts/default_startup.lua b/scripts/default_startup.lua index 6972acc1ce..66c93bbd3c 100644 --- a/scripts/default_startup.lua +++ b/scripts/default_startup.lua @@ -1,9 +1,9 @@ openspace.setInvertRoll(true); --- openspace.time.setTime("2007 FEB 27 16:30:00") +openspace.time.setTime("2007 FEB 27 16:41:00") -- openspace.time.setDeltaTime(50); -openspace.time.setTime("2015-07-14T10:50:00.00") -- PLUTO +-- openspace.time.setTime("2015-07-14T10:50:00.00") -- PLUTO -- NH takes series of images from visible to dark side (across terminator) -- Sequence lasts ~10 mins, (recommended dt = 10) diff --git a/src/rendering/planets/renderableplanetprojection.cpp b/src/rendering/planets/renderableplanetprojection.cpp index 729e9f21d2..9f9a1e6942 100644 --- a/src/rendering/planets/renderableplanetprojection.cpp +++ b/src/rendering/planets/renderableplanetprojection.cpp @@ -57,6 +57,8 @@ namespace { const std::string keyInstrumentNear = "Instrument.Near"; const std::string keyInstrumentFar = "Instrument.Far"; const std::string keySequenceDir = "Projection.Sequence"; + const std::string keySequenceType = "Projection.SequenceType"; + const std::string keyPotentialTargets = "PotentialTargets"; const std::string keyFrame = "Frame"; const std::string keyGeometry = "Geometry"; const std::string keyShading = "PerformShading"; @@ -64,8 +66,13 @@ namespace { const std::string keyBody = "Body"; const std::string _mainFrame = "GALACTIC"; + + const std::string sequenceTypeImage = "image-sequence"; + const std::string sequenceTypePlaybook = "playbook"; } + namespace openspace { + RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _colorTexturePath("planetTexture", "RGB Texture") @@ -78,31 +85,13 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& , _textureProj(nullptr) , _geometry(nullptr) { - bool b1 = dictionary.getValue(keyInstrument , _instrumentID); - bool b2 = dictionary.getValue(keyProjObserver , _projectorID ); - bool b3 = dictionary.getValue(keyProjTarget , _projecteeID ); - bool b4 = dictionary.getValue(keyProjAberration , _aberration ); - bool b5 = dictionary.getValue(keyInstrumentFovy , _fovy ); - bool b6 = dictionary.getValue(keyInstrumentAspect, _aspectRatio ); - bool b7 = dictionary.getValue(keyInstrumentNear , _nearPlane ); - bool b8 = dictionary.getValue(keyInstrumentFar , _farPlane ); - - assert(b1 == true); - assert(b2 == true); - assert(b3 == true); - assert(b4 == true); - assert(b5 == true); - assert(b6 == true); - assert(b7 == true); - assert(b8 == true); - std::string name; bool success = dictionary.getValue(constants::scenegraphnode::keyName, name); - assert(success); + ghoul_assert(success, ""); std::string path; success = dictionary.getValue(constants::scenegraph::keyPathModule, path); - assert(success); + ghoul_assert(success, ""); _defaultProjImage = path + "/textures/defaultProj.png"; @@ -117,6 +106,38 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary.getValue(keyFrame, _target); + + bool b1 = dictionary.getValue(keyInstrument, _instrumentID); + bool b2 = dictionary.getValue(keyProjObserver, _projectorID); + bool b3 = dictionary.getValue(keyProjTarget, _projecteeID); + bool b4 = dictionary.getValue(keyProjAberration, _aberration); + bool b5 = dictionary.getValue(keyInstrumentFovy, _fovy); + bool b6 = dictionary.getValue(keyInstrumentAspect, _aspectRatio); + bool b7 = dictionary.getValue(keyInstrumentNear, _nearPlane); + bool b8 = dictionary.getValue(keyInstrumentFar, _farPlane); + + ghoul_assert(b1, ""); + ghoul_assert(b2, ""); + ghoul_assert(b3, ""); + ghoul_assert(b4, ""); + ghoul_assert(b5, ""); + ghoul_assert(b6, ""); + ghoul_assert(b7, ""); + ghoul_assert(b8, ""); + + // @TODO copy-n-paste from renderablefov ---abock + ghoul::Dictionary potentialTargets; + success = dictionary.getValue(keyPotentialTargets, potentialTargets); + ghoul_assert(success, ""); + + _potentialTargets.resize(potentialTargets.size()); + for (int i = 0; i < potentialTargets.size(); ++i) { + std::string target; + potentialTargets.getValue(std::to_string(i + 1), target); + _potentialTargets[i] = target; + } + + // TODO: textures need to be replaced by a good system similar to the geometry as soon // as the requirements are fixed (ab) std::string texturePath = ""; @@ -138,12 +159,27 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& addProperty(_projectionTexturePath); _projectionTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadProjectionTexture, this)); - bool found = dictionary.getValue(keySequenceDir, _sequenceFile); - _sequenceFile = path + ghoul::filesystem::FileSystem::PathSeparator + _sequenceFile; - if (found) - openspace::ImageSequencer::ref().parsePlaybookFile(_sequenceFile); - else - LERROR("Sequence description file was not specified in module description"); + std::string sequenceSource; + bool found = dictionary.getValue(keySequenceDir, sequenceSource); + if (found) { + //LERROR("RenderablePlanetProjection '" << name << "' did not contain a sequence source"); + sequenceSource = absPath(sequenceSource); + //sequenceSource = path + ghoul::filesystem::FileSystem::PathSeparator + sequenceSource; + + std::string sequenceType; + found = dictionary.getValue(keySequenceType, sequenceType); + if (found) { + if (sequenceType == sequenceTypeImage) { + openspace::ImageSequencer::ref().loadSequence(sequenceSource); + } + else if (sequenceType == sequenceTypePlaybook) { + openspace::ImageSequencer::ref().parsePlaybookFile(sequenceSource); + } + else { + LERROR("RenderablePlanetProjection '" << name << "' had unknown sequence type '" << sequenceType << "'"); + } + } + } } RenderablePlanetProjection::~RenderablePlanetProjection(){ @@ -325,11 +361,15 @@ void RenderablePlanetProjection::attitudeParameters(double time){ std::vector bounds; glm::dvec3 bs; bool found = openspace::SpiceManager::ref().getFieldOfView(_instrumentID, shape, instrument, bs, bounds); - if (!found) LERROR("Could not locate instrument"); + //if (!found) LERROR("Could not locate instrument"); + if (!found) + return ; psc position; //observer target found = SpiceManager::ref().getTargetPosition(_projectorID, _projecteeID, _mainFrame, _aberration, time, position, lightTime); - if (!found) LERROR("Could not locate target position"); + //if (!found) LERROR("Could not locate target position"); + if (!found) + return; position[3] += 3; glm::vec3 cpos = position.vec3(); @@ -388,13 +428,20 @@ void RenderablePlanetProjection::update(const UpdateData& data){ bool _withinFOV; /* -- TEMPORARY TARGETING SOLUTION -- */ - std::string potential[2] = { "PLUTO", "CHARON" }; // only possible to target these two for now. + //std::string potential2[2] = { "PLUTO", "CHARON" }; // only possible to target these two for now. std::string _fovTarget = ""; - for (int i = 0; i < 2; i++){ - bool success = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i], _projectorID, "ELLIPSOID", _aberration, _time[0], _withinFOV); + for (int i = 0; i < _potentialTargets.size(); i++){ + bool success = openspace::SpiceManager::ref().targetWithinFieldOfView( + _instrumentID, + _potentialTargets[i], + _projectorID, + "ELLIPSOID", + _aberration, + _time[0], + _withinFOV); if (success && _withinFOV){ - _fovTarget = potential[i]; + _fovTarget = _potentialTargets[i]; break; } } diff --git a/src/rendering/renderablefov.cpp b/src/rendering/renderablefov.cpp index 1e50372cbd..ab2335624a 100644 --- a/src/rendering/renderablefov.cpp +++ b/src/rendering/renderablefov.cpp @@ -52,6 +52,7 @@ namespace { const std::string keyInstrument = "Instrument.Name"; const std::string keyInstrumentMethod = "Instrument.Method"; const std::string keyInstrumentAberration = "Instrument.Aberration"; + const std::string keyPotentialTargets = "PotentialTargets"; } //#define DEBUG namespace openspace{ @@ -70,18 +71,33 @@ namespace openspace{ , _texture(nullptr) , _mode(GL_LINES){ - bool b1 = dictionary.getValue(keyBody , _spacecraft); - bool b2 = dictionary.getValue(keyFrame , _frame); - bool b3 = dictionary.getValue(keyInstrument , _instrumentID); - bool b4 = dictionary.getValue(keyInstrumentMethod , _method); - bool b5 = dictionary.getValue(keyInstrumentAberration , _aberrationCorrection); + bool success = dictionary.getValue(keyBody , _spacecraft); + ghoul_assert(success, ""); - assert(b1 == true); - assert(b2 == true); - assert(b3 == true); - assert(b4 == true); - assert(b5 == true); + success = dictionary.getValue(keyFrame , _frame); + ghoul_assert(success, ""); + + success = dictionary.getValue(keyInstrument , _instrumentID); + ghoul_assert(success, ""); + + success = dictionary.getValue(keyInstrumentMethod , _method); + ghoul_assert(success, ""); + + success = dictionary.getValue(keyInstrumentAberration , _aberrationCorrection); + ghoul_assert(success, ""); + + ghoul::Dictionary potentialTargets; + success = dictionary.getValue(keyPotentialTargets, potentialTargets); + ghoul_assert(success, ""); + + _potentialTargets.resize(potentialTargets.size()); + for (int i = 0; i < potentialTargets.size(); ++i) { + std::string target; + potentialTargets.getValue(std::to_string(i + 1), target); + _potentialTargets[i] = target; + } } + void RenderableFov::allocateData(){ int points = 8; _stride[0] = points; @@ -433,23 +449,30 @@ void RenderableFov::render(const RenderData& data){ // fetch data for specific instrument (shape, boresight, bounds etc) bool found = openspace::SpiceManager::ref().getFieldOfView(_instrumentID, shape, instrument, boresight, bounds); - if (!found) LERROR("Could not locate instrument"); - + if (!found) { + LERROR("Could not locate instrument"); + return; + } float size = 4 * sizeof(float); int indx = 0; // set target based on visibility to specific instrument, // from here on the _fovTarget is the target for all spice functions. //std::string potential[5] = { "Jupiter", "Io", "Europa", "Ganymede", "Callisto" }; - std::string potential[2] = { "Pluto", "Charon" }; + //std::string potential[2] = { "Pluto", "Charon" }; - _fovTarget = potential[0]; //default - for (int i = 0; i < 2; i++){ - bool success = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i], - _spacecraft, _method, - _aberrationCorrection, _time, _withinFOV); + _fovTarget = _potentialTargets[0]; //default + for (int i = 0; i < _potentialTargets.size(); i++){ + bool success = openspace::SpiceManager::ref().targetWithinFieldOfView( + _instrumentID, + _potentialTargets[i], + _spacecraft, + _method, + _aberrationCorrection, + _time, + _withinFOV); if (success && _withinFOV){ - _fovTarget = potential[i]; + _fovTarget = _potentialTargets[i]; break; } } diff --git a/src/rendering/renderabletrail.cpp b/src/rendering/renderabletrail.cpp index d143c4225a..37656c821a 100644 --- a/src/rendering/renderabletrail.cpp +++ b/src/rendering/renderabletrail.cpp @@ -145,7 +145,10 @@ void RenderableTrail::render(const RenderData& data) { } void RenderableTrail::update(const UpdateData& data) { - // needsSweep also needs to be done when the time has been changed abruptly ---abock + //if (data.isTimeJump) + //_needsSweep = true; + //return; + if (_needsSweep) { fullYearSweep(data.time); sendToGPU(); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index cfeb7859c8..b36a8816df 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -427,10 +427,12 @@ namespace openspace { // 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); // clear the abuffer before rendering the scene @@ -629,6 +631,7 @@ namespace openspace { } void RenderEngine::postDraw() { + //Time::ref().setTimeJumped(false); if (_takeScreenshot) { sgct::Engine::instance()->takeScreenshot(); _takeScreenshot = false; diff --git a/src/util/imagesequencer.cpp b/src/util/imagesequencer.cpp index efcc0ce13e..6a2303a9c3 100644 --- a/src/util/imagesequencer.cpp +++ b/src/util/imagesequencer.cpp @@ -246,7 +246,7 @@ bool ImageSequencer::parsePlaybookFile(const std::string& fileName, std::string */ if (extension == "txt"){// Hong Kang. pre-parsed playbook - std::cout << "USING PREPARSED PLAYBOOK V9H" << std::endl; + LINFO("Using Preparsed Playbook V9H"); std::ifstream file(fileName); if (!file.good()) LERROR("Failed to open txt file '" << fileName << "'"); @@ -353,14 +353,14 @@ bool ImageSequencer::loadSequence(const std::string& dir) { found = true; std::string ext = "jpg"; path.replace(path.begin() + position, path.end(), ext); - std::vector::const_iterator it = std::find(sequencePaths.begin(), sequencePaths.end(), path); - if ( it != sequencePaths.end()){ + bool fileExists = FileSys.fileExists(path); + if (fileExists) { createImage(timestamps[0], timestamps[1], "NH_LORRI", path); /// fix active instrument! std::sort(_timeStamps.begin(), _timeStamps.end(), cmp); } - std::string timestr; - openspace::SpiceManager::ref().getDateFromET(timestamps[0], timestr); - std::cout << "Found at time " << timestr << " " << path << std::endl; + //std::string timestr; + //openspace::SpiceManager::ref().getDateFromET(timestamps[0], timestr); + //std::cout << "Found at time " << timestr << " " << path << std::endl; } } while (!file.eof() && found == false); } @@ -371,7 +371,7 @@ bool ImageSequencer::loadSequence(const std::string& dir) { //_nextCapture = nextCaptureTime(Time::ref().currentTime()); // this is not really working 100% //_intervalLength = _timeStamps[1].startTime; - return !sequencePaths.empty(); + return !_timeStamps.empty(); } diff --git a/src/util/time.cpp b/src/util/time.cpp index a2b1a39a09..e477111d34 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -239,6 +239,9 @@ void Time::deserialize(SyncBuffer* syncBuffer){ syncBuffer->decode(_sharedDt); syncBuffer->decode(_sharedTimeJumped); + //if (_sharedTimeJumped) + // _jockeHasToFixThisLater = true; + _syncMutex.unlock(); } @@ -249,6 +252,11 @@ void Time::postSynchronizationPreDraw(){ _syncedDt = _sharedDt; _syncedTimeJumped = _sharedTimeJumped; + //if (_jockeHasToFixThisLater) { + // _syncedTimeJumped = true; + // _jockeHasToFixThisLater = false; + //} + _syncMutex.unlock(); }