mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 10:40:09 -06:00
Get metadata and add new images
This commit is contained in:
BIN
data/GM_openspace_Z0_20150315_000000.png
Normal file
BIN
data/GM_openspace_Z0_20150315_000000.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -48,8 +48,22 @@ void CygnetPlane::createPlane(){
|
||||
// ============================
|
||||
// GEOMETRY (quad)
|
||||
// ============================
|
||||
const GLfloat x = _data->scale.x/2.0;
|
||||
const GLfloat y = _data->scale.z/2.0;
|
||||
GLfloat x,y;
|
||||
if(!_data->scale.x){
|
||||
x = _data->scale.y/2.0;
|
||||
y = _data->scale.z/2.0;
|
||||
|
||||
}else if(!_data->scale.y){
|
||||
x = _data->scale.x/2.0;
|
||||
y = _data->scale.z/2.0;
|
||||
|
||||
}else{
|
||||
x = _data->scale.x/2.0;
|
||||
y = _data->scale.y/2.0;
|
||||
}
|
||||
|
||||
// const GLfloat x = _data->scale.x/2.0;
|
||||
// const GLfloat y = _data->scale.y/2.0;
|
||||
const GLfloat w = _data->scale.w;
|
||||
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
|
||||
@@ -48,20 +48,24 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
setName("DataPlane" + std::to_string(_id));
|
||||
registerProperties();
|
||||
|
||||
dictionary.getValue("KW", _kw);
|
||||
|
||||
|
||||
KameleonWrapper::Model model = _kw->model();
|
||||
if( model == KameleonWrapper::Model::BATSRUS)
|
||||
_var = "p";
|
||||
else
|
||||
_var = "rho";
|
||||
dictionary.getValue("kwPath", _kwPath);
|
||||
}
|
||||
|
||||
DataPlane::~DataPlane(){}
|
||||
|
||||
|
||||
bool DataPlane::initialize(){
|
||||
// std::string kwPath;
|
||||
_kw = std::make_shared<KameleonWrapper>(_kwPath);
|
||||
// dictionary.getValue("KW", _kw);
|
||||
|
||||
KameleonWrapper::Model model = _kw->model();
|
||||
if( model == KameleonWrapper::Model::BATSRUS)
|
||||
_var = "p";
|
||||
else
|
||||
_var = "rho";
|
||||
|
||||
|
||||
createPlane();
|
||||
createShader();
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
static int id();
|
||||
|
||||
std::shared_ptr<KameleonWrapper> _kw;
|
||||
std::string _kwPath;
|
||||
glm::size3_t _dimensions;
|
||||
float* _dataSlice;
|
||||
std::string _var;
|
||||
|
||||
@@ -43,7 +43,7 @@ bool ISWAContainer::initialize(){
|
||||
ISWAManager::ref().setContainer(this);
|
||||
|
||||
// ISWAManager::ref().addISWACygnet(0, "BATSRUS.cdf");
|
||||
ISWAManager::ref().addISWACygnet(5, "Screen");
|
||||
// ISWAManager::ref().addISWACygnet(5, "Screen");
|
||||
// ISWAManager::ref().addISWACygnet(7, "Sun");
|
||||
|
||||
return true;
|
||||
|
||||
@@ -51,14 +51,21 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
|
||||
_data->offset = renderableOffset;
|
||||
_data->scale = renderableScale;
|
||||
|
||||
dictionary.getValue("Path",_data->path);
|
||||
dictionary.getValue("Parent",_data->parent);
|
||||
// dictionary.getValue("Path",_data->path);
|
||||
// dictionary.getValue("Parent",_data->parent);
|
||||
dictionary.getValue("Frame",_data->frame);
|
||||
|
||||
// addProperty(_enabled);
|
||||
addProperty(_updateInterval);
|
||||
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 << _data->path << std::endl;
|
||||
std::cout << _data->parent << std::endl;
|
||||
std::cout << _data->frame << std::endl;
|
||||
|
||||
_delete.onChange([this](){ISWAManager::ref().deleteISWACygnet(name());});
|
||||
}
|
||||
|
||||
|
||||
@@ -76,28 +76,63 @@ bool TexturePlane::deinitialize(){
|
||||
|
||||
void TexturePlane::render(const RenderData& data){
|
||||
if(_texture){
|
||||
// psc position = data.position;
|
||||
// glm::mat4 transform = glm::mat4(1.0);
|
||||
// // transform = glm::inverse(OsEng.renderEngine().camera()->viewRotationMatrix());
|
||||
|
||||
// float textureRatio = (float (_texture->height()/float(_texture->width())));
|
||||
// transform = glm::scale(transform, glm::vec3(1, textureRatio, 1));
|
||||
|
||||
// glm::mat4 rotx = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
|
||||
// glm::mat4 roty = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(0, 1, 0));
|
||||
// // glm::mat4 rot = glm::mat4(1.0);
|
||||
// /* for (int i = 0; i < 3; i++){
|
||||
// for (int j = 0; j < 3; j++){
|
||||
// transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
|
||||
// }
|
||||
// }*/
|
||||
|
||||
// //transform = transform * roty * rotx;
|
||||
// position += transform*glm::vec4(-_pscOffset.x, _pscOffset.z, _pscOffset.y, _pscOffset.w);
|
||||
|
||||
// // transform = glm::rotate(transform, _roatation.value()[0], glm::vec3(1,0,0));
|
||||
// // transform = glm::rotate(transform, _roatation.value()[1], glm::vec3(0,1,0));
|
||||
// // transform = glm::rotate(transform, _roatation.value()[2], glm::vec3(0,0,1));
|
||||
|
||||
psc position = data.position;
|
||||
glm::mat4 transform = glm::mat4(1.0);
|
||||
transform = glm::inverse(OsEng.renderEngine().camera()->viewRotationMatrix());
|
||||
|
||||
float textureRatio = (float (_texture->height()/float(_texture->width())));
|
||||
transform = glm::scale(transform, glm::vec3(1, textureRatio, 1));
|
||||
|
||||
glm::mat4 rotx = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
|
||||
glm::mat4 roty = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(0, 1, 0));
|
||||
// glm::mat4 rot = glm::mat4(1.0);
|
||||
/* for (int i = 0; i < 3; i++){
|
||||
glm::mat4 roty = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(0, -1, 0));
|
||||
glm::mat4 rotz = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(0, 0, 1));
|
||||
|
||||
glm::mat4 rot = glm::mat4(1.0);
|
||||
for (int i = 0; i < 3; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
//transform = transform * roty * rotx;
|
||||
//position += transform*glm::vec4(-_pscOffset.x, _pscOffset.z, _pscOffset.y, _pscOffset.w);
|
||||
transform = transform * rotz * roty; //BATSRUS
|
||||
|
||||
// transform = glm::rotate(transform, _roatation.value()[0], glm::vec3(1,0,0));
|
||||
// transform = glm::rotate(transform, _roatation.value()[1], glm::vec3(0,1,0));
|
||||
// transform = glm::rotate(transform, _roatation.value()[2], glm::vec3(0,0,1));
|
||||
if(_data->frame == "GSM"){
|
||||
glm::vec4 v(1,0,0,1);
|
||||
glm::vec3 xVec = glm::vec3(transform*v);
|
||||
xVec = glm::normalize(xVec);
|
||||
|
||||
double lt;
|
||||
glm::vec3 sunVec =
|
||||
SpiceManager::ref().targetPosition("SUN", "Earth", "GALACTIC", {}, _time, lt);
|
||||
sunVec = glm::normalize(sunVec);
|
||||
|
||||
float angle = acos(glm::dot(xVec, sunVec));
|
||||
glm::vec3 ref = glm::cross(xVec, sunVec);
|
||||
|
||||
glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), angle, ref);
|
||||
transform = rotation * transform;
|
||||
}
|
||||
|
||||
position += transform*glm::vec4(_data->offset.x, _data->offset.z, _data->offset.y, _data->offset.w);
|
||||
|
||||
// Activate shader
|
||||
_shader->activate();
|
||||
@@ -146,8 +181,9 @@ void TexturePlane::update(const UpdateData& data){
|
||||
void TexturePlane::loadTexture() {
|
||||
// std::cout << _data->path << std::endl;
|
||||
// std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_data->path));
|
||||
if(_memorybuffer != ""){
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTextureFromMemory(_memorybuffer);
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath("${OPENSPACE_DATA}/GM_openspace_Z0_20150315_000000.png"));
|
||||
// if(_memorybuffer != ""){
|
||||
// std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTextureFromMemory(_memorybuffer);
|
||||
if (texture) {
|
||||
// LDEBUG("Loaded texture from '" << absPath(_data->path) << "'");
|
||||
texture->uploadTexture();
|
||||
@@ -156,7 +192,7 @@ void TexturePlane::loadTexture() {
|
||||
|
||||
_texture = std::move(texture);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
void TexturePlane::updateTexture(){
|
||||
|
||||
@@ -46,7 +46,7 @@ Fragment getFragment() {
|
||||
//diffuse.a = diffuse.r;
|
||||
float tot = diffuse.r + diffuse.g + diffuse.b;
|
||||
tot /= 3.0;
|
||||
if (tot <= 0.05)
|
||||
if (tot >= 0.5 || tot <= 0.05)
|
||||
discard;
|
||||
|
||||
Fragment frag;
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace openspace{
|
||||
{std::string("Parent"), kw->getParent()},
|
||||
{std::string("Renderable"), metadataDic}
|
||||
};
|
||||
/* SceneGraphNode* cygnetNode = SceneGraphNode::createFromDictionary(nodeDic);
|
||||
/* SceneGraphNode* cygnetNode = SceneGraphNode::createFromDictionary(nodeDic);
|
||||
cygnetNode->setParent(parentNode);
|
||||
parentNode->addChild(cygnetNode);
|
||||
OsEng.renderEngine().scene()->addSceneGraphNode(cygnetNode);
|
||||
@@ -155,20 +155,25 @@ namespace openspace{
|
||||
|
||||
void ISWAManager::addISWACygnet(int id, std::string info){
|
||||
if(id > 0){
|
||||
std::shared_ptr<ExtensionFuture> extFuture = fileExtension(id);
|
||||
extFuture->parent = info;
|
||||
_extFutures.push_back(extFuture);
|
||||
// std::shared_ptr<ExtensionFuture> extFuture = fileExtension(id);
|
||||
// extFuture->parent = info;
|
||||
// _extFutures.push_back(extFuture);
|
||||
// _container->addISWACygnet(cygnetId, data);
|
||||
//createScreenSpace(id)
|
||||
createScreenSpace(id);
|
||||
}else if(id < 0){
|
||||
//download metadata to texture plane
|
||||
// std::shared_ptr<ExtensionFuture> extFuture = fileExtension(id);
|
||||
// extFuture->parent = info;
|
||||
// _extFutures.push_back(extFuture);
|
||||
// std::shared_ptr<ExtensionFuture> extFuture
|
||||
_metaFutures.push_back(downloadMetadata(id));
|
||||
}
|
||||
else {
|
||||
std::shared_ptr<Metadata> mdata = std::make_shared<Metadata>();
|
||||
mdata->id = 0;
|
||||
mdata->path = absPath("${OPENSPACE_DATA}/"+info);
|
||||
createISWACygnet(mdata);
|
||||
//createDataPlane(absPath("${OPENSPACE_DATA}/"+info);
|
||||
// std::shared_ptr<Metadata> mdata = std::make_shared<Metadata>();
|
||||
// mdata->id = 0;
|
||||
// mdata->path = absPath("${OPENSPACE_DATA}/"+info);
|
||||
// createISWACygnet(mdata);
|
||||
createDataPlane(absPath("${OPENSPACE_DATA}/"+info));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,6 +206,23 @@ namespace openspace{
|
||||
|
||||
void ISWAManager::downloadData(){}
|
||||
|
||||
std::shared_ptr<MetadataFuture> ISWAManager::downloadMetadata(int id){
|
||||
std::shared_ptr<MetadataFuture> metaFuture = std::make_shared<MetadataFuture>();
|
||||
|
||||
metaFuture->id = id;
|
||||
|
||||
std::ifstream file(absPath("${OPENSPACE_DATA}/GM_openspace_Y0_info.txt"));
|
||||
if(file.is_open()){
|
||||
std::string json( (std::istreambuf_iterator<char>(file) ),
|
||||
(std::istreambuf_iterator<char>()));
|
||||
std::cout << "This is in the file: " << json << std::endl;
|
||||
metaFuture->isFinished = true;
|
||||
metaFuture->json = json;
|
||||
}
|
||||
|
||||
return metaFuture;
|
||||
}
|
||||
|
||||
std::shared_ptr<ExtensionFuture> ISWAManager::fileExtension(int id){
|
||||
std::shared_ptr<ExtensionFuture> extFuture = std::make_shared<ExtensionFuture>();
|
||||
extFuture->isFinished = false;
|
||||
@@ -226,6 +248,7 @@ namespace openspace{
|
||||
_container = container;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<ISWACygnet> ISWAManager::iSWACygnet(std::string name){
|
||||
if(_container)
|
||||
return _container->iSWACygnet(name);
|
||||
@@ -267,6 +290,7 @@ namespace openspace{
|
||||
data->path = path;
|
||||
data->parent = (*it)->parent;
|
||||
|
||||
//createTexturePlane(id, json)
|
||||
createISWACygnet(data);
|
||||
it = _extFutures.erase( it );
|
||||
}
|
||||
@@ -274,6 +298,15 @@ namespace openspace{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = _metaFutures.begin(); it != _metaFutures.end(); ){
|
||||
if((*it)->isFinished) {
|
||||
createTexturePlane(7,(*it)->json);
|
||||
it = _metaFutures.erase( it );
|
||||
}else{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string ISWAManager::getDictionaryTable(int id, std::string path){
|
||||
@@ -283,7 +316,6 @@ namespace openspace{
|
||||
j = json::parse(file);
|
||||
}
|
||||
|
||||
|
||||
std::string parent = j["Central Body"];
|
||||
std::string frame = j["Coordinates"];
|
||||
|
||||
@@ -297,8 +329,8 @@ namespace openspace{
|
||||
float spatScale=1, scalew=10;
|
||||
std::string spatialScale = j["Spatial Scale (Custom)"];
|
||||
if(spatialScale == "R_E"){
|
||||
spatScale = 6.371f;
|
||||
scalew = 6;
|
||||
// spatScale = 6.371f;
|
||||
// scalew = 6;
|
||||
}
|
||||
|
||||
std::string scale = "{"
|
||||
@@ -316,8 +348,8 @@ namespace openspace{
|
||||
"}";
|
||||
|
||||
std::string table = "{"
|
||||
"Name : 'TexturePlane' , "
|
||||
"Parent : '" + parent + "', "
|
||||
"Name = 'TexturePlane' , "
|
||||
"Parent = '" + parent + "', "
|
||||
"Renderable = {"
|
||||
"Type = 'TexturePlane', "
|
||||
"Id = " + std::to_string(id) + ", "
|
||||
@@ -413,7 +445,7 @@ namespace openspace{
|
||||
glm::vec4 offset = kw.getModelBarycenterOffsetScaled();
|
||||
|
||||
std::string table = "{"
|
||||
"Name = 'DataPlane' , "
|
||||
"Name = 'DataPlane',"
|
||||
"Parent = '" + parent + "', "
|
||||
"Renderable = {"
|
||||
"Type = 'DataPlane', "
|
||||
@@ -421,11 +453,11 @@ namespace openspace{
|
||||
"Frame = '" + frame + "' , "
|
||||
"Scale = " + std::to_string(scale) + ", "
|
||||
"Offset = " + std::to_string(offset) + ", "
|
||||
"kwPath = " + kwPath +
|
||||
"kwPath = '" + kwPath + "'"
|
||||
"}"
|
||||
"}"
|
||||
;
|
||||
|
||||
std::cout << table << std::endl;
|
||||
return table;
|
||||
}
|
||||
}
|
||||
@@ -448,7 +480,7 @@ namespace openspace{
|
||||
}
|
||||
}
|
||||
|
||||
void createScreenSpace(int id){
|
||||
void ISWAManager::createScreenSpace(int id){
|
||||
OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared<ScreenSpaceCygnet>(id));
|
||||
}
|
||||
}// namsepace openspace
|
||||
@@ -55,6 +55,12 @@ struct Metadata {
|
||||
std::shared_ptr<KameleonWrapper> kw;
|
||||
};
|
||||
|
||||
struct MetadataFuture {
|
||||
int id;
|
||||
std::string json;
|
||||
bool isFinished;
|
||||
};
|
||||
|
||||
|
||||
class ISWAManager : public ghoul::Singleton<ISWAManager> {
|
||||
friend class ghoul::Singleton<ISWAManager>;
|
||||
@@ -81,6 +87,7 @@ public:
|
||||
|
||||
private:
|
||||
std::string iSWAurl(int);
|
||||
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 parseKWToLuaTable(std::string kwPath);
|
||||
@@ -92,6 +99,7 @@ private:
|
||||
std::map<std::string, std::string> _month;
|
||||
ISWAContainer* _container;
|
||||
std::vector<std::shared_ptr<ExtensionFuture>> _extFutures;
|
||||
std::vector<std::shared_ptr<MetadataFuture>> _metaFutures;
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
|
||||
@@ -8,8 +8,8 @@ openspace.setPropertyValue("SunGlare.renderable.enabled", false)
|
||||
openspace.setPropertyValue("SunMarker.renderable.enabled", false)
|
||||
openspace.setPropertyValue("EarthMarker.renderable.enabled", false)
|
||||
--openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false)
|
||||
openspace.setPropertyValue("PlutoTrail.renderable.enabled", false)
|
||||
openspace.setPropertyValue("PlutoTexture.renderable.enabled", false)
|
||||
-- openspace.setPropertyValue("PlutoTrail.renderable.enabled", false)
|
||||
-- openspace.setPropertyValue("PlutoTexture.renderable.enabled", false)
|
||||
|
||||
openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.75)
|
||||
openspace.setPropertyValue("MilkyWay.renderable.segments", 50)
|
||||
|
||||
Reference in New Issue
Block a user