diff --git a/modules/softwareintegration/rendering/renderablepointscloud.cpp b/modules/softwareintegration/rendering/renderablepointscloud.cpp index 316612f23e..3b3a9c4c71 100644 --- a/modules/softwareintegration/rendering/renderablepointscloud.cpp +++ b/modules/softwareintegration/rendering/renderablepointscloud.cpp @@ -30,12 +30,15 @@ #include #include #include +#include #include #include +#include #include namespace { constexpr const char* ProgramName = "shaderProgram"; + constexpr const char* _loggerCat = "PointsCloud"; constexpr openspace::properties::Property::PropertyInfo ColorInfo = { "Color", @@ -74,7 +77,6 @@ namespace openspace { }; } - RenderablePointsCloud::RenderablePointsCloud(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _color( @@ -156,7 +158,7 @@ namespace openspace { _shaderProgram->setUniform("size", _size); // Changes GL state: - glEnable(GL_BLEND); + glEnablei(GL_BLEND, 0); glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_PROGRAM_POINT_SIZE); // Enable gl_PointSize in vertex @@ -171,9 +173,25 @@ namespace openspace { } void RenderablePointsCloud::update(const UpdateData&) { + if (!_isDirty) { + return; + } + std::string planets = absPath("${MODULE_SOFTWAREINTEGRATION}/testdata/testPointsCloud.csv"); + std::vector> dataString = ghoul::loadCSVFile(planets); + //LWARNING(fmt::format("dataString: {}", dataString[0][0])); - // store data point in _varray - _varray.push_back({ 0.f, 0.f, 0.f }); + for (int i = 0; i < dataString.size(); i++ ) { // rows + float x = std::stof(dataString[i][0]) * 3.0857E16; + float y = std::stof(dataString[i][1]) * 3.0857E16; + float z = std::stof(dataString[i][2]) * 3.0857E16; + + _varray.push_back({ x, y, z }); + } + + // store data point in _varray dataString[i][j] + //_varray.push_back({ 10000000000.f, 0.f, 0.f }); + + //_varray.push_back({ dataString.x, v0.y, v0.z }); glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); @@ -194,6 +212,8 @@ namespace openspace { ); glBindVertexArray(0); + + _isDirty = false; } } // namespace openspace diff --git a/modules/softwareintegration/rendering/renderablepointscloud.h b/modules/softwareintegration/rendering/renderablepointscloud.h index 7c01da5688..4988bb2fbb 100644 --- a/modules/softwareintegration/rendering/renderablepointscloud.h +++ b/modules/softwareintegration/rendering/renderablepointscloud.h @@ -65,6 +65,8 @@ namespace openspace { GLuint _vaoID = 0; GLuint _vBufferID = 0; + bool _isDirty = true; + std::vector _varray; }; diff --git a/modules/softwareintegration/testdata/testPointsCloud.csv b/modules/softwareintegration/testdata/testPointsCloud.csv index 5d51562a19..ba04f41b2e 100644 --- a/modules/softwareintegration/testdata/testPointsCloud.csv +++ b/modules/softwareintegration/testdata/testPointsCloud.csv @@ -1,10 +1,3 @@ -# This file was produced by the NASA Exoplanet Archive http://exoplanetarchive.ipac.caltech.edu,, -# Thu Mar 5 07:41:55 2020,, -#,, -# COLUMN ra: RA [decimal degrees],, -# COLUMN dec: Dec [decimal degrees],, -# COLUMN st_dist: Distance [pc],, -#,, ra,dec,st_dist 185.179276,17.792868,93.37 229.274536,71.823898,125.72 @@ -1239,7 +1232,6 @@ ra,dec,st_dist 172.334946,-1.454787,44.13 172.334946,-1.454787,44.13 52.341961,22.299404,336.26 -78.339134,16.414202, 245.44075,-23.547865,110.87 252.426086,-19.542822,158.39 252.426086,-19.542822,158.39 @@ -3744,13 +3736,11 @@ ra,dec,st_dist 271.223333,-27.220944,7560 270.442963,-29.108778,5300 268.143097,-32.040092,7210 -269.678542,-29.398239, 271.9487,-28.170279,7100 271.473755,-27.714287,6500 268.742218,-29.750463,6800 261.7925,-29.793972,5100 269.375958,-29.736564,7120 -255.527252,-29.945583, 132.48676,11.692484,837.03 132.82283,11.756299,842.01 132.753364,11.814655,895.73 @@ -3812,9 +3802,7 @@ ra,dec,st_dist 267.970612,-29.27136,4705 269.329407,-31.951723,5915 269.048889,-30.52836,5800 -266.883057,-24.522667, 268.280365,-30.245722,860 -270.319366,-28.461971, 269.055542,-29.199083,5650 272.176958,-29.835806,3200 269.014,-29.082889,7100 @@ -3837,7 +3825,6 @@ ra,dec,st_dist 195.014903,12.682353,600 195.014903,12.682353,600 195.014903,12.682353,600 -245.909262,-26.531594, 259.791971,-14.6336,1200 350.644348,-26.849533,230 130.432596,20.226891,181.54