From 568a6a3416e22d5b9d40c06a6d70a56aa9127120 Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Fri, 1 Apr 2016 17:47:00 +0200 Subject: [PATCH 1/7] fix bug when numberOfSamples is 0 --- src/rendering/abufferrenderer.cpp | 3 +++ src/rendering/framebufferrenderer.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/rendering/abufferrenderer.cpp b/src/rendering/abufferrenderer.cpp index e0f4783ec5..15e2911877 100644 --- a/src/rendering/abufferrenderer.cpp +++ b/src/rendering/abufferrenderer.cpp @@ -99,6 +99,9 @@ void ABufferRenderer::initialize() { glGenTextures(1, &_fragmentTexture); _nAaSamples = OsEng.windowWrapper().currentNumberOfAaSamples(); + if (_nAaSamples == 0) { + _nAaSamples = 1; + } if (_nAaSamples > 8) { LERROR("ABuffer renderer does not support more than 8 MSAA samples."); _nAaSamples = 8; diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index f9a441aafe..e2e7213ede 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -123,6 +123,9 @@ void FramebufferRenderer::initialize() { OsEng.renderEngine().raycasterManager().addListener(*this); _nAaSamples = OsEng.windowWrapper().currentNumberOfAaSamples(); + if (_nAaSamples == 0) { + _nAaSamples = 1; + } if (_nAaSamples > 8) { LERROR("Framebuffer renderer does not support more than 8 MSAA samples."); _nAaSamples = 8; From 019092e98ebb29b7eef3316f9060ae5d4eeb7af9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 4 Apr 2016 20:26:10 +0200 Subject: [PATCH 2/7] Correctly set child nodes for SceneGraphNode%s --- ext/ghoul | 2 +- include/openspace/scene/scenegraphnode.h | 1 + src/scene/scenegraph.cpp | 2 ++ src/scene/scenegraphnode.cpp | 13 +++++++++---- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 849cc67bdc..901a96beda 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 849cc67bdc2550a43d8174490d39b14ee148b795 +Subproject commit 901a96bedad5fa789b4e45e61e97c5c1d909631c diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 0ae92c4713..e547159681 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -71,6 +71,7 @@ public: //void addNode(SceneGraphNode* child); + void addChild(SceneGraphNode* child); void setParent(SceneGraphNode* parent); //bool abandonChild(SceneGraphNode* child); diff --git a/src/scene/scenegraph.cpp b/src/scene/scenegraph.cpp index cf69955fb5..00975b8485 100644 --- a/src/scene/scenegraph.cpp +++ b/src/scene/scenegraph.cpp @@ -261,6 +261,8 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) { } node->node->setParent(parentNode); + parentNode->addChild(node->node); + } // Setup dependencies diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index c3f36f9e23..5f88de541d 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -155,10 +155,10 @@ bool SceneGraphNode::deinitialize() { delete _ephemeris; _ephemeris = nullptr; - for (SceneGraphNode* child : _children) { - child->deinitialize(); - delete child; - } + // for (SceneGraphNode* child : _children) { + // child->deinitialize(); + // delete child; + //} _children.clear(); // reset variables @@ -283,6 +283,11 @@ void SceneGraphNode::setParent(SceneGraphNode* parent) _parent = parent; } +void SceneGraphNode::addChild(SceneGraphNode* child) { + _children.push_back(child); +} + + //not used anymore @AA //bool SceneGraphNode::abandonChild(SceneGraphNode* child) { // std::vector < SceneGraphNode* >::iterator it = std::find(_children.begin(), _children.end(), child); From e23a1f3e3cd1bf42937b7335d2a4857363ca0436 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 4 Apr 2016 20:26:27 +0200 Subject: [PATCH 3/7] Fix compilatioon of renderablefieldlines --- modules/fieldlines/rendering/renderablefieldlines.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fieldlines/rendering/renderablefieldlines.cpp b/modules/fieldlines/rendering/renderablefieldlines.cpp index 76b18d889a..80f7ccbe04 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.cpp +++ b/modules/fieldlines/rendering/renderablefieldlines.cpp @@ -225,7 +225,7 @@ void RenderableFieldlines::render(const RenderData& data) { _program->setUniform("modelViewProjection", data.camera.viewProjectionMatrix()); _program->setUniform("modelTransform", glm::mat4(1.0)); _program->setUniform("cameraViewDir", data.camera.viewDirection()); - setPscUniforms(_program.get(), &data.camera, data.position); + setPscUniforms(*(_program.get()), data.camera, data.position); _program->setUniform("classification", _classification); if (!_classification) From 7263b251ca7e7bc5b907c2fb286d28f85505d4ce Mon Sep 17 00:00:00 2001 From: Michael Nilsson Date: Tue, 5 Apr 2016 11:03:55 -0400 Subject: [PATCH 4/7] iswa module ready for api change in downloadmanager --- modules/iswa/rendering/screenspacecygnet.cpp | 4 +--- modules/iswa/rendering/screenspacecygnet.h | 2 +- modules/iswa/rendering/textureplane.cpp | 3 +-- modules/iswa/rendering/textureplane.h | 2 +- modules/iswa/util/iswamanager.cpp | 4 +--- modules/iswa/util/iswamanager.h | 2 +- 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/modules/iswa/rendering/screenspacecygnet.cpp b/modules/iswa/rendering/screenspacecygnet.cpp index 42b80f3f21..c0b7b860b1 100644 --- a/modules/iswa/rendering/screenspacecygnet.cpp +++ b/modules/iswa/rendering/screenspacecygnet.cpp @@ -40,7 +40,6 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(int cygnetId, std::string path) , _cygnetId(cygnetId) , _path(path) { - std::cout << "screenspacecygnet constructor 1" << std::endl; _id = id(); setName("ScreenSpaceCygnet" + std::to_string(_id)); addProperty(_updateInterval); @@ -125,14 +124,13 @@ void ScreenSpaceCygnet::update(){ loadTexture(); - delete _futureTexture; _futureTexture = nullptr; } } void ScreenSpaceCygnet::updateTexture(){ - DownloadManager::FileFuture* future = ISWAManager::ref().downloadImage(_cygnetId, absPath(_path)); + std::shared_ptr future = ISWAManager::ref().downloadImage(_cygnetId, absPath(_path)); if(future){ _futureTexture = future; } diff --git a/modules/iswa/rendering/screenspacecygnet.h b/modules/iswa/rendering/screenspacecygnet.h index 95733400fb..e6bde37950 100644 --- a/modules/iswa/rendering/screenspacecygnet.h +++ b/modules/iswa/rendering/screenspacecygnet.h @@ -53,7 +53,7 @@ private: int _id; float _time; float _lastUpdateTime = 0.0f; - DownloadManager::FileFuture* _futureTexture; + std::shared_ptr _futureTexture; std::string _fileExtension; float _openSpaceUpdateInterval; diff --git a/modules/iswa/rendering/textureplane.cpp b/modules/iswa/rendering/textureplane.cpp index 9175c278fe..c41c94eb17 100644 --- a/modules/iswa/rendering/textureplane.cpp +++ b/modules/iswa/rendering/textureplane.cpp @@ -137,7 +137,6 @@ void TexturePlane::update(){ if(_futureTexture && _futureTexture->isFinished){ loadTexture(); - delete _futureTexture; _futureTexture = nullptr; } } @@ -147,7 +146,7 @@ void TexturePlane::setParent(){ } void TexturePlane::updateTexture(){ - DownloadManager::FileFuture* future = ISWAManager::ref().downloadImage(_cygnetId, absPath(_path)); + std::shared_ptr future = ISWAManager::ref().downloadImage(_cygnetId, absPath(_path)); if(future){ _futureTexture = future; } diff --git a/modules/iswa/rendering/textureplane.h b/modules/iswa/rendering/textureplane.h index e289607738..fc1d7ea771 100644 --- a/modules/iswa/rendering/textureplane.h +++ b/modules/iswa/rendering/textureplane.h @@ -50,7 +50,7 @@ static int id(); - DownloadManager::FileFuture* _futureTexture; + std::shared_ptr _futureTexture; }; } // namespace openspace diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index babd2ef5cc..89a9b35bea 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -83,7 +83,6 @@ namespace openspace{ } std::shared_ptr ISWAManager::createISWACygnet(int id, std::string path){ - std::cout << "createISWACygnet " << id << std::endl; if(path != ""){ const std::string& extension = ghoul::filesystem::File(absPath(path)).fileExtension(); std::shared_ptr cygnet; @@ -106,7 +105,7 @@ namespace openspace{ } } - DownloadManager::FileFuture* ISWAManager::downloadImage(int id, std::string path){ + std::shared_ptr ISWAManager::downloadImage(int id, std::string path){ return DlManager.downloadFile( iSWAurl(id), @@ -126,7 +125,6 @@ namespace openspace{ std::shared_ptr extFuture = std::make_shared(); extFuture->isFinished = false; extFuture->id = id; - std::cout << "extension id: "<< id << std::endl; DlManager.getFileExtension( iSWAurl(id), [extFuture](std::string extension){ diff --git a/modules/iswa/util/iswamanager.h b/modules/iswa/util/iswamanager.h index 2953b0fca3..713a995c48 100644 --- a/modules/iswa/util/iswamanager.h +++ b/modules/iswa/util/iswamanager.h @@ -52,7 +52,7 @@ public: std::shared_ptr createISWACygnet(int, std::string); void addCygnet(std::string info); - DownloadManager::FileFuture* downloadImage(int, std::string); + std::shared_ptr downloadImage(int, std::string); void downloadData(); std::shared_ptr fileExtension(int); From 0d0f761d6ef520010b50fd9c498e16ef48a1108a Mon Sep 17 00:00:00 2001 From: Michael Nilsson Date: Tue, 5 Apr 2016 11:33:58 -0400 Subject: [PATCH 5/7] downloadmanager return shared_ptr to FileFutures instead of bare pointers --- apps/Launcher/infowidget.cpp | 2 +- apps/Launcher/infowidget.h | 2 +- apps/Launcher/syncwidget.cpp | 15 +++++++-------- apps/Launcher/syncwidget.h | 8 ++++---- include/openspace/engine/downloadmanager.h | 6 +++--- src/engine/downloadmanager.cpp | 16 ++++++++-------- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/apps/Launcher/infowidget.cpp b/apps/Launcher/infowidget.cpp index ff2537c407..ddde63591a 100644 --- a/apps/Launcher/infowidget.cpp +++ b/apps/Launcher/infowidget.cpp @@ -75,7 +75,7 @@ InfoWidget::InfoWidget(QString name, int totalBytes) setLayout(layout); } -void InfoWidget::update(openspace::DownloadManager::FileFuture* f) { +void InfoWidget::update(std::shared_ptr f) { _bytes->setText( QString("%1 / %2") .arg(f->currentSize) diff --git a/apps/Launcher/infowidget.h b/apps/Launcher/infowidget.h index 2099a774af..2eaec279b9 100644 --- a/apps/Launcher/infowidget.h +++ b/apps/Launcher/infowidget.h @@ -40,7 +40,7 @@ Q_OBJECT public: InfoWidget(QString name, int totalBytes = -1); - void update(openspace::DownloadManager::FileFuture* f); + void update(std::shared_ptr f); void update(libtorrent::torrent_status s); void error(QString message); diff --git a/apps/Launcher/syncwidget.cpp b/apps/Launcher/syncwidget.cpp index 6ed87b2544..0710378173 100644 --- a/apps/Launcher/syncwidget.cpp +++ b/apps/Launcher/syncwidget.cpp @@ -230,7 +230,7 @@ void SyncWidget::setSceneFiles(QMap sceneFiles) { } void SyncWidget::clear() { - for (openspace::DownloadManager::FileFuture* f : _futures) + for (std::shared_ptr f : _futures) f->abortDownload = true; using libtorrent::torrent_handle; @@ -254,7 +254,7 @@ void SyncWidget::handleDirectFiles() { for (const DirectFile& f : _directFiles) { LDEBUG(f.url.toStdString() << " -> " << f.destination.toStdString()); - openspace::DownloadManager::FileFuture* future = DlManager.downloadFile( + std::shared_ptr future = DlManager.downloadFile( f.url.toStdString(), absPath("${SCENE}/" + f.module.toStdString() + "/" + f.destination.toStdString()), OverwriteFiles @@ -571,8 +571,8 @@ void SyncWidget::handleTimer() { using namespace libtorrent; using FileFuture = openspace::DownloadManager::FileFuture; - std::vector toRemove; - for (FileFuture* f : _futures) { + std::vector> toRemove; + for (std::shared_ptr f : _futures) { InfoWidget* w = _futureInfoWidgetMap[f]; if (CleanInfoWidgets && (f->isFinished || f->isAborted)) { @@ -585,13 +585,12 @@ void SyncWidget::handleTimer() { w->update(f); } - for (FileFuture* f : toRemove) { + for (std::shared_ptr f : toRemove) { _futures.erase(std::remove(_futures.begin(), _futures.end(), f), _futures.end()); - delete f; } while (_mutex.test_and_set()) {} - for (openspace::DownloadManager::FileFuture* f : _futuresToAdd) { + for (std::shared_ptr f : _futuresToAdd) { InfoWidget* w = new InfoWidget(QString::fromStdString(f->filePath), -1); _downloadLayout->insertWidget(_downloadLayout->count() - 1, w); @@ -679,7 +678,7 @@ void SyncWidget::handleTimer() { } void SyncWidget::handleFileFutureAddition( - const std::vector& futures) + const std::vector>& futures) { while (_mutex.test_and_set()) {} _futuresToAdd.insert(_futuresToAdd.end(), futures.begin(), futures.end()); diff --git a/apps/Launcher/syncwidget.h b/apps/Launcher/syncwidget.h index b4b2c108e4..e17f54be7f 100644 --- a/apps/Launcher/syncwidget.h +++ b/apps/Launcher/syncwidget.h @@ -83,7 +83,7 @@ private: void clear(); QStringList selectedScenes() const; - void handleFileFutureAddition(const std::vector& futures); + void handleFileFutureAddition(const std::vector>& futures); void handleDirectFiles(); void handleFileRequest(); @@ -101,10 +101,10 @@ private: QList _fileRequests; QList _torrentFiles; - std::vector _futures; - std::map _futureInfoWidgetMap; + std::vector> _futures; + std::map, InfoWidget*> _futureInfoWidgetMap; - std::vector _futuresToAdd; + std::vector> _futuresToAdd; std::atomic_flag _mutex; }; diff --git a/include/openspace/engine/downloadmanager.h b/include/openspace/engine/downloadmanager.h index 653dd1edd1..53b90cf683 100644 --- a/include/openspace/engine/downloadmanager.h +++ b/include/openspace/engine/downloadmanager.h @@ -63,20 +63,20 @@ public: using DownloadProgressCallback = std::function; using DownloadFinishedCallback = std::function; using AsyncDownloadFinishedCallback = - std::function&)>; + std::function>&)>; DownloadManager(std::string requestURL, int applicationVersion, bool useMultithreadedDownload = true); // callers responsibility to delete // callbacks happen on a different thread - FileFuture* downloadFile(const std::string& url, const ghoul::filesystem::File& file, + std::shared_ptr downloadFile(const std::string& url, const ghoul::filesystem::File& file, bool overrideFile = true, DownloadFinishedCallback finishedCallback = DownloadFinishedCallback(), DownloadProgressCallback progressCallback = DownloadProgressCallback() ); - std::vector downloadRequestFiles(const std::string& identifier, + std::vector> downloadRequestFiles(const std::string& identifier, const ghoul::filesystem::Directory& destination, int version, bool overrideFiles = true, DownloadFinishedCallback finishedCallback = DownloadFinishedCallback(), diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index 7c69aa0638..e4f608fd36 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -50,7 +50,7 @@ namespace { const std::string RequestApplicationVersion = "application_version"; struct ProgressInformation { - openspace::DownloadManager::FileFuture* future; + std::shared_ptr future; std::chrono::system_clock::time_point startTime; const openspace::DownloadManager::DownloadProgressCallback* callback; }; @@ -133,14 +133,14 @@ DownloadManager::DownloadManager(std::string requestURL, int applicationVersion, // TODO: Allow for multiple requestURLs } -DownloadManager::FileFuture* DownloadManager::downloadFile( +std::shared_ptr DownloadManager::downloadFile( const std::string& url, const ghoul::filesystem::File& file, bool overrideFile, DownloadFinishedCallback finishedCallback, DownloadProgressCallback progressCallback) { if (!overrideFile && FileSys.fileExists(file)) return nullptr; - FileFuture* future = new FileFuture(file.filename()); + std::shared_ptr future = std::make_shared(file.filename()); FILE* fp = fopen(file.path().c_str(), "wb"); LDEBUG("Start downloading file: '" << url << "' into file '" << file.path() << "'"); @@ -196,12 +196,12 @@ DownloadManager::FileFuture* DownloadManager::downloadFile( return future; } -std::vector DownloadManager::downloadRequestFiles( +std::vector> DownloadManager::downloadRequestFiles( const std::string& identifier, const ghoul::filesystem::Directory& destination, int version, bool overrideFiles, DownloadFinishedCallback finishedCallback, DownloadProgressCallback progressCallback) { - std::vector futures; + std::vector> futures; FileSys.createDirectory(destination, ghoul::filesystem::FileSystem::Recursive::Yes); // TODO: Check s ---abock // TODO: Escaping is necessary ---abock @@ -232,7 +232,7 @@ std::vector DownloadManager::downloadRequestFiles( LDEBUG("\tLine: " << line << " ; Dest: " << destination.path() + "/" + file); - FileFuture* future = DlManager.downloadFile( + std::shared_ptr future = DlManager.downloadFile( line, destination.path() + "/" + file, overrideFiles, @@ -244,7 +244,7 @@ std::vector DownloadManager::downloadRequestFiles( isFinished = true; }; - FileFuture* f = downloadFile( + std::shared_ptr f = downloadFile( fullRequest, requestFile, true, @@ -261,7 +261,7 @@ void DownloadManager::downloadRequestFilesAsync(const std::string& identifier, AsyncDownloadFinishedCallback callback) { auto downloadFunction = [this, identifier, destination, version, overrideFiles, callback](){ - std::vector f = downloadRequestFiles( + std::vector> f = downloadRequestFiles( identifier, destination, version, From b1a009e1b080ac0a5514e05efa2b574802116208 Mon Sep 17 00:00:00 2001 From: Sebastian Piwell Date: Tue, 5 Apr 2016 11:44:49 -0400 Subject: [PATCH 6/7] Create ISWACygnets with metadata struct --- ext/ghoul | 2 +- modules/iswa/rendering/cygnetplane.cpp | 125 +++++++++---------- modules/iswa/rendering/cygnetplane.h | 19 +-- modules/iswa/rendering/dataplane.cpp | 89 +++++++------ modules/iswa/rendering/dataplane.h | 14 +-- modules/iswa/rendering/iswacontainer.cpp | 27 ++-- modules/iswa/rendering/iswacontainer.h | 2 +- modules/iswa/rendering/iswacygnet.cpp | 56 +++++---- modules/iswa/rendering/iswacygnet.h | 36 +++--- modules/iswa/rendering/screenspacecygnet.cpp | 31 ++++- modules/iswa/rendering/screenspacecygnet.h | 9 +- modules/iswa/rendering/textureplane.cpp | 66 +++++----- modules/iswa/rendering/textureplane.h | 4 +- modules/iswa/util/iswamanager.cpp | 64 +++++----- modules/iswa/util/iswamanager.h | 14 ++- modules/kameleon/include/kameleonwrapper.h | 2 + modules/kameleon/src/kameleonwrapper.cpp | 36 ++++++ src/rendering/screenspacerenderable.cpp | 6 - 18 files changed, 346 insertions(+), 256 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index f31ddda5d7..901a96beda 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit f31ddda5d7104f0625059ff00880463a34bdaa6d +Subproject commit 901a96bedad5fa789b4e45e61e97c5c1d909631c diff --git a/modules/iswa/rendering/cygnetplane.cpp b/modules/iswa/rendering/cygnetplane.cpp index 72fa8a920a..f27bb9eee3 100644 --- a/modules/iswa/rendering/cygnetplane.cpp +++ b/modules/iswa/rendering/cygnetplane.cpp @@ -19,89 +19,51 @@ #include #include #include -#include #include namespace openspace{ -CygnetPlane::CygnetPlane(int cygnetId, std::string path) - :ISWACygnet(cygnetId, path) - ,_quad(0) - ,_vertexPositionBuffer(0) +// CygnetPlane::CygnetPlane(int cygnetId, std::string path) +// :ISWACygnet(cygnetId, path) +// ,_quad(0) +// ,_vertexPositionBuffer(0) +// ,_planeIsDirty(true) +// {} + +CygnetPlane::CygnetPlane(std::shared_ptr data) + :ISWACygnet(data) + ,_quad(0) + ,_vertexPositionBuffer(0) ,_planeIsDirty(true) {} CygnetPlane::~CygnetPlane(){} -bool CygnetPlane::initialize(){ - ISWACygnet::initialize(); - - glGenVertexArrays(1, &_quad); // generate array - glGenBuffers(1, &_vertexPositionBuffer); // generate buffer - createPlane(); - - if (_shader == nullptr) { - // Plane Program - RenderEngine& renderEngine = OsEng.renderEngine(); - _shader = renderEngine.buildRenderProgram("PlaneProgram", - "${MODULE_ISWA}/shaders/cygnetplane_vs.glsl", - "${MODULE_ISWA}/shaders/cygnetplane_fs.glsl" - ); - if (!_shader) - return false; - } -} - -bool CygnetPlane::deinitialize(){ - ISWACygnet::deinitialize(); - glDeleteVertexArrays(1, &_quad); - _quad = 0; - - glDeleteBuffers(1, &_vertexPositionBuffer); - _vertexPositionBuffer = 0; - - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_shader) { - renderEngine.removeRenderProgram(_shader); - _shader = nullptr; - } - - return true; -} - bool CygnetPlane::isReady(){ - bool ready = true; - if (!_shader) - ready &= false; - if(!_texture) - ready &= false; - return ready; -} - -void CygnetPlane::render(){} - -void CygnetPlane::update(){ - ISWACygnet::update(); - - _time = Time::ref().currentTime(); - _stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _frame, _time); - _openSpaceUpdateInterval = Time::ref().deltaTime()*_updateInterval; - - if(_openSpaceUpdateInterval){ - if((_time-_lastUpdateTime) >= _openSpaceUpdateInterval){ - updateTexture(); - _lastUpdateTime = _time; - } - } + bool ready = true; + if (!_shader) + ready &= false; + if(!_texture) + ready &= false; + return ready; } void CygnetPlane::createPlane(){ + glGenVertexArrays(1, &_quad); // generate array + glGenBuffers(1, &_vertexPositionBuffer); // generate buffer // ============================ // GEOMETRY (quad) // ============================ - const GLfloat x = _modelScale.x/2.0; - const GLfloat y = _modelScale.z/2.0; - const GLfloat w = _modelScale.w; + // GLfloat x, y, w; + // if(!_data){ + // x = _modelScale.x/2.0; + // y = _modelScale.z/2.0; + // w = _modelScale.w; + // }else{ + const GLfloat x = _data->scale.x/2.0; + const GLfloat y = _data->scale.z/2.0; + const GLfloat w = _data->scale.w; + // } const GLfloat vertex_data[] = { // square of two triangles (sigh) // x y z w s t -x, -y, 0, w, 0, 1, @@ -123,4 +85,33 @@ void CygnetPlane::createPlane(){ _planeIsDirty = false; } +void CygnetPlane::destroyPlane(){ + glDeleteVertexArrays(1, &_quad); + _quad = 0; + + glDeleteBuffers(1, &_vertexPositionBuffer); + _vertexPositionBuffer = 0; +} + +bool CygnetPlane::createShader(){ + if (_shader == nullptr) { + // Plane Program + RenderEngine& renderEngine = OsEng.renderEngine(); + _shader = renderEngine.buildRenderProgram("PlaneProgram", + "${MODULE_ISWA}/shaders/cygnetplane_vs.glsl", + "${MODULE_ISWA}/shaders/cygnetplane_fs.glsl" + ); + if (!_shader) + return false; + } +} + +void CygnetPlane::destroyShader(){ + RenderEngine& renderEngine = OsEng.renderEngine(); + if (_shader) { + renderEngine.removeRenderProgram(_shader); + _shader = nullptr; + } +} + } //namespace openspace \ No newline at end of file diff --git a/modules/iswa/rendering/cygnetplane.h b/modules/iswa/rendering/cygnetplane.h index 0a45a68b63..96735249b9 100644 --- a/modules/iswa/rendering/cygnetplane.h +++ b/modules/iswa/rendering/cygnetplane.h @@ -32,23 +32,24 @@ namespace openspace{ class CygnetPlane : public ISWACygnet { public: - CygnetPlane(int cygnetId, std::string path); + // CygnetPlane(int cygnetId, std::string path); + CygnetPlane(std::shared_ptr data); ~CygnetPlane(); - virtual bool initialize(); - virtual bool deinitialize(); - - bool isReady() override; - - virtual void render(); - virtual void update(); + virtual bool initialize() = 0; + virtual bool deinitialize() = 0; + virtual bool isReady(); + virtual void render() = 0; + virtual void update() = 0; protected: - virtual void setParent() = 0; virtual void loadTexture() = 0; virtual void updateTexture() = 0; void createPlane(); + void destroyPlane(); + bool createShader(); + void destroyShader(); GLuint _quad; GLuint _vertexPositionBuffer; diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index 15d5f79cdd..3415396775 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -33,7 +33,7 @@ #include #include #include - +#include namespace { const std::string _loggerCat = "DataPlane"; @@ -41,8 +41,25 @@ namespace { namespace openspace { -DataPlane::DataPlane(std::shared_ptr kw, std::string path) - :CygnetPlane(1, path) +// DataPlane::DataPlane(std::shared_ptr kw, std::string path) +// :CygnetPlane(1, path) +// , _kw(kw) +// { +// _id = id(); +// setName("DataPlane" + std::to_string(_id)); +// registerProperties(); + +// KameleonWrapper::Model model = _kw->model(); +// if( model == KameleonWrapper::Model::BATSRUS){ +// _var = "p"; +// }else{ +// _var = "rho"; +// } + +// } + +DataPlane::DataPlane(std::shared_ptr kw, std::shared_ptr data) + :CygnetPlane(data) , _kw(kw) { _id = id(); @@ -56,19 +73,20 @@ DataPlane::DataPlane(std::shared_ptr kw, std::string path) _var = "rho"; } + if(!_data){ + std::cout << "No data" << std::endl; + }else{ + std::cout << _data->parent << std::endl; + } + } - - DataPlane::~DataPlane(){} bool DataPlane::initialize(){ - _modelScale = _kw->getModelScaleScaled(); - _pscOffset = _kw->getModelBarycenterOffsetScaled(); - - CygnetPlane::initialize(); - // std::cout << _modelScale.x << ", " << _modelScale.y << ", " << _modelScale.z << ", " << _modelScale.w << std::endl; - // std::cout << _pscOffset.x << ", " << _pscOffset.y << ", " << _pscOffset.z << ", " << _pscOffset.w << std::endl; + setParent(); + createPlane(); + createShader(); _dimensions = glm::size3_t(500,500,1); float zSlice = 0.5f; @@ -80,7 +98,10 @@ bool DataPlane::initialize(){ } bool DataPlane::deinitialize(){ - CygnetPlane::deinitialize(); + _parent = nullptr; + unregisterProperties(); + destroyPlane(); + destroyShader(); _kw = nullptr; return true; @@ -124,7 +145,11 @@ void DataPlane::render(){ glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), angle, ref); transform = rotation * transform; - position += transform*glm::vec4(_pscOffset.x, _pscOffset.z, _pscOffset.y, _pscOffset.w); + + // if(!_data) + // position += transform*glm::vec4(_pscOffset.x, _pscOffset.z, _pscOffset.y, _pscOffset.w); + // else + position += transform*glm::vec4(_data->offset.x, _data->offset.z, _data->offset.y, _data->offset.w); // Activate shader _shader->activate(); @@ -152,33 +177,23 @@ void DataPlane::update(){ if(_planeIsDirty) createPlane(); - CygnetPlane::update(); + _time = Time::ref().currentTime(); + + // if(!_data) + // _stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _frame, _time); + // else + _stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _data->frame, _time); + _openSpaceUpdateInterval = Time::ref().deltaTime()*_updateInterval; + + if(_openSpaceUpdateInterval){ + if((_time-_lastUpdateTime) >= _openSpaceUpdateInterval){ + updateTexture(); + _lastUpdateTime = _time; + } + } } -void DataPlane::setParent(){ - KameleonWrapper::Model model = _kw->model(); - if( model == KameleonWrapper::Model::BATSRUS || - model == KameleonWrapper::Model::OpenGGCM || - model == KameleonWrapper::Model::LFM) - { - _parent = OsEng.renderEngine().scene()->sceneGraphNode("Earth"); - _frame = "GSM"; - }else if( - model == KameleonWrapper::Model::ENLIL || - model == KameleonWrapper::Model::MAS || - model == KameleonWrapper::Model::Adapt3D || - model == KameleonWrapper::Model::SWMF) - { - _parent = OsEng.renderEngine().scene()->sceneGraphNode("SolarSystem"); - _frame = "GALACTIC"; - }else{ - //Warning! - } -} - - - void DataPlane::loadTexture() { //std::unique_ptr texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath)); ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear; diff --git a/modules/iswa/rendering/dataplane.h b/modules/iswa/rendering/dataplane.h index 3b45382e51..73cd55680b 100644 --- a/modules/iswa/rendering/dataplane.h +++ b/modules/iswa/rendering/dataplane.h @@ -32,17 +32,16 @@ class DataPlane : public CygnetPlane { public: - DataPlane(std::shared_ptr kw, std::string path); + // DataPlane(std::shared_ptr kw, std::string path); + DataPlane(std::shared_ptr kw, std::shared_ptr data); ~DataPlane(); - virtual bool initialize(); - virtual bool deinitialize(); - - virtual void render(); - virtual void update(); + virtual bool initialize() override; + virtual bool deinitialize() override; + virtual void render() override; + virtual void update() override; private: - virtual void setParent() override; virtual void loadTexture() override; virtual void updateTexture() override; @@ -51,6 +50,7 @@ std::shared_ptr _kw; glm::size3_t _dimensions; float* _dataSlice; + std::string _var; }; } // namespace openspace diff --git a/modules/iswa/rendering/iswacontainer.cpp b/modules/iswa/rendering/iswacontainer.cpp index 65b8e58d24..4936fb996a 100644 --- a/modules/iswa/rendering/iswacontainer.cpp +++ b/modules/iswa/rendering/iswacontainer.cpp @@ -44,11 +44,11 @@ bool ISWAContainer::initialize(){ ISWAManager::initialize(); ISWAManager::ref().setContainer(this); - addISWACygnet("${OPENSPACE_DATA}/BATSRUS.cdf"); + // addISWACygnet("${OPENSPACE_DATA}/BATSRUS.cdf"); // addISWACygnet("${OPENSPACE_DATA}/ENLIL.cdf"); //addISWACygnet("${OPENSPACE_DATA}/test.png"); - addISWACygnet(5); - addISWACygnet(7); + addISWACygnet(5, "Screen"); + // addISWACygnet(7, "Sun"); return true; } @@ -72,12 +72,17 @@ void ISWAContainer::render(const RenderData& data){ } void ISWAContainer::update(const UpdateData& data){ - for (auto it = _extFutures.begin(); it != _extFutures.end(); ) { - if ((*it)->isFinished) { + if ((*it)->isFinished) { std::string path = "${OPENSPACE_DATA}/scene/iswa/" + std::to_string((*it)->id) + (*it)->extension; - std::shared_ptr cygnet = ISWAManager::ref().createISWACygnet((*it)->id, std::move(path)); + + std::shared_ptr data = std::make_shared(); + data->id = (*it)->id; + data->path = path; + data->parent = (*it)->parent; + + std::shared_ptr cygnet = ISWAManager::ref().createISWACygnet(data); if(cygnet){ _iSWACygnets.push_back(cygnet); } @@ -96,16 +101,20 @@ void ISWAContainer::update(const UpdateData& data){ } void ISWAContainer::addISWACygnet(std::string path){ - std::shared_ptr cygnet = ISWAManager::ref().createISWACygnet(1, path); + std::shared_ptr data = std::make_shared(); + data->id = 0; + data->path = path; + + std::shared_ptr cygnet = ISWAManager::ref().createISWACygnet(data); if(cygnet){ _iSWACygnets.push_back(cygnet); } } -void ISWAContainer::addISWACygnet(int id){ - +void ISWAContainer::addISWACygnet(int id, std::string data){ std::shared_ptr extFuture = ISWAManager::ref().fileExtension(id); + extFuture->parent = data; _extFutures.push_back(extFuture); } diff --git a/modules/iswa/rendering/iswacontainer.h b/modules/iswa/rendering/iswacontainer.h index 433ded12fb..fce1693a9a 100644 --- a/modules/iswa/rendering/iswacontainer.h +++ b/modules/iswa/rendering/iswacontainer.h @@ -45,7 +45,7 @@ public: virtual void update(const UpdateData& data) override; void addISWACygnet(std::string path); - void addISWACygnet(int id); + void addISWACygnet(int id, std::string data); void addISWACygnet(std::shared_ptr cygnet); void deleteCygnet(ISWACygnet* cygnet); diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index a1b74d0bfe..94d5844d05 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -28,19 +28,36 @@ #include #include - namespace openspace{ -ISWACygnet::ISWACygnet(int cygnetId, std::string path) +// ISWACygnet::ISWACygnet(int cygnetId, std::string path) +// : _enabled("enabled", "Is Enabled", true) +// , _updateInterval("updateInterval", "Update Interval", 3, 1, 10) +// , _delete("delete", "Delete") +// , _cygnetId(cygnetId) +// , _shader(nullptr) +// , _texture(nullptr) +// , _frame("GALACTIC") +// , _path(path) +// , _data(nullptr) +// { +// addProperty(_enabled); +// addProperty(_updateInterval); +// addProperty(_delete); + +// _delete.onChange([this](){ISWAManager::ref().deleteCygnet(name());}); +// } + +ISWACygnet::ISWACygnet(std::shared_ptr data) : _enabled("enabled", "Is Enabled", true) , _updateInterval("updateInterval", "Update Interval", 3, 1, 10) - ,_delete("delete", "Delete") - , _cygnetId(cygnetId) + , _delete("delete", "Delete") + // , _cygnetId(data->id) , _shader(nullptr) , _texture(nullptr) - , _frame("GALACTIC") - , _path(path) - ,_toDelete(false) + // , _frame(data->frame) + // , _path(data->path) + , _data(data) { addProperty(_enabled); addProperty(_updateInterval); @@ -51,23 +68,6 @@ ISWACygnet::ISWACygnet(int cygnetId, std::string path) ISWACygnet::~ISWACygnet(){} -bool ISWACygnet::initialize(){ - - setParent(); - return true; -} - -bool ISWACygnet::deinitialize(){ - OsEng.gui()._iSWAproperty.unregisterProperties(name()); - _parent = nullptr; - return true; -} - -void ISWACygnet::render(){ - -} - -void ISWACygnet::update(){} void ISWACygnet::setPscUniforms( ghoul::opengl::ProgramObject* program, @@ -81,11 +81,17 @@ void ISWACygnet::setPscUniforms( } void ISWACygnet::registerProperties(){ - OsEng.gui()._iSWAproperty.registerProperty(&_enabled); OsEng.gui()._iSWAproperty.registerProperty(&_updateInterval); OsEng.gui()._iSWAproperty.registerProperty(&_delete); +} +void ISWACygnet::unregisterProperties(){ + OsEng.gui()._iSWAproperty.unregisterProperties(name()); +} + +void ISWACygnet::setParent(){ + _parent = OsEng.renderEngine().scene()->sceneGraphNode(_data->parent); } }//namespace openspac \ No newline at end of file diff --git a/modules/iswa/rendering/iswacygnet.h b/modules/iswa/rendering/iswacygnet.h index 46c4e40969..2570ca1d30 100644 --- a/modules/iswa/rendering/iswacygnet.h +++ b/modules/iswa/rendering/iswacygnet.h @@ -40,26 +40,31 @@ #include #include #include +#include + namespace openspace{ class ISWACygnet : public properties::PropertyOwner{ public: - ISWACygnet(int cygnetId, std::string path); + // ISWACygnet(int cygnetId, std::string path); + ISWACygnet(std::shared_ptr data); ~ISWACygnet(); - virtual bool initialize(); - virtual bool deinitialize(); + virtual bool initialize() = 0; + virtual bool deinitialize() = 0; - virtual void render(); - virtual void update(); + virtual void render() = 0; + virtual void update() = 0; + virtual bool isReady() = 0; bool enabled(){return _enabled.value();} - virtual bool isReady() = 0; - + protected: void setPscUniforms(ghoul::opengl::ProgramObject* program, const Camera* camera, const PowerScaledCoordinate& position); - virtual void setParent() = 0; void registerProperties(); + void unregisterProperties(); + + void setParent(); properties::BoolProperty _enabled; properties::FloatProperty _updateInterval; @@ -68,26 +73,15 @@ protected: std::unique_ptr _shader; std::unique_ptr _texture; - SceneGraphNode* _parent; - glm::vec4 _pscOffset; - glm::vec4 _modelScale; + std::shared_ptr _data; - const int _cygnetId; + SceneGraphNode* _parent; glm::dmat3 _stateMatrix; - std::string _frame; - std::string _var; double _time; double _lastUpdateTime = 0; - std::map _month; - - std::string _fileExtension; - std::string _path; - float _openSpaceUpdateInterval; - bool _toDelete; - int _id; }; diff --git a/modules/iswa/rendering/screenspacecygnet.cpp b/modules/iswa/rendering/screenspacecygnet.cpp index 42b80f3f21..8d9435e0b3 100644 --- a/modules/iswa/rendering/screenspacecygnet.cpp +++ b/modules/iswa/rendering/screenspacecygnet.cpp @@ -35,10 +35,33 @@ namespace { namespace openspace { ScreenSpaceCygnet::ScreenSpaceCygnet(int cygnetId, std::string path) -: ScreenSpaceRenderable() -, _updateInterval("updateInterval", "Update Interval", 3, 1, 10) -, _cygnetId(cygnetId) -, _path(path) + : ScreenSpaceRenderable() + , _updateInterval("updateInterval", "Update Interval", 3, 1, 10) + , _cygnetId(cygnetId) + , _path(path) +{ + std::cout << "screenspacecygnet constructor 1" << std::endl; + _id = id(); + setName("ScreenSpaceCygnet" + std::to_string(_id)); + addProperty(_updateInterval); + + // registerProperties(); + OsEng.gui()._iSWAproperty.registerProperty(&_enabled); + OsEng.gui()._iSWAproperty.registerProperty(&_useFlatScreen); + OsEng.gui()._iSWAproperty.registerProperty(&_euclideanPosition); + OsEng.gui()._iSWAproperty.registerProperty(&_sphericalPosition); + OsEng.gui()._iSWAproperty.registerProperty(&_depth); + OsEng.gui()._iSWAproperty.registerProperty(&_scale); + OsEng.gui()._iSWAproperty.registerProperty(&_alpha); + OsEng.gui()._iSWAproperty.registerProperty(&_updateInterval); + OsEng.gui()._iSWAproperty.registerProperty(&_delete); +} + +ScreenSpaceCygnet::ScreenSpaceCygnet(std::shared_ptr data) + : ScreenSpaceRenderable() + , _updateInterval("updateInterval", "Update Interval", 3, 1, 10) + , _cygnetId(data->id) + , _path(data->path) { std::cout << "screenspacecygnet constructor 1" << std::endl; _id = id(); diff --git a/modules/iswa/rendering/screenspacecygnet.h b/modules/iswa/rendering/screenspacecygnet.h index 95733400fb..e0d573a3bb 100644 --- a/modules/iswa/rendering/screenspacecygnet.h +++ b/modules/iswa/rendering/screenspacecygnet.h @@ -27,12 +27,14 @@ #include #include +#include namespace openspace{ class ScreenSpaceCygnet : public ScreenSpaceRenderable { public: ScreenSpaceCygnet(int cygnetId, std::string path); + ScreenSpaceCygnet(std::shared_ptr data); ~ScreenSpaceCygnet(); void render() override; @@ -50,13 +52,14 @@ private: std::string _path; const int _cygnetId; - int _id; float _time; float _lastUpdateTime = 0.0f; + float _openSpaceUpdateInterval; + DownloadManager::FileFuture* _futureTexture; std::string _fileExtension; - - float _openSpaceUpdateInterval; + + int _id; }; } // namespace openspace diff --git a/modules/iswa/rendering/textureplane.cpp b/modules/iswa/rendering/textureplane.cpp index 9175c278fe..2046fe1e47 100644 --- a/modules/iswa/rendering/textureplane.cpp +++ b/modules/iswa/rendering/textureplane.cpp @@ -34,6 +34,7 @@ #include #include #include +#include namespace { const std::string _loggerCat = "TexutePlane"; @@ -41,8 +42,17 @@ namespace { namespace openspace { -TexturePlane::TexturePlane(int cygnetId, std::string path) - :CygnetPlane(cygnetId, path) +// TexturePlane::TexturePlane(int cygnetId, std::string path) +// :CygnetPlane(cygnetId, path) +// ,_futureTexture(nullptr) +// { +// _id = id(); +// setName("TexturePlane" + std::to_string(_id)); +// registerProperties(); +// } + +TexturePlane::TexturePlane(std::shared_ptr data) + :CygnetPlane(data) ,_futureTexture(nullptr) { _id = id(); @@ -51,35 +61,25 @@ TexturePlane::TexturePlane(int cygnetId, std::string path) } -TexturePlane::~TexturePlane(){ - -} +TexturePlane::~TexturePlane(){} bool TexturePlane::initialize(){ - _modelScale = glm::vec4(3, 3, 3, 10); - _pscOffset = glm::vec4(0, 0, 0, 1); - CygnetPlane::initialize(); + setParent(); + createPlane(); + createShader(); + updateTexture(); return isReady(); } bool TexturePlane::deinitialize(){ - CygnetPlane::deinitialize(); + _parent = nullptr; + unregisterProperties(); + destroyPlane(); + destroyShader(); - glDeleteVertexArrays(1, &_quad); - _quad = 0; - - glDeleteBuffers(1, &_vertexPositionBuffer); - _vertexPositionBuffer = 0; - - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_shader) { - renderEngine.removeRenderProgram(_shader); - _shader = nullptr; - } - - std::remove(absPath(_path).c_str()); + std::remove(absPath(_data->path).c_str()); return true; } @@ -133,7 +133,18 @@ void TexturePlane::update(){ if(_planeIsDirty) createPlane(); - CygnetPlane::update(); + _time = Time::ref().currentTime(); + _stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _data->frame, _time); + + _openSpaceUpdateInterval = Time::ref().deltaTime()*_updateInterval; + + if(_openSpaceUpdateInterval){ + if((_time-_lastUpdateTime) >= _openSpaceUpdateInterval){ + updateTexture(); + _lastUpdateTime = _time; + } + } + if(_futureTexture && _futureTexture->isFinished){ loadTexture(); @@ -142,12 +153,9 @@ void TexturePlane::update(){ } } -void TexturePlane::setParent(){ - _parent = OsEng.renderEngine().scene()->sceneGraphNode("Sun"); -} void TexturePlane::updateTexture(){ - DownloadManager::FileFuture* future = ISWAManager::ref().downloadImage(_cygnetId, absPath(_path)); + DownloadManager::FileFuture* future = ISWAManager::ref().downloadImage(_data->id, absPath(_data->path)); if(future){ _futureTexture = future; } @@ -155,10 +163,10 @@ void TexturePlane::updateTexture(){ void TexturePlane::loadTexture() { - std::unique_ptr texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_path)); + std::unique_ptr texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_data->path)); if (texture) { - LDEBUG("Loaded texture from '" << absPath(_path) << "'"); + LDEBUG("Loaded texture from '" << absPath(_data->path) << "'"); texture->uploadTexture(); // Textures of planets looks much smoother with AnisotropicMipMap rather than linear diff --git a/modules/iswa/rendering/textureplane.h b/modules/iswa/rendering/textureplane.h index e289607738..65e447e1a8 100644 --- a/modules/iswa/rendering/textureplane.h +++ b/modules/iswa/rendering/textureplane.h @@ -34,7 +34,8 @@ class TexturePlane : public CygnetPlane{ public: - TexturePlane(int cygnetId, std::string path); + // TexturePlane(int cygnetId, std::string path); + TexturePlane(std::shared_ptr data); ~TexturePlane(); virtual bool initialize(); @@ -44,7 +45,6 @@ virtual void update(); private: - virtual void setParent() override; virtual void loadTexture() override; virtual void updateTexture() override; diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index babd2ef5cc..efa72d8a32 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -56,47 +56,43 @@ namespace openspace{ std::stringstream ss(info); getline(ss,token,','); int cygnetId = std::stoi(token); - /* // std::cout << token << std::endl; + getline(ss,token,','); - std::string parent = token;*/ + std::string data = token; - //if(parent == "Earth" || parent == "Sun"){ - /*std::shared_ptr cygnet; - cygnet = std::make_shared(); - cygnet->initialize();*/ - // cygnet->cygnetId(cygnetId); - // cygnet->parent(parent); - //_container->addISWACygnet(cygnet); - _container->addISWACygnet(cygnetId); - - //}else{ - // OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared(cygnetId)); - - //} - // std::cout << token << std::endl; - // if(token = ""){ - // std::cout << "empty" << std::endl; - // } - - // std::shared_ptr cygnet; - // _container->addCygnet(cygnet); + if(cygnetId != 0) + _container->addISWACygnet(cygnetId, data); + else + _container->addISWACygnet("${OPENSPACE_DATA}/"+data); } - std::shared_ptr ISWAManager::createISWACygnet(int id, std::string path){ - std::cout << "createISWACygnet " << id << std::endl; - if(path != ""){ - const std::string& extension = ghoul::filesystem::File(absPath(path)).fileExtension(); + std::shared_ptr ISWAManager::createISWACygnet(std::shared_ptr metadata){ + std::cout << "createISWACygnet " << metadata->id << std::endl; + if(metadata->path != ""){ + const std::string& extension = ghoul::filesystem::File(absPath(metadata->path)).fileExtension(); std::shared_ptr cygnet; if(extension == "cdf"){ - std::shared_ptr kw = std::make_shared(absPath(path)); - cygnet = std::make_shared(kw, path); - } else if(id == 5) { - //check some other condition that id==5 (based on metadata maybe?) - OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared(id, path)); - return nullptr; - } else { - cygnet = std::make_shared(id, path); + std::shared_ptr kw = std::make_shared(absPath(metadata->path)); + + metadata->scale = kw->getModelScaleScaled(); + metadata->offset = kw->getModelBarycenterOffsetScaled(); + metadata->parent = kw->getParent(); + metadata->frame = kw->getFrame(); + + cygnet = std::make_shared(kw, metadata); + }else { + auto node = OsEng.renderEngine().scene()->sceneGraphNode(metadata->parent); + if(node){ + metadata->scale = glm::vec4(3, 3, 3, 10); + metadata->offset = glm::vec4(0, 0, 0, 1); + metadata->frame = "GALACTIC"; + + cygnet = std::make_shared(metadata); + }else{ + OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared(metadata)); + return nullptr; + } } cygnet->initialize(); diff --git a/modules/iswa/util/iswamanager.h b/modules/iswa/util/iswamanager.h index 2953b0fca3..7463798a41 100644 --- a/modules/iswa/util/iswamanager.h +++ b/modules/iswa/util/iswamanager.h @@ -28,16 +28,27 @@ #include #include #include +#include namespace openspace { class ISWACygnet; class ISWAContainer; struct ExtensionFuture { - std::string extension; bool isFinished; int id; + std::string parent; +}; + +struct Metadata { + int id; + std::string path; + std::string parent; + std::string frame; + glm::vec4 offset; + glm::vec4 scale; + std::string scaleVariable; }; @@ -50,6 +61,7 @@ public: ~ISWAManager(); std::shared_ptr createISWACygnet(int, std::string); + std::shared_ptr createISWACygnet(std::shared_ptr metadata); void addCygnet(std::string info); DownloadManager::FileFuture* downloadImage(int, std::string); diff --git a/modules/kameleon/include/kameleonwrapper.h b/modules/kameleon/include/kameleonwrapper.h index 673300dd24..c2ed631275 100644 --- a/modules/kameleon/include/kameleonwrapper.h +++ b/modules/kameleon/include/kameleonwrapper.h @@ -136,6 +136,8 @@ public: Model model(); GridType gridType(); + std::string getParent(); + std::string getFrame(); private: typedef std::vector TraceLine; diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index c3e7ab34ef..f2efa738fe 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -998,4 +998,40 @@ glm::vec4 KameleonWrapper::classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEn return color; } +std::string KameleonWrapper::getParent(){ + if( _type == KameleonWrapper::Model::BATSRUS || + _type == KameleonWrapper::Model::OpenGGCM || + _type == KameleonWrapper::Model::LFM) + { + return "Earth"; + }else if( + _type == KameleonWrapper::Model::ENLIL || + _type == KameleonWrapper::Model::MAS || + _type == KameleonWrapper::Model::Adapt3D || + _type == KameleonWrapper::Model::SWMF) + { + return "SolarSystem"; + }else{ + return ""; + } +} + +std::string KameleonWrapper::getFrame(){ + if( _type == KameleonWrapper::Model::BATSRUS || + _type == KameleonWrapper::Model::OpenGGCM || + _type == KameleonWrapper::Model::LFM) + { + return "GSM"; + }else if( + _type == KameleonWrapper::Model::ENLIL || + _type == KameleonWrapper::Model::MAS || + _type == KameleonWrapper::Model::Adapt3D || + _type == KameleonWrapper::Model::SWMF) + { + return "GALACTIC"; + }else{ + return ""; + } +} + } // namespace openspace diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index e27e47d924..4fe02d86b0 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -78,12 +78,6 @@ ScreenSpaceRenderable::ScreenSpaceRenderable() ScreenSpaceRenderable::~ScreenSpaceRenderable(){} - -//deinitialzie(){ - // unregisterProperies -// } - - bool ScreenSpaceRenderable::isEnabled() const { return _enabled; } From a3266dfcc5edadb0d5fa2c48f448b813fe3726b1 Mon Sep 17 00:00:00 2001 From: Michael Nilsson Date: Tue, 5 Apr 2016 11:57:55 -0400 Subject: [PATCH 7/7] small addition to solving conflict --- modules/iswa/rendering/textureplane.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/iswa/rendering/textureplane.cpp b/modules/iswa/rendering/textureplane.cpp index d181100d96..0779822963 100644 --- a/modules/iswa/rendering/textureplane.cpp +++ b/modules/iswa/rendering/textureplane.cpp @@ -154,7 +154,7 @@ void TexturePlane::update(){ void TexturePlane::updateTexture(){ - std::shared_ptr future = ISWAManager::ref().downloadImage(_data->id, absPath(_path)); + std::shared_ptr future = ISWAManager::ref().downloadImage(_data->id, absPath(_data->path)); if(future){ _futureTexture = future; }