mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-07 03:49:43 -05:00
Require renderables to derive from PropertyOwner and use dictionary-constructor
This commit is contained in:
@@ -1,5 +1,29 @@
|
||||
#ifndef RENDERABLE_H
|
||||
#define RENDERABLE_H
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __RENDERABLE_H__
|
||||
#define __RENDERABLE_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/util/psc.h>
|
||||
@@ -15,7 +39,10 @@ public:
|
||||
// constructors & destructor
|
||||
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;
|
||||
|
||||
@@ -25,12 +52,14 @@ public:
|
||||
virtual void render(const Camera *camera, const psc &thisPosition) = 0;
|
||||
virtual void update();
|
||||
protected:
|
||||
Renderable();
|
||||
//Renderable();
|
||||
private:
|
||||
pss boundingSphere_;
|
||||
std::string _name;
|
||||
|
||||
pss boundingSphere_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
#endif // __RENDERABLE_H__
|
||||
@@ -1,5 +1,29 @@
|
||||
#ifndef RENDERABLEPLANET_H
|
||||
#define RENDERABLEPLANET_H
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __RENDERABLEPLANET_H__
|
||||
#define __RENDERABLEPLANET_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
@@ -18,9 +42,6 @@ public:
|
||||
RenderablePlanet(const ghoul::Dictionary& dictionary);
|
||||
~RenderablePlanet();
|
||||
|
||||
void setName(std::string name);
|
||||
const std::string& name() const override;
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
|
||||
@@ -31,8 +52,6 @@ public:
|
||||
virtual void update();
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
|
||||
// shader
|
||||
ghoul::opengl::ProgramObject* _programObject;
|
||||
|
||||
@@ -46,4 +65,4 @@ private:
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
#endif // __RENDERABLEPLANET_H__
|
||||
@@ -25,35 +25,4 @@
|
||||
#ifndef SCENEGRAPHNODE_INL
|
||||
#define SCENEGRAPHNODE_INL
|
||||
|
||||
#include <openspace/util/factorymanager.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
template <class T>
|
||||
bool safeCreationWithDictionary(T** object, const std::string& key,
|
||||
ghoul::Dictionary* dictionary,
|
||||
const std::string& path = "") {
|
||||
if (dictionary->hasKey(key)) {
|
||||
ghoul::Dictionary tmpDictionary;
|
||||
if (dictionary->getValue(key, tmpDictionary)) {
|
||||
if (!tmpDictionary.hasKey("Path") && path != "") {
|
||||
tmpDictionary.setValue("Path", path);
|
||||
}
|
||||
std::string renderableType;
|
||||
if (tmpDictionary.getValue("Type", renderableType)) {
|
||||
ghoul::TemplateFactory<T>* factory
|
||||
= FactoryManager::ref().factoryByType<T>();
|
||||
T* tmp = factory->create(renderableType, tmpDictionary);
|
||||
if (tmp != nullptr) {
|
||||
*object = tmp;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
+10
-10
@@ -25,16 +25,16 @@ namespace {
|
||||
namespace openspace {
|
||||
using namespace osp;
|
||||
|
||||
Flare::Flare() {
|
||||
_leftMouseButton = false;
|
||||
_currentMouseX = 0;
|
||||
_currentMouseY = 0;
|
||||
_lastMouseX = 0;
|
||||
_lastMouseY = 0;
|
||||
_oldTime = 0.f;
|
||||
_currentTime = 0.f;
|
||||
|
||||
}
|
||||
Flare::Flare()
|
||||
: Renderable(ghoul::Dictionary())
|
||||
, _leftMouseButton(false)
|
||||
, _currentMouseX(0)
|
||||
, _currentMouseY(0)
|
||||
, _lastMouseX(0)
|
||||
, _lastMouseY(0)
|
||||
, _oldTime(0.f)
|
||||
, _currentTime(0.f)
|
||||
{}
|
||||
|
||||
Flare::~Flare() {
|
||||
// Clean up like a good citizen
|
||||
|
||||
@@ -1,28 +1,67 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Renderable::Renderable() {}
|
||||
|
||||
Renderable::Renderable(const ghoul::Dictionary& dictionary) {}
|
||||
|
||||
//Renderable::Renderable()
|
||||
// : _name("")
|
||||
//{}
|
||||
|
||||
Renderable::Renderable(const ghoul::Dictionary& dictionary)
|
||||
: _name("")
|
||||
{
|
||||
}
|
||||
|
||||
Renderable::~Renderable() {
|
||||
|
||||
}
|
||||
|
||||
void Renderable::setBoundingSphere(const pss &boundingSphere) {
|
||||
boundingSphere_ = boundingSphere;
|
||||
void Renderable::setName(std::string name)
|
||||
{
|
||||
_name = std::move(name);
|
||||
}
|
||||
|
||||
const pss& Renderable::getBoundingSphere() {
|
||||
return boundingSphere_;
|
||||
const std::string& Renderable::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void Renderable::update() {
|
||||
void Renderable::setBoundingSphere(const pss& boundingSphere)
|
||||
{
|
||||
boundingSphere_ = boundingSphere;
|
||||
}
|
||||
|
||||
const pss& Renderable::getBoundingSphere()
|
||||
{
|
||||
return boundingSphere_;
|
||||
}
|
||||
|
||||
void Renderable::update()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
@@ -1,3 +1,26 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderableplanet.h>
|
||||
@@ -14,10 +37,12 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary): _programObject(nullptr),
|
||||
_texturePath(""),
|
||||
_texture(nullptr),
|
||||
_planet(nullptr)
|
||||
RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _programObject(nullptr)
|
||||
, _texturePath("")
|
||||
, _texture(nullptr)
|
||||
, _planet(nullptr)
|
||||
{
|
||||
double value = 1.0f, exponent = 0.0f;
|
||||
double segments = 20.0;
|
||||
@@ -142,14 +167,4 @@ void RenderablePlanet::update() {
|
||||
|
||||
}
|
||||
|
||||
void RenderablePlanet::setName(std::string name) {
|
||||
_name = std::move(name);
|
||||
}
|
||||
|
||||
const std::string& RenderablePlanet::name() const {
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -72,8 +72,9 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
RenderableVolume::RenderableVolume(const ghoul::Dictionary& dictionary) {
|
||||
|
||||
RenderableVolume::RenderableVolume(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
{
|
||||
// get path if available
|
||||
_relativePath = "";
|
||||
if(dictionary.hasKey("Path")) {
|
||||
|
||||
@@ -36,16 +36,45 @@
|
||||
|
||||
#include <openspace/scenegraph/constantpositioninformation.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
|
||||
namespace {
|
||||
std::string _loggerCat = "SceneGraphNode";
|
||||
const std::string _loggerCat = "SceneGraphNode";
|
||||
|
||||
const std::string _unnamedSceneGraphNodeName = "Unnamed";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
template <class T>
|
||||
bool safeCreationWithDictionary(T** object, const std::string& key,
|
||||
ghoul::Dictionary* dictionary,
|
||||
const std::string& path = "") {
|
||||
if (dictionary->hasKey(key)) {
|
||||
ghoul::Dictionary tmpDictionary;
|
||||
if (dictionary->getValue(key, tmpDictionary)) {
|
||||
if (!tmpDictionary.hasKey("Path") && path != "") {
|
||||
tmpDictionary.setValue("Path", path);
|
||||
}
|
||||
std::string renderableType;
|
||||
if (tmpDictionary.getValue("Type", renderableType)) {
|
||||
ghoul::TemplateFactory<T>* factory
|
||||
= FactoryManager::ref().factoryByType<T>();
|
||||
T* tmp = factory->create(renderableType, tmpDictionary);
|
||||
if (tmp != nullptr) {
|
||||
*object = tmp;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SceneGraphNode::SceneGraphNode(const ghoul::Dictionary& dictionary)
|
||||
: _parent(nullptr)
|
||||
, _nodeName("Unnamed OpenSpace SceneGraphNode")
|
||||
, _nodeName(_unnamedSceneGraphNodeName)
|
||||
, _position(nullptr)
|
||||
, _renderable(nullptr)
|
||||
, _renderableVisible(false)
|
||||
@@ -63,6 +92,7 @@ SceneGraphNode::SceneGraphNode(const ghoul::Dictionary& dictionary)
|
||||
if (safeCreationWithDictionary<Renderable>(&_renderable, "Renderable",
|
||||
&localDictionary, path)) {
|
||||
LDEBUG(_nodeName << ": Successful creation of renderable!");
|
||||
_renderable->setName(_nodeName);
|
||||
} else {
|
||||
LDEBUG(_nodeName << ": Failed to create renderable!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user