diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_asat.asset b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_asat.asset index 1599f83bad..455adad84e 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_asat.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_asat.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('../debris_shared') local group = { Title = "Indian ASAT test Debris", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/debris/volume/debris_volume.asset b/data/assets/scene/solarsystem/planets/earth/satellites/debris/volume/debris_volume.asset index 572530faf9..47100127ff 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/debris/volume/debris_volume.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/debris/volume/debris_volume.asset @@ -7,14 +7,14 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require("scene/solarsystem/planets/earth/transforms") -local earthRadius = 2*10946320 +local maxApogee = 2 * 10946320; local volume = { Identifier = "DebrisVolume", Parent = transforms.EarthInertial.Identifier, Renderable = { Type = "RenderableTimeVaryingVolume", - SourceDirectory = asset.localResource("generated"), + SourceDirectory = asset.localResource("generatedSequence"), TransferFunction = asset.localResource("transferfunction.txt"), StepSize = 0.01, MinValue = 0, @@ -29,7 +29,7 @@ local volume = { Transform = { Scale = { Type = "StaticScale", - Scale = earthRadius -- do not multiply this. That will not show real representation. + Scale = maxApogee -- do not multiply this. That will not show real representation. } } } diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/debris/volume/transferfunction.txt b/data/assets/scene/solarsystem/planets/earth/satellites/debris/volume/transferfunction.txt index 166c988ad3..f3e64cc6e8 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/debris/volume/transferfunction.txt +++ b/data/assets/scene/solarsystem/planets/earth/satellites/debris/volume/transferfunction.txt @@ -1,5 +1,6 @@ width 1024 lower 0.0 upper 1.0 -mappingkey 0.0 250 120 250 0 -mappingkey 1.0 200 200 200 255 \ No newline at end of file +mappingkey 0.08 40 160 40 0 +mappingkey 0.14 40 40 240 50 +mappingkey 0.3 200 80 0 250 diff --git a/data/tasks/volume/debristasks/generate_all_debris.task b/data/tasks/volume/debristasks/generate_all_debris.task new file mode 100644 index 0000000000..76f4d71f8e --- /dev/null +++ b/data/tasks/volume/debristasks/generate_all_debris.task @@ -0,0 +1,11 @@ +return {{ + Type = "GenerateDebrisVolumeTask", + Dimensions = {32, 32, 32}, + LowerDomainBound = {-0.5, -0.5, -0.5}, + UpperDomainBound = {0.5, 0.5, 0.5}, + InputPath = "D:/OpenSpace/sync/url/satellite_tle_data_DebrisAll/files/allDebrisInOneTLE.txt", + StartTime = "2018-05-04T00:00:00", + RawVolumeOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generatedAll/singleDebris.rawvolume", + DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generatedAll/singleDebris.dictionary" +}} + diff --git a/data/tasks/volume/debristasks/generate_all_individual.task b/data/tasks/volume/debristasks/generate_all_individual.task new file mode 100644 index 0000000000..4ae445932d --- /dev/null +++ b/data/tasks/volume/debristasks/generate_all_individual.task @@ -0,0 +1,16 @@ +return {{ + Type = "GenerateDebrisVolumeTask", + Dimensions = {32, 32, 32}, + LowerDomainBound = {-0.5, -0.5, -0.5}, + UpperDomainBound = {0.5, 0.5, 0.5}, + InputPath = "D:/OpenSpace/sync/url/satellite_tle_data_BreezeMBreakup(18391204735368316775)/files/2012-044.txt", + InputPath1 = "D:/OpenSpace/sync/url/satellite_tle_data_FengyunDebris(17139759358359376863)/files/1999-025.txt", + InputPath2 = "D:/OpenSpace/sync/url/satellite_tle_data_IndianASATtestDebris(10018654073589624780)/files/2019-006.txt", + InputPath3 = "D:/OpenSpace/sync/url/satellite_tle_data_Iridium33Debris(10708435089634408069)/files/iridium-33-debris.txt", + InputPath4 = "D:/OpenSpace/sync/url/satellite_tle_data_Kosmos2251Debris(14362705017065532804)/files/cosmos-2251-debris.txt", + + StartTime = "2018-05-04T00:00:00", + RawVolumeOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generatedAllInOne/debris.rawvolume", + DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generatedAllInOne/debris.dictionary" +}} + diff --git a/data/tasks/volume/debristasks/generate_debris_volume.task b/data/tasks/volume/debristasks/generate_debris_volume.task index 8a783c0bd4..8840173a20 100644 --- a/data/tasks/volume/debristasks/generate_debris_volume.task +++ b/data/tasks/volume/debristasks/generate_debris_volume.task @@ -1,33 +1,20 @@ -local length = 60 +local length = 10 local tasks = {} for i=1,length do - local radius = 0.5 * (1 - i/length) - local fn = - "return function (x, y, z) " .. "\n" .. - " local v = math.sqrt(x^2 + y^2 + z^2) - " .. radius .. "\n" .. - " v = (-v - 0.1) / 0.2 " .. "\n" .. - " v = math.min(math.max(v, 0), 1) " .. "\n" .. - " v = 3*v^2 - 2*v^3 " .. "\n" .. - " return v" .. "\n" .. - "end" local step = string.format("%02d", i-1) - local fn = - "return function (x, y, z)" .. - "return 1.0" .. - "end" tasks[#tasks+1] = { - Type = "GenerateRawVolumeTask", -- fix name - Dimensions = {32, 32, 32}, + Type = "GenerateDebrisVolumeTask", + Dimensions = {256, 256, 256}, LowerDomainBound = {-0.5, -0.5, -0.5}, UpperDomainBound = {0.5, 0.5, 0.5}, - ValueFunction = fn, - Time = "2018-05-04T00:00:00" .. step, - RawVolumeOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated/" .. step .. ".rawvolume", - DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated/" .. step .. ".dictionary" + InputPath = "D:/OpenSpace/sync/url/satellite_tle_data_DebrisAll/files/allDebrisInOneTLE.txt", + StartTime = "2019-05-21T00:00" .. step .. ":00", + RawVolumeOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generatedSequence/" .. step .. ".rawvolume", + DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generatedSequence/" .. step .. ".dictionary" } end diff --git a/data/tasks/volume/debristasks/generate_single_debris_volume.task b/data/tasks/volume/debristasks/generate_single_debris_volume.task index 12d3f0665b..1a20614a07 100644 --- a/data/tasks/volume/debristasks/generate_single_debris_volume.task +++ b/data/tasks/volume/debristasks/generate_single_debris_volume.task @@ -1,4 +1,3 @@ - return {{ Type = "GenerateDebrisVolumeTask", Dimensions = {64, 64, 64}, diff --git a/data/tasks/volume/generate_cartesian_sequence.task b/data/tasks/volume/generate_cartesian_sequence.task index 08aa2edd53..17b1e45c73 100644 --- a/data/tasks/volume/generate_cartesian_sequence.task +++ b/data/tasks/volume/generate_cartesian_sequence.task @@ -18,7 +18,7 @@ for i=1,length do LowerDomainBound = {-0.5, -0.5, -0.5}, UpperDomainBound = {0.5, 0.5, 0.5}, ValueFunction = fn, - Time = "2018-05-04T00:00:" .. step, + Time = "2018-05-04T00:00:01" .. step, RawVolumeOutput = "${DATA}/assets/examples/volume/generated/cartesiansequence/" .. step .. ".rawvolume", DictionaryOutput = "${DATA}/assets/examples/volume/generated/cartesiansequence/" .. step .. ".dictionary" } diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index ec12804bfa..2e1e05465e 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -23,7 +23,7 @@ ****************************************************************************************/ #include #include -#include +#include #include #include @@ -476,7 +476,7 @@ RenderableSatellites::~RenderableSatellites() { void RenderableSatellites::initialize() { - updateBuffers(); +// updateBuffers(); //_path.onChange([this]() { // readTLEFile(_path); @@ -534,9 +534,8 @@ void RenderableSatellites::deinitializeGL() { SpaceModule::ProgramObjectManager.release(ProgramName); glDeleteBuffers(1, &_vertexBuffer); - glDeleteBuffers(1, &_indexBuffer); + //glDeleteBuffers(1, &_indexBuffer); glDeleteVertexArrays(1, &_vertexArray); - _vertexArray = 0; } @@ -576,8 +575,7 @@ void RenderableSatellites::render(const RenderData& data, RendererTasks&) { _programObject->setUniform(_uniformCache.numberOfSegments, static_cast(_nSegments)); - //glEnableVertexAttribArray(0); // We like submitting vertices on stream 0 for no special reason - //glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), 0); + glLineWidth(_appearance.lineWidth); const size_t nrOrbits = _TLEData.size(); gl::GLint vertices = 0; @@ -599,7 +597,6 @@ void RenderableSatellites::render(const RenderData& data, RendererTasks&) { void RenderableSatellites::updateBuffers() { _TLEData = readTLEFile(_path); - LINFO(fmt::format("Pathpath: {} ", _path)); const size_t nVerticesPerOrbit = _nSegments + 1; _vertexBufferData.resize(_TLEData.size() * nVerticesPerOrbit); diff --git a/modules/space/shaders/debrisViz_fs.glsl b/modules/space/shaders/debrisViz_fs.glsl index b0d32b618b..677d6685d0 100644 --- a/modules/space/shaders/debrisViz_fs.glsl +++ b/modules/space/shaders/debrisViz_fs.glsl @@ -32,7 +32,6 @@ uniform float lineFade; // uniform int numberOfSegments; in vec4 viewSpacePosition; - in vec4 vs_position; in float periodFraction_f; diff --git a/modules/space/shaders/renderablekeplerorbits_vs.glsl b/modules/space/shaders/renderablekeplerorbits_vs.glsl index 29c3ff6897..e08980ab21 100644 --- a/modules/space/shaders/renderablekeplerorbits_vs.glsl +++ b/modules/space/shaders/renderablekeplerorbits_vs.glsl @@ -28,9 +28,9 @@ layout(location = 0) in vec4 vertexData; uniform dmat4 modelViewTransform; uniform mat4 projectionTransform; -uniform bool useLineFade; -uniform float lineFade; -uniform int vertexSortingMethod; +// uniform bool useLineFade; +// uniform float lineFade; +// uniform int vertexSortingMethod; uniform int pointSize; out vec4 viewSpacePosition; diff --git a/modules/space/tasks/generatedebrisvolumetask.cpp b/modules/space/tasks/generatedebrisvolumetask.cpp index bc4448c5d7..c700fc829f 100644 --- a/modules/space/tasks/generatedebrisvolumetask.cpp +++ b/modules/space/tasks/generatedebrisvolumetask.cpp @@ -30,6 +30,7 @@ #include +#include #include #include @@ -49,11 +50,17 @@ namespace { constexpr const char* KeyDictionaryOutput = "DictionaryOutput"; constexpr const char* KeyDimensions = "Dimensions"; constexpr const char* KeyStartTime = "StartTime"; - // constexpr const char* KeyEndTime = "EndTime"; + //constexpr const char* KeyEndTime = "EndTime"; constexpr const char* KeyInputPath = "InputPath"; - // constexpr const char* KeyLowerDomainBound = "LowerDomainBound"; - // constexpr const char* KeyUpperDomainBound = "UpperDomainBound"; - constexpr const char* _loggerCat = "SpaceDebris"; + + // constexpr const char* KeyInputPath1 = "InputPath1"; + // constexpr const char* KeyInputPath2 = "InputPath2"; + // constexpr const char* KeyInputPath3 = "InputPath3"; + // constexpr const char* KeyInputPath4 = "InputPath4"; + + + constexpr const char* KeyLowerDomainBound = "LowerDomainBound"; + constexpr const char* KeyUpperDomainBound = "UpperDomainBound"; } @@ -396,14 +403,14 @@ std::vector generatePositions(int numberOfPositions) { float radius = 700000; // meter float degreeStep = 360 / numberOfPositions; - for(int i=0 ; i<= 360 ; i == degreeStep){ + for(int i=0 ; i<= 360 ; i += degreeStep){ glm::dvec3 singlePosition = glm::dvec3(radius* sin(i), radius*cos(i), 0.0); positions.push_back(singlePosition); } return positions; } -float getDensityAt(glm::uvec3 cell) { +float getDensityAt(glm::uvec3 cell, int* densityArray, RawVolume& raw) { float value; // return value at position cell from _densityPerVoxel size_t index = raw.coordsToIndex(cell); @@ -463,7 +470,6 @@ GenerateDebrisVolumeTask::GenerateDebrisVolumeTask(const ghoul::Dictionary& dict _dimensions = dictionary.value(KeyDimensions); _startTime = dictionary.value(KeyStartTime); //_endTime = dictionary.value(KeyEndTime); - // since _inputPath is past from task, // there will have to be either one task per dataset, // or you need to combine the datasets into one file. @@ -473,8 +479,6 @@ GenerateDebrisVolumeTask::GenerateDebrisVolumeTask(const ghoul::Dictionary& dict _TLEDataVector = {}; - _lowerDomainBound = dictionary.value(KeyLowerDomainBound); - _upperDomainBound = dictionary.value(KeyUpperDomainBound); } std::string GenerateDebrisVolumeTask::description() { @@ -489,26 +493,39 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal SpiceManager::ref().unloadKernel(kernel); }; + ////////// //1. read TLE-data and position of debris elements. + // std::vectorTLEDataVector = readTLEFile(_inputPath); + // std::vectorTLEDataVector1 = readTLEFile(_inputPath1); + // std::vectorTLEDataVector2 = readTLEFile(_inputPath2); + // std::vectorTLEDataVector3 = readTLEFile(_inputPath3); + // std::vectorTLEDataVector4 = readTLEFile(_inputPath4); + + // _TLEDataVector.reserve( TLEDataVector.size() + TLEDataVector1.size() + TLEDataVector2.size() + TLEDataVector3.size() + TLEDataVector4.size()); + // _TLEDataVector.insert(_TLEDataVector.end(), TLEDataVector.begin(), TLEDataVector.end()); + // _TLEDataVector.insert(_TLEDataVector.end(), TLEDataVector1.begin(), TLEDataVector1.end()); + // _TLEDataVector.insert(_TLEDataVector.end(), TLEDataVector2.begin(), TLEDataVector2.end()); + // _TLEDataVector.insert(_TLEDataVector.end(), TLEDataVector3.begin(), TLEDataVector3.end()); + // _TLEDataVector.insert(_TLEDataVector.end(), TLEDataVector4.begin(), TLEDataVector4.end()); + // ----- or ----- if only one _TLEDataVector = readTLEFile(_inputPath); + ////////// + + std::vector startPositionBuffer = getPositionBuffer(_TLEDataVector, _startTime); // if we deside to integrate the density over time // std::vector endPositionBuffer = getPositionBuffer(_TLEDataVector, _endTime); - int numberOfPoints = 40; + //int numberOfPoints = 40; //Needs to be looked at, caused my computer to crash... //std::vector generatedPositions = generatePositions(numberOfPoints); - const int size = _dimensions.x *_dimensions.y *_dimensions.z; - int *densityArrayp = new int[size]; - for (int i = 0; i < size; ++i) { - densityArrayp[i] = 0; - } - LINFO(fmt::format("densityArray: {} ", densityArrayp[0])); - + float maxApogee = getMaxApogee(_TLEDataVector); LINFO(fmt::format("Max Apogee: {} ", maxApogee)); + const int size = _dimensions.x *_dimensions.y *_dimensions.z; + int *densityArrayp = new int[size](); //densityArrayp = mapDensityToVoxels(densityArrayp, generatedPositions, _dimensions, maxApogee); densityArrayp = mapDensityToVoxels(densityArrayp, startPositionBuffer, _dimensions, maxApogee); @@ -539,44 +556,14 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal LINFO(fmt::format("max: {} ", maxVal));*/ }); - - - - - - - - - - - // indexed grid with cooresponding xyz: gridIndex - // int array with number of slots = number of voxels: densityArray = {0,0,0,0,0,0} - for(const glm::dvec3& debris : startPositionBuffer) { - // call function to increment densityArray where debris position ~= voxel position + ghoul::filesystem::File file(_rawVolumeOutputPath); + const std::string directory = file.directoryName(); + if (!FileSys.directoryExists(directory)) { + FileSys.createDirectory(directory, ghoul::filesystem::FileSystem::Recursive::Yes); } - // make raw volume of densityArray. - - //2. create a grid using dimensions and other .task-parameters. - - //3. calculate what voxel each debris is within for each time step. - // and increment density with one for each debris in that voxel. - - glm::vec3 domainSize = _upperDomainBound - _lowerDomainBound; - - rawVolume.forEachVoxel([&](glm::uvec3 cell, float) { - glm::vec3 coord = _lowerDomainBound + - glm::vec3(cell) / glm::vec3(_dimensions) * domainSize; - - // TODO: coord is relative to the dimensions of the volume - // and the points from getPositionBuffer is relative - // to the earth (i think) so we need to convert them to be in the same - // coordinate system to be able to compare them - - - - - }); - //4. + + volume::RawVolumeWriter writer(_rawVolumeOutputPath); + writer.write(rawVolume); RawVolumeMetadata metadata; // alternatively metadata.hasTime = false; diff --git a/modules/space/tasks/generatedebrisvolumetask.h~9a4d41871b260bded35ea264d131ab00c7d60125 b/modules/space/tasks/generatedebrisvolumetask.h~9a4d41871b260bded35ea264d131ab00c7d60125 new file mode 100644 index 0000000000..415819df75 --- /dev/null +++ b/modules/space/tasks/generatedebrisvolumetask.h~9a4d41871b260bded35ea264d131ab00c7d60125 @@ -0,0 +1,78 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2019 * + * * + * 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 __OPENSPACE_MODULE_SPACE___GENERATERDEBRISVOLUMETASK___H__ +#define __OPENSPACE_MODULE_SPACE___GENERATERDEBRISVOLUMETASK___H__ + +#include +#include + +#include +#include + + +#include + +#include +#include + +namespace openspace { +namespace volume { + + +class GenerateDebrisVolumeTask : public Task { +public: + GenerateDebrisVolumeTask(const ghoul::Dictionary& dictionary); + std::string description() override; + void perform(const Task::ProgressCallback& progressCallback) override; + static documentation::Documentation documentation(); + +private: + std::string _rawVolumeOutputPath; + std::string _dictionaryOutputPath; + std::string _startTime; + std::string _endTime; + std::string _inputPath; + + // std::string _inputPath1; + // std::string _inputPath2; + // std::string _inputPath3; + // std::string _inputPath4; + + glm::uvec3 _dimensions; + glm::vec3 _lowerDomainBound; + glm::vec3 _upperDomainBound; + + std::vector _TLEDataVector; + + // not sure if it should be local function or hidden function. + //std::vector readTLEFile(const std::string& filename); + +}; + + + +} // namespace volume +} // namespace openspace + +#endif // __OPENSPACE_MODULE_SPACE___GENERATEDEBRISVOLUMETASK___H__ diff --git a/modules/space/translation/keplertranslation.cpp b/modules/space/translation/keplertranslation.cpp index 34838fdec2..83a49b0de5 100644 --- a/modules/space/translation/keplertranslation.cpp +++ b/modules/space/translation/keplertranslation.cpp @@ -324,27 +324,6 @@ glm::dvec3 KeplerTranslation::debrisPos(const double& time) const { return _orbitPlaneRotation * p; } -// Is only used in renderableDebris so far. -glm::dvec3 KeplerTranslation::position(const Time& time) const { - if (_orbitPlaneDirty) { - computeOrbitPlane(); - _orbitPlaneDirty = false; - } - - const double t = time.j2000Seconds() - _epoch; - const double meanMotion = glm::two_pi() / _period; - const double meanAnomaly = glm::radians(_meanAnomalyAtEpoch.value()) + t * meanMotion; - const double e = eccentricAnomaly(meanAnomaly); - - // Use the eccentric anomaly to compute the actual location - const glm::dvec3 p = { - _semiMajorAxis * 1000.0 * (cos(e) - _eccentricity), - _semiMajorAxis * 1000.0 * sin(e) * sqrt(1.0 - _eccentricity * _eccentricity), - 0.0 - }; - return _orbitPlaneRotation * p; -} - void KeplerTranslation::computeOrbitPlane() const { // We assume the following coordinate system: // z = axis of rotation diff --git a/modules/space/translation/keplertranslation.h b/modules/space/translation/keplertranslation.h index ed5be1e3b4..c16da23f2c 100644 --- a/modules/space/translation/keplertranslation.h +++ b/modules/space/translation/keplertranslation.h @@ -155,12 +155,6 @@ public: protected: -private: - - -protected: - - private: