diff --git a/modules/datasurface/rendering/dataplane.cpp b/modules/datasurface/rendering/dataplane.cpp index 37ecf52c03..359e431f6e 100644 --- a/modules/datasurface/rendering/dataplane.cpp +++ b/modules/datasurface/rendering/dataplane.cpp @@ -124,6 +124,8 @@ bool DataPlane::isReady() const { }; void DataPlane::render(){ + // getiSWAurl(1); + psc position = _parent->worldPosition(); glm::mat4 transform = glm::mat4(1.0); @@ -146,16 +148,22 @@ void DataPlane::render(){ // transform = glm::rotate(transform, _roatation.value()[1], glm::vec3(0,1,0)); // transform = glm::rotate(transform, _roatation.value()[2], glm::vec3(0,0,1)); - glm::vec4 vec(1,0,0,1); - vec = transform*vec; + glm::vec4 v(1,0,0,1); + glm::vec3 v1 = glm::vec3(transform*v); + v1 = glm::normalize(v1); double lt; - glm::vec3 sun_vec = + glm::vec3 v2 = SpiceManager::ref().targetPosition("SUN", "Earth", "GALACTIC", {}, _time, lt); - sun_vec = glm::normalize(sun_vec); - float angle = acos(glm::dot(sun_vec, glm::vec3(vec))/(glm::length(sun_vec)*glm::length(glm::vec3(vec)))); - glm::vec3 v = glm::cross(sun_vec, glm::vec3(vec)); - transform = glm::rotate(transform, -angle, v); + v2 = glm::normalize(v2); + + float angle = acos(glm::dot(v1,v2)); + glm::vec3 ref = glm::cross(v1, v2); + + transform = glm::rotate(transform, angle, ref); + + + // float angle = acos(glm::dot(sun_vec, (vec))/(glm::length(sun_vec)*glm::length(glm::vec3(vec)))); position += transform*glm::vec4(_pscOffset.x, _pscOffset.z, _pscOffset.y, _pscOffset.w); // std::cout << sun_vec.x << ", " << sun_vec.y << ", " << sun_vec.z << std::endl; diff --git a/modules/datasurface/rendering/datasurface.cpp b/modules/datasurface/rendering/datasurface.cpp index fb3e7a32c7..3510a9d645 100644 --- a/modules/datasurface/rendering/datasurface.cpp +++ b/modules/datasurface/rendering/datasurface.cpp @@ -26,8 +26,11 @@ #include #include #include +#include + namespace openspace{ + DataSurface::DataSurface(std::string path) :_path("path", "Path", path) ,_shader(nullptr) @@ -37,6 +40,20 @@ DataSurface::~DataSurface(){} bool DataSurface::initialize(){ setParent(); + + _month["JAN"] = "01"; + _month["FEB"] = "02"; + _month["MAR"] = "03"; + _month["APR"] = "04"; + _month["MAY"] = "05"; + _month["JUN"] = "06"; + _month["JUL"] = "07"; + _month["AUG"] = "08"; + _month["SEP"] = "09"; + _month["OCT"] = "10"; + _month["NOV"] = "11"; + _month["DEC"] = "12"; + return true; } @@ -60,4 +77,29 @@ void DataSurface::setPscUniforms( program->setUniform("camrot", camera->viewRotationMatrix()); program->setUniform("scaling", camera->scaling()); } + +std::string DataSurface::getiSWAurl(int id){ + std::string url = "http://iswa2.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?timestamp="; + std::string t = Time::ref().currentTimeUTC(); + + std::stringstream ss(t); + std::string token; + + std::getline(ss, token, ' '); + url += token + "-"; + std::getline(ss, token, ' '); + url += _month[token] + "-"; + std::getline(ss, token, 'T'); + url += token + "%20"; + std::getline(ss, token, '.'); + url += token; + + url += "&window=-1&cygnetId="; + url += std::to_string(id); + + std::cout << url << std::endl; + + // puts(buffer); + return url; +} }//namespace openspac \ No newline at end of file diff --git a/modules/datasurface/rendering/datasurface.h b/modules/datasurface/rendering/datasurface.h index 4b62be1994..e5c919d096 100644 --- a/modules/datasurface/rendering/datasurface.h +++ b/modules/datasurface/rendering/datasurface.h @@ -43,6 +43,8 @@ public: virtual void update(); protected: + std::string getiSWAurl(int id); + void setPscUniforms(ghoul::opengl::ProgramObject* program, const Camera* camera, const PowerScaledCoordinate& position); virtual void setParent() = 0; @@ -51,6 +53,7 @@ protected: SceneGraphNode* _parent; double _time; + std::map _month; }; }//namespace openspace diff --git a/modules/datasurface/rendering/datasurfacecontainer.cpp b/modules/datasurface/rendering/datasurfacecontainer.cpp index d4cdae8acd..82d1441f89 100644 --- a/modules/datasurface/rendering/datasurfacecontainer.cpp +++ b/modules/datasurface/rendering/datasurfacecontainer.cpp @@ -43,7 +43,7 @@ namespace openspace{ addDataSurface("${OPENSPACE_DATA}/BATSRUS.cdf"); // addDataSurface("${OPENSPACE_DATA}/ENLIL.cdf"); - //addTextureSurface("${OPENSPACE_DATA}/test.png"); + addTextureSurface("${OPENSPACE_DATA}/test.png"); } bool DataSurfaceContainer::deinitialize(){} bool DataSurfaceContainer::isReady() const {} diff --git a/modules/datasurface/rendering/textureplane.cpp b/modules/datasurface/rendering/textureplane.cpp index c20bc138db..f9eef9a083 100644 --- a/modules/datasurface/rendering/textureplane.cpp +++ b/modules/datasurface/rendering/textureplane.cpp @@ -171,8 +171,9 @@ void TexturePlane::updateTexture(){ while(true) { std::this_thread::sleep_for(std::chrono::milliseconds(6000)); future = DlManager.downloadFile( - std::string("http://placehold.it/" + std::to_string(imageSize) + "x" + std::to_string(imageSize)), - absPath("${OPENSPACE_DATA}/dataplane.png"), + getiSWAurl(5), + // std::string("http://placehold.it/" + std::to_string(imageSize) + "x" + std::to_string(imageSize)), + absPath("${OPENSPACE_DATA}/dataplane.jpg"), true, [](const DownloadManager::FileFuture& f){ std::cout<<"download finished"<