mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 20:21:24 -06:00
Merge branch 'feature/iSWA' of github.com:OpenSpace/OpenSpace-Development into feature/iSWA
This commit is contained in:
@@ -30,9 +30,10 @@ function postInitialization()
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
|
||||
openspace.iswa.addCygnet("0");
|
||||
--openspace.iswa.addCygnet("-1,Data,1");
|
||||
openspace.iswa.addCygnet("-2,Data,1");
|
||||
openspace.iswa.addCygnet("-3,Data,1");
|
||||
--openspace.iswa.addCygnet("-2,Data,1");
|
||||
--openspace.iswa.addCygnet("-3,Data,1");
|
||||
|
||||
--[[
|
||||
openspace.registerScreenSpaceRenderable(
|
||||
|
||||
@@ -77,7 +77,6 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
else
|
||||
_segments = static_cast<int>(segments);
|
||||
|
||||
// The shader need the radii values but they are not changeable runtime
|
||||
// TODO: Possibly add a scaling property @AA
|
||||
addProperty(_realRadius);
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace openspace {
|
||||
|
||||
fRenderable->registerClass<TexturePlane>("TexturePlane");
|
||||
fRenderable->registerClass<DataPlane>("DataPlane");
|
||||
fRenderable->registerClass<KameleonPlane>("KameleonPlane");
|
||||
// fRenderable->registerClass<KameleonPlane>("KameleonPlane");
|
||||
fRenderable->registerClass<DataSphere>("DataSphere");
|
||||
|
||||
auto fScreenSpaceRenderable = FactoryManager::ref().factory<ScreenSpaceRenderable>();
|
||||
|
||||
@@ -28,113 +28,11 @@ CygnetPlane::CygnetPlane(const ghoul::Dictionary& dictionary)
|
||||
:ISWACygnet(dictionary)
|
||||
,_quad(0)
|
||||
,_vertexPositionBuffer(0)
|
||||
,_futureObject(nullptr)
|
||||
{}
|
||||
|
||||
CygnetPlane::~CygnetPlane(){}
|
||||
|
||||
bool CygnetPlane::isReady() const{
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
return ready;
|
||||
}
|
||||
|
||||
void CygnetPlane::render(const RenderData& data){
|
||||
if(!textureReady()) return;
|
||||
|
||||
psc position = data.position;
|
||||
glm::mat4 transform = glm::mat4(1.0);
|
||||
|
||||
// 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));
|
||||
// glm::mat4 rotz = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(0, 0, 1));
|
||||
|
||||
glm::mat4 rot = glm::mat4(1.0);
|
||||
for (int i = 0; i < 3; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Correct for the small error of x-axis not pointing directly at the sun
|
||||
// if(_data->frame == "GSM"){
|
||||
|
||||
// transform = transform * rotz * roty; //BATSRUS
|
||||
|
||||
// glm::vec4 v(1,0,0,1);
|
||||
// glm::vec3 xVec = glm::vec3(transform*v);
|
||||
// xVec = glm::normalize(xVec);
|
||||
|
||||
// double lt;
|
||||
// glm::vec3 sunVec =
|
||||
// SpiceManager::ref().targetPosition("Sun", "Earth", "GALACTIC", {}, _openSpaceTime, lt);
|
||||
// sunVec = glm::normalize(sunVec);
|
||||
|
||||
// float angle = acos(glm::dot(xVec, sunVec));
|
||||
// glm::vec3 ref = glm::cross(xVec, sunVec);
|
||||
|
||||
// glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), angle, ref);
|
||||
// transform = rotation * transform;
|
||||
// }
|
||||
|
||||
position += transform*glm::vec4(_data->spatialScale.x*_data->offset, _data->spatialScale.w);
|
||||
|
||||
|
||||
// Activate shader
|
||||
_shader->activate();
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", transform);
|
||||
|
||||
setPscUniforms(*_shader.get(), data.camera, position);
|
||||
|
||||
setUniforms();
|
||||
|
||||
glBindVertexArray(_quad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
glEnable(GL_CULL_FACE);
|
||||
_shader->deactivate();
|
||||
|
||||
}
|
||||
|
||||
void CygnetPlane::update(const UpdateData& data){
|
||||
_openSpaceTime = Time::ref().currentTime();
|
||||
_realTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
|
||||
|
||||
|
||||
_stateMatrix = ISWAManager::ref().getTransform(_data->frame, "GALACTIC", _openSpaceTime);
|
||||
// glm::dmat3 spiceMatrix = SpiceManager::ref().positionTransformMatrix("J2000", "GALACTIC", _openSpaceTime);
|
||||
// = spiceMatrix*kameleonMatrix;
|
||||
|
||||
bool timeToUpdate = (fabs(_openSpaceTime-_lastUpdateOpenSpaceTime) >= _data->updateTime &&
|
||||
(_realTime.count()-_lastUpdateRealTime.count()) > _minRealTimeUpdateInterval);
|
||||
if( _data->updateTime != 0 && (Time::ref().timeJumped() || timeToUpdate )){
|
||||
updateTexture();
|
||||
|
||||
_lastUpdateRealTime = _realTime;
|
||||
_lastUpdateOpenSpaceTime = _openSpaceTime;
|
||||
}
|
||||
|
||||
if(_futureObject && _futureObject->isFinished){
|
||||
if(loadTexture())
|
||||
_futureObject = nullptr;
|
||||
}
|
||||
|
||||
if(!_transferFunctions.empty())
|
||||
for(auto tf : _transferFunctions)
|
||||
tf->update();
|
||||
}
|
||||
|
||||
bool CygnetPlane::textureReady(){
|
||||
return ((!_textures.empty()) && (_textures[0] != nullptr));
|
||||
}
|
||||
|
||||
void CygnetPlane::createPlane(){
|
||||
bool CygnetPlane::createGeometry() {
|
||||
glGenVertexArrays(1, &_quad); // generate array
|
||||
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
|
||||
|
||||
@@ -150,12 +48,12 @@ void CygnetPlane::createPlane(){
|
||||
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// x y z w s t
|
||||
-x, -z, -y, w, 0, 1,
|
||||
x, z, y, w, 1, 0,
|
||||
-x, ((x>0)?z:-z), y, w, 0, 0,
|
||||
-x, -z, -y, w, 0, 1,
|
||||
x, ((x>0)?-z:z), -y, w, 1, 1,
|
||||
x, z, y, w, 1, 0,
|
||||
-x, -y, -z, w, 0, 1,
|
||||
x, y, z, w, 1, 0,
|
||||
-x, ((x>0)?y:-y), z, w, 0, 0,
|
||||
-x, -y, -z, w, 0, 1,
|
||||
x, ((x>0)?-y:y), -z, w, 1, 1,
|
||||
x, y, z, w, 1, 0,
|
||||
};
|
||||
|
||||
glBindVertexArray(_quad); // bind array
|
||||
@@ -165,9 +63,10 @@ void CygnetPlane::createPlane(){
|
||||
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 CygnetPlane::destroyPlane(){
|
||||
bool CygnetPlane::destroyGeometry(){
|
||||
glDeleteVertexArrays(1, &_quad);
|
||||
_quad = 0;
|
||||
|
||||
@@ -175,26 +74,11 @@ void CygnetPlane::destroyPlane(){
|
||||
_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;
|
||||
}
|
||||
return true;
|
||||
bool CygnetPlane::renderGeometry(){
|
||||
glBindVertexArray(_quad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
}
|
||||
|
||||
void CygnetPlane::destroyShader(){
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_shader) {
|
||||
renderEngine.removeRenderProgram(_shader);
|
||||
_shader = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} //namespace openspace
|
||||
@@ -35,26 +35,13 @@ public:
|
||||
CygnetPlane(const ghoul::Dictionary& dictionary);
|
||||
~CygnetPlane();
|
||||
|
||||
virtual bool isReady() const override;
|
||||
virtual void render(const RenderData& data) override;
|
||||
virtual void update(const UpdateData& data) override;
|
||||
|
||||
protected:
|
||||
virtual bool loadTexture() = 0;
|
||||
virtual bool updateTexture() = 0;
|
||||
virtual void setUniforms() = 0;
|
||||
virtual bool textureReady();
|
||||
|
||||
void createPlane();
|
||||
void destroyPlane();
|
||||
bool createShader();
|
||||
void destroyShader();
|
||||
private:
|
||||
virtual bool createGeometry() override;
|
||||
virtual bool destroyGeometry() override;
|
||||
virtual bool renderGeometry() override;
|
||||
|
||||
GLuint _quad;
|
||||
GLuint _vertexPositionBuffer;
|
||||
|
||||
std::shared_ptr<DownloadManager::FileFuture> _futureObject;
|
||||
// float _backgroundValue;
|
||||
};
|
||||
} //namespace openspace
|
||||
|
||||
|
||||
@@ -17,30 +17,42 @@
|
||||
// ****************************************************************************************/
|
||||
|
||||
#include <modules/iswa/rendering/cygnetsphere.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <modules/base/rendering/planetgeometry.h>
|
||||
#include <modules/base/rendering/simplespheregeometry.h>
|
||||
#include <openspace/util/powerscaledsphere.h>
|
||||
#include <openspace/util/powerscaledscalar.h>
|
||||
|
||||
namespace openspace{
|
||||
|
||||
CygnetSphere::CygnetSphere(const ghoul::Dictionary& dictionary)
|
||||
:ISWACygnet(dictionary)
|
||||
,_futureObject(nullptr)
|
||||
,_sphere(nullptr)
|
||||
{}
|
||||
|
||||
CygnetSphere::~CygnetSphere(){}
|
||||
|
||||
bool CygnetSphere::isReady() const{
|
||||
return true;
|
||||
bool CygnetSphere::createGeometry(){
|
||||
PowerScaledScalar radius = PowerScaledScalar(3*6.371f, 6.0);
|
||||
int segments = 100;
|
||||
_sphere = std::make_shared<PowerScaledSphere>(radius, segments);
|
||||
_sphere->initialize();
|
||||
}
|
||||
|
||||
void CygnetSphere::render(const RenderData& data){
|
||||
|
||||
bool CygnetSphere::destroyGeometry(){
|
||||
_sphere = nullptr;
|
||||
}
|
||||
|
||||
void CygnetSphere::update(const UpdateData& data){
|
||||
|
||||
bool CygnetSphere::renderGeometry(){
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
_sphere->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} //namespace openspace
|
||||
@@ -28,20 +28,23 @@
|
||||
#include <modules/iswa/rendering/iswacygnet.h>
|
||||
|
||||
namespace openspace{
|
||||
class PowerScaledSphere;
|
||||
|
||||
namespace planetgeometry {
|
||||
class PlanetGeometry;
|
||||
}
|
||||
|
||||
class CygnetSphere : public ISWACygnet {
|
||||
public:
|
||||
CygnetSphere(const ghoul::Dictionary& dictionary);
|
||||
~CygnetSphere();
|
||||
|
||||
virtual bool isReady() const override;
|
||||
virtual void render(const RenderData& data) override;
|
||||
virtual void update(const UpdateData& data) override;
|
||||
|
||||
protected:
|
||||
virtual bool loadTexture() = 0;
|
||||
virtual bool updateTexture() = 0;
|
||||
|
||||
std::shared_ptr<DownloadManager::FileFuture> _futureObject;
|
||||
std::shared_ptr<PowerScaledSphere> _sphere;
|
||||
private:
|
||||
virtual bool createGeometry() override;
|
||||
virtual bool destroyGeometry() override;
|
||||
virtual bool renderGeometry() override;
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
|
||||
@@ -87,65 +87,13 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
});
|
||||
|
||||
_type = ISWAManager::CygnetType::Data;
|
||||
|
||||
setTransferFunctions(_transferFunctionsFile.value());
|
||||
}
|
||||
|
||||
DataPlane::~DataPlane(){}
|
||||
|
||||
|
||||
bool DataPlane::initialize(){
|
||||
initializeTime();
|
||||
|
||||
createPlane();
|
||||
|
||||
if (_shader == nullptr) {
|
||||
// DatePlane Program
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_shader = renderEngine.buildRenderProgram("DataPlaneProgram",
|
||||
"${MODULE_ISWA}/shaders/dataplane_vs.glsl",
|
||||
"${MODULE_ISWA}/shaders/dataplane_fs.glsl"
|
||||
);
|
||||
if (!_shader)
|
||||
return false;
|
||||
}
|
||||
|
||||
updateTexture();
|
||||
setTransferFunctions(_transferFunctionsFile.value());
|
||||
|
||||
// std::cout << "Creating Colorbar" << std::endl;
|
||||
// _colorbar = std::make_shared<ColorBar>();
|
||||
// if(_colorbar){
|
||||
// _colorbar->initialize();
|
||||
// }
|
||||
|
||||
// _textures.push_back(nullptr);
|
||||
if(_data->groupId > 0)
|
||||
ISWAManager::ref().registerToGroup(_data->groupId, _type, this);
|
||||
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool DataPlane::deinitialize(){
|
||||
|
||||
if(_data->groupId > 0)
|
||||
ISWAManager::ref().unregisterFromGroup(_data->groupId, this);
|
||||
|
||||
|
||||
unregisterProperties();
|
||||
destroyPlane();
|
||||
destroyShader();
|
||||
|
||||
_textures[0] = nullptr;
|
||||
_memorybuffer = "";
|
||||
|
||||
// _colorbar->deinitialize();
|
||||
// _colorbar = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataPlane::loadTexture() {
|
||||
|
||||
std::vector<float*> data = readData();
|
||||
if(data.empty())
|
||||
return false;
|
||||
@@ -200,8 +148,12 @@ bool DataPlane::updateTexture(){
|
||||
return false;
|
||||
}
|
||||
|
||||
void DataPlane::setUniforms(){
|
||||
bool DataPlane::readyToRender(){
|
||||
return (!_textures.empty());
|
||||
}
|
||||
|
||||
bool DataPlane::setUniformAndTextures(){
|
||||
|
||||
// _shader->setUniform("textures", 1, units[1]);
|
||||
// _shader->setUniform("textures", 2, units[2]);
|
||||
// }
|
||||
@@ -254,10 +206,18 @@ void DataPlane::setUniforms(){
|
||||
_shader->setUniform("numTextures", activeTextures);
|
||||
_shader->setUniform("numTransferFunctions", activeTransferfunctions);
|
||||
_shader->setUniform("backgroundValues", _backgroundValues.value());
|
||||
};
|
||||
}
|
||||
|
||||
bool DataPlane::textureReady(){
|
||||
return (!_textures.empty());
|
||||
bool DataPlane::createShader(){
|
||||
if (_shader == nullptr) {
|
||||
// DatePlane Program
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_shader = renderEngine.buildRenderProgram("DataPlaneProgram",
|
||||
"${MODULE_ISWA}/shaders/dataplane_vs.glsl",
|
||||
"${MODULE_ISWA}/shaders/dataplane_fs.glsl"
|
||||
);
|
||||
if (!_shader) return false;
|
||||
}
|
||||
}
|
||||
|
||||
void DataPlane::readHeader(){
|
||||
@@ -407,6 +367,7 @@ std::vector<float*> DataPlane::readData(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DataPlane::processData(float* outputData, std::vector<float>& inputData, float min, float max,float sum){
|
||||
|
||||
// HISTOGRAM
|
||||
@@ -524,13 +485,6 @@ float DataPlane::normalizeWithStandardScore(float value, float mean, float sd){
|
||||
return ( standardScore + zScoreMin )/(zScoreMin + zScoreMax );
|
||||
}
|
||||
|
||||
float DataPlane::normalizeWithLogarithm(float value, int logMean){
|
||||
float logMin = 10*_normValues.value().x;
|
||||
float logMax = 10*_normValues.value().y;
|
||||
|
||||
float logNormalized = ((value/pow(10,logMean)+logMin))/(logMin+logMax);
|
||||
return glm::clamp(logNormalized,0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void DataPlane::setTransferFunctions(std::string tfPath){
|
||||
std::string line;
|
||||
@@ -552,4 +506,12 @@ void DataPlane::setTransferFunctions(std::string tfPath){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}// namespace openspace
|
||||
@@ -40,11 +40,6 @@ friend class ISWAGroup;
|
||||
DataPlane(const ghoul::Dictionary& dictionary);
|
||||
~DataPlane();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
// virtual void render(const RenderData& data) override; //moved to cygnetPlane
|
||||
// virtual void update(const UpdateData& data) override; //moved to cygnetPlane
|
||||
|
||||
protected:
|
||||
void useLog(bool useLog){ _useLog.setValue(useLog); };
|
||||
void normValues(glm::vec2 normValues){ _normValues.setValue(normValues); };
|
||||
@@ -53,13 +48,13 @@ friend class ISWAGroup;
|
||||
void transferFunctionsFile(std::string tfPath){ _transferFunctionsFile.setValue(tfPath); };
|
||||
void backgroundValues(glm::vec2 backgroundValues){ _backgroundValues.setValue(backgroundValues); };
|
||||
|
||||
// const std::vector<openspace::properties::SelectionProperty::Option>& dataOptions() const {return _dataOptions.options(); };
|
||||
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
virtual void setUniforms() override;
|
||||
virtual bool textureReady() override;
|
||||
|
||||
virtual bool readyToRender() override;
|
||||
virtual bool setUniformAndTextures() override;
|
||||
virtual bool createShader() override;
|
||||
|
||||
void readHeader();
|
||||
std::vector<float*> readData();
|
||||
@@ -72,8 +67,6 @@ friend class ISWAGroup;
|
||||
);
|
||||
|
||||
float normalizeWithStandardScore(float value, float mean, float sd);
|
||||
float normalizeWithLogarithm(float value, int logMean);
|
||||
|
||||
void setTransferFunctions(std::string tfPath);
|
||||
|
||||
properties::SelectionProperty _dataOptions;
|
||||
|
||||
@@ -23,30 +23,78 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/iswa/rendering/datasphere.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <modules/base/rendering/planetgeometry.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
DataSphere::DataSphere(const ghoul::Dictionary& dictionary)
|
||||
:CygnetSphere(dictionary)
|
||||
{}
|
||||
{
|
||||
std::string name;
|
||||
dictionary.getValue("Name", name);
|
||||
setName(name);
|
||||
|
||||
registerProperties();
|
||||
}
|
||||
|
||||
DataSphere::~DataSphere(){}
|
||||
|
||||
|
||||
bool DataSphere::initialize(){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataSphere::deinitialize(){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataSphere::loadTexture(){
|
||||
std::string texturepath = "${OPENSPACE_DATA}/scene/mars/textures/mars.jpg";
|
||||
|
||||
auto texture = ghoul::io::TextureReader::ref().loadTexture(absPath(texturepath));
|
||||
if(texture){
|
||||
texture->uploadTexture();
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
_textures[0] = std::move(texture);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataSphere::updateTexture(){
|
||||
if(_textures.empty())
|
||||
_textures.push_back(nullptr);
|
||||
if(!_textures[0])
|
||||
loadTexture();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DataSphere::readyToRender(){
|
||||
bool ready = isReady();
|
||||
ready &= (!_textures.empty() && _textures[0]);
|
||||
ready &= (_sphere != nullptr);
|
||||
return ready;
|
||||
}
|
||||
|
||||
|
||||
bool DataSphere::setUniformAndTextures(){
|
||||
_shader->setUniform("transparency",0.5f);
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
_textures[0]->bind();
|
||||
_shader->setUniform("texture1", unit);
|
||||
}
|
||||
|
||||
|
||||
bool DataSphere::createShader(){
|
||||
if (_shader == nullptr) {
|
||||
// Plane Program
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_shader = renderEngine.buildRenderProgram(
|
||||
"DataSphereProgram",
|
||||
"${MODULE_ISWA}/shaders/datasphere_vs.glsl",
|
||||
"${MODULE_ISWA}/shaders/datasphere_fs.glsl");
|
||||
if (!_shader)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} //namespace openspace
|
||||
@@ -28,20 +28,21 @@
|
||||
#include <modules/iswa/rendering/cygnetsphere.h>
|
||||
|
||||
namespace openspace{
|
||||
|
||||
class PowerScaledSphere;
|
||||
class DataSphere : public CygnetSphere {
|
||||
public:
|
||||
DataSphere(const ghoul::Dictionary& dictionary);
|
||||
~DataSphere();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
|
||||
virtual bool readyToRender() override;
|
||||
virtual bool setUniformAndTextures() override;
|
||||
virtual bool createShader() override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
|
||||
// , _texture(nullptr)
|
||||
, _memorybuffer("")
|
||||
,_type(ISWAManager::CygnetType::NoType)
|
||||
,_futureObject(nullptr)
|
||||
// ,_transferFunction(nullptr)
|
||||
{
|
||||
_data = std::make_shared<Metadata>();
|
||||
@@ -102,6 +103,108 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
|
||||
ISWACygnet::~ISWACygnet(){}
|
||||
bool ISWACygnet::initialize(){
|
||||
_textures.push_back(nullptr);
|
||||
|
||||
initializeTime();
|
||||
createGeometry();
|
||||
createShader();
|
||||
updateTexture();
|
||||
|
||||
if(_data->groupId > 0)
|
||||
ISWAManager::ref().registerToGroup(_data->groupId, _type, this);
|
||||
|
||||
// return isReady();
|
||||
}
|
||||
|
||||
bool ISWACygnet::deinitialize(){
|
||||
if(_data->groupId > 0)
|
||||
ISWAManager::ref().unregisterFromGroup(_data->groupId, this);
|
||||
|
||||
unregisterProperties();
|
||||
destroyGeometry();
|
||||
destroyShader();
|
||||
_memorybuffer = "";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ISWACygnet::isReady() const{
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
return ready;
|
||||
}
|
||||
|
||||
void ISWACygnet::render(const RenderData& data){
|
||||
if(!readyToRender()) return;
|
||||
|
||||
psc position = data.position;
|
||||
glm::mat4 transform = glm::mat4(1.0);
|
||||
|
||||
glm::mat4 rot = glm::mat4(1.0);
|
||||
for (int i = 0; i < 3; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
position += transform*glm::vec4(_data->spatialScale.x*_data->offset, _data->spatialScale.w);
|
||||
|
||||
// Activate shader
|
||||
_shader->activate();
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", transform);
|
||||
|
||||
setPscUniforms(*_shader.get(), data.camera, position);
|
||||
|
||||
setUniformAndTextures();
|
||||
renderGeometry();
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
_shader->deactivate();
|
||||
}
|
||||
|
||||
void ISWACygnet::update(const UpdateData& data){
|
||||
_openSpaceTime = Time::ref().currentTime();
|
||||
_realTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
|
||||
|
||||
|
||||
_stateMatrix = ISWAManager::ref().getTransform(_data->frame, "GALACTIC", _openSpaceTime);
|
||||
// glm::dmat3 spiceMatrix = SpiceManager::ref().positionTransformMatrix("J2000", "GALACTIC", _openSpaceTime);
|
||||
// = spiceMatrix*kameleonMatrix;
|
||||
|
||||
bool timeToUpdate = (fabs(_openSpaceTime-_lastUpdateOpenSpaceTime) >= _data->updateTime &&
|
||||
(_realTime.count()-_lastUpdateRealTime.count()) > _minRealTimeUpdateInterval);
|
||||
if( _data->updateTime != 0 && (Time::ref().timeJumped() || timeToUpdate )){
|
||||
updateTexture();
|
||||
|
||||
_lastUpdateRealTime = _realTime;
|
||||
_lastUpdateOpenSpaceTime = _openSpaceTime;
|
||||
}
|
||||
|
||||
if(_futureObject && _futureObject->isFinished){
|
||||
if(loadTexture())
|
||||
_futureObject = nullptr;
|
||||
}
|
||||
|
||||
if(!_transferFunctions.empty())
|
||||
for(auto tf : _transferFunctions)
|
||||
tf->update();
|
||||
}
|
||||
|
||||
|
||||
bool ISWACygnet::destroyShader(){
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_shader) {
|
||||
renderEngine.removeRenderProgram(_shader);
|
||||
_shader = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ISWACygnet::registerProperties(){
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
|
||||
|
||||
@@ -75,15 +75,29 @@ public:
|
||||
ISWACygnet(const ghoul::Dictionary& dictionary);
|
||||
~ISWACygnet();
|
||||
|
||||
virtual bool initialize() = 0;
|
||||
virtual bool deinitialize() = 0;
|
||||
virtual bool initialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
virtual bool isReady() const override;
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
protected:
|
||||
void enabled(bool enabled){_enabled.setValue(enabled);};
|
||||
|
||||
void registerProperties();
|
||||
void unregisterProperties();
|
||||
void initializeTime();
|
||||
bool destroyShader();
|
||||
|
||||
void enabled(bool enabled){_enabled.setValue(enabled);};
|
||||
virtual bool createGeometry() = 0;
|
||||
virtual bool destroyGeometry() = 0;
|
||||
virtual bool renderGeometry() = 0;
|
||||
|
||||
virtual bool loadTexture() = 0;
|
||||
virtual bool updateTexture() = 0;
|
||||
virtual bool readyToRender() = 0;
|
||||
virtual bool setUniformAndTextures() = 0;
|
||||
virtual bool createShader() = 0;
|
||||
|
||||
properties::TriggerProperty _delete;
|
||||
|
||||
@@ -103,6 +117,7 @@ protected:
|
||||
int _minRealTimeUpdateInterval;
|
||||
|
||||
std::vector<std::shared_ptr<TransferFunction>> _transferFunctions;
|
||||
std::shared_ptr<DownloadManager::FileFuture> _futureObject;
|
||||
|
||||
ISWAManager::CygnetType _type;
|
||||
};
|
||||
|
||||
@@ -1,153 +1,153 @@
|
||||
// /*****************************************************************************************
|
||||
// * *
|
||||
// * OpenSpace *
|
||||
// * *
|
||||
// * Copyright (c) 2014-2016 *
|
||||
// * *
|
||||
// * 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. *
|
||||
// ****************************************************************************************/
|
||||
// // /*****************************************************************************************
|
||||
// // * *
|
||||
// // * OpenSpace *
|
||||
// // * *
|
||||
// // * Copyright (c) 2014-2016 *
|
||||
// // * *
|
||||
// // * 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/kameleonplane.h>
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/time.h>
|
||||
// #include <modules/iswa/rendering/kameleonplane.h>
|
||||
// #include <ghoul/filesystem/filesystem>
|
||||
// #include <ghoul/io/texture/texturereader.h>
|
||||
// #include <ghoul/opengl/programobject.h>
|
||||
// #include <ghoul/opengl/textureunit.h>
|
||||
// #include <modules/kameleon/include/kameleonwrapper.h>
|
||||
// #include <openspace/scene/scene.h>
|
||||
// #include <openspace/scene/scenegraphnode.h>
|
||||
// #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 = "KameleonPlane";
|
||||
}
|
||||
// namespace {
|
||||
// const std::string _loggerCat = "KameleonPlane";
|
||||
// }
|
||||
|
||||
namespace openspace {
|
||||
// namespace openspace {
|
||||
|
||||
KameleonPlane::KameleonPlane(const ghoul::Dictionary& dictionary)
|
||||
:CygnetPlane(dictionary)
|
||||
{
|
||||
std::string name;
|
||||
dictionary.getValue("Name", name);
|
||||
setName(name);
|
||||
// KameleonPlane::KameleonPlane(const ghoul::Dictionary& dictionary)
|
||||
// :CygnetPlane(dictionary)
|
||||
// {
|
||||
// std::string name;
|
||||
// dictionary.getValue("Name", name);
|
||||
// setName(name);
|
||||
|
||||
registerProperties();
|
||||
// registerProperties();
|
||||
|
||||
|
||||
dictionary.getValue("kwPath", _kwPath);
|
||||
// dictionary.getValue("kwPath", _kwPath);
|
||||
|
||||
std::string axis;
|
||||
dictionary.getValue("axisCut", axis);
|
||||
// std::string axis;
|
||||
// dictionary.getValue("axisCut", axis);
|
||||
|
||||
if(axis == "x"){
|
||||
_data->scale.x = 0;
|
||||
}else if(axis == "y"){
|
||||
_data->scale.y = 0;
|
||||
}else{
|
||||
_data->scale.z = 0;
|
||||
}
|
||||
}
|
||||
// if(axis == "x"){
|
||||
// _data->scale.x = 0;
|
||||
// }else if(axis == "y"){
|
||||
// _data->scale.y = 0;
|
||||
// }else{
|
||||
// _data->scale.z = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
KameleonPlane::~KameleonPlane(){}
|
||||
// KameleonPlane::~KameleonPlane(){}
|
||||
|
||||
|
||||
bool KameleonPlane::initialize(){
|
||||
_textures.push_back(nullptr);
|
||||
// bool KameleonPlane::initialize(){
|
||||
// _textures.push_back(nullptr);
|
||||
|
||||
std::cout << "initialize kameleonplane" << std::endl;
|
||||
// std::string kwPath;
|
||||
_kw = std::make_shared<KameleonWrapper>(absPath(_kwPath));
|
||||
// dictionary.getValue("KW", _kw);
|
||||
// std::cout << "initialize kameleonplane" << std::endl;
|
||||
// // std::string kwPath;
|
||||
// _kw = std::make_shared<KameleonWrapper>(absPath(_kwPath));
|
||||
// // dictionary.getValue("KW", _kw);
|
||||
|
||||
KameleonWrapper::Model model = _kw->model();
|
||||
if( model == KameleonWrapper::Model::BATSRUS)
|
||||
_var = "p";
|
||||
else
|
||||
_var = "rho";
|
||||
// KameleonWrapper::Model model = _kw->model();
|
||||
// if( model == KameleonWrapper::Model::BATSRUS)
|
||||
// _var = "p";
|
||||
// else
|
||||
// _var = "rho";
|
||||
|
||||
|
||||
createPlane();
|
||||
// createPlane();
|
||||
|
||||
if (_shader == nullptr) {
|
||||
// DatePlane Program
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_shader = renderEngine.buildRenderProgram("PlaneProgram",
|
||||
"${MODULE_ISWA}/shaders/dataplane_vs.glsl",
|
||||
"${MODULE_ISWA}/shaders/dataplane_fs.glsl"
|
||||
);
|
||||
if (!_shader)
|
||||
return false;
|
||||
}
|
||||
// if (_shader == nullptr) {
|
||||
// // DatePlane Program
|
||||
// RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
// _shader = renderEngine.buildRenderProgram("PlaneProgram",
|
||||
// "${MODULE_ISWA}/shaders/dataplane_vs.glsl",
|
||||
// "${MODULE_ISWA}/shaders/dataplane_fs.glsl"
|
||||
// );
|
||||
// if (!_shader)
|
||||
// return false;
|
||||
// }
|
||||
|
||||
_dimensions = glm::size3_t(500,500,1);
|
||||
float zSlice = 0.5f;
|
||||
_dataSlice = _kw->getUniformSliceValues(std::string(_var), _dimensions, zSlice);
|
||||
// _dimensions = glm::size3_t(500,500,1);
|
||||
// float zSlice = 0.5f;
|
||||
// _dataSlice = _kw->getUniformSliceValues(std::string(_var), _dimensions, zSlice);
|
||||
|
||||
loadTexture();
|
||||
// loadTexture();
|
||||
|
||||
return isReady();
|
||||
}
|
||||
// return isReady();
|
||||
// }
|
||||
|
||||
bool KameleonPlane::deinitialize(){
|
||||
unregisterProperties();
|
||||
destroyPlane();
|
||||
destroyShader();
|
||||
// bool KameleonPlane::deinitialize(){
|
||||
// unregisterProperties();
|
||||
// destroyPlane();
|
||||
// destroyShader();
|
||||
|
||||
_kw = nullptr;
|
||||
_memorybuffer = "";
|
||||
// _kw = nullptr;
|
||||
// _memorybuffer = "";
|
||||
|
||||
return true;
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
bool KameleonPlane::loadTexture() {
|
||||
std::cout << "load kameleonplane texture" << std::endl;
|
||||
ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear;
|
||||
ghoul::opengl::Texture::WrappingMode wrappingmode = ghoul::opengl::Texture::WrappingMode::ClampToEdge;
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture =
|
||||
std::make_unique<ghoul::opengl::Texture>(_dataSlice, _dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, filtermode, wrappingmode);
|
||||
// bool KameleonPlane::loadTexture() {
|
||||
// std::cout << "load kameleonplane texture" << std::endl;
|
||||
// ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear;
|
||||
// ghoul::opengl::Texture::WrappingMode wrappingmode = ghoul::opengl::Texture::WrappingMode::ClampToEdge;
|
||||
// std::unique_ptr<ghoul::opengl::Texture> texture =
|
||||
// std::make_unique<ghoul::opengl::Texture>(_dataSlice, _dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, filtermode, wrappingmode);
|
||||
|
||||
if (!texture)
|
||||
return false;
|
||||
// LDEBUG("Loaded texture from '" << absPath(_path) << "'");
|
||||
// if (!texture)
|
||||
// return false;
|
||||
// // LDEBUG("Loaded texture from '" << absPath(_path) << "'");
|
||||
|
||||
texture->uploadTexture();
|
||||
// texture->uploadTexture();
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
// // Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
// texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
|
||||
_textures[0] = std::move(texture);
|
||||
// _textures[0] = std::move(texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
|
||||
bool KameleonPlane::updateTexture(){
|
||||
return true;
|
||||
}
|
||||
// bool KameleonPlane::updateTexture(){
|
||||
// return true;
|
||||
// }
|
||||
|
||||
void KameleonPlane::setUniforms(){
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
// void KameleonPlane::setUniforms(){
|
||||
// ghoul::opengl::TextureUnit unit;
|
||||
|
||||
unit.activate();
|
||||
_textures[0]->bind();
|
||||
_shader->setUniform("texture1", unit);
|
||||
}
|
||||
// unit.activate();
|
||||
// _textures[0]->bind();
|
||||
// _shader->setUniform("texture1", unit);
|
||||
// }
|
||||
|
||||
}// namespace openspace
|
||||
// }// namespace openspace
|
||||
@@ -1,57 +1,57 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
// ****************************************************************************************
|
||||
// * *
|
||||
// * 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 __KAMELEONPLANE_H__
|
||||
#define __KAMELEONPLANE_H__
|
||||
// #ifndef __KAMELEONPLANE_H__
|
||||
// #define __KAMELEONPLANE_H__
|
||||
|
||||
#include <modules/iswa/rendering/cygnetplane.h>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
// #include <modules/iswa/rendering/cygnetplane.h>
|
||||
// #include <modules/kameleon/include/kameleonwrapper.h>
|
||||
|
||||
namespace openspace{
|
||||
// namespace openspace{
|
||||
|
||||
class KameleonPlane : public CygnetPlane {
|
||||
public:
|
||||
KameleonPlane(const ghoul::Dictionary& dictionary);
|
||||
~KameleonPlane();
|
||||
// class KameleonPlane : public CygnetPlane {
|
||||
// public:
|
||||
// KameleonPlane(const ghoul::Dictionary& dictionary);
|
||||
// ~KameleonPlane();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
// virtual bool initialize() override;
|
||||
// virtual bool deinitialize() override;
|
||||
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
virtual void setUniforms() override;
|
||||
// private:
|
||||
// virtual bool loadTexture() override;
|
||||
// virtual bool updateTexture() override;
|
||||
// virtual void setUniforms() override;
|
||||
|
||||
static int id();
|
||||
// static int id();
|
||||
|
||||
std::shared_ptr<KameleonWrapper> _kw;
|
||||
std::string _kwPath;
|
||||
glm::size3_t _dimensions;
|
||||
float* _dataSlice;
|
||||
std::string _var;
|
||||
};
|
||||
// std::shared_ptr<KameleonWrapper> _kw;
|
||||
// std::string _kwPath;
|
||||
// glm::size3_t _dimensions;
|
||||
// float* _dataSlice;
|
||||
// std::string _var;
|
||||
// };
|
||||
|
||||
} // namespace openspace
|
||||
// } // namespace openspace
|
||||
|
||||
#endif //__KAMELEONPLANE_H__
|
||||
// #endif //__KAMELEONPLANE_H__
|
||||
@@ -54,33 +54,6 @@ TexturePlane::TexturePlane(const ghoul::Dictionary& dictionary)
|
||||
|
||||
TexturePlane::~TexturePlane(){}
|
||||
|
||||
bool TexturePlane::initialize(){
|
||||
|
||||
_textures.push_back(nullptr);
|
||||
|
||||
initializeTime();
|
||||
createPlane();
|
||||
createShader();
|
||||
updateTexture();
|
||||
|
||||
if(_data->groupId > 0)
|
||||
ISWAManager::ref().registerToGroup(_data->groupId, _type, this);
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool TexturePlane::deinitialize(){
|
||||
if(_data->groupId > 0)
|
||||
ISWAManager::ref().unregisterFromGroup(_data->groupId, this);
|
||||
|
||||
unregisterProperties();
|
||||
destroyPlane();
|
||||
destroyShader();
|
||||
_memorybuffer = "";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TexturePlane::loadTexture() {
|
||||
if(_memorybuffer != ""){
|
||||
|
||||
@@ -112,6 +85,9 @@ bool TexturePlane::loadTexture() {
|
||||
|
||||
bool TexturePlane::updateTexture(){
|
||||
|
||||
if(_textures.empty())
|
||||
_textures.push_back(nullptr);
|
||||
|
||||
// If a download is in progress, dont send another request.
|
||||
if(_futureObject && !_futureObject->isFinished && !_futureObject->isAborted)
|
||||
return false;
|
||||
@@ -128,12 +104,34 @@ bool TexturePlane::updateTexture(){
|
||||
return false;
|
||||
}
|
||||
|
||||
void TexturePlane::setUniforms(){
|
||||
|
||||
bool TexturePlane::readyToRender(){
|
||||
return (isReady() && ((!_textures.empty()) && (_textures[0] != nullptr)));
|
||||
}
|
||||
|
||||
|
||||
bool TexturePlane::setUniformAndTextures(){
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
|
||||
unit.activate();
|
||||
_textures[0]->bind();
|
||||
_shader->setUniform("texture1", unit);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TexturePlane::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;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
@@ -35,16 +35,14 @@
|
||||
public:
|
||||
TexturePlane(const ghoul::Dictionary& dictionary);
|
||||
~TexturePlane();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
virtual void setUniforms() override;
|
||||
|
||||
static int id();
|
||||
virtual bool readyToRender() override;
|
||||
virtual bool setUniformAndTextures() override;
|
||||
virtual bool createShader() override;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
51
modules/iswa/shaders/datasphere_fs.glsl
Normal file
51
modules/iswa/shaders/datasphere_fs.glsl
Normal file
@@ -0,0 +1,51 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
uniform vec4 campos;
|
||||
uniform vec4 objpos;
|
||||
|
||||
uniform float time;
|
||||
uniform float transparency;
|
||||
uniform sampler2D texture1;
|
||||
in vec2 vs_st;
|
||||
|
||||
in vec4 vs_position;
|
||||
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
#include "fragment.glsl"
|
||||
|
||||
Fragment getFragment() {
|
||||
vec4 position = vs_position;
|
||||
float depth = pscDepth(position);
|
||||
vec4 diffuse = texture(texture1, vs_st);
|
||||
|
||||
diffuse.w = transparency;
|
||||
|
||||
Fragment frag;
|
||||
frag.color = diffuse;
|
||||
frag.depth = depth;
|
||||
|
||||
return frag;
|
||||
}
|
||||
|
||||
53
modules/iswa/shaders/datasphere_vs.glsl
Normal file
53
modules/iswa/shaders/datasphere_vs.glsl
Normal file
@@ -0,0 +1,53 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
layout(location = 1) in vec2 in_st;
|
||||
|
||||
out vec2 vs_st;
|
||||
out vec4 vs_position;
|
||||
out float s;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
// set variables
|
||||
vs_st = in_st;
|
||||
vs_position = in_position;
|
||||
vec4 tmp = in_position;
|
||||
|
||||
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
|
||||
// vs_normal = normalize(ModelTransform * vec4(in_normal,0));
|
||||
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_position = tmp;
|
||||
position = ViewProjection * position;
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
@@ -143,7 +143,27 @@ void ISWAManager::addISWACygnet(int id, std::string info, int group){
|
||||
);
|
||||
}else{
|
||||
//create kameleonplane
|
||||
createKameleonPlane(info);
|
||||
// createKameleonPlane(info);
|
||||
std::shared_ptr<MetadataFuture> metaFuture = std::make_shared<MetadataFuture>();
|
||||
metaFuture->id = -1;
|
||||
metaFuture->group = group;
|
||||
metaFuture->type = CygnetType::Data;
|
||||
metaFuture->geom = CygnetGeometry::Sphere;
|
||||
|
||||
auto metadataCallback =
|
||||
[this, metaFuture](const DownloadManager::FileFuture& f){
|
||||
LDEBUG("Download to memory finished");
|
||||
metaFuture->isFinished = true;
|
||||
createPlane(metaFuture);
|
||||
};
|
||||
|
||||
// Download metadata
|
||||
DlManager.downloadToMemory(
|
||||
"http://128.183.168.116:3000/" + std::to_string(1),
|
||||
// "http://10.0.0.76:3000/" + std::to_string(-id),
|
||||
metaFuture->json,
|
||||
metadataCallback
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,6 +307,12 @@ std::string ISWAManager::parseJSONToLuaTable(std::shared_ptr<MetadataFuture> dat
|
||||
std::string coordinateType = j["Coordinate Type"];
|
||||
int updateTime = j["ISWA_UPDATE_SECONDS"];
|
||||
|
||||
std::string radius = "";
|
||||
if(j["Radius"] == NULL){
|
||||
radius ="Radius = {6.371, 6.01}, "
|
||||
"Segments = 100,";
|
||||
}
|
||||
|
||||
glm::vec3 max(
|
||||
j["Plot XMAX"],
|
||||
j["Plot YMAX"],
|
||||
@@ -322,6 +348,7 @@ std::string ISWAManager::parseJSONToLuaTable(std::shared_ptr<MetadataFuture> dat
|
||||
"UpdateTime = " + std::to_string(updateTime) + ", "
|
||||
"CoordinateType = '" + coordinateType + "', "
|
||||
"Group = "+ std::to_string(data->group) + " ,"
|
||||
+ radius +
|
||||
"}"
|
||||
"}";
|
||||
|
||||
@@ -450,15 +477,24 @@ scripting::ScriptEngine::LuaLibrary ISWAManager::luaLibrary() {
|
||||
}
|
||||
|
||||
glm::dmat3 ISWAManager::getTransform(std::string from, std::string to, double et){
|
||||
auto fromit = _kameleonFrames.find(from);
|
||||
auto toit = _kameleonFrames.find(to);
|
||||
std::set<std::string> _diopoleFrames = {"GSM", "SM", "MAG"};
|
||||
|
||||
auto fromit = _diopoleFrames.find(from);
|
||||
auto toit = _diopoleFrames.find(to);
|
||||
|
||||
//diopole frame to J200 makes the frame rotate.
|
||||
if(fromit != _diopoleFrames.end()) from = "GSE";
|
||||
if(toit != _diopoleFrames.end()) to = "GSE";
|
||||
|
||||
fromit = _kameleonFrames.find(from);
|
||||
toit = _kameleonFrames.find(to);
|
||||
|
||||
bool fromKameleon = (fromit != _kameleonFrames.end());
|
||||
bool toKameleon = (toit != _kameleonFrames.end());
|
||||
|
||||
ccmc::Position in0 = {1, 0, 0};
|
||||
ccmc::Position in1 = {0, 1, 0};
|
||||
ccmc::Position in2 = {0, 0, 1};
|
||||
ccmc::Position in0 = {1.f, 0.f, 0.f};
|
||||
ccmc::Position in1 = {0.f, 1.f, 0.f};
|
||||
ccmc::Position in2 = {0.f, 0.f , 1.f};
|
||||
|
||||
ccmc::Position out0;
|
||||
ccmc::Position out1;
|
||||
@@ -486,8 +522,6 @@ glm::dmat3 ISWAManager::getTransform(std::string from, std::string to, double et
|
||||
out2.c0 , out2.c1 , out2.c2
|
||||
);
|
||||
|
||||
// std::cout << std::to_string(kameleonTrans) << std::endl;
|
||||
|
||||
glm::dmat3 spiceTrans = SpiceManager::ref().frameTransformationMatrix("J2000", to, et);
|
||||
|
||||
return spiceTrans*kameleonTrans;
|
||||
|
||||
Reference in New Issue
Block a user