download texture resource ahead of time

This commit is contained in:
Michael Nilsson
2016-06-13 15:44:31 -04:00
parent db9af4c886
commit 55e1850045
9 changed files with 35 additions and 33 deletions
+4 -3
View File
@@ -35,10 +35,11 @@ function postInitialization()
openspace.iswa.addCygnet(-4,"Data","Gm");
openspace.iswa.addCygnet(-5,"Data","Gm");
openspace.iswa.addCygnet(-6,"Data","Gm");
openspace.iswa.addCygnet(-7,"Data","Gm");
openspace.iswa.addCygnet(-8,"Data","Gm");
-- openspace.iswa.addCygnet(-6,"Data","Gm");
-- openspace.iswa.addCygnet(-7,"Data","Gm");
-- openspace.iswa.addCygnet(-8,"Data","Gm");
openspace.iswa.addCygnet(-9,"Data","Gm");
end
+2 -2
View File
@@ -97,11 +97,11 @@ bool DataCygnet::updateTexture(){
return texturesReady;
}
bool DataCygnet::downloadTextureResource(){
bool DataCygnet::downloadTextureResource(double timestamp){
if(_futureObject.valid())
return false;
std::future<DownloadManager::MemoryFile> future = IswaManager::ref().fetchDataCygnet(_data->id);
std::future<DownloadManager::MemoryFile> future = IswaManager::ref().fetchDataCygnet(_data->id, timestamp);
if(future.valid()){
_futureObject = std::move(future);
+1 -1
View File
@@ -104,7 +104,7 @@ protected:
private:
bool readyToRender() const override;
bool downloadTextureResource() override;
bool downloadTextureResource(double timestamp = Time::ref().currentTime()) override;
};
} //namespace openspace
+11 -10
View File
@@ -174,6 +174,10 @@ void IswaCygnet::render(const RenderData& data){
}
void IswaCygnet::update(const UpdateData& data){
// the texture resource is downloaded ahead of time, so we need to
// now if we are going backwards or forwards
double clockwiseSign = (Time::ref().deltaTime()>0) ? 1.0 : -1.0;
_openSpaceTime = Time::ref().currentTime();
_realTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
_stateMatrix = TransformationManager::ref().frameTransformationMatrix(_data->frame, "GALACTIC", _openSpaceTime);
@@ -181,22 +185,19 @@ void IswaCygnet::update(const UpdateData& data){
bool timeToUpdate = (fabs(_openSpaceTime-_lastUpdateOpenSpaceTime) >= _data->updateTime &&
(_realTime.count()-_lastUpdateRealTime.count()) > _minRealTimeUpdateInterval);
if( _data->updateTime != 0 && (Time::ref().timeJumped() || timeToUpdate )){
downloadTextureResource();
_lastUpdateRealTime = _realTime;
_lastUpdateOpenSpaceTime = _openSpaceTime;
}
if(_futureObject.valid() && DownloadManager::futureReady(_futureObject)) {
bool success = updateTextureResource();
if(success)
_textureDirty = true;
}
if(_textureDirty) {
if(_textureDirty && _data->updateTime != 0 && timeToUpdate) {
updateTexture();
_textureDirty = false;
downloadTextureResource(_openSpaceTime + clockwiseSign*_data->updateTime);
_lastUpdateRealTime = _realTime;
_lastUpdateOpenSpaceTime =_openSpaceTime;
}
if(!_transferFunctions.empty())
@@ -225,7 +226,7 @@ void IswaCygnet::unregisterProperties(){
void IswaCygnet::initializeTime(){
_openSpaceTime = Time::ref().currentTime();
_lastUpdateOpenSpaceTime = _openSpaceTime;
_lastUpdateOpenSpaceTime = 0.0;
_realTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
_lastUpdateRealTime = _realTime;
+2 -1
View File
@@ -38,6 +38,7 @@
#include <openspace/properties/triggerproperty.h>
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/transferfunction.h>
#include <openspace/util/time.h>
#include <modules/iswa/rendering/iswabasegroup.h>
#include <modules/iswa/rendering/iswadatagroup.h>
@@ -118,7 +119,7 @@ protected:
* this should be the data file.
* @return true if update was successfull
*/
virtual bool downloadTextureResource() = 0;
virtual bool downloadTextureResource(double timestamp = Time::ref().currentTime()) = 0;
virtual bool readyToRender() const = 0;
/**
* should set all uniforms needed to render
+2 -2
View File
@@ -58,7 +58,7 @@ bool TextureCygnet::updateTexture() {
return false;
}
bool TextureCygnet::downloadTextureResource(){
bool TextureCygnet::downloadTextureResource(double timestamp){
if(_futureObject.valid())
return false;
@@ -66,7 +66,7 @@ bool TextureCygnet::downloadTextureResource(){
if(_textures.empty())
_textures.push_back(nullptr);
std::future<DownloadManager::MemoryFile> future = IswaManager::ref().fetchImageCygnet(_data->id);
std::future<DownloadManager::MemoryFile> future = IswaManager::ref().fetchImageCygnet(_data->id, timestamp);
if(future.valid()){
_futureObject = std::move(future);
+1 -1
View File
@@ -43,7 +43,7 @@ public:
protected:
bool updateTexture() override;
bool downloadTextureResource() override;
bool downloadTextureResource(double timestamp = Time::ref().currentTime()) override;
bool readyToRender() const override;
bool updateTextureResource() override;
+8 -7
View File
@@ -40,7 +40,7 @@
#include <ghoul/filesystem/filesystem>
#include <modules/kameleon/include/kameleonwrapper.h>
#include <openspace/scene/scene.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/scripting/script_helper.h>
#include <ghoul/lua/ghoul_lua.h>
@@ -168,9 +168,9 @@ void IswaManager::addKameleonCdf(std::string groupName, int pos){
createKameleonPlane(_cdfInformation[groupName][pos], "x");
}
std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id){
std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id, double timestamp){
return std::move( DlManager.fetchFile(
iswaUrl(id, "image"),
iswaUrl(id, timestamp, "image"),
[id](const DownloadManager::MemoryFile& file){
LDEBUG("Download to memory finished for image cygnet with id: " + std::to_string(id));
},
@@ -180,9 +180,9 @@ std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id){
) );
}
std::future<DownloadManager::MemoryFile> IswaManager::fetchDataCygnet(int id){
std::future<DownloadManager::MemoryFile> IswaManager::fetchDataCygnet(int id, double timestamp){
return std::move( DlManager.fetchFile(
iswaUrl(id, "data"),
iswaUrl(id, timestamp, "data"),
[id](const DownloadManager::MemoryFile& file){
LDEBUG("Download to memory finished for data cygnet with id: " + std::to_string(id));
},
@@ -192,7 +192,7 @@ std::future<DownloadManager::MemoryFile> IswaManager::fetchDataCygnet(int id){
) );
}
std::string IswaManager::iswaUrl(int id, std::string type){
std::string IswaManager::iswaUrl(int id, double timestamp, std::string type){
std::string url;
if(id < 0){
url = "http://128.183.168.116:3000/"+type+"/" + std::to_string(-id) + "/";
@@ -201,7 +201,8 @@ std::string IswaManager::iswaUrl(int id, std::string type){
url = "http://iswa3.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?window=-1&cygnetId="+ std::to_string(id) +"&timestamp=";
}
std::string t = Time::ref().currentTimeUTC();
//std::string t = Time::ref().currentTimeUTC();
std::string t = SpiceManager::ref().dateFromEphemerisTime(timestamp);
std::stringstream ss(t);
std::string token;
+4 -6
View File
@@ -40,9 +40,7 @@
#include <openspace/util/spicemanager.h>
#include <openspace/properties/selectionproperty.h>
#include <modules/iswa/ext/json/json.hpp>
// #include <modules/iswa/rendering/iswacygnet.h>
// #include <modules/iswa/rendering/iswagroup.h>
#include <openspace/util/time.h>
namespace openspace {
@@ -89,9 +87,9 @@ public:
void addKameleonCdf(std::string group, int pos);
void createFieldline(std::string name, std::string cdfPath, std::string seedPath);
std::future<DownloadManager::MemoryFile> fetchImageCygnet(int id);
std::future<DownloadManager::MemoryFile> fetchDataCygnet(int id);
std::string iswaUrl(int id, std::string type = "image");
std::future<DownloadManager::MemoryFile> fetchImageCygnet(int id, double timestamp);
std::future<DownloadManager::MemoryFile> fetchDataCygnet(int id, double timestamp);
std::string iswaUrl(int id, double timestamp = Time::ref().currentTime(), std::string type = "image");
std::shared_ptr<IswaBaseGroup> iswaGroup(std::string name);