diff --git a/data/scene/default.scene b/data/scene/default.scene index 1369a61f4a..97264e6e05 100644 --- a/data/scene/default.scene +++ b/data/scene/default.scene @@ -30,9 +30,10 @@ function postInitialization() openspace.printInfo("Done setting default values") - openspace.iswa.addCygnet("-1,Data,1"); - openspace.iswa.addCygnet("-2,Data,1"); - openspace.iswa.addCygnet("-3,Data,1"); + openspace.iswa.addCygnet("0"); + --openspace.iswa.addCygnet("-1,Data,1"); + --openspace.iswa.addCygnet("-2,Data,1"); + --openspace.iswa.addCygnet("-3,Data,1"); --[[ openspace.registerScreenSpaceRenderable( diff --git a/modules/base/rendering/simplespheregeometry.cpp b/modules/base/rendering/simplespheregeometry.cpp index 8bd94c268f..ff037a8ef3 100644 --- a/modules/base/rendering/simplespheregeometry.cpp +++ b/modules/base/rendering/simplespheregeometry.cpp @@ -78,8 +78,6 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary) else _segments = static_cast(segments); - glm::vec4 rradius(6.371f, 6.371f, 6.371f, 7); - _realRadius.setValue(rradius); // The shader need the radii values but they are not changeable runtime // TODO: Possibly add a scaling property @AA addProperty(_realRadius); diff --git a/modules/iswa/rendering/cygnetsphere.cpp b/modules/iswa/rendering/cygnetsphere.cpp index 3fc2da3bf1..e1792b4305 100644 --- a/modules/iswa/rendering/cygnetsphere.cpp +++ b/modules/iswa/rendering/cygnetsphere.cpp @@ -31,27 +31,12 @@ CygnetSphere::CygnetSphere(const ghoul::Dictionary& dictionary) :ISWACygnet(dictionary) ,_geometry(nullptr) { - //read segments from dictronary - _segments = 20; + _geometry = std::make_shared(dictionary); } CygnetSphere::~CygnetSphere(){} bool CygnetSphere::createGeometry(){ - glm::vec4 radius(6.371f, 6.371f, 6.371f, 6); //use scale in _data - - ghoul::Dictionary geometryDictionary; - geometryDictionary.setValue(SceneGraphNode::KeyName, name()); - geometryDictionary.setValue("Radius", radius); - geometryDictionary.setValue("Segments", _segments); - - glm::vec4 radiuss; - bool success = geometryDictionary.getValue("Radius", radiuss); - if(success){ - std::cout << "It exists" << std::endl; - } - - _geometry = std::make_shared(geometryDictionary); _geometry->initialize(this); } diff --git a/modules/iswa/rendering/datasphere.cpp b/modules/iswa/rendering/datasphere.cpp index 8f8d328011..d7a7653b20 100644 --- a/modules/iswa/rendering/datasphere.cpp +++ b/modules/iswa/rendering/datasphere.cpp @@ -43,14 +43,11 @@ DataSphere::~DataSphere(){} bool DataSphere::loadTexture(){ - std::cout << "Load texture" << std::endl; - _textures[0] = nullptr; std::string texturepath = "${OPENSPACE_DATA}/scene/mars/textures/mars.jpg"; auto texture = ghoul::io::TextureReader::ref().loadTexture(absPath(texturepath)); if(texture){ - std::cout << "Created the texture" << std::endl; texture->uploadTexture(); texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); _textures[0] = std::move(texture); @@ -63,7 +60,6 @@ bool DataSphere::updateTexture(){ if(_textures.empty()) _textures.push_back(nullptr); - std::cout << "Update texture" << std::endl; loadTexture(); return true; } @@ -75,8 +71,9 @@ bool DataSphere::readyToRender(){ bool DataSphere::setUniformAndTextures(){ - ghoul::opengl::TextureUnit unit; - + _shader->setUniform("transparency",0.5f); + + ghoul::opengl::TextureUnit unit; unit.activate(); _textures[0]->bind(); _shader->setUniform("texture1", unit); @@ -88,9 +85,9 @@ bool DataSphere::createShader(){ // Plane Program RenderEngine& renderEngine = OsEng.renderEngine(); _shader = renderEngine.buildRenderProgram( - "pscstandard", - "${MODULE_BASE}/shaders/pscstandard_vs.glsl", - "${MODULE_BASE}/shaders/pscstandard_fs.glsl"); + "DataSphereProgram", + "${MODULE_ISWA}/shaders/datasphere_vs.glsl", + "${MODULE_ISWA}/shaders/datasphere_fs.glsl"); if (!_shader) return false; } diff --git a/modules/iswa/shaders/datasphere_fs.glsl b/modules/iswa/shaders/datasphere_fs.glsl new file mode 100644 index 0000000000..555d19dea4 --- /dev/null +++ b/modules/iswa/shaders/datasphere_fs.glsl @@ -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; +} + diff --git a/modules/iswa/shaders/datasphere_vs.glsl b/modules/iswa/shaders/datasphere_vs.glsl new file mode 100644 index 0000000000..1f9664e401 --- /dev/null +++ b/modules/iswa/shaders/datasphere_vs.glsl @@ -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); +} \ No newline at end of file diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index f7e070558c..96151ac20a 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -139,7 +139,27 @@ void ISWAManager::addISWACygnet(int id, std::string info, int group){ ); }else{ //create kameleonplane - createKameleonPlane(info); + // createKameleonPlane(info); + std::shared_ptr metaFuture = std::make_shared(); + 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 + ); } } @@ -259,6 +279,8 @@ std::string ISWAManager::parseJSONToLuaTable(std::shared_ptr dat std::string coordinateType = j["Coordinate Type"]; int updateTime = j["ISWA_UPDATE_SECONDS"]; + j["Radius"]; + glm::vec3 max( j["Plot XMAX"], j["Plot YMAX"], @@ -294,8 +316,8 @@ std::string ISWAManager::parseJSONToLuaTable(std::shared_ptr dat "UpdateTime = " + std::to_string(updateTime) + ", " "CoordinateType = '" + coordinateType + "', " "Group = "+ std::to_string(data->group) + " ," - // "Radius = {6.371, 6.371, 6.371, 6} , " - // "Segments = 20," + "Radius = {6.371, 6.01}, " + "Segments = 20," "}" "}"; @@ -430,9 +452,9 @@ glm::dmat3 ISWAManager::getTransform(std::string from, std::string to, double et 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; @@ -460,6 +482,8 @@ 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;