From d3df58ff9264c7dd7d542e67bd8eb5b5e05c9824 Mon Sep 17 00:00:00 2001 From: Sebastian Piwell Date: Mon, 25 Apr 2016 13:37:27 -0400 Subject: [PATCH] Preparation for ENLIL model --- modules/iswa/rendering/iswacygnet.cpp | 104 +++++++++++++---------- modules/iswa/rendering/iswacygnet.h | 1 + modules/iswa/shaders/dataplane_fs.glsl | 3 +- modules/iswa/util/iswamanager.cpp | 17 +++- modules/kameleon/src/kameleonwrapper.cpp | 2 +- 5 files changed, 77 insertions(+), 50 deletions(-) diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index 366108a6b5..998cba2ba3 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -39,54 +39,68 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary) { _data = std::make_shared(); - // dict.getValue can only set strings in _data directly - float renderableId; - float updateTime; - glm::vec3 min, max; - glm::vec4 spatialScale; + // dict.getValue can only set strings in _data directly + float renderableId; + float updateTime; + glm::vec3 min, max; + glm::vec4 spatialScale; - dictionary.getValue("Id", renderableId); - dictionary.getValue("UpdateTime", updateTime); - dictionary.getValue("SpatialScale", spatialScale); - dictionary.getValue("Min", min); - dictionary.getValue("Max", max); - dictionary.getValue("Frame",_data->frame); - - - _data->id = (int) renderableId; - _data->updateTime = (int) updateTime; - _data->spatialScale = spatialScale; - _data->min = min; - _data->max = max; - - _data->scale = glm::vec3( - (max.x - min.x), - (max.y - min.y), - (max.z - min.z) - ); - - _data->offset = glm::vec3( - (min.x + (std::abs(min.x)+std::abs(max.x))/2.0f), - (min.y + (std::abs(min.y)+std::abs(max.y))/2.0f), - (min.z + (std::abs(min.z)+std::abs(max.z))/2.0f) - ); + dictionary.getValue("Id", renderableId); + dictionary.getValue("UpdateTime", updateTime); + dictionary.getValue("SpatialScale", spatialScale); + dictionary.getValue("Min", min); + dictionary.getValue("Max", max); + dictionary.getValue("Frame",_data->frame); + dictionary.getValue("CoordinateType", _data->coordinateType); + + _data->id = (int) renderableId; + _data->updateTime = (int) updateTime; + _data->spatialScale = spatialScale; + _data->min = min; + _data->max = max; - // dictionary.getValue("Path",_data->path); - // dictionary.getValue("Parent",_data->parent); + glm::vec3 scale; + glm::vec3 offset; + + std::cout << _data->coordinateType << std::endl; + if(_data->coordinateType == "Cartesian"){ + scale = glm::vec3( + (max.x - min.x), + (max.y - min.y), + (max.z - min.z) + ); + + offset = glm::vec3( + (min.x + (std::abs(min.x)+std::abs(max.x))/2.0f), + (min.y + (std::abs(min.y)+std::abs(max.y))/2.0f), + (min.z + (std::abs(min.z)+std::abs(max.z))/2.0f) + ); + } else if(_data->coordinateType == "Polar"){ + scale = glm::vec3( + (max.x - min.x), + 0.0f, + (max.x - min.x) + ); + + offset = glm::vec3(0.0f); + } + + _data->scale = scale; + _data->offset = offset; + // dictionary.getValue("Path",_data->path); + // dictionary.getValue("Parent",_data->parent); // addProperty(_enabled); addProperty(_delete); - // std::cout << _data->id << std::endl; - // std::cout << std::to_string(_data->offset) << std::endl; - // std::cout << std::to_string(_data->scale) << std::endl; - // std::cout << std::to_string(_data->max) << std::endl; + // std::cout << _data->id << std::endl; + std::cout << _data->frame << std::endl; + std::cout << std::to_string(_data->offset) << std::endl; + std::cout << std::to_string(_data->scale) << std::endl; + // std::cout << std::to_string(_data->max) << std::endl; // std::cout << std::to_string(_data->min) << std::endl; - // std::cout << std::to_string(_data->spatialScale) << std::endl; - // std::cout << _data->path << std::endl; - // std::cout << _data->parent << std::endl; - // std::cout << _data->frame << std::endl; + std::cout << std::to_string(_data->spatialScale) << std::endl; _delete.onChange([this](){ISWAManager::ref().deleteISWACygnet(name());}); } @@ -103,13 +117,13 @@ void ISWACygnet::unregisterProperties(){ } void ISWACygnet::initializeTime(){ - _openSpaceTime = Time::ref().currentTime(); - _lastUpdateOpenSpaceTime = _openSpaceTime; + _openSpaceTime = Time::ref().currentTime(); + _lastUpdateOpenSpaceTime = _openSpaceTime; - _realTime = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); - _lastUpdateRealTime = _realTime; + _realTime = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); + _lastUpdateRealTime = _realTime; - _minRealTimeUpdateInterval = 100; + _minRealTimeUpdateInterval = 100; } }//namespace openspac \ No newline at end of file diff --git a/modules/iswa/rendering/iswacygnet.h b/modules/iswa/rendering/iswacygnet.h index 3b36d7c5bc..3a4cc0db37 100644 --- a/modules/iswa/rendering/iswacygnet.h +++ b/modules/iswa/rendering/iswacygnet.h @@ -60,6 +60,7 @@ struct Metadata { glm::vec3 scale; glm::vec4 spatialScale; std::string scaleVariable; + std::string coordinateType; }; diff --git a/modules/iswa/shaders/dataplane_fs.glsl b/modules/iswa/shaders/dataplane_fs.glsl index f3d1dc4ed1..ff8683424c 100644 --- a/modules/iswa/shaders/dataplane_fs.glsl +++ b/modules/iswa/shaders/dataplane_fs.glsl @@ -42,7 +42,8 @@ Fragment getFragment() { vec4 diffuse; // diffuse = top; diffuse = texture(texture1, vec2(vs_st.s, 1-vs_st.t)); - //float v = texture(texture1, vs_st).r; + // diffuse = vec4(1,0,0,1); + // float v = texture(texture1, vs_st).r; //float x = tfValues.x; //float y = tfValues.y; diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index c675b40d01..01224cfadb 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -223,6 +223,7 @@ namespace openspace{ std::string parent = j["Central Body"]; std::string frame = j["Coordinates"]; + std::string coordinateType = j["Coordinate Type"]; int updateTime = j["ISWA_UPDATE_SECONDS"]; glm::vec3 max( @@ -257,6 +258,7 @@ namespace openspace{ "Max = " + std::to_string(max) + ", " "SpatialScale = " + std::to_string(spatialScale) + ", " "UpdateTime = " + std::to_string(updateTime) + ", " + "CoordinateType = '" + coordinateType + "', " "}" "}" ; @@ -279,19 +281,26 @@ namespace openspace{ glm::vec3 max = kw.getGridMax(); glm::vec4 spatialScale; + std::string coordinateType; + std::tuple < std::string, std::string, std::string > gridUnits = kw.getGridUnits(); if (std::get<0>(gridUnits) == "R" && std::get<1>(gridUnits) == "R" && std::get<2>(gridUnits) == "R") { spatialScale.x = 6.371f; spatialScale.y = 6.371f; spatialScale.z = 6.371f; spatialScale.w = 6; + + coordinateType = "Cartesian"; }else{ spatialScale = glm::vec4(1.0); - spatialScale.w = -log10(1.0f/max.x); + spatialScale.w = 1; //-log10(1.0f/max.x); + + coordinateType = "Polar"; } std::string table = "{" "Name = 'KameleonPlane0'," - "Parent = '" + parent + "', " + // "Parent = 'Earth', " + "Parent = '" + parent + "', " "Renderable = {" "Type = 'KameleonPlane', " "Id = 0 ," @@ -301,7 +310,8 @@ namespace openspace{ "SpatialScale = " + std::to_string(spatialScale) + ", " "UpdateTime = 0, " "kwPath = '" + kwPath + "' ," - "axisCut = 'y'" + "axisCut = 'y' ," + "CoordinateType = '" + coordinateType + "', " "}" "}" ; @@ -340,6 +350,7 @@ namespace openspace{ if(FileSys.fileExists(absPath(kwPath)) && extension == "cdf"){ std::string luaTable = parseKWToLuaTable(kwPath); if(!luaTable.empty()){ + std::cout << luaTable << std::endl; std::string script = "openspace.addSceneGraphNode(" + luaTable + ");"; OsEng.scriptEngine().queueScript(script); } diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index 0097ce7250..424dff82dc 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -1005,7 +1005,7 @@ std::string KameleonWrapper::getParent(){ _type == KameleonWrapper::Model::Adapt3D || _type == KameleonWrapper::Model::SWMF) { - return "SolarSystem"; + return "Sun"; }else{ return ""; }