Implemented dataSphere

This commit is contained in:
Sebastian Piwell
2016-05-05 17:57:52 -04:00
parent b56f85e968
commit c284986c21
7 changed files with 145 additions and 36 deletions

View File

@@ -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(

View File

@@ -78,8 +78,6 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
else
_segments = static_cast<int>(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);

View File

@@ -31,27 +31,12 @@ CygnetSphere::CygnetSphere(const ghoul::Dictionary& dictionary)
:ISWACygnet(dictionary)
,_geometry(nullptr)
{
//read segments from dictronary
_segments = 20;
_geometry = std::make_shared<planetgeometry::SimpleSphereGeometry>(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<planetgeometry::SimpleSphereGeometry>(geometryDictionary);
_geometry->initialize(this);
}

View File

@@ -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;
}

View 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;
}

View 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);
}

View File

@@ -139,7 +139,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
);
}
}
@@ -259,6 +279,8 @@ std::string ISWAManager::parseJSONToLuaTable(std::shared_ptr<MetadataFuture> 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<MetadataFuture> 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;