From 97cbf977c551f8b2d6aa7ecbfb1a65773f3b882b Mon Sep 17 00:00:00 2001 From: Anton Arbring Date: Tue, 21 Apr 2015 20:31:33 -0400 Subject: [PATCH] Added body string to renderable to be able to search for target in scenegraph --- include/openspace/rendering/renderable.h | 7 +++++++ src/rendering/planets/renderableplanet.cpp | 4 ++-- .../planets/renderableplanetprojection.cpp | 5 +++-- src/rendering/renderable.cpp | 21 ++++++++++++++++++- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index 99d9fed3d8..1149c247a8 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -69,8 +69,13 @@ public: virtual void update(const UpdateData& data); bool isVisible() const; + bool hasTimeInterval(); bool getInterval(double& start, double& end); + + bool hasBody(); + bool getBody(std::string& body); + void setBody(std::string& body); protected: std::string findPath(const std::string& path); @@ -83,6 +88,8 @@ private: std::string _relativePath; std::string _startTime; std::string _endTime; + std::string _targetBody; + bool _hasBody; bool _hasTimeInterval; }; diff --git a/src/rendering/planets/renderableplanet.cpp b/src/rendering/planets/renderableplanet.cpp index 817cf1acd4..a9e8bc2fb5 100644 --- a/src/rendering/planets/renderableplanet.cpp +++ b/src/rendering/planets/renderableplanet.cpp @@ -84,9 +84,9 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) } dictionary.getValue(keyFrame, _frame); - dictionary.getValue(keyBody, _target); - //assert(b1 == true); + if (_target != "") + setBody(_target); // TODO: textures need to be replaced by a good system similar to the geometry as soon // as the requirements are fixed (ab) diff --git a/src/rendering/planets/renderableplanetprojection.cpp b/src/rendering/planets/renderableplanetprojection.cpp index 9a59b4b612..f9fddf98c6 100644 --- a/src/rendering/planets/renderableplanetprojection.cpp +++ b/src/rendering/planets/renderableplanetprojection.cpp @@ -105,9 +105,10 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& _geometry = planetgeometryprojection::PlanetGeometryProjection::createFromDictionary(geometryDictionary); } - dictionary.getValue(keyBody, _target); dictionary.getValue(keyFrame, _frame); - + dictionary.getValue(keyBody, _target); + if (_target != "") + setBody(_target); bool b1 = dictionary.getValue(keyInstrument, _instrumentID); bool b2 = dictionary.getValue(keyProjObserver, _projectorID); diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 3ed7ed06f0..e11ed1052c 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -74,7 +74,8 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary) : _enabled("enabled", "Is Enabled", true), _hasTimeInterval(false), _startTime(""), - _endTime("") + _endTime(""), + _targetBody("") { setName("renderable"); #ifndef NDEBUG @@ -152,6 +153,10 @@ bool Renderable::hasTimeInterval() { return _hasTimeInterval; } +bool Renderable::hasBody() { + return _hasBody; +} + bool Renderable::getInterval(double& start, double& end) { if (_startTime != "" && _endTime != "") { bool successStart = openspace::SpiceManager::ref().getETfromDate(_startTime, start); @@ -162,6 +167,20 @@ bool Renderable::getInterval(double& start, double& end) { return false; } +bool Renderable::getBody(std::string& body) { + if (_hasBody) { + body = _targetBody; + return true; + } + else + return false; +} + +void Renderable::setBody(std::string& body) { + _targetBody = body; + _hasBody = true; +} + bool Renderable::isReady() const { return true; }