mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 06:19:02 -06:00
Replaced SimpleSphereGeometry with PowerScaledSphere
This commit is contained in:
@@ -78,8 +78,7 @@ public:
|
||||
|
||||
std::shared_ptr<FileFuture> downloadToMemory(
|
||||
const std::string& url, std::string& memoryBuffer,
|
||||
DownloadFinishedCallback finishedCallback = DownloadFinishedCallback(),
|
||||
DownloadProgressCallback progressCallback = DownloadProgressCallback()
|
||||
DownloadFinishedCallback finishedCallback = DownloadFinishedCallback()
|
||||
);
|
||||
|
||||
std::vector<std::shared_ptr<FileFuture>> downloadRequestFiles(const std::string& identifier,
|
||||
|
||||
@@ -77,7 +77,6 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
else
|
||||
_segments = static_cast<int>(segments);
|
||||
|
||||
// The shader need the radii values but they are not changeable runtime
|
||||
// TODO: Possibly add a scaling property @AA
|
||||
addProperty(_realRadius);
|
||||
|
||||
@@ -48,12 +48,12 @@ bool CygnetPlane::createGeometry() {
|
||||
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// x y z w s t
|
||||
-x, -z, -y, w, 0, 1,
|
||||
x, z, y, w, 1, 0,
|
||||
-x, ((x>0)?z:-z), y, w, 0, 0,
|
||||
-x, -z, -y, w, 0, 1,
|
||||
x, ((x>0)?-z:z), -y, w, 1, 1,
|
||||
x, z, y, w, 1, 0,
|
||||
-x, -y, -z, w, 0, 1,
|
||||
x, y, z, w, 1, 0,
|
||||
-x, ((x>0)?y:-y), z, w, 0, 0,
|
||||
-x, -y, -z, w, 0, 1,
|
||||
x, ((x>0)?-y:y), -z, w, 1, 1,
|
||||
x, y, z, w, 1, 0,
|
||||
};
|
||||
|
||||
glBindVertexArray(_quad); // bind array
|
||||
|
||||
@@ -24,33 +24,33 @@
|
||||
#include <openspace/util/time.h>
|
||||
#include <modules/base/rendering/planetgeometry.h>
|
||||
#include <modules/base/rendering/simplespheregeometry.h>
|
||||
#include <openspace/util/powerscaledsphere.h>
|
||||
#include <openspace/util/powerscaledscalar.h>
|
||||
|
||||
namespace openspace{
|
||||
|
||||
CygnetSphere::CygnetSphere(const ghoul::Dictionary& dictionary)
|
||||
:ISWACygnet(dictionary)
|
||||
,_geometry(nullptr)
|
||||
{
|
||||
_geometry = std::make_shared<planetgeometry::SimpleSphereGeometry>(dictionary);
|
||||
}
|
||||
,_sphere(nullptr)
|
||||
{}
|
||||
|
||||
CygnetSphere::~CygnetSphere(){}
|
||||
|
||||
bool CygnetSphere::createGeometry(){
|
||||
_geometry->initialize(this);
|
||||
PowerScaledScalar radius = PowerScaledScalar(3*6.371f, 6.0);
|
||||
int segments = 100;
|
||||
_sphere = std::make_shared<PowerScaledSphere>(radius, segments);
|
||||
_sphere->initialize();
|
||||
}
|
||||
|
||||
bool CygnetSphere::destroyGeometry(){
|
||||
if(_geometry)
|
||||
_geometry->deinitialize();
|
||||
|
||||
_geometry = nullptr;
|
||||
_sphere = nullptr;
|
||||
}
|
||||
|
||||
bool CygnetSphere::renderGeometry(){
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
_geometry->render();
|
||||
_sphere->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <modules/iswa/rendering/iswacygnet.h>
|
||||
|
||||
namespace openspace{
|
||||
class PowerScaledSphere;
|
||||
|
||||
namespace planetgeometry {
|
||||
class PlanetGeometry;
|
||||
@@ -38,13 +39,12 @@ public:
|
||||
CygnetSphere(const ghoul::Dictionary& dictionary);
|
||||
~CygnetSphere();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<PowerScaledSphere> _sphere;
|
||||
private:
|
||||
virtual bool createGeometry() override;
|
||||
virtual bool destroyGeometry() override;
|
||||
virtual bool renderGeometry() override;
|
||||
|
||||
std::shared_ptr<planetgeometry::PlanetGeometry> _geometry;
|
||||
double _segments;
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
|
||||
@@ -132,7 +132,9 @@ bool DataPlane::loadTexture() {
|
||||
}
|
||||
|
||||
bool DataPlane::updateTexture(){
|
||||
if(_futureObject)
|
||||
|
||||
// If a download is in progress, dont send another request.
|
||||
if(_futureObject && !_futureObject->isFinished && !_futureObject->isAborted)
|
||||
return false;
|
||||
|
||||
_memorybuffer = "";
|
||||
|
||||
@@ -43,7 +43,6 @@ DataSphere::~DataSphere(){}
|
||||
|
||||
|
||||
bool DataSphere::loadTexture(){
|
||||
_textures[0] = nullptr;
|
||||
std::string texturepath = "${OPENSPACE_DATA}/scene/mars/textures/mars.jpg";
|
||||
|
||||
auto texture = ghoul::io::TextureReader::ref().loadTexture(absPath(texturepath));
|
||||
@@ -59,14 +58,17 @@ bool DataSphere::loadTexture(){
|
||||
bool DataSphere::updateTexture(){
|
||||
if(_textures.empty())
|
||||
_textures.push_back(nullptr);
|
||||
|
||||
loadTexture();
|
||||
if(!_textures[0])
|
||||
loadTexture();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DataSphere::readyToRender(){
|
||||
return (isReady() && ((!_textures.empty()) && (_textures[0] != nullptr)));
|
||||
bool ready = isReady();
|
||||
ready &= (!_textures.empty() && _textures[0]);
|
||||
ready &= (_sphere != nullptr);
|
||||
return ready;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <modules/iswa/rendering/cygnetsphere.h>
|
||||
|
||||
namespace openspace{
|
||||
|
||||
class PowerScaledSphere;
|
||||
class DataSphere : public CygnetSphere {
|
||||
public:
|
||||
DataSphere(const ghoul::Dictionary& dictionary);
|
||||
|
||||
@@ -114,7 +114,7 @@ bool ISWACygnet::initialize(){
|
||||
if(_data->groupId > 0)
|
||||
ISWAManager::ref().registerToGroup(_data->groupId, _type, this);
|
||||
|
||||
return isReady();
|
||||
// return isReady();
|
||||
}
|
||||
|
||||
bool ISWACygnet::deinitialize(){
|
||||
|
||||
@@ -136,8 +136,7 @@ bool ScreenSpaceCygnet::isReady() const{
|
||||
|
||||
void ScreenSpaceCygnet::updateTexture(){
|
||||
// If a download is in progress, dont send another request.
|
||||
//What if image failed to download?
|
||||
if(_futureTexture && !_futureTexture->isFinished)
|
||||
if(_futureTexture && !_futureTexture->isFinished && !_futureTexture->isAborted)
|
||||
return;
|
||||
|
||||
_memorybuffer = "";
|
||||
|
||||
@@ -84,10 +84,12 @@ bool TexturePlane::loadTexture() {
|
||||
|
||||
|
||||
bool TexturePlane::updateTexture(){
|
||||
|
||||
if(_textures.empty())
|
||||
_textures.push_back(nullptr);
|
||||
|
||||
if(_futureObject)
|
||||
// If a download is in progress, dont send another request.
|
||||
if(_futureObject && !_futureObject->isFinished && !_futureObject->isAborted)
|
||||
return false;
|
||||
|
||||
_memorybuffer = "";
|
||||
@@ -114,6 +116,8 @@ bool TexturePlane::setUniformAndTextures(){
|
||||
unit.activate();
|
||||
_textures[0]->bind();
|
||||
_shader->setUniform("texture1", unit);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -125,10 +125,14 @@ void ISWAManager::addISWACygnet(int id, std::string info, int group){
|
||||
|
||||
auto metadataCallback =
|
||||
[this, metaFuture](const DownloadManager::FileFuture& f){
|
||||
LDEBUG("Download to memory finished");
|
||||
metaFuture->isFinished = true;
|
||||
createPlane(metaFuture);
|
||||
};
|
||||
if(f.isFinished){
|
||||
metaFuture->isFinished;
|
||||
createPlane(metaFuture);
|
||||
LDEBUG("Download to memory finished");
|
||||
} else if (f.isAborted){
|
||||
LWARNING("Download to memory was aborted: " + f.errorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
// Download metadata
|
||||
DlManager.downloadToMemory(
|
||||
@@ -183,7 +187,11 @@ std::shared_ptr<DownloadManager::FileFuture> ISWAManager::downloadImageToMemory(
|
||||
iSWAurl(id, "image"),
|
||||
buffer,
|
||||
[](const DownloadManager::FileFuture& f){
|
||||
LDEBUG("Download to memory finished");
|
||||
if(f.isFinished){
|
||||
LDEBUG("Download to memory finished");
|
||||
} else if (f.isAborted){
|
||||
LWARNING("Download to memory was aborted: " + f.errorMessage);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -193,7 +201,11 @@ std::shared_ptr<DownloadManager::FileFuture> ISWAManager::downloadDataToMemory(i
|
||||
iSWAurl(id, "data"),
|
||||
buffer,
|
||||
[](const DownloadManager::FileFuture& f){
|
||||
LDEBUG("Download data finished");
|
||||
if(f.isFinished){
|
||||
LDEBUG("Download to memory finished");
|
||||
} else if (f.isAborted){
|
||||
LWARNING("Download to memory was aborted: " + f.errorMessage);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -233,8 +245,12 @@ std::shared_ptr<MetadataFuture> ISWAManager::downloadMetadata(int id){
|
||||
// "http://10.0.0.76:3000/" + std::to_string(-id),
|
||||
metaFuture->json,
|
||||
[metaFuture](const DownloadManager::FileFuture& f){
|
||||
LDEBUG("Download to memory finished");
|
||||
metaFuture->isFinished = true;
|
||||
if(f.isFinished){
|
||||
metaFuture->isFinished;
|
||||
LDEBUG("Download to memory finished");
|
||||
} else if (f.isAborted){
|
||||
LWARNING("Download to memory was aborted: " + f.errorMessage);
|
||||
}
|
||||
}
|
||||
);
|
||||
return metaFuture;
|
||||
@@ -279,7 +295,11 @@ std::string ISWAManager::parseJSONToLuaTable(std::shared_ptr<MetadataFuture> dat
|
||||
std::string coordinateType = j["Coordinate Type"];
|
||||
int updateTime = j["ISWA_UPDATE_SECONDS"];
|
||||
|
||||
j["Radius"];
|
||||
std::string radius = "";
|
||||
if(j["Radius"] == NULL){
|
||||
radius ="Radius = {6.371, 6.01}, "
|
||||
"Segments = 100,";
|
||||
}
|
||||
|
||||
glm::vec3 max(
|
||||
j["Plot XMAX"],
|
||||
@@ -316,8 +336,7 @@ std::string ISWAManager::parseJSONToLuaTable(std::shared_ptr<MetadataFuture> dat
|
||||
"UpdateTime = " + std::to_string(updateTime) + ", "
|
||||
"CoordinateType = '" + coordinateType + "', "
|
||||
"Group = "+ std::to_string(data->group) + " ,"
|
||||
"Radius = {6.371, 6.01}, "
|
||||
"Segments = 20,"
|
||||
+ radius +
|
||||
"}"
|
||||
"}";
|
||||
|
||||
@@ -446,8 +465,17 @@ scripting::ScriptEngine::LuaLibrary ISWAManager::luaLibrary() {
|
||||
}
|
||||
|
||||
glm::dmat3 ISWAManager::getTransform(std::string from, std::string to, double et){
|
||||
auto fromit = _kameleonFrames.find(from);
|
||||
auto toit = _kameleonFrames.find(to);
|
||||
std::set<std::string> _diopoleFrames = {"GSM", "SM", "MAG"};
|
||||
|
||||
auto fromit = _diopoleFrames.find(from);
|
||||
auto toit = _diopoleFrames.find(to);
|
||||
|
||||
//diopole frame to J200 makes the frame rotate.
|
||||
if(fromit != _diopoleFrames.end()) from = "GSE";
|
||||
if(toit != _diopoleFrames.end()) to = "GSE";
|
||||
|
||||
fromit = _kameleonFrames.find(from);
|
||||
toit = _kameleonFrames.find(to);
|
||||
|
||||
bool fromKameleon = (fromit != _kameleonFrames.end());
|
||||
bool toKameleon = (toit != _kameleonFrames.end());
|
||||
@@ -482,8 +510,6 @@ glm::dmat3 ISWAManager::getTransform(std::string from, std::string to, double et
|
||||
out2.c0 , out2.c1 , out2.c2
|
||||
);
|
||||
|
||||
// std::cout << std::to_string(kameleonTrans) << std::endl;
|
||||
|
||||
glm::dmat3 spiceTrans = SpiceManager::ref().frameTransformationMatrix("J2000", to, et);
|
||||
|
||||
return spiceTrans*kameleonTrans;
|
||||
|
||||
@@ -205,48 +205,40 @@ std::shared_ptr<DownloadManager::FileFuture> DownloadManager::downloadFile(
|
||||
|
||||
std::shared_ptr<DownloadManager::FileFuture> DownloadManager::downloadToMemory(
|
||||
const std::string& url, std::string& memoryBuffer,
|
||||
DownloadFinishedCallback finishedCallback, DownloadProgressCallback progressCallback)
|
||||
DownloadFinishedCallback finishedCallback)
|
||||
{
|
||||
|
||||
std::shared_ptr<FileFuture> future = std::make_shared<FileFuture>(std::string("memory"));
|
||||
LDEBUG("Start downloading file: '" << url << "' into memory");
|
||||
|
||||
auto downloadFunction = [url, finishedCallback, progressCallback, future, &memoryBuffer]() {
|
||||
auto downloadFunction = [url, finishedCallback, future, &memoryBuffer]() {
|
||||
CURL* curl = curl_easy_init();
|
||||
if (curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &memoryBuffer);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeToMemory);
|
||||
|
||||
ProgressInformation p = {
|
||||
future,
|
||||
std::chrono::system_clock::now(),
|
||||
&progressCallback
|
||||
};
|
||||
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, xferinfo);
|
||||
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &p);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L);
|
||||
|
||||
CURLcode res = curl_easy_perform(curl);
|
||||
if(res == CURLE_OK){
|
||||
// ask for the content-type
|
||||
char *ct;
|
||||
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
|
||||
if(ct){
|
||||
if (res == CURLE_OK){
|
||||
future->format = std::string(ct);
|
||||
}
|
||||
}
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if (res == CURLE_OK)
|
||||
future->isFinished = true;
|
||||
else
|
||||
future->isFinished = true;
|
||||
}
|
||||
} else {
|
||||
future->errorMessage = curl_easy_strerror(res);
|
||||
|
||||
future->isAborted = true;
|
||||
}
|
||||
|
||||
if (finishedCallback)
|
||||
finishedCallback(*future);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user