Add scale as a property of every scenegraph node.

This commit is contained in:
Kalle Bladin
2016-08-26 20:32:08 -04:00
parent 99cfc4453f
commit a82ad66374
4 changed files with 15 additions and 7 deletions

View File

@@ -27,10 +27,11 @@
#include <ghoul/misc/dictionary.h>
#include <openspace/util/updatestructures.h>
#include <openspace/properties/propertyowner.h>
namespace openspace {
class Scale {
class Scale : public properties::PropertyOwner {
public:
static Scale* createFromDictionary(const ghoul::Dictionary& dictionary);

View File

@@ -25,24 +25,28 @@
#include <modules/base/scale/staticscale.h>
namespace {
const std::string _loggerCat = "StaticScale";
const std::string KeyValue = "Scale";
}
namespace openspace {
StaticScale::StaticScale(const ghoul::Dictionary& dictionary)
: _scaleValue(1.0)
: _scaleValue("scale", "Scale", 1.0, 1.0, 1000.0)
{
const bool hasValue = dictionary.hasKeyAndValue<glm::vec3>(KeyValue);
if (hasValue) {
dictionary.getValue(KeyValue, _scaleValue);
float value;
dictionary.getValue(KeyValue, value);
_scaleValue.setValue(value);
}
Scale::addProperty(_scaleValue);
}
StaticScale::~StaticScale() {}
double StaticScale::scaleValue() const {
return _scaleValue;
return _scaleValue.value();
}
void StaticScale::update(const UpdateData&) {}

View File

@@ -31,13 +31,13 @@ namespace openspace {
class StaticScale: public Scale {
public:
StaticScale(const ghoul::Dictionary& dictionary
= ghoul::Dictionary());
StaticScale(const ghoul::Dictionary& dictionary = ghoul::Dictionary());
virtual ~StaticScale();
virtual double scaleValue() const;
virtual void update(const UpdateData& data) override;
private:
double _scaleValue;
properties::FloatProperty _scaleValue;
//double _scaleValue;
};
} // namespace openspace

View File

@@ -150,6 +150,9 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di
//parentNode->addNode(result);
result->_scale->setName("Transform");
result->addPropertySubOwner(result->_scale);
LDEBUG("Successfully created SceneGraphNode '"
<< result->name() << "'");
return result;