mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-13 23:20:48 -06:00
Merge branch 'feature/iSWA' of github.com:OpenSpace/OpenSpace-Development into feature/iSWA
This commit is contained in:
@@ -26,6 +26,7 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
|
||||
|
||||
set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswamanager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/cygnetplane.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswacygnet.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/dataplane.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/textureplane.h
|
||||
@@ -35,6 +36,7 @@ source_group("Header Files" FILES ${HEADER_FILES})
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswamanager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswacygnet.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/cygnetplane.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/dataplane.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/textureplane.cpp
|
||||
|
||||
|
||||
@@ -21,6 +21,4 @@ Renderable
|
||||
keeps a list of ISWACygnets to update and render.
|
||||
registers the ScreenSpaceCygnets with the renderengine.
|
||||
|
||||
change names in everyting in iswa folder and
|
||||
query.cpp
|
||||
datasurface.mod
|
||||
change names in everyting in iswa folder
|
||||
126
modules/iswa/rendering/cygnetplane.cpp
Normal file
126
modules/iswa/rendering/cygnetplane.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
// * 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. *
|
||||
// ****************************************************************************************/
|
||||
|
||||
#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(std::string path)
|
||||
:ISWACygnet(path)
|
||||
,_quad(0)
|
||||
,_vertexPositionBuffer(0)
|
||||
{}
|
||||
|
||||
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(){
|
||||
_time = Time::ref().currentTime();
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _frame, _time);
|
||||
|
||||
if((_time-_lastUpdateTime) >= _updateInterval){
|
||||
updateTexture();
|
||||
_lastUpdateTime = _time;
|
||||
}
|
||||
}
|
||||
|
||||
// void CygnetPlane::loadTexture(){
|
||||
|
||||
// }
|
||||
|
||||
void CygnetPlane::createPlane(){
|
||||
// ============================
|
||||
// GEOMETRY (quad)
|
||||
// ============================
|
||||
const GLfloat x = _modelScale.x/2.0;
|
||||
const GLfloat y = _modelScale.z/2.0;
|
||||
const GLfloat w = _modelScale.w;
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// x y z w s t
|
||||
-x, -y, 0, w, 0, 1,
|
||||
x, y, 0, w, 1, 0,
|
||||
-x, y, 0, w, 0, 0,
|
||||
-x, -y, 0, w, 0, 1,
|
||||
x, -y, 0, w, 1, 1,
|
||||
x, y, 0, w, 1, 0,
|
||||
};
|
||||
|
||||
glBindVertexArray(_quad); // bind array
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
|
||||
}
|
||||
|
||||
} //namespace openspace
|
||||
// :ISWACygnet(path)
|
||||
// , _quad(0)
|
||||
// , _vertexPositionBuffer(0)
|
||||
59
modules/iswa/rendering/cygnetplane.h
Normal file
59
modules/iswa/rendering/cygnetplane.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* 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 __CYGNETPLANE_H__
|
||||
#define __CYGNETPLANE_H__
|
||||
|
||||
#include <modules/iswa/rendering/iswacygnet.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
|
||||
namespace openspace{
|
||||
class CygnetPlane : public ISWACygnet {
|
||||
public:
|
||||
CygnetPlane(std::string path);
|
||||
~CygnetPlane();
|
||||
|
||||
virtual bool initialize();
|
||||
virtual bool deinitialize();
|
||||
|
||||
bool isReady();
|
||||
|
||||
virtual void render();
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
virtual void setParent() = 0;
|
||||
virtual void loadTexture() = 0;
|
||||
virtual void updateTexture() = 0;
|
||||
|
||||
void createPlane();
|
||||
|
||||
GLuint _quad;
|
||||
GLuint _vertexPositionBuffer;
|
||||
bool _planeIsDirty;
|
||||
};
|
||||
} //namespace openspace
|
||||
|
||||
#endif //__CYGNETPLANE_H__
|
||||
@@ -23,19 +23,18 @@
|
||||
// ****************************************************************************************/
|
||||
|
||||
#include <modules/iswa/rendering/dataplane.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "DataPlane";
|
||||
}
|
||||
@@ -43,18 +42,12 @@ namespace {
|
||||
namespace openspace {
|
||||
|
||||
DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::string path)
|
||||
:ISWACygnet(path)
|
||||
:CygnetPlane(path)
|
||||
, _kw(kw)
|
||||
, _texture(nullptr)
|
||||
, _quad(0)
|
||||
, _vertexPositionBuffer(0)
|
||||
{
|
||||
_id = id();
|
||||
setName("DataPlane" + std::to_string(_id));
|
||||
OsEng.gui()._property.registerProperty(&_enabled);
|
||||
OsEng.gui()._property.registerProperty(&_cygnetId);
|
||||
OsEng.gui()._property.registerProperty(&_path);
|
||||
OsEng.gui()._property.registerProperty(&_updateInterval);
|
||||
registerProperties();
|
||||
|
||||
KameleonWrapper::Model model = _kw->model();
|
||||
if( model == KameleonWrapper::Model::BATSRUS){
|
||||
@@ -70,35 +63,17 @@ DataPlane::~DataPlane(){}
|
||||
|
||||
|
||||
bool DataPlane::initialize(){
|
||||
ISWACygnet::initialize();
|
||||
|
||||
_modelScale = _kw->getModelScaleScaled();
|
||||
_pscOffset = _kw->getModelBarycenterOffsetScaled();
|
||||
|
||||
std::cout << _modelScale.x << ", " << _modelScale.y << ", " << _modelScale.z << ", " << _modelScale.w << std::endl;
|
||||
std::cout << _pscOffset.x << ", " << _pscOffset.y << ", " << _pscOffset.z << ", " << _pscOffset.w << std::endl;
|
||||
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;
|
||||
|
||||
_dimensions = glm::size3_t(500,500,1);
|
||||
float zSlice = 0.5f;
|
||||
|
||||
_dataSlice = _kw->getUniformSliceValues(std::string(_var), _dimensions, zSlice);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
loadTexture();
|
||||
|
||||
return isReady();
|
||||
@@ -106,37 +81,13 @@ bool DataPlane::initialize(){
|
||||
|
||||
bool DataPlane::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 DataPlane::isReady() const {
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
if(!_texture)
|
||||
ready &= false;
|
||||
return ready;
|
||||
};
|
||||
|
||||
void DataPlane::render(){
|
||||
// getiSWAurl(1);
|
||||
|
||||
psc position = _parent->worldPosition();
|
||||
|
||||
glm::mat4 transform = glm::mat4(1.0);
|
||||
|
||||
glm::mat4 rotx = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
|
||||
@@ -203,9 +154,7 @@ void DataPlane::render(){
|
||||
}
|
||||
|
||||
void DataPlane::update(){
|
||||
_time = Time::ref().currentTime();
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _frame, _time);
|
||||
|
||||
CygnetPlane::update();
|
||||
}
|
||||
|
||||
void DataPlane::setParent(){
|
||||
@@ -250,31 +199,33 @@ void DataPlane::loadTexture() {
|
||||
|
||||
}
|
||||
|
||||
void DataPlane::createPlane() {
|
||||
// ============================
|
||||
// GEOMETRY (quad)
|
||||
// ============================
|
||||
const GLfloat x = _modelScale.x/2.0;
|
||||
const GLfloat y = _modelScale.z/2.0;
|
||||
const GLfloat w = _modelScale.w;
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// x y z w s t
|
||||
-x, -y, 0, w, 0, 1,
|
||||
x, y, 0, w, 1, 0,
|
||||
-x, y, 0, w, 0, 0,
|
||||
-x, -y, 0, w, 0, 1,
|
||||
x, -y, 0, w, 1, 1,
|
||||
x, y, 0, w, 1, 0,
|
||||
};
|
||||
// void DataPlane::createPlane() {
|
||||
// // ============================
|
||||
// // GEOMETRY (quad)
|
||||
// // ============================
|
||||
// const GLfloat x = _modelScale.x/2.0;
|
||||
// const GLfloat y = _modelScale.z/2.0;
|
||||
// const GLfloat w = _modelScale.w;
|
||||
// const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// // x y z w s t
|
||||
// -x, -y, 0, w, 0, 1,
|
||||
// x, y, 0, w, 1, 0,
|
||||
// -x, y, 0, w, 0, 0,
|
||||
// -x, -y, 0, w, 0, 1,
|
||||
// x, -y, 0, w, 1, 1,
|
||||
// x, y, 0, w, 1, 0,
|
||||
// };
|
||||
|
||||
glBindVertexArray(_quad); // bind array
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
}
|
||||
// glBindVertexArray(_quad); // bind array
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
// glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
// glEnableVertexAttribArray(0);
|
||||
// glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
// glEnableVertexAttribArray(1);
|
||||
// glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
// }
|
||||
|
||||
void DataPlane::updateTexture(){}
|
||||
|
||||
int DataPlane::id(){
|
||||
static int id = 0;
|
||||
|
||||
@@ -25,17 +25,12 @@
|
||||
#ifndef __DATAPLANE_H__
|
||||
#define __DATAPLANE_H__
|
||||
|
||||
// #include <openspace/rendering/renderable.h>
|
||||
#include <modules/iswa/rendering/iswacygnet.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <modules/iswa/rendering/cygnetplane.h>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
|
||||
namespace openspace{
|
||||
|
||||
class DataPlane : public ISWACygnet {
|
||||
class DataPlane : public CygnetPlane {
|
||||
public:
|
||||
DataPlane(std::shared_ptr<KameleonWrapper> kw, std::string path);
|
||||
~DataPlane();
|
||||
@@ -43,33 +38,21 @@
|
||||
virtual bool initialize();
|
||||
virtual bool deinitialize();
|
||||
|
||||
bool isReady() const;
|
||||
|
||||
virtual void render();
|
||||
virtual void update();
|
||||
|
||||
private:
|
||||
virtual void setParent() override;
|
||||
void loadTexture();
|
||||
void createPlane();
|
||||
virtual void loadTexture() override;
|
||||
virtual void updateTexture() override;
|
||||
|
||||
static int id();
|
||||
|
||||
int _id;
|
||||
// properties::StringProperty _texturePath;
|
||||
// properties::Vec3Property _roatation;
|
||||
|
||||
// std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
std::shared_ptr<KameleonWrapper> _kw;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
|
||||
float* _dataSlice;
|
||||
glm::size3_t _dimensions;
|
||||
|
||||
GLuint _quad;
|
||||
GLuint _vertexPositionBuffer;
|
||||
// bool _planeIsDirty;
|
||||
float* _dataSlice;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
#endif //__DATAPLANE_H__
|
||||
@@ -37,6 +37,8 @@ ISWACygnet::ISWACygnet(std::string path)
|
||||
,_path("path", "Path", path)
|
||||
,_updateInterval("updateInterval", "Update Interval", 3, 1, 10)
|
||||
,_shader(nullptr)
|
||||
,_texture(nullptr)
|
||||
,_frame("GALACTIC")
|
||||
{
|
||||
addProperty(_enabled);
|
||||
addProperty(_cygnetId);
|
||||
@@ -87,7 +89,14 @@ void ISWACygnet::setPscUniforms(
|
||||
program->setUniform("scaling", camera->scaling());
|
||||
}
|
||||
|
||||
std::string ISWACygnet::getiSWAurl(int id){
|
||||
void ISWACygnet::registerProperties(){
|
||||
OsEng.gui()._property.registerProperty(&_enabled);
|
||||
OsEng.gui()._property.registerProperty(&_cygnetId);
|
||||
OsEng.gui()._property.registerProperty(&_path);
|
||||
OsEng.gui()._property.registerProperty(&_updateInterval);
|
||||
}
|
||||
|
||||
std::string ISWACygnet::iSWAurl(int id){
|
||||
std::string url = "http://iswa2.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?timestamp=";
|
||||
std::string t = Time::ref().currentTimeUTC();
|
||||
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
|
||||
#ifndef __ISWACYGNET_H__
|
||||
#define __ISWACYGNET_H__
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <memory>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
@@ -33,6 +35,7 @@
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
namespace openspace{
|
||||
class ISWACygnet : public properties::PropertyOwner{
|
||||
@@ -47,11 +50,13 @@ public:
|
||||
virtual void update();
|
||||
|
||||
bool enabled(){return _enabled.value();}
|
||||
|
||||
protected:
|
||||
std::string getiSWAurl(int id);
|
||||
std::string iSWAurl(int id);
|
||||
|
||||
void setPscUniforms(ghoul::opengl::ProgramObject* program, const Camera* camera, const PowerScaledCoordinate& position);
|
||||
virtual void setParent() = 0;
|
||||
void registerProperties();
|
||||
|
||||
properties::BoolProperty _enabled;
|
||||
properties::IntProperty _cygnetId;
|
||||
@@ -59,7 +64,9 @@ protected:
|
||||
properties::FloatProperty _updateInterval;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
|
||||
SceneGraphNode* _parent;
|
||||
glm::vec4 _pscOffset;
|
||||
glm::vec4 _modelScale;
|
||||
|
||||
@@ -67,10 +74,11 @@ protected:
|
||||
std::string _frame;
|
||||
std::string _var;
|
||||
|
||||
SceneGraphNode* _parent;
|
||||
double _time;
|
||||
double _lastUpdateTime = 0;
|
||||
std::map<std::string, std::string> _month;
|
||||
|
||||
int _id;
|
||||
};
|
||||
|
||||
}//namespace openspace
|
||||
|
||||
@@ -43,18 +43,12 @@ namespace {
|
||||
namespace openspace {
|
||||
|
||||
TexturePlane::TexturePlane(std::string path)
|
||||
:ISWACygnet(path)
|
||||
,_texture(nullptr)
|
||||
, _quad(0)
|
||||
, _vertexPositionBuffer(0)
|
||||
, _futureTexture(nullptr)
|
||||
:CygnetPlane(path)
|
||||
,_futureTexture(nullptr)
|
||||
{
|
||||
_id = id();
|
||||
setName("TexturePlane" + std::to_string(_id));
|
||||
OsEng.gui()._property.registerProperty(&_enabled);
|
||||
OsEng.gui()._property.registerProperty(&_cygnetId);
|
||||
OsEng.gui()._property.registerProperty(&_path);
|
||||
OsEng.gui()._property.registerProperty(&_updateInterval);
|
||||
registerProperties();
|
||||
|
||||
_path.setValue("${OPENSPACE_DATA}/"+ name() + ".jpg");
|
||||
_cygnetId.onChange([this](){ updateTexture(); });
|
||||
@@ -67,22 +61,13 @@ TexturePlane::~TexturePlane(){
|
||||
|
||||
|
||||
bool TexturePlane::initialize(){
|
||||
ISWACygnet::initialize();
|
||||
glGenVertexArrays(1, &_quad); // generate array
|
||||
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
|
||||
createPlane();
|
||||
_modelScale = glm::vec4(3, 3, 3, 10);
|
||||
_pscOffset = glm::vec4(0, 0, 0, 1);
|
||||
|
||||
if (_shader == nullptr) {
|
||||
// Plane Program
|
||||
CygnetPlane::initialize();
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_shader = renderEngine.buildRenderProgram("PlaneProgram",
|
||||
"${MODULE_ISWA}/shaders/cygnetplane_vs.glsl",
|
||||
"${MODULE_ISWA}/shaders/cygnetplane_fs.glsl"
|
||||
);
|
||||
if (!_shader)
|
||||
return false;
|
||||
}
|
||||
std::thread t = std::thread(std::bind(&TexturePlane::updateTexture, this));
|
||||
t.detach();
|
||||
|
||||
loadTexture();
|
||||
|
||||
@@ -90,7 +75,7 @@ bool TexturePlane::initialize(){
|
||||
}
|
||||
|
||||
bool TexturePlane::deinitialize(){
|
||||
ISWACygnet::deinitialize();
|
||||
CygnetPlane::deinitialize();
|
||||
|
||||
glDeleteVertexArrays(1, &_quad);
|
||||
_quad = 0;
|
||||
@@ -109,16 +94,6 @@ bool TexturePlane::deinitialize(){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TexturePlane::isReady() const {
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
if(!_texture)
|
||||
ready &= false;
|
||||
return ready;
|
||||
};
|
||||
|
||||
void TexturePlane::render(){
|
||||
psc position = _parent->worldPosition();
|
||||
|
||||
@@ -126,7 +101,7 @@ void TexturePlane::render(){
|
||||
transform = glm::inverse(OsEng.renderEngine().camera()->viewRotationMatrix());
|
||||
|
||||
float textureRatio = (float (_texture->height()/float(_texture->width())));
|
||||
transform = glm::scale(transform, glm::vec3(1000, 1000*textureRatio, 1));
|
||||
transform = glm::scale(transform, glm::vec3(1, textureRatio, 1));
|
||||
|
||||
glm::mat4 rotx = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
|
||||
glm::mat4 roty = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(0, 1, 0));
|
||||
@@ -166,9 +141,8 @@ void TexturePlane::render(){
|
||||
}
|
||||
|
||||
void TexturePlane::update(){
|
||||
_time = Time::ref().currentTime();
|
||||
CygnetPlane::update();
|
||||
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", "GSM", Time::ref().currentTime());
|
||||
if(_futureTexture && _futureTexture->isFinished){
|
||||
_path.set(absPath("${OPENSPACE_DATA}/"+_futureTexture->filePath));
|
||||
loadTexture();
|
||||
@@ -176,10 +150,6 @@ void TexturePlane::update(){
|
||||
delete _futureTexture;
|
||||
_futureTexture = nullptr;
|
||||
}
|
||||
|
||||
if((_time-_lastUpdateTime) >= _updateInterval){
|
||||
updateTexture();
|
||||
}
|
||||
}
|
||||
|
||||
void TexturePlane::setParent(){
|
||||
@@ -190,7 +160,7 @@ void TexturePlane::updateTexture(){
|
||||
int imageSize = 1024;
|
||||
DownloadManager::FileFuture* future;
|
||||
future = DlManager.downloadFile(
|
||||
getiSWAurl(_cygnetId.value()),
|
||||
iSWAurl(_cygnetId.value()),
|
||||
absPath(_path.value()),
|
||||
true,
|
||||
[](const DownloadManager::FileFuture& f){
|
||||
@@ -202,7 +172,7 @@ void TexturePlane::updateTexture(){
|
||||
_futureTexture = future;
|
||||
imageSize-=1;
|
||||
}
|
||||
_lastUpdateTime = _time;
|
||||
|
||||
}
|
||||
|
||||
void TexturePlane::loadTexture() {
|
||||
@@ -221,31 +191,31 @@ void TexturePlane::loadTexture() {
|
||||
|
||||
}
|
||||
|
||||
void TexturePlane::createPlane() {
|
||||
// ============================
|
||||
// GEOMETRY (quad)
|
||||
// ============================
|
||||
const GLfloat x = 1.0;//_modelScale.x/2.0;
|
||||
const GLfloat y = 1.0;//_modelScale.y/2.0;
|
||||
const GLfloat w = 7.0;//_modelScale.w;
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// x y z w s t
|
||||
-x, -y, 0.0f, w, 0, 1,
|
||||
x, y, 0.0f, w, 1, 0,
|
||||
-x, y, 0.0f, w, 0, 0,
|
||||
-x, -y, 0.0f, w, 0, 1,
|
||||
x, -y, 0.0f, w, 1, 1,
|
||||
x, y, 0.0f, w, 1, 0,
|
||||
};
|
||||
// void TexturePlane::createPlane() {
|
||||
// // ============================
|
||||
// // GEOMETRY (quad)
|
||||
// // ============================
|
||||
// const GLfloat x = 1.0;//_modelScale.x/2.0;
|
||||
// const GLfloat y = 1.0;//_modelScale.y/2.0;
|
||||
// const GLfloat w = 7.0;//_modelScale.w;
|
||||
// const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// // x y z w s t
|
||||
// -x, -y, 0.0f, w, 0, 1,
|
||||
// x, y, 0.0f, w, 1, 0,
|
||||
// -x, y, 0.0f, w, 0, 0,
|
||||
// -x, -y, 0.0f, w, 0, 1,
|
||||
// x, -y, 0.0f, w, 1, 1,
|
||||
// x, y, 0.0f, w, 1, 0,
|
||||
// };
|
||||
|
||||
glBindVertexArray(_quad); // bind array
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
}
|
||||
// glBindVertexArray(_quad); // bind array
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
// glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
// glEnableVertexAttribArray(0);
|
||||
// glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
// glEnableVertexAttribArray(1);
|
||||
// glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
// }
|
||||
|
||||
int TexturePlane::id(){
|
||||
static int id = 0;
|
||||
|
||||
@@ -26,17 +26,13 @@
|
||||
#define __TEXTUREPLANE_H__
|
||||
|
||||
// #include <openspace/rendering/renderable.h>
|
||||
#include <modules/iswa/rendering/iswacygnet.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <modules/iswa/rendering/cygnetplane.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/engine/downloadmanager.h>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
|
||||
namespace openspace{
|
||||
|
||||
class TexturePlane : public ISWACygnet {
|
||||
class TexturePlane : public CygnetPlane{
|
||||
public:
|
||||
TexturePlane(std::string path);
|
||||
~TexturePlane();
|
||||
@@ -44,29 +40,17 @@
|
||||
virtual bool initialize();
|
||||
virtual bool deinitialize();
|
||||
|
||||
bool isReady() const;
|
||||
|
||||
virtual void render();
|
||||
virtual void update();
|
||||
|
||||
private:
|
||||
virtual void setParent() override;
|
||||
|
||||
void loadTexture();
|
||||
void createPlane();
|
||||
void updateTexture();
|
||||
virtual void loadTexture() override;
|
||||
virtual void updateTexture() override;
|
||||
|
||||
static int id();
|
||||
int _id;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
|
||||
glm::size3_t _dimensions;
|
||||
|
||||
DownloadManager::FileFuture* _futureTexture;
|
||||
|
||||
GLuint _quad;
|
||||
GLuint _vertexPositionBuffer;
|
||||
|
||||
// bool _planeIsDirty;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -43,7 +43,10 @@ Fragment getFragment() {
|
||||
// diffuse = vec4(1,0,0,1);
|
||||
// }
|
||||
|
||||
if (diffuse.r <= 0.05)
|
||||
//diffuse.a = diffuse.r;
|
||||
float tot = diffuse.r + diffuse.g + diffuse.b;
|
||||
tot /= 3.0;
|
||||
if (tot <= 0.05)
|
||||
discard;
|
||||
|
||||
Fragment frag;
|
||||
|
||||
Reference in New Issue
Block a user