Create ISWACygnets with dictionary

This commit is contained in:
Sebastian Piwell
2016-04-08 11:58:46 -04:00
parent 20c1fa0cfa
commit 263bc9508e
11 changed files with 99 additions and 20 deletions
+10 -3
View File
@@ -37,6 +37,13 @@ CygnetPlane::CygnetPlane(std::shared_ptr<Metadata> data)
,_planeIsDirty(true)
{}
CygnetPlane::CygnetPlane(const ghoul::Dictionary& dictionary)
:ISWACygnet(dictionary)
,_quad(0)
,_vertexPositionBuffer(0)
,_planeIsDirty(true)
{}
CygnetPlane::~CygnetPlane(){}
bool CygnetPlane::isReady(){
@@ -55,9 +62,9 @@ void CygnetPlane::createPlane(){
// ============================
// GEOMETRY (quad)
// ============================
const GLfloat x = _data->scale.x/2.0;
const GLfloat y = _data->scale.z/2.0;
const GLfloat w = _data->scale.w;
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
+1
View File
@@ -34,6 +34,7 @@ class CygnetPlane : public ISWACygnet {
public:
// CygnetPlane(int cygnetId, std::string path);
CygnetPlane(std::shared_ptr<Metadata> data);
CygnetPlane(const ghoul::Dictionary& dictionary);
~CygnetPlane();
virtual bool initialize() = 0;
+21 -3
View File
@@ -40,9 +40,9 @@ namespace {
}
namespace openspace {
DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::shared_ptr<Metadata> data)
DataPlane::DataPlane(std::shared_ptr<Metadata> data)
:CygnetPlane(data)
, _kw(kw)
, _kw(data->kw)
{
_id = id();
setName("DataPlane" + std::to_string(_id));
@@ -54,6 +54,24 @@ DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::shared_ptr<Metada
else
_var = "rho";
}
DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
:CygnetPlane(dictionary)
{
_id = id();
setName("DataPlane" + std::to_string(_id));
registerProperties();
dictionary.getValue("KW", _kw);
KameleonWrapper::Model model = _kw->model();
if( model == KameleonWrapper::Model::BATSRUS)
_var = "p";
else
_var = "rho";
}
DataPlane::~DataPlane(){}
@@ -119,7 +137,7 @@ void DataPlane::render(){
transform = rotation * transform;
}
position += transform*glm::vec4(_data->offset.x, _data->offset.z, _data->offset.y, _data->offset.w);
position += transform*glm::vec4(_data->offset->x, _data->offset->z, _data->offset->y, _data->offset->w);
// Activate shader
_shader->activate();
+2 -1
View File
@@ -32,7 +32,8 @@
class DataPlane : public CygnetPlane {
public:
DataPlane(std::shared_ptr<KameleonWrapper> kw, std::shared_ptr<Metadata> data);
DataPlane(std::shared_ptr<Metadata> data);
DataPlane(const ghoul::Dictionary& dictionary);
~DataPlane();
virtual bool initialize() override;
+1 -1
View File
@@ -42,7 +42,7 @@ bool ISWAContainer::initialize(){
ISWAManager::ref().setContainer(this);
addISWACygnet("${OPENSPACE_DATA}/BATSRUS.cdf");
addISWACygnet(5, "Screen");
// addISWACygnet(5, "Screen");
addISWACygnet(7, "Sun");
return true;
+25
View File
@@ -46,6 +46,31 @@ ISWACygnet::ISWACygnet(std::shared_ptr<Metadata> data)
_delete.onChange([this](){ISWAManager::ref().deleteISWACygnet(name());});
}
ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
: _enabled("enabled", "Is Enabled", true)
, _updateInterval("updateInterval", "Update Interval", 3, 1, 10)
, _delete("delete", "Delete")
, _shader(nullptr)
, _texture(nullptr)
// , _data(data)
, _memorybuffer("")
{
_data = std::make_shared<Metadata>();
dictionary.getValue("Id",_data->id);
dictionary.getValue("Path",_data->path);
dictionary.getValue("Parent",_data->parent);
dictionary.getValue("Frame",_data->frame);
dictionary.getValue("Offset",_data->offset);
dictionary.getValue("Scale",_data->scale);
addProperty(_enabled);
addProperty(_updateInterval);
addProperty(_delete);
_delete.onChange([this](){ISWAManager::ref().deleteISWACygnet(name());});
}
ISWACygnet::~ISWACygnet(){}
+1
View File
@@ -48,6 +48,7 @@ namespace openspace{
class ISWACygnet : public properties::PropertyOwner{
public:
ISWACygnet(std::shared_ptr<Metadata> data);
ISWACygnet(const ghoul::Dictionary& dictionary);
~ISWACygnet();
virtual bool initialize() = 0;
+10
View File
@@ -50,6 +50,16 @@ TexturePlane::TexturePlane(std::shared_ptr<Metadata> data)
registerProperties();
}
TexturePlane::TexturePlane(const ghoul::Dictionary& dictionary)
:CygnetPlane(dictionary)
,_futureTexture(nullptr)
{
_id = id();
setName("TexturePlane" + std::to_string(_id));
registerProperties();
}
TexturePlane::~TexturePlane(){}
bool TexturePlane::initialize(){
+1
View File
@@ -35,6 +35,7 @@
class TexturePlane : public CygnetPlane{
public:
TexturePlane(std::shared_ptr<Metadata> data);
TexturePlane(const ghoul::Dictionary& dictionary);
~TexturePlane();
virtual bool initialize();
+22 -10
View File
@@ -69,24 +69,36 @@ namespace openspace{
}
std::shared_ptr<KameleonWrapper> kw = std::make_shared<KameleonWrapper>(absPath(metadata->path));
ghoul::Dictionary metadataDic =
{
{std::string("Id"), metadata->id},
{std::string("Path"), metadata->path},
{std::string("Scale"), std::make_shared<glm::vec4>(kw->getModelScaleScaled())},
{std::string("Offset"), std::make_shared<glm::vec4>(kw->getModelBarycenterOffsetScaled())},
{std::string("Parent"), kw->getParent()},
{std::string("Frame"), kw->getFrame()},
{std::string("KW"), kw}
};
metadata->scale = kw->getModelScaleScaled();
metadata->offset = kw->getModelBarycenterOffsetScaled();
metadata->parent = kw->getParent();
metadata->frame = kw->getFrame();
cygnet = std::make_shared<DataPlane>(kw, metadata);
cygnet = std::make_shared<DataPlane>(metadataDic);
}else if(extension == "plain"){
LWARNING("This cygnet image does not exist");
return nullptr;
}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";
ghoul::Dictionary metadataDic =
{
{std::string("Id"), metadata->id},
{std::string("Path"), metadata->path},
{std::string("Frame"), std::string("GALACTIC")},
{std::string("Parent"), metadata->parent},
{std::string("Scale"), std::make_shared<glm::vec4>(3,3,3,10)},
{std::string("Offset"), std::make_shared<glm::vec4>(0,0,0,1)}
};
cygnet = std::make_shared<TexturePlane>(metadata);
cygnet = std::make_shared<TexturePlane>(metadataDic);
}else{
OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared<ScreenSpaceCygnet>(metadata));
return nullptr;
+5 -2
View File
@@ -29,6 +29,8 @@
#include <map>
#include <openspace/engine/downloadmanager.h>
#include <ghoul/glm.h>
#include <modules/kameleon/include/kameleonwrapper.h>
namespace openspace {
class ISWACygnet;
@@ -46,9 +48,10 @@ struct Metadata {
std::string path;
std::string parent;
std::string frame;
glm::vec4 offset;
glm::vec4 scale;
std::shared_ptr<glm::vec4> offset;
std::shared_ptr<glm::vec4> scale;
std::string scaleVariable;
std::shared_ptr<KameleonWrapper> kw;
};