mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-18 01:56:26 -05:00
Create ISWACygnets with dictionary
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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(){}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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(){
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
class TexturePlane : public CygnetPlane{
|
||||
public:
|
||||
TexturePlane(std::shared_ptr<Metadata> data);
|
||||
TexturePlane(const ghoul::Dictionary& dictionary);
|
||||
~TexturePlane();
|
||||
|
||||
virtual bool initialize();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user