mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-08 12:39:49 -06:00
solved merge conflict
This commit is contained in:
Submodule ext/ghoul updated: f31ddda5d7...901a96beda
@@ -19,89 +19,51 @@
|
||||
#include <modules/iswa/rendering/cygnetplane.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
namespace openspace{
|
||||
|
||||
CygnetPlane::CygnetPlane(int cygnetId, std::string path)
|
||||
:ISWACygnet(cygnetId, path)
|
||||
,_quad(0)
|
||||
,_vertexPositionBuffer(0)
|
||||
// CygnetPlane::CygnetPlane(int cygnetId, std::string path)
|
||||
// :ISWACygnet(cygnetId, path)
|
||||
// ,_quad(0)
|
||||
// ,_vertexPositionBuffer(0)
|
||||
// ,_planeIsDirty(true)
|
||||
// {}
|
||||
|
||||
CygnetPlane::CygnetPlane(std::shared_ptr<Metadata> data)
|
||||
:ISWACygnet(data)
|
||||
,_quad(0)
|
||||
,_vertexPositionBuffer(0)
|
||||
,_planeIsDirty(true)
|
||||
{}
|
||||
|
||||
CygnetPlane::~CygnetPlane(){}
|
||||
|
||||
bool CygnetPlane::initialize(){
|
||||
ISWACygnet::initialize();
|
||||
|
||||
glGenVertexArrays(1, &_quad); // generate array
|
||||
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
|
||||
createPlane();
|
||||
|
||||
if (_shader == nullptr) {
|
||||
// Plane Program
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_shader = renderEngine.buildRenderProgram("PlaneProgram",
|
||||
"${MODULE_ISWA}/shaders/cygnetplane_vs.glsl",
|
||||
"${MODULE_ISWA}/shaders/cygnetplane_fs.glsl"
|
||||
);
|
||||
if (!_shader)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CygnetPlane::deinitialize(){
|
||||
ISWACygnet::deinitialize();
|
||||
glDeleteVertexArrays(1, &_quad);
|
||||
_quad = 0;
|
||||
|
||||
glDeleteBuffers(1, &_vertexPositionBuffer);
|
||||
_vertexPositionBuffer = 0;
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_shader) {
|
||||
renderEngine.removeRenderProgram(_shader);
|
||||
_shader = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CygnetPlane::isReady(){
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
if(!_texture)
|
||||
ready &= false;
|
||||
return ready;
|
||||
}
|
||||
|
||||
void CygnetPlane::render(){}
|
||||
|
||||
void CygnetPlane::update(){
|
||||
ISWACygnet::update();
|
||||
|
||||
_time = Time::ref().currentTime();
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _frame, _time);
|
||||
_openSpaceUpdateInterval = Time::ref().deltaTime()*_updateInterval;
|
||||
|
||||
if(_openSpaceUpdateInterval){
|
||||
if((_time-_lastUpdateTime) >= _openSpaceUpdateInterval){
|
||||
updateTexture();
|
||||
_lastUpdateTime = _time;
|
||||
}
|
||||
}
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
if(!_texture)
|
||||
ready &= false;
|
||||
return ready;
|
||||
}
|
||||
|
||||
void CygnetPlane::createPlane(){
|
||||
glGenVertexArrays(1, &_quad); // generate array
|
||||
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
|
||||
// ============================
|
||||
// GEOMETRY (quad)
|
||||
// ============================
|
||||
const GLfloat x = _modelScale.x/2.0;
|
||||
const GLfloat y = _modelScale.z/2.0;
|
||||
const GLfloat w = _modelScale.w;
|
||||
// GLfloat x, y, w;
|
||||
// if(!_data){
|
||||
// x = _modelScale.x/2.0;
|
||||
// y = _modelScale.z/2.0;
|
||||
// w = _modelScale.w;
|
||||
// }else{
|
||||
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
|
||||
-x, -y, 0, w, 0, 1,
|
||||
@@ -123,4 +85,33 @@ void CygnetPlane::createPlane(){
|
||||
_planeIsDirty = false;
|
||||
}
|
||||
|
||||
void CygnetPlane::destroyPlane(){
|
||||
glDeleteVertexArrays(1, &_quad);
|
||||
_quad = 0;
|
||||
|
||||
glDeleteBuffers(1, &_vertexPositionBuffer);
|
||||
_vertexPositionBuffer = 0;
|
||||
}
|
||||
|
||||
bool CygnetPlane::createShader(){
|
||||
if (_shader == nullptr) {
|
||||
// Plane Program
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_shader = renderEngine.buildRenderProgram("PlaneProgram",
|
||||
"${MODULE_ISWA}/shaders/cygnetplane_vs.glsl",
|
||||
"${MODULE_ISWA}/shaders/cygnetplane_fs.glsl"
|
||||
);
|
||||
if (!_shader)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CygnetPlane::destroyShader(){
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_shader) {
|
||||
renderEngine.removeRenderProgram(_shader);
|
||||
_shader = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace openspace
|
||||
@@ -32,23 +32,24 @@
|
||||
namespace openspace{
|
||||
class CygnetPlane : public ISWACygnet {
|
||||
public:
|
||||
CygnetPlane(int cygnetId, std::string path);
|
||||
// CygnetPlane(int cygnetId, std::string path);
|
||||
CygnetPlane(std::shared_ptr<Metadata> data);
|
||||
~CygnetPlane();
|
||||
|
||||
virtual bool initialize();
|
||||
virtual bool deinitialize();
|
||||
|
||||
bool isReady() override;
|
||||
|
||||
virtual void render();
|
||||
virtual void update();
|
||||
virtual bool initialize() = 0;
|
||||
virtual bool deinitialize() = 0;
|
||||
virtual bool isReady();
|
||||
virtual void render() = 0;
|
||||
virtual void update() = 0;
|
||||
|
||||
protected:
|
||||
virtual void setParent() = 0;
|
||||
virtual void loadTexture() = 0;
|
||||
virtual void updateTexture() = 0;
|
||||
|
||||
void createPlane();
|
||||
void destroyPlane();
|
||||
bool createShader();
|
||||
void destroyShader();
|
||||
|
||||
GLuint _quad;
|
||||
GLuint _vertexPositionBuffer;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
#include <openspace/util/time.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "DataPlane";
|
||||
@@ -41,8 +41,25 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::string path)
|
||||
:CygnetPlane(1, path)
|
||||
// DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::string path)
|
||||
// :CygnetPlane(1, path)
|
||||
// , _kw(kw)
|
||||
// {
|
||||
// _id = id();
|
||||
// setName("DataPlane" + std::to_string(_id));
|
||||
// registerProperties();
|
||||
|
||||
// KameleonWrapper::Model model = _kw->model();
|
||||
// if( model == KameleonWrapper::Model::BATSRUS){
|
||||
// _var = "p";
|
||||
// }else{
|
||||
// _var = "rho";
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::shared_ptr<Metadata> data)
|
||||
:CygnetPlane(data)
|
||||
, _kw(kw)
|
||||
{
|
||||
_id = id();
|
||||
@@ -56,19 +73,20 @@ DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::string path)
|
||||
_var = "rho";
|
||||
}
|
||||
|
||||
if(!_data){
|
||||
std::cout << "No data" << std::endl;
|
||||
}else{
|
||||
std::cout << _data->parent << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
DataPlane::~DataPlane(){}
|
||||
|
||||
|
||||
bool DataPlane::initialize(){
|
||||
_modelScale = _kw->getModelScaleScaled();
|
||||
_pscOffset = _kw->getModelBarycenterOffsetScaled();
|
||||
|
||||
CygnetPlane::initialize();
|
||||
// std::cout << _modelScale.x << ", " << _modelScale.y << ", " << _modelScale.z << ", " << _modelScale.w << std::endl;
|
||||
// std::cout << _pscOffset.x << ", " << _pscOffset.y << ", " << _pscOffset.z << ", " << _pscOffset.w << std::endl;
|
||||
setParent();
|
||||
createPlane();
|
||||
createShader();
|
||||
|
||||
_dimensions = glm::size3_t(500,500,1);
|
||||
float zSlice = 0.5f;
|
||||
@@ -80,7 +98,10 @@ bool DataPlane::initialize(){
|
||||
}
|
||||
|
||||
bool DataPlane::deinitialize(){
|
||||
CygnetPlane::deinitialize();
|
||||
_parent = nullptr;
|
||||
unregisterProperties();
|
||||
destroyPlane();
|
||||
destroyShader();
|
||||
_kw = nullptr;
|
||||
|
||||
return true;
|
||||
@@ -124,7 +145,11 @@ void DataPlane::render(){
|
||||
|
||||
glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), angle, ref);
|
||||
transform = rotation * transform;
|
||||
position += transform*glm::vec4(_pscOffset.x, _pscOffset.z, _pscOffset.y, _pscOffset.w);
|
||||
|
||||
// if(!_data)
|
||||
// position += transform*glm::vec4(_pscOffset.x, _pscOffset.z, _pscOffset.y, _pscOffset.w);
|
||||
// else
|
||||
position += transform*glm::vec4(_data->offset.x, _data->offset.z, _data->offset.y, _data->offset.w);
|
||||
|
||||
// Activate shader
|
||||
_shader->activate();
|
||||
@@ -152,33 +177,23 @@ void DataPlane::update(){
|
||||
if(_planeIsDirty)
|
||||
createPlane();
|
||||
|
||||
CygnetPlane::update();
|
||||
_time = Time::ref().currentTime();
|
||||
|
||||
// if(!_data)
|
||||
// _stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _frame, _time);
|
||||
// else
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _data->frame, _time);
|
||||
_openSpaceUpdateInterval = Time::ref().deltaTime()*_updateInterval;
|
||||
|
||||
if(_openSpaceUpdateInterval){
|
||||
if((_time-_lastUpdateTime) >= _openSpaceUpdateInterval){
|
||||
updateTexture();
|
||||
_lastUpdateTime = _time;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DataPlane::setParent(){
|
||||
KameleonWrapper::Model model = _kw->model();
|
||||
if( model == KameleonWrapper::Model::BATSRUS ||
|
||||
model == KameleonWrapper::Model::OpenGGCM ||
|
||||
model == KameleonWrapper::Model::LFM)
|
||||
{
|
||||
_parent = OsEng.renderEngine().scene()->sceneGraphNode("Earth");
|
||||
_frame = "GSM";
|
||||
}else if(
|
||||
model == KameleonWrapper::Model::ENLIL ||
|
||||
model == KameleonWrapper::Model::MAS ||
|
||||
model == KameleonWrapper::Model::Adapt3D ||
|
||||
model == KameleonWrapper::Model::SWMF)
|
||||
{
|
||||
_parent = OsEng.renderEngine().scene()->sceneGraphNode("SolarSystem");
|
||||
_frame = "GALACTIC";
|
||||
}else{
|
||||
//Warning!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DataPlane::loadTexture() {
|
||||
//std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath));
|
||||
ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear;
|
||||
|
||||
@@ -32,17 +32,16 @@
|
||||
|
||||
class DataPlane : public CygnetPlane {
|
||||
public:
|
||||
DataPlane(std::shared_ptr<KameleonWrapper> kw, std::string path);
|
||||
// DataPlane(std::shared_ptr<KameleonWrapper> kw, std::string path);
|
||||
DataPlane(std::shared_ptr<KameleonWrapper> kw, std::shared_ptr<Metadata> data);
|
||||
~DataPlane();
|
||||
|
||||
virtual bool initialize();
|
||||
virtual bool deinitialize();
|
||||
|
||||
virtual void render();
|
||||
virtual void update();
|
||||
virtual bool initialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
virtual void render() override;
|
||||
virtual void update() override;
|
||||
|
||||
private:
|
||||
virtual void setParent() override;
|
||||
virtual void loadTexture() override;
|
||||
virtual void updateTexture() override;
|
||||
|
||||
@@ -51,6 +50,7 @@
|
||||
std::shared_ptr<KameleonWrapper> _kw;
|
||||
glm::size3_t _dimensions;
|
||||
float* _dataSlice;
|
||||
std::string _var;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -44,11 +44,11 @@ bool ISWAContainer::initialize(){
|
||||
ISWAManager::initialize();
|
||||
ISWAManager::ref().setContainer(this);
|
||||
|
||||
addISWACygnet("${OPENSPACE_DATA}/BATSRUS.cdf");
|
||||
// addISWACygnet("${OPENSPACE_DATA}/BATSRUS.cdf");
|
||||
// addISWACygnet("${OPENSPACE_DATA}/ENLIL.cdf");
|
||||
//addISWACygnet("${OPENSPACE_DATA}/test.png");
|
||||
addISWACygnet(5);
|
||||
addISWACygnet(7);
|
||||
addISWACygnet(5, "Screen");
|
||||
// addISWACygnet(7, "Sun");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -72,12 +72,17 @@ void ISWAContainer::render(const RenderData& data){
|
||||
}
|
||||
|
||||
void ISWAContainer::update(const UpdateData& data){
|
||||
|
||||
for (auto it = _extFutures.begin(); it != _extFutures.end(); )
|
||||
{
|
||||
if ((*it)->isFinished) {
|
||||
if ((*it)->isFinished) {
|
||||
std::string path = "${OPENSPACE_DATA}/scene/iswa/" + std::to_string((*it)->id) + (*it)->extension;
|
||||
std::shared_ptr<ISWACygnet> cygnet = ISWAManager::ref().createISWACygnet((*it)->id, std::move(path));
|
||||
|
||||
std::shared_ptr<Metadata> data = std::make_shared<Metadata>();
|
||||
data->id = (*it)->id;
|
||||
data->path = path;
|
||||
data->parent = (*it)->parent;
|
||||
|
||||
std::shared_ptr<ISWACygnet> cygnet = ISWAManager::ref().createISWACygnet(data);
|
||||
if(cygnet){
|
||||
_iSWACygnets.push_back(cygnet);
|
||||
}
|
||||
@@ -96,16 +101,20 @@ void ISWAContainer::update(const UpdateData& data){
|
||||
}
|
||||
|
||||
void ISWAContainer::addISWACygnet(std::string path){
|
||||
std::shared_ptr<ISWACygnet> cygnet = ISWAManager::ref().createISWACygnet(1, path);
|
||||
std::shared_ptr<Metadata> data = std::make_shared<Metadata>();
|
||||
data->id = 0;
|
||||
data->path = path;
|
||||
|
||||
std::shared_ptr<ISWACygnet> cygnet = ISWAManager::ref().createISWACygnet(data);
|
||||
if(cygnet){
|
||||
_iSWACygnets.push_back(cygnet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ISWAContainer::addISWACygnet(int id){
|
||||
|
||||
void ISWAContainer::addISWACygnet(int id, std::string data){
|
||||
std::shared_ptr<ExtensionFuture> extFuture = ISWAManager::ref().fileExtension(id);
|
||||
extFuture->parent = data;
|
||||
_extFutures.push_back(extFuture);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
virtual void update(const UpdateData& data) override;
|
||||
|
||||
void addISWACygnet(std::string path);
|
||||
void addISWACygnet(int id);
|
||||
void addISWACygnet(int id, std::string data);
|
||||
void addISWACygnet(std::shared_ptr<ISWACygnet> cygnet);
|
||||
|
||||
void deleteCygnet(ISWACygnet* cygnet);
|
||||
|
||||
@@ -28,19 +28,36 @@
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/time.h>
|
||||
|
||||
|
||||
namespace openspace{
|
||||
|
||||
ISWACygnet::ISWACygnet(int cygnetId, std::string path)
|
||||
// ISWACygnet::ISWACygnet(int cygnetId, std::string path)
|
||||
// : _enabled("enabled", "Is Enabled", true)
|
||||
// , _updateInterval("updateInterval", "Update Interval", 3, 1, 10)
|
||||
// , _delete("delete", "Delete")
|
||||
// , _cygnetId(cygnetId)
|
||||
// , _shader(nullptr)
|
||||
// , _texture(nullptr)
|
||||
// , _frame("GALACTIC")
|
||||
// , _path(path)
|
||||
// , _data(nullptr)
|
||||
// {
|
||||
// addProperty(_enabled);
|
||||
// addProperty(_updateInterval);
|
||||
// addProperty(_delete);
|
||||
|
||||
// _delete.onChange([this](){ISWAManager::ref().deleteCygnet(name());});
|
||||
// }
|
||||
|
||||
ISWACygnet::ISWACygnet(std::shared_ptr<Metadata> data)
|
||||
: _enabled("enabled", "Is Enabled", true)
|
||||
, _updateInterval("updateInterval", "Update Interval", 3, 1, 10)
|
||||
,_delete("delete", "Delete")
|
||||
, _cygnetId(cygnetId)
|
||||
, _delete("delete", "Delete")
|
||||
// , _cygnetId(data->id)
|
||||
, _shader(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _frame("GALACTIC")
|
||||
, _path(path)
|
||||
,_toDelete(false)
|
||||
// , _frame(data->frame)
|
||||
// , _path(data->path)
|
||||
, _data(data)
|
||||
{
|
||||
addProperty(_enabled);
|
||||
addProperty(_updateInterval);
|
||||
@@ -51,23 +68,6 @@ ISWACygnet::ISWACygnet(int cygnetId, std::string path)
|
||||
|
||||
ISWACygnet::~ISWACygnet(){}
|
||||
|
||||
bool ISWACygnet::initialize(){
|
||||
|
||||
setParent();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ISWACygnet::deinitialize(){
|
||||
OsEng.gui()._iSWAproperty.unregisterProperties(name());
|
||||
_parent = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ISWACygnet::render(){
|
||||
|
||||
}
|
||||
|
||||
void ISWACygnet::update(){}
|
||||
|
||||
void ISWACygnet::setPscUniforms(
|
||||
ghoul::opengl::ProgramObject* program,
|
||||
@@ -81,11 +81,17 @@ void ISWACygnet::setPscUniforms(
|
||||
}
|
||||
|
||||
void ISWACygnet::registerProperties(){
|
||||
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_updateInterval);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_delete);
|
||||
}
|
||||
|
||||
void ISWACygnet::unregisterProperties(){
|
||||
OsEng.gui()._iSWAproperty.unregisterProperties(name());
|
||||
}
|
||||
|
||||
void ISWACygnet::setParent(){
|
||||
_parent = OsEng.renderEngine().scene()->sceneGraphNode(_data->parent);
|
||||
}
|
||||
|
||||
}//namespace openspac
|
||||
@@ -40,26 +40,31 @@
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
|
||||
|
||||
namespace openspace{
|
||||
class ISWACygnet : public properties::PropertyOwner{
|
||||
public:
|
||||
ISWACygnet(int cygnetId, std::string path);
|
||||
// ISWACygnet(int cygnetId, std::string path);
|
||||
ISWACygnet(std::shared_ptr<Metadata> data);
|
||||
~ISWACygnet();
|
||||
|
||||
virtual bool initialize();
|
||||
virtual bool deinitialize();
|
||||
virtual bool initialize() = 0;
|
||||
virtual bool deinitialize() = 0;
|
||||
|
||||
virtual void render();
|
||||
virtual void update();
|
||||
virtual void render() = 0;
|
||||
virtual void update() = 0;
|
||||
virtual bool isReady() = 0;
|
||||
|
||||
bool enabled(){return _enabled.value();}
|
||||
virtual bool isReady() = 0;
|
||||
|
||||
|
||||
protected:
|
||||
void setPscUniforms(ghoul::opengl::ProgramObject* program, const Camera* camera, const PowerScaledCoordinate& position);
|
||||
virtual void setParent() = 0;
|
||||
void registerProperties();
|
||||
void unregisterProperties();
|
||||
|
||||
void setParent();
|
||||
|
||||
properties::BoolProperty _enabled;
|
||||
properties::FloatProperty _updateInterval;
|
||||
@@ -68,26 +73,15 @@ protected:
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
|
||||
SceneGraphNode* _parent;
|
||||
glm::vec4 _pscOffset;
|
||||
glm::vec4 _modelScale;
|
||||
std::shared_ptr<Metadata> _data;
|
||||
|
||||
const int _cygnetId;
|
||||
SceneGraphNode* _parent;
|
||||
glm::dmat3 _stateMatrix;
|
||||
std::string _frame;
|
||||
std::string _var;
|
||||
|
||||
double _time;
|
||||
double _lastUpdateTime = 0;
|
||||
std::map<std::string, std::string> _month;
|
||||
|
||||
std::string _fileExtension;
|
||||
std::string _path;
|
||||
|
||||
float _openSpaceUpdateInterval;
|
||||
|
||||
bool _toDelete;
|
||||
|
||||
int _id;
|
||||
};
|
||||
|
||||
|
||||
@@ -35,10 +35,33 @@ namespace {
|
||||
namespace openspace {
|
||||
|
||||
ScreenSpaceCygnet::ScreenSpaceCygnet(int cygnetId, std::string path)
|
||||
: ScreenSpaceRenderable()
|
||||
, _updateInterval("updateInterval", "Update Interval", 3, 1, 10)
|
||||
, _cygnetId(cygnetId)
|
||||
, _path(path)
|
||||
: ScreenSpaceRenderable()
|
||||
, _updateInterval("updateInterval", "Update Interval", 3, 1, 10)
|
||||
, _cygnetId(cygnetId)
|
||||
, _path(path)
|
||||
{
|
||||
std::cout << "screenspacecygnet constructor 1" << std::endl;
|
||||
_id = id();
|
||||
setName("ScreenSpaceCygnet" + std::to_string(_id));
|
||||
addProperty(_updateInterval);
|
||||
|
||||
// registerProperties();
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useFlatScreen);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_euclideanPosition);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_sphericalPosition);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_depth);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_scale);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_alpha);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_updateInterval);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_delete);
|
||||
}
|
||||
|
||||
ScreenSpaceCygnet::ScreenSpaceCygnet(std::shared_ptr<Metadata> data)
|
||||
: ScreenSpaceRenderable()
|
||||
, _updateInterval("updateInterval", "Update Interval", 3, 1, 10)
|
||||
, _cygnetId(data->id)
|
||||
, _path(data->path)
|
||||
{
|
||||
_id = id();
|
||||
setName("ScreenSpaceCygnet" + std::to_string(_id));
|
||||
|
||||
@@ -27,12 +27,14 @@
|
||||
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <openspace/engine/downloadmanager.h>
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
|
||||
namespace openspace{
|
||||
|
||||
class ScreenSpaceCygnet : public ScreenSpaceRenderable {
|
||||
public:
|
||||
ScreenSpaceCygnet(int cygnetId, std::string path);
|
||||
ScreenSpaceCygnet(std::shared_ptr<Metadata> data);
|
||||
~ScreenSpaceCygnet();
|
||||
|
||||
void render() override;
|
||||
@@ -50,13 +52,15 @@ private:
|
||||
|
||||
std::string _path;
|
||||
const int _cygnetId;
|
||||
int _id;
|
||||
float _time;
|
||||
float _lastUpdateTime = 0.0f;
|
||||
std::shared_ptr<DownloadManager::FileFuture> _futureTexture;
|
||||
std::string _fileExtension;
|
||||
|
||||
std::shared_ptr<DownloadManager::FileFuture> _futureTexture;
|
||||
float _openSpaceUpdateInterval;
|
||||
|
||||
std::string _fileExtension;
|
||||
|
||||
int _id;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/time.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "TexutePlane";
|
||||
@@ -41,8 +42,17 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
TexturePlane::TexturePlane(int cygnetId, std::string path)
|
||||
:CygnetPlane(cygnetId, path)
|
||||
// TexturePlane::TexturePlane(int cygnetId, std::string path)
|
||||
// :CygnetPlane(cygnetId, path)
|
||||
// ,_futureTexture(nullptr)
|
||||
// {
|
||||
// _id = id();
|
||||
// setName("TexturePlane" + std::to_string(_id));
|
||||
// registerProperties();
|
||||
// }
|
||||
|
||||
TexturePlane::TexturePlane(std::shared_ptr<Metadata> data)
|
||||
:CygnetPlane(data)
|
||||
,_futureTexture(nullptr)
|
||||
{
|
||||
_id = id();
|
||||
@@ -51,35 +61,25 @@ TexturePlane::TexturePlane(int cygnetId, std::string path)
|
||||
}
|
||||
|
||||
|
||||
TexturePlane::~TexturePlane(){
|
||||
|
||||
}
|
||||
TexturePlane::~TexturePlane(){}
|
||||
|
||||
|
||||
bool TexturePlane::initialize(){
|
||||
_modelScale = glm::vec4(3, 3, 3, 10);
|
||||
_pscOffset = glm::vec4(0, 0, 0, 1);
|
||||
CygnetPlane::initialize();
|
||||
setParent();
|
||||
createPlane();
|
||||
createShader();
|
||||
|
||||
updateTexture();
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool TexturePlane::deinitialize(){
|
||||
CygnetPlane::deinitialize();
|
||||
_parent = nullptr;
|
||||
unregisterProperties();
|
||||
destroyPlane();
|
||||
destroyShader();
|
||||
|
||||
glDeleteVertexArrays(1, &_quad);
|
||||
_quad = 0;
|
||||
|
||||
glDeleteBuffers(1, &_vertexPositionBuffer);
|
||||
_vertexPositionBuffer = 0;
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_shader) {
|
||||
renderEngine.removeRenderProgram(_shader);
|
||||
_shader = nullptr;
|
||||
}
|
||||
|
||||
std::remove(absPath(_path).c_str());
|
||||
std::remove(absPath(_data->path).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -133,7 +133,18 @@ void TexturePlane::update(){
|
||||
if(_planeIsDirty)
|
||||
createPlane();
|
||||
|
||||
CygnetPlane::update();
|
||||
_time = Time::ref().currentTime();
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _data->frame, _time);
|
||||
|
||||
_openSpaceUpdateInterval = Time::ref().deltaTime()*_updateInterval;
|
||||
|
||||
if(_openSpaceUpdateInterval){
|
||||
if((_time-_lastUpdateTime) >= _openSpaceUpdateInterval){
|
||||
updateTexture();
|
||||
_lastUpdateTime = _time;
|
||||
}
|
||||
}
|
||||
|
||||
if(_futureTexture && _futureTexture->isFinished){
|
||||
loadTexture();
|
||||
|
||||
@@ -141,12 +152,9 @@ void TexturePlane::update(){
|
||||
}
|
||||
}
|
||||
|
||||
void TexturePlane::setParent(){
|
||||
_parent = OsEng.renderEngine().scene()->sceneGraphNode("Sun");
|
||||
}
|
||||
|
||||
void TexturePlane::updateTexture(){
|
||||
std::shared_ptr<DownloadManager::FileFuture> future = ISWAManager::ref().downloadImage(_cygnetId, absPath(_path));
|
||||
std::shared_ptr<DownloadManager::FileFuture> future = ISWAManager::ref().downloadImage(_data->id, absPath(_path));
|
||||
if(future){
|
||||
_futureTexture = future;
|
||||
}
|
||||
@@ -154,10 +162,10 @@ void TexturePlane::updateTexture(){
|
||||
|
||||
void TexturePlane::loadTexture() {
|
||||
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_path));
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_data->path));
|
||||
|
||||
if (texture) {
|
||||
LDEBUG("Loaded texture from '" << absPath(_path) << "'");
|
||||
LDEBUG("Loaded texture from '" << absPath(_data->path) << "'");
|
||||
|
||||
texture->uploadTexture();
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
|
||||
class TexturePlane : public CygnetPlane{
|
||||
public:
|
||||
TexturePlane(int cygnetId, std::string path);
|
||||
// TexturePlane(int cygnetId, std::string path);
|
||||
TexturePlane(std::shared_ptr<Metadata> data);
|
||||
~TexturePlane();
|
||||
|
||||
virtual bool initialize();
|
||||
@@ -44,7 +45,6 @@
|
||||
virtual void update();
|
||||
|
||||
private:
|
||||
virtual void setParent() override;
|
||||
virtual void loadTexture() override;
|
||||
virtual void updateTexture() override;
|
||||
|
||||
|
||||
@@ -56,46 +56,43 @@ namespace openspace{
|
||||
std::stringstream ss(info);
|
||||
getline(ss,token,',');
|
||||
int cygnetId = std::stoi(token);
|
||||
/* // std::cout << token << std::endl;
|
||||
|
||||
getline(ss,token,',');
|
||||
std::string parent = token;*/
|
||||
std::string data = token;
|
||||
|
||||
//if(parent == "Earth" || parent == "Sun"){
|
||||
/*std::shared_ptr<TexturePlane> cygnet;
|
||||
cygnet = std::make_shared<TexturePlane>();
|
||||
cygnet->initialize();*/
|
||||
// cygnet->cygnetId(cygnetId);
|
||||
// cygnet->parent(parent);
|
||||
//_container->addISWACygnet(cygnet);
|
||||
_container->addISWACygnet(cygnetId);
|
||||
|
||||
//}else{
|
||||
// OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared<ScreenSpaceCygnet>(cygnetId));
|
||||
|
||||
//}
|
||||
// std::cout << token << std::endl;
|
||||
// if(token = ""){
|
||||
// std::cout << "empty" << std::endl;
|
||||
// }
|
||||
|
||||
// std::shared_ptr<ISWACygnet> cygnet;
|
||||
// _container->addCygnet(cygnet);
|
||||
if(cygnetId != 0)
|
||||
_container->addISWACygnet(cygnetId, data);
|
||||
else
|
||||
_container->addISWACygnet("${OPENSPACE_DATA}/"+data);
|
||||
}
|
||||
|
||||
std::shared_ptr<ISWACygnet> ISWAManager::createISWACygnet(int id, std::string path){
|
||||
if(path != ""){
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(path)).fileExtension();
|
||||
std::shared_ptr<ISWACygnet> ISWAManager::createISWACygnet(std::shared_ptr<Metadata> metadata){
|
||||
std::cout << "createISWACygnet " << metadata->id << std::endl;
|
||||
if(metadata->path != ""){
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(metadata->path)).fileExtension();
|
||||
std::shared_ptr<ISWACygnet> cygnet;
|
||||
|
||||
if(extension == "cdf"){
|
||||
std::shared_ptr<KameleonWrapper> kw = std::make_shared<KameleonWrapper>(absPath(path));
|
||||
cygnet = std::make_shared<DataPlane>(kw, path);
|
||||
} else if(id == 5) {
|
||||
//check some other condition that id==5 (based on metadata maybe?)
|
||||
OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared<ScreenSpaceCygnet>(id, path));
|
||||
return nullptr;
|
||||
} else {
|
||||
cygnet = std::make_shared<TexturePlane>(id, path);
|
||||
std::shared_ptr<KameleonWrapper> kw = std::make_shared<KameleonWrapper>(absPath(metadata->path));
|
||||
|
||||
metadata->scale = kw->getModelScaleScaled();
|
||||
metadata->offset = kw->getModelBarycenterOffsetScaled();
|
||||
metadata->parent = kw->getParent();
|
||||
metadata->frame = kw->getFrame();
|
||||
|
||||
cygnet = std::make_shared<DataPlane>(kw, metadata);
|
||||
}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";
|
||||
|
||||
cygnet = std::make_shared<TexturePlane>(metadata);
|
||||
}else{
|
||||
OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared<ScreenSpaceCygnet>(metadata));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
cygnet->initialize();
|
||||
|
||||
@@ -28,16 +28,27 @@
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <openspace/engine/downloadmanager.h>
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
namespace openspace {
|
||||
class ISWACygnet;
|
||||
class ISWAContainer;
|
||||
|
||||
struct ExtensionFuture {
|
||||
|
||||
std::string extension;
|
||||
bool isFinished;
|
||||
int id;
|
||||
std::string parent;
|
||||
};
|
||||
|
||||
struct Metadata {
|
||||
int id;
|
||||
std::string path;
|
||||
std::string parent;
|
||||
std::string frame;
|
||||
glm::vec4 offset;
|
||||
glm::vec4 scale;
|
||||
std::string scaleVariable;
|
||||
};
|
||||
|
||||
|
||||
@@ -50,6 +61,7 @@ public:
|
||||
~ISWAManager();
|
||||
|
||||
std::shared_ptr<ISWACygnet> createISWACygnet(int, std::string);
|
||||
std::shared_ptr<ISWACygnet> createISWACygnet(std::shared_ptr<Metadata> metadata);
|
||||
void addCygnet(std::string info);
|
||||
|
||||
std::shared_ptr<DownloadManager::FileFuture> downloadImage(int, std::string);
|
||||
|
||||
@@ -136,6 +136,8 @@ public:
|
||||
|
||||
Model model();
|
||||
GridType gridType();
|
||||
std::string getParent();
|
||||
std::string getFrame();
|
||||
|
||||
private:
|
||||
typedef std::vector<glm::vec3> TraceLine;
|
||||
|
||||
@@ -998,4 +998,40 @@ glm::vec4 KameleonWrapper::classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEn
|
||||
return color;
|
||||
}
|
||||
|
||||
std::string KameleonWrapper::getParent(){
|
||||
if( _type == KameleonWrapper::Model::BATSRUS ||
|
||||
_type == KameleonWrapper::Model::OpenGGCM ||
|
||||
_type == KameleonWrapper::Model::LFM)
|
||||
{
|
||||
return "Earth";
|
||||
}else if(
|
||||
_type == KameleonWrapper::Model::ENLIL ||
|
||||
_type == KameleonWrapper::Model::MAS ||
|
||||
_type == KameleonWrapper::Model::Adapt3D ||
|
||||
_type == KameleonWrapper::Model::SWMF)
|
||||
{
|
||||
return "SolarSystem";
|
||||
}else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
std::string KameleonWrapper::getFrame(){
|
||||
if( _type == KameleonWrapper::Model::BATSRUS ||
|
||||
_type == KameleonWrapper::Model::OpenGGCM ||
|
||||
_type == KameleonWrapper::Model::LFM)
|
||||
{
|
||||
return "GSM";
|
||||
}else if(
|
||||
_type == KameleonWrapper::Model::ENLIL ||
|
||||
_type == KameleonWrapper::Model::MAS ||
|
||||
_type == KameleonWrapper::Model::Adapt3D ||
|
||||
_type == KameleonWrapper::Model::SWMF)
|
||||
{
|
||||
return "GALACTIC";
|
||||
}else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -78,12 +78,6 @@ ScreenSpaceRenderable::ScreenSpaceRenderable()
|
||||
|
||||
ScreenSpaceRenderable::~ScreenSpaceRenderable(){}
|
||||
|
||||
|
||||
//deinitialzie(){
|
||||
// unregisterProperies
|
||||
// }
|
||||
|
||||
|
||||
bool ScreenSpaceRenderable::isEnabled() const {
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user