Kameleon plane

This commit is contained in:
Sebastian Piwell
2016-04-25 10:34:43 -04:00
parent 999b9706c0
commit f13367e717
13 changed files with 291 additions and 147 deletions

View File

@@ -55,7 +55,7 @@ public:
bool isAborted;
std::string filePath;
std::string errorMessage;
std::string extension;
std::string format;
// Values set by others to be consumed by the DownloadManager
bool abortDownload;
};

View File

@@ -30,6 +30,7 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswacygnet.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/dataplane.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/textureplane.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/kameleonplane.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspacecygnet.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/colorbar.h
${CMAKE_CURRENT_SOURCE_DIR}/util/iswamanager.h
@@ -42,6 +43,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/cygnetplane.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/dataplane.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/textureplane.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/kameleonplane.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspacecygnet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/colorbar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/iswamanager.cpp

View File

@@ -32,6 +32,7 @@
#include <modules/iswa/rendering/iswacontainer.h>
#include <modules/iswa/rendering/textureplane.h>
#include <modules/iswa/rendering/dataplane.h>
#include <modules/iswa/rendering/kameleonplane.h>
namespace openspace {
@@ -46,5 +47,6 @@ namespace openspace {
fRenderable->registerClass<ISWAContainer>("ISWAContainer");
fRenderable->registerClass<TexturePlane>("TexturePlane");
fRenderable->registerClass<DataPlane>("DataPlane");
fRenderable->registerClass<KameleonPlane>("KameleonPlane");
}
}

View File

@@ -80,7 +80,7 @@ void CygnetPlane::render(const RenderData& data){
transform = rotation * transform;
}
position += transform*glm::vec4(_data->spatialScale.x*_data->offset, _data->spatialScale.y);
position += transform*glm::vec4(_data->spatialScale.x*_data->offset, _data->spatialScale.w);
// Activate shader
@@ -129,7 +129,7 @@ void CygnetPlane::update(const UpdateData& data){
bool timeToUpdate = (fabs(_openSpaceTime-_lastUpdateOpenSpaceTime) >= _data->updateTime &&
(_realTime.count()-_lastUpdateRealTime.count()) > _minRealTimeUpdateInterval));
(_realTime.count()-_lastUpdateRealTime.count()) > _minRealTimeUpdateInterval);
if( Time::ref().timeJumped() || timeToUpdate ){
updateTexture();
@@ -155,7 +155,7 @@ void CygnetPlane::createPlane(){
const GLfloat x = s*_data->scale.x/2.0;
const GLfloat y = s*_data->scale.y/2.0;
const GLfloat z = s*_data->scale.z/2.0;
const GLfloat w = _data->spatialScale.y;
const GLfloat w = _data->spatialScale.w;
const GLfloat vertex_data[] = { // square of two triangles (sigh)
// x y z w s t

View File

@@ -26,7 +26,6 @@
#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>
@@ -42,9 +41,9 @@ namespace openspace {
DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
:CygnetPlane(dictionary)
,_dataOptions("dataOptions", "Data Options")
,_normValues("normValues", "Normalize Values", glm::vec2(1.0, 1.0), glm::vec2(0), glm::vec2(5.0))
,_normValues("normValues", "Normalize Values", glm::vec2(0.1,0.2), glm::vec2(0), glm::vec2(0.5))
,_useLog("useLog","Use Logarithm Norm", false)
,_useHistogram("useHistogram","Use Histogram Equalization", true)
,_useHistogram("_useHistogram", "Use Histogram", true)
,_useRGB("useRGB","Use RGB Channels", false)
// ,_topColor("topColor", "Top Color", glm::vec4(1,0,0,1), glm::vec4(0), glm::vec4(1))
// ,_midColor("midColor", "Mid Color", glm::vec4(0,0,0,0), glm::vec4(0), glm::vec4(1))
@@ -59,7 +58,6 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
setName(name);
addProperty(_useLog);
addProperty(_useHistogram);
addProperty(_useRGB);
addProperty(_normValues);
addProperty(_dataOptions);
@@ -72,7 +70,6 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
registerProperties();
OsEng.gui()._iSWAproperty.registerProperty(&_useLog);
OsEng.gui()._iSWAproperty.registerProperty(&_useHistogram);
OsEng.gui()._iSWAproperty.registerProperty(&_useRGB);
OsEng.gui()._iSWAproperty.registerProperty(&_normValues);
OsEng.gui()._iSWAproperty.registerProperty(&_dataOptions);
@@ -85,7 +82,6 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
_normValues.onChange([this](){loadTexture();});
_useLog.onChange([this](){loadTexture();});
_useHistogram.onChange([this](){loadTexture();});
_dataOptions.onChange([this](){
if( _useRGB.value() && (_dataOptions.value().size() > 3)){
LWARNING("More than 3 values, using only the red channel.");
@@ -108,6 +104,7 @@ bool DataPlane::initialize(){
initializeTime();
createPlane();
if (_shader == nullptr) {
// DatePlane Program
RenderEngine& renderEngine = OsEng.renderEngine();
@@ -154,7 +151,7 @@ bool DataPlane::loadTexture() {
return false;
if (!_texture) {
std::unique_ptr<ghoul::opengl::Texture> texture = std::make_unique<ghoul::opengl::Texture>(
std::unique_ptr<ghoul::opengl::Texture> texture = std::make_unique<ghoul::opengl::Texture>(
values,
_dimensions,
ghoul::opengl::Texture::Format::RGB,
@@ -257,22 +254,6 @@ float* DataPlane::readData(){
std::vector<float> standardDeviation;
std::vector<std::vector<float>> optionValues;
// HISTOGRAM
// number of levels/bins/values
const int levels = 512;
// Normal Histogram where "levels" is the number of steps/bins
std::vector<std::vector<int>> histogram;
// Maps the old levels to new ones.
std::vector<std::vector<float>> newLevels;
// maps the data values to the histogram bin/index/level
auto mapToHistogram = [levels](float val, float varMin, float varMax) {
float probability = (val-varMin)/(varMax-varMin);
float mappedValue = probability * levels;
return glm::clamp(mappedValue, 0.0f, static_cast<float>(levels - 1));
};
for(int i=0; i < selectedOptions.size(); i++){
min.push_back(std::numeric_limits<float>::max());
@@ -283,11 +264,6 @@ float* DataPlane::readData(){
std::vector<float> v;
optionValues.push_back(v);
//initialize histogram for chosen values
histogram.push_back( std::vector<int>(levels, 0) );
//initialize the newLevels for chosen values
newLevels.push_back( std::vector<float>(levels, 0.0f) );
}
float* combinedValues = new float[3*_dimensions.x*_dimensions.y];
@@ -331,81 +307,39 @@ float* DataPlane::readData(){
mean.push_back((1.0 / numValues) * sum[i]);
//Calculate the Standard Deviation
standardDeviation.push_back(sqrt (((pow(sum[i], 2.0)) - ((1.0/numValues) * (pow(sum[i],2.0)))) / (numValues - 1.0)));
//calulate log mean
logmean[i] /= numValues;
logmean[i] /= numValues;
}
//HISTOGRAM FUNCTIONALITY
//======================
if(_useHistogram.value()){
for(int j=0; j<optionValues.size(); j++){
for(int i = 0; i < numValues; i++){
float v = optionValues[j][i];
float pixelVal = mapToHistogram(v, min[j], max[j]);
histogram[j][(int)pixelVal]++;
optionValues[j][i] = pixelVal;
}
// Map mean and standard deviation to histogram levels (Not sure about this)
mean[j] = mapToHistogram(mean[j] , min[j], max[j]);
logmean[j] = mapToHistogram(logmean[j] , min[j], max[j]);
standardDeviation[j] = mapToHistogram(standardDeviation[j], min[j], max[j]);
min[j] = 0.0f;
max[j] = levels - 1.0f;
}
//Calculate the cumulative distributtion function (CDF)
for(int j=0; j<optionValues.size(); j++){
float previousCdf = 0.0f;
for(int i = 0; i < levels; i++){
float probability = histogram[j][i] / (float)numValues;
float cdf = previousCdf + probability;
cdf = glm::clamp(cdf, 0.0f, 1.0f); //just in case
newLevels[j][i] = cdf * (levels-1);
previousCdf = cdf;
}
}
}
//======================
for(int i=0; i< numValues; i++){
combinedValues[3*i+0] = 0;
combinedValues[3*i+1] = 0;
combinedValues[3*i+2] = 0;
for(int j=0; j<optionValues.size(); j++){
float v = optionValues[j][i];
if(_useRGB.value() && (optionValues.size() <= 3)){
for(int j=0; j<optionValues.size(); j++){
// if use histogram get the equalized values
if(_useHistogram.value()){
v = newLevels[j][(int)v];
// Map mean and standard deviation to new histogram levels (Not sure about this)
mean[j] = newLevels[j][(int) mean[j]];
logmean[j] = newLevels[j][(int) logmean[j]];
standardDeviation[j] = newLevels[j][(int) standardDeviation[j]];
}
float v = optionValues[j][i];
if(_useRGB.value() && (optionValues.size() <= 3)){
if(_useLog.value()){
combinedValues[3*i+j] += normalizeWithLogarithm(v, logmean[j]);
}else{
combinedValues[3*i+j] += normalizeWithStandardScore(v, mean[j], standardDeviation[j]);
}
}else{
}
}else{
for(int j=0; j<optionValues.size(); j++){
float v = optionValues[j][i];
if(_useLog.value()){
combinedValues[3*i+0] += normalizeWithLogarithm(v, logmean[j]);
}else{
combinedValues[3*i+0] += normalizeWithStandardScore(v, mean[j], standardDeviation[j]);
}
combinedValues[3*i+0] /= selectedOptions.size();
}
combinedValues[3*i+0] /= selectedOptions.size();
}
}
return combinedValues;

View File

@@ -32,7 +32,6 @@ namespace openspace{
ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _updateInterval("updateInterval", "Update Interval", 0.35, 0.1 , 1.0)
, _delete("delete", "Delete")
, _shader(nullptr)
, _texture(nullptr)
@@ -44,7 +43,7 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
float renderableId;
float updateTime;
glm::vec3 min, max;
glm::vec2 spatialScale;
glm::vec4 spatialScale;
dictionary.getValue("Id", renderableId);
dictionary.getValue("UpdateTime", updateTime);
@@ -77,7 +76,6 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
// dictionary.getValue("Parent",_data->parent);
// addProperty(_enabled);
addProperty(_updateInterval);
addProperty(_delete);
// std::cout << _data->id << std::endl;
@@ -85,6 +83,7 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
// 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;
@@ -96,7 +95,6 @@ ISWACygnet::~ISWACygnet(){}
void ISWACygnet::registerProperties(){
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
OsEng.gui()._iSWAproperty.registerProperty(&_updateInterval);
OsEng.gui()._iSWAproperty.registerProperty(&_delete);
}

View File

@@ -58,7 +58,7 @@ struct Metadata {
glm::vec3 max;
glm::vec3 offset;
glm::vec3 scale;
glm::vec2 spatialScale;
glm::vec4 spatialScale;
std::string scaleVariable;
std::shared_ptr<KameleonWrapper> kw;
};
@@ -89,7 +89,6 @@ protected:
// void setParent();
// properties::BoolProperty _enabled;
properties::FloatProperty _updateInterval;
properties::TriggerProperty _delete;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;

View File

@@ -0,0 +1,138 @@
// /*****************************************************************************************
// * *
// * 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>
namespace {
const std::string _loggerCat = "KameleonPlane";
}
namespace openspace {
KameleonPlane::KameleonPlane(const ghoul::Dictionary& dictionary)
:CygnetPlane(dictionary)
{
_id = id();
std::string name;
dictionary.getValue("Name", name);
setName(name);
registerProperties();
dictionary.getValue("kwPath", _kwPath);
std::cout << "Creating kameleonplane" << std::endl;
}
KameleonPlane::~KameleonPlane(){}
bool KameleonPlane::initialize(){
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";
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;
}
_dimensions = glm::size3_t(500,500,1);
float zSlice = 0.5f;
_dataSlice = _kw->getUniformSliceValues(std::string(_var), _dimensions, zSlice);
loadTexture();
return isReady();
}
bool KameleonPlane::deinitialize(){
unregisterProperties();
destroyPlane();
destroyShader();
_kw = nullptr;
_memorybuffer = "";
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);
if (!texture)
return false;
// LDEBUG("Loaded texture from '" << absPath(_path) << "'");
texture->uploadTexture();
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
_texture = std::move(texture);
return true;
}
bool KameleonPlane::updateTexture(){
return true;
}
int KameleonPlane::id(){
static int id = 0;
return id++;
}
}// namespace openspace

View File

@@ -0,0 +1,56 @@
/*****************************************************************************************
* *
* 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__
#include <modules/iswa/rendering/cygnetplane.h>
#include <modules/kameleon/include/kameleonwrapper.h>
namespace openspace{
class KameleonPlane : public CygnetPlane {
public:
KameleonPlane(const ghoul::Dictionary& dictionary);
~KameleonPlane();
virtual bool initialize() override;
virtual bool deinitialize() override;
private:
virtual bool loadTexture() override;
virtual bool updateTexture() override;
static int id();
std::shared_ptr<KameleonWrapper> _kw;
std::string _kwPath;
glm::size3_t _dimensions;
float* _dataSlice;
std::string _var;
};
} // namespace openspace
#endif //__KAMELEONPLANE_H__

View File

@@ -85,7 +85,10 @@ namespace openspace{
metaFuture->type = info;
metaFuture->id = id;
_metaFutures.push_back(metaFuture);
}
}else{
//create kameleonplane
createKameleonPlane(info);
}
}
void ISWAManager::deleteISWACygnet(std::string name){
@@ -128,8 +131,8 @@ namespace openspace{
metaFuture->id = id;
DlManager.downloadToMemory(
// "http://128.183.168.116:3000/" + std::to_string(-id),
"http://10.0.0.76:3000/" + std::to_string(-id),
"http://128.183.168.116:3000/" + std::to_string(-id),
// "http://10.0.0.76:3000/" + std::to_string(-id),
metaFuture->json,
[metaFuture](const DownloadManager::FileFuture& f){
LDEBUG("Download to memory finished");
@@ -175,8 +178,8 @@ namespace openspace{
std::string ISWAManager::iSWAurl(int id, std::string type){
std::string url;
if(id < 0){
// url = "http://128.183.168.116:3000/ "+type+"/" + std::to_string(-id) + "/";
url = "http://10.0.0.76:3000/"+type+"/" + std::to_string(-id) + "/";
url = "http://128.183.168.116:3000/"+type+"/" + std::to_string(-id) + "/";
// url = "http://10.0.0.76:3000/"+type+"/" + std::to_string(-id) + "/";
} else{
url = "http://iswa2.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?window=-1&cygnetId="+ std::to_string(id) +"&timestamp=";
}
@@ -234,11 +237,13 @@ namespace openspace{
j["Plot ZMIN"]
);
glm::vec2 spatialScale(1, 10);
glm::vec4 spatialScale(1, 1, 1, 10);
std::string spatial = j["Spatial Scale (Custom)"];
if(spatial == "R_E"){
spatialScale.x = 6.371f;
spatialScale.y = 6;
spatialScale.y = 6.371f;
spatialScale.z = 6.371f;
spatialScale.w = 6;
}
std::string table = "{"
@@ -262,55 +267,48 @@ namespace openspace{
return "";
}
// std::string ISWAManager::parseKWToLuaTable(std::string kwPath){
// //NEED TO REWRITE IF USED AGAIN
// if(kwPath != ""){
// const std::string& extension = ghoul::filesystem::File(absPath(kwPath)).fileExtension();
// if(extension == "cdf"){
// KameleonWrapper kw = KameleonWrapper(absPath(kwPath));
std::string ISWAManager::parseKWToLuaTable(std::string kwPath){
if(kwPath != ""){
const std::string& extension = ghoul::filesystem::File(absPath(kwPath)).fileExtension();
if(extension == "cdf"){
KameleonWrapper kw = KameleonWrapper(absPath(kwPath));
// std::string parent = kw.getParent();
// std::string frame = kw.getFrame();
// glm::vec4 scale = kw.getModelScaleScaled();
// glm::vec4 offset = kw.getModelBarycenterOffsetScaled();
std::string parent = kw.getParent();
std::string frame = kw.getFrame();
glm::vec3 min = kw.getGridMin();
glm::vec3 max = kw.getGridMax();
// std::string table = "{"
// "Name = 'DataPlane',"
// "Parent = '" + parent + "', "
// "Renderable = {"
// "Type = 'DataPlane', "
// "Id = 0 ,"
// "Frame = '" + frame + "' , "
// "Scale = " + std::to_string(scale) + ", "
// "Offset = " + std::to_string(offset) + ", "
// "kwPath = '" + kwPath + "'"
// "}"
// "}"
// ;
// // std::cout << table << std::endl;
// return table;
// }
// }
// return "";
// }
glm::vec4 spatialScale;
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;
}else{
spatialScale = glm::vec4(1.0);
spatialScale.w = -log10(1.0f/max.x);
}
std::string table = "{"
"Name = 'KameleonPlane0',"
"Parent = '" + parent + "', "
"Renderable = {"
"Type = 'KameleonPlane', "
"Id = 0 ,"
"Frame = '" + frame + "' , "
"Min = " + std::to_string(min) + ", "
"Max = " + std::to_string(max) + ", "
"kwPath = '" + kwPath + "'"
"}"
"}"
;
// std::cout << table << std::endl;
return table;
}
}
return "";
}
//Create KameleonPlane?
// void ISWAManager::createDataPlane(std::string kwPath){
// std::string luaTable = parseKWToLuaTable(kwPath);
// if(luaTable != ""){
// std::string script = "openspace.addSceneGraphNode(" + luaTable + ");";
// OsEng.scriptEngine().queueScript(script);
// }
// }
// void ISWAManager::createTexturePlane(int id, std::string json){
// std::string luaTable = parseJSONToLuaTable(id, json);
// if(luaTable != ""){
// std::string script = "openspace.addSceneGraphNode(" + parseJSONToLuaTable(id, json) + ");";
// OsEng.scriptEngine().queueScript(script);
// }
// }
void ISWAManager::createPlane(int id, std::string json, std::string type){
@@ -331,4 +329,19 @@ namespace openspace{
void ISWAManager::createScreenSpace(int id){
OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared<ScreenSpaceCygnet>(id));
}
void ISWAManager::createKameleonPlane(std::string kwPath){
kwPath = "${OPENSPACE_DATA}/" + kwPath;
const std::string& extension = ghoul::filesystem::File(absPath(kwPath)).fileExtension();
if(FileSys.fileExists(absPath(kwPath)) && extension == "cdf"){
std::string luaTable = parseKWToLuaTable(kwPath);
if(!luaTable.empty()){
std::string script = "openspace.addSceneGraphNode(" + luaTable + ");";
OsEng.scriptEngine().queueScript(script);
}
}else{
LWARNING( kwPath + " is not a cdf file or can't be found.");
}
}
}// namsepace openspace

View File

@@ -81,12 +81,13 @@ private:
std::shared_ptr<MetadataFuture> downloadMetadata(int id);
std::string getDictionaryTable(int id, std::string path);
std::string parseJSONToLuaTable(int id, std::string json, std::string type);
// std::string parseKWToLuaTable(std::string kwPath);
std::string parseKWToLuaTable(std::string kwPath);
// void createDataPlane(std::string kwPath);
// void createTexturePlane(int id, std::string json);
void createPlane(int id, std::string json, std::string type);
void createScreenSpace(int id);
void createKameleonPlane(std::string kwPath);
std::map<std::string, std::string> _month;
ISWAContainer* _container;

View File

@@ -234,7 +234,7 @@ std::shared_ptr<DownloadManager::FileFuture> DownloadManager::downloadToMemory(
char *ct;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if(ct){
future->extension = std::string(ct);
future->format = std::string(ct);
}
}

View File

@@ -53,6 +53,7 @@ Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary
std::string renderableType;
success = dictionary.getValue(KeyType, renderableType);
std::cout << renderableType << std::endl;
if (!success) {
LERROR("Renderable '" << name << "' did not have key '" << KeyType << "'");
return nullptr;