diff --git a/include/openspace/properties/propertyowner.h b/include/openspace/properties/propertyowner.h index e30e280994..6211c877b4 100644 --- a/include/openspace/properties/propertyowner.h +++ b/include/openspace/properties/propertyowner.h @@ -35,9 +35,11 @@ namespace properties { class PropertyOwner { public: + PropertyOwner(); virtual ~PropertyOwner(); - virtual const std::string& name() const = 0; + void setName(std::string name); + virtual const std::string& name() const; const std::vector& properties() const; Property* property(const std::string& id) const; @@ -52,6 +54,7 @@ protected: void removeProperty(Property& prop); private: + std::string _name; std::vector _properties; std::map _groupNames; }; diff --git a/include/openspace/rendering/planets/planetgeometry.h b/include/openspace/rendering/planets/planetgeometry.h new file mode 100644 index 0000000000..9e0735a929 --- /dev/null +++ b/include/openspace/rendering/planets/planetgeometry.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * 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 __PLANETGEOMETRY_H__ +#define __PLANETGEOMETRY_H__ + +#include +#include +#include + +namespace openspace { + +namespace planetgeometry { + +class PlanetGeometry : public properties::PropertyOwner { +public: + static PlanetGeometry* createFromDictionary(const ghoul::Dictionary& dictionary); + + PlanetGeometry(); + virtual ~PlanetGeometry(); + virtual void initialize(RenderablePlanet* parent); + virtual void deinitialize(); + virtual void render() = 0; + +protected: + RenderablePlanet* _parent; +}; + +} // namespace planetgeometry +} // namespace openspace + +#endif // __PLANETGEOMETRY_H__ diff --git a/include/openspace/rendering/planets/renderableplanet.h b/include/openspace/rendering/planets/renderableplanet.h index e2f531deaa..4b147b98bc 100644 --- a/include/openspace/rendering/planets/renderableplanet.h +++ b/include/openspace/rendering/planets/renderableplanet.h @@ -27,10 +27,8 @@ // open space includes #include -#include -#include + #include -#include // ghoul includes #include @@ -38,6 +36,10 @@ namespace openspace { +namespace planetgeometry { +class PlanetGeometry; +} + class RenderablePlanet : public Renderable { public: RenderablePlanet(const ghoul::Dictionary& dictionary); @@ -53,17 +55,14 @@ public: void update() override; protected: - void createSphere(); void loadTexture(); private: - properties::Vec2Property _radius; - properties::IntProperty _segments; properties::StringProperty _colorTexturePath; ghoul::opengl::ProgramObject* _programObject; ghoul::opengl::Texture* _texture; - PowerScaledSphere* _planet; + planetgeometry::PlanetGeometry* _geometry; }; } // namespace openspace diff --git a/include/openspace/rendering/planets/simplespheregeometry.h b/include/openspace/rendering/planets/simplespheregeometry.h new file mode 100644 index 0000000000..3e7199e36c --- /dev/null +++ b/include/openspace/rendering/planets/simplespheregeometry.h @@ -0,0 +1,61 @@ +/***************************************************************************************** +* * +* 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 __SIMPLESPHEREGEOMETRY_H__ +#define __SIMPLESPHEREGEOMETRY_H__ + +#include +#include +#include +#include + +namespace openspace { + +class RenderablePlanet; + +namespace planetgeometry { + +class SimpleSphereGeometry : public PlanetGeometry { +public: + SimpleSphereGeometry(const ghoul::Dictionary& dictionary); + ~SimpleSphereGeometry(); + + + void initialize(RenderablePlanet* parent) override; + void deinitialize() override; + void render() override; + +private: + void createSphere(); + + properties::Vec2Property _radius; + properties::IntProperty _segments; + + PowerScaledSphere* _planet; +}; + +} // namespace planetgeometry +} // namespace openspace + +#endif // __SIMPLESPHEREGEOMETRY_H__ diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index 782c907f97..fe4e2abca1 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -42,9 +42,6 @@ public: Renderable(const ghoul::Dictionary& dictionary); virtual ~Renderable(); - void setName(std::string name); - const std::string& name() const override; - virtual bool initialize() = 0; virtual bool deinitialize() = 0; @@ -57,8 +54,6 @@ public: protected: // Renderable(); private: - std::string _name; - pss boundingSphere_; }; diff --git a/include/openspace/util/constants.h b/include/openspace/util/constants.h index af92c53337..5327fb8357 100644 --- a/include/openspace/util/constants.h +++ b/include/openspace/util/constants.h @@ -55,9 +55,19 @@ namespace renderable { const std::string keyType = "Type"; } // namespace renderable +namespace renderableplanet { + const std::string keyGeometry = "Geometry"; +} // namespace renderableplanet + +namespace planetgeometry { + const std::string keyType = "Type"; +} // namespace planetgeometry + + + namespace ephemeris { const std::string keyType = "Type"; -} +} // namespace ephemeris } // namespace constants } // namespace openspace diff --git a/include/openspace/util/factorymanager.h b/include/openspace/util/factorymanager.h index f19f4c921f..333319f43d 100644 --- a/include/openspace/util/factorymanager.h +++ b/include/openspace/util/factorymanager.h @@ -29,9 +29,6 @@ #include #include -#include -#include - namespace openspace { class FactoryManager { @@ -54,7 +51,7 @@ public: void addFactory(ghoul::TemplateFactoryBase* factory); template - ghoul::TemplateFactory* factory(); + ghoul::TemplateFactory* factory() const; private: FactoryManager(); diff --git a/include/openspace/util/factorymanager.inl b/include/openspace/util/factorymanager.inl index d8da706d1d..6d25abd9f7 100644 --- a/include/openspace/util/factorymanager.inl +++ b/include/openspace/util/factorymanager.inl @@ -25,7 +25,7 @@ namespace openspace { template -ghoul::TemplateFactory* FactoryManager::factory() +ghoul::TemplateFactory* FactoryManager::factory() const { for (ghoul::TemplateFactoryBase* factory : _factories) { if (factory->baseClassType() == typeid(T)) diff --git a/src/properties/propertyowner.cpp b/src/properties/propertyowner.cpp index e2af6ebc19..19dc8bd1cc 100644 --- a/src/properties/propertyowner.cpp +++ b/src/properties/propertyowner.cpp @@ -31,20 +31,31 @@ namespace openspace { namespace properties { namespace { - const std::string _loggerCat = "PropertyOwner"; +const std::string _loggerCat = "PropertyOwner"; - bool propertyLess(Property* lhs, Property* rhs) { - return lhs->identifier() < rhs->identifier(); - } +bool propertyLess(Property* lhs, Property* rhs) +{ + return lhs->identifier() < rhs->identifier(); +} } -PropertyOwner::~PropertyOwner() {} +PropertyOwner::PropertyOwner() + : _name("") +{ -const std::vector& PropertyOwner::properties() const { +} + +PropertyOwner::~PropertyOwner() +{ +} + +const std::vector& PropertyOwner::properties() const +{ return _properties; } -Property* PropertyOwner::property(const std::string& id) const { +Property* PropertyOwner::property(const std::string& id) const +{ assert(std::is_sorted(_properties.begin(), _properties.end(), propertyLess)); std::vector::const_iterator it @@ -59,11 +70,13 @@ Property* PropertyOwner::property(const std::string& id) const { return *it; } -void PropertyOwner::setPropertyGroupName(std::string groupID, std::string name) { +void PropertyOwner::setPropertyGroupName(std::string groupID, std::string name) +{ _groupNames[std::move(groupID)] = std::move(name); } -const std::string& PropertyOwner::propertyGroupName(const std::string& groupID) const { +const std::string& PropertyOwner::propertyGroupName(const std::string& groupID) const +{ auto it = _groupNames.find(groupID); if (it == _groupNames.end()) return groupID; @@ -71,7 +84,8 @@ const std::string& PropertyOwner::propertyGroupName(const std::string& groupID) return it->second; } -void PropertyOwner::addProperty(Property* prop) { +void PropertyOwner::addProperty(Property* prop) +{ assert(prop != nullptr); assert(std::is_sorted(_properties.begin(), _properties.end(), propertyLess)); @@ -82,51 +96,62 @@ void PropertyOwner::addProperty(Property* prop) { // See if we can find the identifier of the property to add in the properties list std::vector::iterator it - = std::lower_bound(_properties.begin(), _properties.end(), prop->identifier(), - [](Property* prop, const std::string& str) { - return prop->identifier() < str; - }); + = std::lower_bound(_properties.begin(), _properties.end(), prop->identifier(), + [](Property* prop, const std::string& str) { + return prop->identifier() < str; + }); // If we found the property identifier, we need to bail out if (it != _properties.end() && (*it)->identifier() == prop->identifier()) { LERROR("Property identifier '" << prop->identifier() << "' already present in PropertyOwner"); return; - } - else { + } else { // Otherwise we have found the correct position to add it in _properties.insert(it, prop); prop->setPropertyOwner(this); } } -void PropertyOwner::addProperty(Property& prop) { +void PropertyOwner::addProperty(Property& prop) +{ addProperty(&prop); } -void PropertyOwner::removeProperty(Property* prop) { +void PropertyOwner::removeProperty(Property* prop) +{ assert(prop != nullptr); // See if we can find the identifier of the property to add in the properties list std::vector::iterator it - = std::lower_bound(_properties.begin(), _properties.end(), prop->identifier(), - [](Property* prop, const std::string& str) { - return prop->identifier() < str; - }); + = std::lower_bound(_properties.begin(), _properties.end(), prop->identifier(), + [](Property* prop, const std::string& str) { + return prop->identifier() < str; + }); // If we found the property identifier, we can delete it if (it != _properties.end() && (*it)->identifier() == prop->identifier()) { (*it)->setPropertyOwner(nullptr); _properties.erase(it); - } - else + } else LERROR("Property with identifier '" << prop->identifier() << "' not found for removal."); } -void PropertyOwner::removeProperty(Property& prop) { +void PropertyOwner::removeProperty(Property& prop) +{ removeProperty(&prop); } +void PropertyOwner::setName(std::string name) +{ + _name = std::move(name); +} + +const std::string& PropertyOwner::name() const +{ + return _name; +} + } // namespace properties } // namespace openspace diff --git a/src/rendering/planets/planetgeometry.cpp b/src/rendering/planets/planetgeometry.cpp new file mode 100644 index 0000000000..20cf4860b6 --- /dev/null +++ b/src/rendering/planets/planetgeometry.cpp @@ -0,0 +1,81 @@ +/***************************************************************************************** + * * + * 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. * + ****************************************************************************************/ + +#include +#include +#include +#include + +namespace { +const std::string _loggerCat = "PlanetGeometry"; +} + +namespace openspace { +namespace planetgeometry { + +PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) +{ + std::string name; + dictionary.getValue(constants::scenegraphnode::keyName, name); + + if (!dictionary.hasValue(constants::planetgeometry::keyType)) { + LERROR("PlanetGeometry for '" << name << "' did not contain a '" + << constants::planetgeometry::keyType << "' key"); + return nullptr; + } + std::string geometryType; + dictionary.getValue(constants::planetgeometry::keyType, geometryType); + + ghoul::TemplateFactory* factory + = FactoryManager::ref().factory(); + + PlanetGeometry* result = factory->create(geometryType, dictionary); + if (result == nullptr) { + LERROR("Failed to create a PlanetGeometry object of type '" << geometryType + << "'"); + return nullptr; + } + return result; +} + +PlanetGeometry::PlanetGeometry() + : _parent(nullptr) +{ +} + +PlanetGeometry::~PlanetGeometry() +{ +} + +void PlanetGeometry::initialize(RenderablePlanet* parent) +{ + _parent = parent; +} + +void PlanetGeometry::deinitialize() +{ +} + +} // namespace planetgeometry +} // namespace openspace diff --git a/src/rendering/planets/renderableplanet.cpp b/src/rendering/planets/renderableplanet.cpp index 7770190b83..896ae83572 100644 --- a/src/rendering/planets/renderableplanet.cpp +++ b/src/rendering/planets/renderableplanet.cpp @@ -25,6 +25,7 @@ // open space includes #include #include +#include #include #include @@ -33,43 +34,32 @@ #include namespace { - std::string _loggerCat = "RenderablePlanet"; + const std::string _loggerCat = "RenderablePlanet"; } namespace openspace { RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _radius("radius", "Radius", glm::vec2(1.f, 0.f), glm::vec2(-10.f, -20.f), - glm::vec2(10.f, 20.f)) - , _segments("segments", "Segments", 20, 1, 1000) , _colorTexturePath("colorTexture", "Color Texture") , _programObject(nullptr) , _texture(nullptr) - , _planet(nullptr) + //, _planet(nullptr) + , _geometry(nullptr) { - double value = 1.0f, exponent = 0.0f; - int segments = 20; + std::string path; + dictionary.getValue(constants::scenegraph::keyPathModule, path); - if (dictionary.hasKey("Geometry.Radius.1")) - dictionary.getValue("Geometry.Radius.1", value); + if (dictionary.hasKey(constants::renderableplanet::keyGeometry)) { + ghoul::Dictionary geometryDictionary; + dictionary.getValue(constants::renderableplanet::keyGeometry, geometryDictionary); + geometryDictionary.setValue(constants::scenegraph::keyPathModule, path); + geometryDictionary.setValue(constants::scenegraphnode::keyName, name()); - if (dictionary.hasKey("Geometry.Radius.2")) - dictionary.getValue("Geometry.Radius.2", exponent); - - _radius = glm::vec2(value, exponent); - - if (dictionary.hasKey("Geometry.Segments")) - dictionary.getValue("Geometry.Segments", segments); - - _segments = segments; - - // get path if available - std::string path = ""; - if (dictionary.hasKey(constants::scenegraph::keyPathModule)) { - dictionary.getValue(constants::scenegraph::keyPathModule, path); - path += "/"; + _geometry + = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary); } + path += "/"; std::string texturePath = ""; if (dictionary.hasKey("Textures.Color")) @@ -77,16 +67,13 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) _colorTexturePath = path + texturePath; + for (properties::Property* p : _geometry->properties()) + addProperty(p); - addProperty(_radius); - _radius.onChange(std::bind(&RenderablePlanet::createSphere, this)); - addProperty(_segments); - _segments.onChange(std::bind(&RenderablePlanet::createSphere, this)); + //addProperty(_colorTexturePath); + //_colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this)); - addProperty(_colorTexturePath); - _colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this)); - - createSphere(); + //createSphere(); } RenderablePlanet::~RenderablePlanet() { @@ -101,14 +88,17 @@ bool RenderablePlanet::initialize() { loadTexture(); completeSuccess &= (_texture != nullptr); - _planet->initialize(); + _geometry->initialize(this); return completeSuccess; } bool RenderablePlanet::deinitialize() { - delete _planet; + _geometry->deinitialize(); + delete _geometry; + _geometry = nullptr; delete _texture; + _texture = nullptr; return true; } @@ -155,26 +145,13 @@ void RenderablePlanet::render(const Camera *camera, const psc &thisPosition) { _programObject->setUniform("texture1", 0); // render - _planet->render(); + _geometry->render(); // disable shader _programObject->deactivate(); - } void RenderablePlanet::update() { - -} - -void RenderablePlanet::createSphere() { - // create the power scaled scalar - - pss planetSize(_radius); - setBoundingSphere(planetSize); - - delete _planet; - _planet = new PowerScaledSphere(planetSize, _segments); - _planet->initialize(); } void RenderablePlanet::loadTexture() { diff --git a/src/rendering/planets/simplespheregeometry.cpp b/src/rendering/planets/simplespheregeometry.cpp new file mode 100644 index 0000000000..140e854e24 --- /dev/null +++ b/src/rendering/planets/simplespheregeometry.cpp @@ -0,0 +1,118 @@ +/***************************************************************************************** +* * +* 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. * +****************************************************************************************/ + +#include +#include + +namespace { + const std::string _loggerCat = "SimpleSphereGeometry"; +} + +namespace openspace { + +namespace constants { +namespace simplespheregeometry { +const std::string keyRadius = "Radius"; +const std::string keySegments = "Segments"; +} // namespace simplespheregeometry +} + +namespace planetgeometry { + +SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary) + : PlanetGeometry() + , _radius("radius", "Radius", glm::vec2(1.f, 0.f), glm::vec2(-10.f, -20.f), + glm::vec2(10.f, 20.f)) + , _segments("segments", "Segments", 20, 1, 1000) + , _planet(nullptr) +{ + if (!dictionary.hasValue(constants::simplespheregeometry::keyRadius)) { + std::string name; + dictionary.getValue(constants::scenegraphnode::keyName, name); + LERROR("SimpleSphereGeometry of '" << name << "' did not provide a key '" + << constants::simplespheregeometry::keyRadius + << "'"); + } + else { + glm::vec2 radius; + dictionary.getValue(constants::simplespheregeometry::keyRadius, radius); + _radius = radius; + } + + if (!dictionary.hasValue(constants::simplespheregeometry::keySegments)) { + std::string name; + dictionary.getValue(constants::scenegraphnode::keyName, name); + LERROR("SimpleSphereGeometry of '" << name << "' did not provide a key '" + << constants::simplespheregeometry::keySegments + << "'"); + } + else { + float segments; + dictionary.getValue(constants::simplespheregeometry::keySegments, segments); + _segments = static_cast(segments); + } + + addProperty(_radius); + _radius.onChange(std::bind(&SimpleSphereGeometry::createSphere, this)); + addProperty(_segments); + _segments.onChange(std::bind(&SimpleSphereGeometry::createSphere, this)); + + //createSphere(); +} + +SimpleSphereGeometry::~SimpleSphereGeometry() +{ +} + +void SimpleSphereGeometry::initialize(RenderablePlanet* parent) +{ + PlanetGeometry::initialize(parent); + createSphere(); +} + +void SimpleSphereGeometry::deinitialize() +{ + delete _planet; + _planet = nullptr; +} + +void SimpleSphereGeometry::render() +{ + _planet->render(); +} + +void SimpleSphereGeometry::createSphere() +{ + //create the power scaled scalar + + pss planetSize(_radius); + _parent->setBoundingSphere(planetSize); + + delete _planet; + _planet = new PowerScaledSphere(planetSize, _segments); + _planet->initialize(); +} + +} // namespace planetgeometry +} // namespace openspace diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 2c99067315..f0c8cf2a99 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -33,10 +33,6 @@ const std::string _loggerCat = "Renderable"; namespace openspace { -//Renderable::Renderable() -// : _name("") -//{} - Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary) { std::string name; @@ -53,7 +49,7 @@ Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary = FactoryManager::ref().factory(); Renderable* result = factory->create(renderableType, dictionary); if (result == nullptr) { - LERROR("Failed creating Renderable object of type '" << renderableType << "'"); + LERROR("Failed to create a Renderable object of type '" << renderableType << "'"); return nullptr; } @@ -63,22 +59,14 @@ Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary } Renderable::Renderable(const ghoul::Dictionary& dictionary) - : _name("") { + std::string name; + dictionary.getValue(constants::scenegraphnode::keyName, name); + setName(name); } -Renderable::~Renderable() { - -} - -void Renderable::setName(std::string name) +Renderable::~Renderable() { - _name = std::move(name); -} - -const std::string& Renderable::name() const -{ - return _name; } void Renderable::setBoundingSphere(const pss& boundingSphere) @@ -95,4 +83,4 @@ void Renderable::update() { } -} // namespace openspace \ No newline at end of file +} // namespace openspace \ No newline at end of file diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp index bb89ecbde2..46561078dc 100644 --- a/src/util/factorymanager.cpp +++ b/src/util/factorymanager.cpp @@ -37,6 +37,8 @@ #include #include +#include + namespace openspace { FactoryManager* FactoryManager::_manager = nullptr; @@ -66,7 +68,10 @@ void FactoryManager::initialize() _manager->factory()->registerClass("Static"); _manager->factory()->registerClass("Spice"); - + // Add PlanetGeometry + _manager->addFactory(new ghoul::TemplateFactory); + _manager->factory() + ->registerClass("SimpleSphere"); } void FactoryManager::deinitialize()