This commit is contained in:
Elon
2019-06-17 17:22:57 -06:00
19 changed files with 96 additions and 291 deletions
@@ -1,38 +0,0 @@
-- This asset requires OpenSpace to be built with the OPENSPACE_MODULE_VOLUME enabled
-- Before using this asset,
-- the volume data itself needs to be generated,
-- using the task 'data/tasks/volume/debristasks/generate_debris_volume.task'
local assetHelper = asset.require('util/asset_helper')
local transforms = asset.require("scene/solarsystem/planets/earth/transforms")
local earthRadius = 2 * 9762650;
local volume = {
Identifier = "DebrisVolume1",
Parent = transforms.EarthInertial.Identifier,
Renderable = {
Type = "RenderableTimeVaryingVolume",
SourceDirectory = asset.localResource("generated1"),
TransferFunction = asset.localResource("transferfunction.txt"),
StepSize = 0.01,
MinValue = 0,
MaxValue = 1,
GridType = "Cartesian",
SecondsBefore = 50*365*24*60*60,
SecondsAfter = 50*365*24*60*60
},
GUI = {
Path = "/Volumes"
},
Transform = {
Scale = {
Type = "StaticScale",
Scale = earthRadius -- do not multiply this. That will not show real representation.
}
}
}
local objects = { volume }
assetHelper.registerSceneGraphNodes(asset, objects)
@@ -1,38 +0,0 @@
-- This asset requires OpenSpace to be built with the OPENSPACE_MODULE_VOLUME enabled
-- Before using this asset,
-- the volume data itself needs to be generated,
-- using the task 'data/tasks/volume/debristasks/generate_debris_volume.task'
local assetHelper = asset.require('util/asset_helper')
local transforms = asset.require("scene/solarsystem/planets/earth/transforms")
local earthRadius = 2 * 8540390;
local volume = {
Identifier = "DebrisVolume2",
Parent = transforms.EarthInertial.Identifier,
Renderable = {
Type = "RenderableTimeVaryingVolume",
SourceDirectory = asset.localResource("generated2"),
TransferFunction = asset.localResource("transferfunction.txt"),
StepSize = 0.01,
MinValue = 0,
MaxValue = 1,
GridType = "Cartesian",
SecondsBefore = 50*365*24*60*60,
SecondsAfter = 50*365*24*60*60
},
GUI = {
Path = "/Volumes"
},
Transform = {
Scale = {
Type = "StaticScale",
Scale = earthRadius -- do not multiply this. That will not show real representation.
}
}
}
local objects = { volume }
assetHelper.registerSceneGraphNodes(asset, objects)
@@ -1,38 +0,0 @@
-- This asset requires OpenSpace to be built with the OPENSPACE_MODULE_VOLUME enabled
-- Before using this asset,
-- the volume data itself needs to be generated,
-- using the task 'data/tasks/volume/debristasks/generate_debris_volume.task'
local assetHelper = asset.require('util/asset_helper')
local transforms = asset.require("scene/solarsystem/planets/earth/transforms")
local earthRadius = 2 * 7847140;
local volume = {
Identifier = "DebrisVolume3",
Parent = transforms.EarthInertial.Identifier,
Renderable = {
Type = "RenderableTimeVaryingVolume",
SourceDirectory = asset.localResource("generated3"),
TransferFunction = asset.localResource("transferfunction.txt"),
StepSize = 0.01,
MinValue = 0,
MaxValue = 1,
GridType = "Cartesian",
SecondsBefore = 50*365*24*60*60,
SecondsAfter = 50*365*24*60*60
},
GUI = {
Path = "/Volumes"
},
Transform = {
Scale = {
Type = "StaticScale",
Scale = earthRadius -- do not multiply this. That will not show real representation.
}
}
}
local objects = { volume }
assetHelper.registerSceneGraphNodes(asset, objects)
@@ -1,38 +0,0 @@
-- This asset requires OpenSpace to be built with the OPENSPACE_MODULE_VOLUME enabled
-- Before using this asset,
-- the volume data itself needs to be generated,
-- using the task 'data/tasks/volume/debristasks/generate_debris_volume.task'
local assetHelper = asset.require('util/asset_helper')
local transforms = asset.require("scene/solarsystem/planets/earth/transforms")
local earthRadius = 2 * 8035460;
local volume = {
Identifier = "DebrisVolume4",
Parent = transforms.EarthInertial.Identifier,
Renderable = {
Type = "RenderableTimeVaryingVolume",
SourceDirectory = asset.localResource("generated4"),
TransferFunction = asset.localResource("transferfunction.txt"),
StepSize = 0.01,
MinValue = 0,
MaxValue = 1,
GridType = "Cartesian",
SecondsBefore = 50*365*24*60*60,
SecondsAfter = 50*365*24*60*60
},
GUI = {
Path = "/Volumes"
},
Transform = {
Scale = {
Type = "StaticScale",
Scale = earthRadius -- do not multiply this. That will not show real representation.
}
}
}
local objects = { volume }
assetHelper.registerSceneGraphNodes(asset, objects)
@@ -10,7 +10,7 @@ local transforms = asset.require("scene/solarsystem/planets/earth/transforms")
local maxApogee = 10946320;
local volume = {
Identifier = "DebrisVolume",
Identifier = "DebrisVolume - Spherical",
Parent = transforms.EarthInertial.Identifier,
Renderable = {
Type = "RenderableTimeVaryingVolume",
@@ -29,7 +29,7 @@ local volume = {
Transform = {
Scale = {
Type = "StaticScale",
Scale = maxApogee -- do not multiply this. That will not show real representation.
Scale = maxApogee --do not multiply this. That will not show real representation.
}
}
}
@@ -1,7 +1,7 @@
asset.request('./debris/debris_asat')
--asset.request('./debris/debris_asat')
asset.request('./debris/debris_breezem')
asset.request('./debris/debris_fengyun')
asset.request('./debris/debris_iridium33')
asset.request('./debris/debris_kosmos2251')
--asset.request('./debris/debris_fengyun')
--asset.request('./debris/debris_iridium33')
--asset.request('./debris/debris_kosmos2251')
--asset.request('./satellites_debris_old')
asset.request('./satellites_debris_old')
@@ -1,11 +0,0 @@
return {{
Type = "GenerateDebrisVolumeTask",
Dimensions = {32, 32, 32},
LowerDomainBound = {-0.5, -0.5, -0.5},
UpperDomainBound = {0.5, 0.5, 0.5},
InputPath = "${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"
}}
@@ -1,21 +0,0 @@
local length = 10
local tasks = {}
for i=1,length do
local step = string.format("%02d", i-1)
tasks[#tasks+1] = {
Type = "GenerateDebrisVolumeTask",
Dimensions = {256, 256, 256},
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 = "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
return tasks
@@ -1,15 +0,0 @@
return {{
Type = "GenerateDebrisVolumeTask",
Dimensions = {32, 16, 32},
LowerDomainBound = {0, 0, 0},
UpperDomainBound = {1, 2*math.pi, math.pi}, -- does not seem to do any difference.
InputPath = "${SYNC}/url/satellite_tle_data_DebrisAll/files/allDebrisInOneTLE.txt",
StartTime = "2019-05-04T00:00:10",
TimeStep = "1",
EndTime = "2019-05-04T00:00:10",
GridType = "Spherical",
RawVolumeOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated/singleDebris.rawvolume",
DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated/singleDebris.dictionary"
}}
-- C:\Users\Jonathan\Documents\exjobb\OpenSpace\sync\url\satellite_tle_data_BreezeMBreakup(18391204735368316775)\files
@@ -1,12 +0,0 @@
return {{
Type = "GenerateDebrisVolumeTask",
Dimensions = {16, 16, 16},
LowerDomainBound = {-0.5, -0.5, -0.5},
UpperDomainBound = {0.5, 0.5, 0.5},
InputPath = "C:/Users/Jonathan/Documents/exjobb/OpenSpace/sync/url/satellite_tle_data_FengyunDebris(17139759358359376863)/files/1999-025.txt",
StartTime = "2018-05-04T00:00:00",
RawVolumeOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated1/singleDebris.rawvolume",
DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated1/singleDebris.dictionary"
}}
-- C:\Users\Jonathan\Documents\exjobb\OpenSpace\sync\url\satellite_tle_data_BreezeMBreakup(18391204735368316775)\files
@@ -1,12 +0,0 @@
return {{
Type = "GenerateDebrisVolumeTask",
Dimensions = {16, 16, 16},
LowerDomainBound = {-0.5, -0.5, -0.5},
UpperDomainBound = {0.5, 0.5, 0.5},
InputPath = "C:/Users/Jonathan/Documents/exjobb/OpenSpace/sync/url/satellite_tle_data_IndianASATtestDebris(10018654073589624780)/files/2019-006.txt",
StartTime = "2018-05-04T00:00:00",
RawVolumeOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated2/singleDebris.rawvolume",
DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated2/singleDebris.dictionary"
}}
-- C:\Users\Jonathan\Documents\exjobb\OpenSpace\sync\url\satellite_tle_data_BreezeMBreakup(18391204735368316775)\files
@@ -1,12 +0,0 @@
return {{
Type = "GenerateDebrisVolumeTask",
Dimensions = {16, 16, 16},
LowerDomainBound = {-0.5, -0.5, -0.5},
UpperDomainBound = {0.5, 0.5, 0.5},
InputPath = "C:/Users/Jonathan/Documents/exjobb/OpenSpace/sync/url/satellite_tle_data_Iridium33Debris(10708435089634408069)/files/iridium-33-debris.txt",
StartTime = "2018-05-04T00:00:00",
RawVolumeOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated3/singleDebris.rawvolume",
DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated3/singleDebris.dictionary"
}}
-- C:\Users\Jonathan\Documents\exjobb\OpenSpace\sync\url\satellite_tle_data_BreezeMBreakup(18391204735368316775)\files
@@ -1,12 +0,0 @@
return {{
Type = "GenerateDebrisVolumeTask",
Dimensions = {16, 16, 16},
LowerDomainBound = {-0.5, -0.5, -0.5},
UpperDomainBound = {0.5, 0.5, 0.5},
InputPath = "C:/Users/Jonathan/Documents/exjobb/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/generated4/singleDebris.rawvolume",
DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated4/singleDebris.dictionary"
}}
-- C:\Users\Jonathan\Documents\exjobb\OpenSpace\sync\url\satellite_tle_data_BreezeMBreakup(18391204735368316775)\files
@@ -0,0 +1,14 @@
return {{
Type = "GenerateDebrisVolumeTask",
Dimensions = {32, 32, 64},
LowerDomainBound = {0, 0, 0},
UpperDomainBound = {1, math.pi, 2 * math.pi},
InputPath = "${SYNC}/url/satellite_tle_data_DebrisAll/files/allDebrisInOneTLE.txt",
--InputPath = "${SYNC}/url/satellite_tle_data_BreezeMBreakup(18391204735368316775)/files/2012-044.txt",
StartTime = "2018-05-04T00:00:00",
TimeStep = "3",
EndTime = "2018-05-04T00:00:00",
GridType = "Spherical",
RawVolumeOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated/singleDebris.rawvolume",
DictionaryOutput = "${DATA}/assets/scene/solarsystem/planets/earth/satellites/debris/volume/generated/singleDebris.dictionary"
}}
@@ -630,8 +630,8 @@ void RenderableSatellites::updateBuffers() {
_vertexBufferData[index].y = static_cast<float>(positionY);
_vertexBufferData[index].z = static_cast<float>(positionZ);
_vertexBufferData[index].time = static_cast<float>(timeOffset);
_vertexBufferData[index].epoch = static_cast<float>(orbit.epoch);
_vertexBufferData[index].period = static_cast<float>(orbit.period);
_vertexBufferData[index].epoch = orbit.epoch;
_vertexBufferData[index].period = orbit.period;
// The difference in the print below resulted in large differences, up to 0.35.
// LINFO(fmt::format("diff : {} ", position.x - _vertexBufferData[index].x));
@@ -660,10 +660,10 @@ void RenderableSatellites::updateBuffers() {
);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)0); // stride : 4*sizeof(GL_FLOAT) + 2*sizeof(GL_DOUBLE)
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)0); // stride : 4*sizeof(GL_FLOAT) + 2*sizeof(GL_DOUBLE)
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(3*sizeof(GL_FLOAT)) );
glVertexAttribPointer(1, 2, GL_DOUBLE, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4*sizeof(GL_FLOAT)) );
glBindVertexArray(0);
@@ -95,7 +95,8 @@ namespace openspace {
private:
/// The layout of the VBOs
struct TrailVBOLayout {
float x, y, z, time, epoch, period;
float x, y, z, time;
double epoch, period;
};
// static_assert(sizeof(struct TrailVBOLayout)==4*sizeof(float)+2*sizeof(double),"Implementation error!");
+2 -2
View File
@@ -33,7 +33,7 @@ uniform float lineFade;
in vec4 viewSpacePosition;
in vec4 vs_position;
in float vs_position_w;
in float periodFraction_f;
in float offsetPeriods;
@@ -68,7 +68,7 @@ Fragment getFragment() {
Fragment frag;
frag.color = vec4(color, fade * opacity);
frag.depth = vs_position.w;
frag.depth = vs_position_w;
frag.gPosition = viewSpacePosition;
frag.gNormal = vec4(1, 1, 1, 0);
// frag.blend = BLEND_MODE_ADDITIVE;
+15 -15
View File
@@ -26,8 +26,8 @@
#include "PowerScaling/powerScalingMath.hglsl"
layout (location = 0) in vec3 vertex_data; // 1: x, 2: y, 3: z
layout (location = 1) in vec3 orbit_data; // 1: timeOffset, 2: epoch, 3: period
layout (location = 0) in vec4 vertex_data; // 1: x, 2: y, 3: z
layout (location = 1) in vec2 orbit_data; // 1: timeOffset, 2: epoch, 3: period
uniform dmat4 modelViewTransform;
uniform mat4 projectionTransform;
@@ -36,7 +36,7 @@ uniform mat4 projectionTransform;
uniform double inGameTime;
out vec4 viewSpacePosition;
out vec4 vs_position;
out float vs_position_w;
out float periodFraction_f;
out float offsetPeriods;
@@ -62,23 +62,22 @@ void main() {
*/
// If orbit_data is doubles, cast to float first
float offset = orbit_data.x;
float epoch = orbit_data.y;
float period = orbit_data.z;
float offset = vertex_data.w;
double epoch = orbit_data.x;
double period = orbit_data.y;
// calculate nr of periods, get fractional part to know where
// the vertex closest to the debris part is right now
// double nrOfRevolutions = (inGameTime - epoch)/period;
double nrOfRevolutions = inGameTime/period - epoch/period;
// double periodFraction = fract(nrOfRevolutions); //mod(nrOfRevolutions, 1.0);
int nrOfRevolutions_i = int(nrOfRevolutions);
double periodFraction = nrOfRevolutions - nrOfRevolutions_i;
double nrOfRevolutions = (inGameTime - epoch) / period;
//double periodFraction = fract(nrOfRevolutions); //mod(nrOfRevolutions, 1.0);
int intfrac = int(nrOfRevolutions);
double doublefrac = double(intfrac);
double periodFraction = nrOfRevolutions - doublefrac;
periodFraction_f = float(periodFraction);
// same procedure for the current vertex
offsetPeriods = offset / period;
float period_f = float(period);
offsetPeriods = offset / period_f;
// offsetPeriods can also be calculated by passing the vertexID as a float
// to the fragment shader and deviding it by nrOfSegments.
@@ -86,8 +85,9 @@ void main() {
dvec3 positions = dvec3(vertex_data.x, vertex_data.y, vertex_data.z);
dvec4 vertexPosition = dvec4(positions, 1);
viewSpacePosition = vec4(modelViewTransform * vertexPosition);
vs_position = z_normalization( projectionTransform * viewSpacePosition);
vec4 vs_position = z_normalization( projectionTransform * viewSpacePosition);
gl_Position = vs_position;
vs_position_w = vs_position.w;
}
@@ -445,8 +445,6 @@ std::vector<glm::dvec3> getPositionBuffer(std::vector<KeplerParameters> tleData,
LINFO(fmt::format("max phi: {} ", maxPhi));
LINFO(fmt::format("min theta: {} ", minTheta));
LINFO(fmt::format("min phi: {} ", minPhi));
return positionBuffer;
}
// std::vector<glm::dvec3> generatePositions(int numberOfPositions) {
@@ -462,7 +460,7 @@ std::vector<glm::dvec3> getPositionBuffer(std::vector<KeplerParameters> tleData,
// return positions;
// }
float getDensityAt(glm::uvec3 cell, int* densityArray, RawVolume<float>& raw) {
float getDensityAt(glm::uvec3 cell, double* densityArray, RawVolume<float>& raw) {
float value;
// return value at position cell from _densityPerVoxel
size_t index = raw.coordsToIndex(cell);
@@ -499,7 +497,15 @@ int getIndexFromPosition(glm::dvec3 position, glm::uvec3 dim, float maxApogee, s
return coordinateIndex.z * (dim.x * dim.y) + coordinateIndex.y * dim.x + coordinateIndex.x;
}
else if(gridType == "Spherical"){
else if(gridType == "Spherical"){
if(position.y >= 3.141592){
position.y = 0;
}
if(position.z >= (2 * 3.141592)){
position.z = 0;
}
glm::uvec3 coordinateIndex = glm::uvec3(static_cast<int>(position.x * dim.x / (maxApogee))
,static_cast<int>(position.y * dim.y / (3.14159265358979323846264338327950288))
,static_cast<int>(position.z * dim.z / (2*3.14159265358979323846264338327950288)));
@@ -515,13 +521,37 @@ int getIndexFromPosition(glm::dvec3 position, glm::uvec3 dim, float maxApogee, s
return -1;
}
int* mapDensityToVoxels(int* densityArray, std::vector<glm::dvec3> positions, glm::uvec3 dim, float maxApogee, std::string gridType) {
double getVoxelVolume(int index, RawVolume<float>& raw, glm::uvec3 dim, float maxApogee){
// get coords from index
glm::uvec3 coords = raw.indexToCoords(index);
double rMax = maxApogee / dim.x;
double thetaMax = 3.141592 / dim.y;
double phiMax = (2 * 3.141592) / dim.z;
//use coords to calc volume
//integral(dTheta) * integral(r^2 dr) * integral(sin(phi) dPhi)
double rIntegral = (pow(((coords.x + 1) * rMax),3) - pow(((coords.x) * rMax),3)) / 3;
double thetaIntegral = -cos((coords.y + 1) * thetaMax) + cos(coords.y * thetaMax);
double phiIntegral = ((coords.z + 1) - coords.z) * phiMax;
return rIntegral * thetaIntegral * phiIntegral;
//return volume
}
double* mapDensityToVoxels(double* densityArray, std::vector<glm::dvec3> positions, glm::uvec3 dim, float maxApogee, std::string gridType, RawVolume<float>& raw) {
for(const glm::dvec3& position : positions) {
//LINFO(fmt::format("pos: {} ", position));
int index = getIndexFromPosition(position, dim, maxApogee, gridType);
//LINFO(fmt::format("index: {} ", index));
++densityArray[index];
if(gridType == "Cartesian"){
++densityArray[index];
}
else if(gridType == "Spherical"){
double voxelVolume = getVoxelVolume(index, raw, dim, maxApogee); //something like this
densityArray[index] += 1/voxelVolume;
}
}
return densityArray;
@@ -623,18 +653,25 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal
for(int i=0 ; i<=numberOfIterations ; ++i) {
std::vector<glm::dvec3> startPositionBuffer = getPositionBuffer(_TLEDataVector, startTimeInSeconds+(i*timeStep), _gridType); //+(i*timeStep)
//LINFO(fmt::format("pos: {} ", startPositionBuffer[4]));
int *densityArrayp = new int[size]();
double *densityArrayp = new double[size]();
//densityArrayp = mapDensityToVoxels(densityArrayp, generatedPositions, _dimensions, maxApogee);
//densityArrayp = mapDensityToVoxels(densityArrayp, startPositionBuffer, _dimensions, _maxApogee, _gridType);
// std::vector<glm::dvec3> testBuffer;
// testBuffer.push_back(glm::dvec3(0,0,0));
// testBuffer.push_back(glm::dvec3(100,100,100));
densityArrayp = mapDensityToVoxels(densityArrayp, startPositionBuffer, _dimensions, _maxApogee, _gridType);
// create object rawVolume
volume::RawVolume<float> rawVolume(_dimensions);
densityArrayp = mapDensityToVoxels(densityArrayp, startPositionBuffer, _dimensions, _maxApogee, _gridType, rawVolume);
/*std::vector<glm::dvec3> testBuffer;
testBuffer.push_back(glm::dvec3(0,0,0));
testBuffer.push_back(glm::dvec3(1,1.5,1.5));
testBuffer.push_back(glm::dvec3(1,3,3));
testBuffer.push_back(glm::dvec3(3,5,3));
//testBuffer.push_back(glm::dvec3(10000,1000000000,1000000000));
densityArrayp = mapDensityToVoxels(densityArrayp, testBuffer, _dimensions, _maxApogee, _gridType);
*/
// create object rawVolume
//glm::vec3 domainSize = _upperDomainBound - _lowerDomainBound;
// TODO: Create a forEachSatallite and set(cell, value) to combine mapDensityToVoxel