Implemented num orbital trail segments proportional to eccentricity

This commit is contained in:
GPayne
2020-04-09 13:33:30 -06:00
parent 9884d7e25d
commit a95d01d781
20 changed files with 70 additions and 54 deletions

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'amor_asteroid', 'sssb_data_amor_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_amor_asteroid.csv', "Amor Asteroids", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 11
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'apollo_asteroid', 'sssb_data_apollo_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_apollo_asteroid.csv', "Apollo Asteroids", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 10
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'aten_asteroid', 'sssb_data_aten_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_aten_asteroid.csv', "Aten Asteroids", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 18
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'atira_asteroid', 'sssb_data_atira_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_atira_asteroid.csv', "Atira Asteroids", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 25
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'centaur_asteroid', 'sssb_data_centaur_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_centaur_asteroid.csv', "Centaur Asteroids", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 18
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'chiron-type_comet', 'sssb_data_chiron-type_comet')
local object = sharedSssb.createSssbGroupObject('sssb_data_chiron-type_comet.csv', "Chiron-type Comets", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 50
object.Renderable.TrailFade = 25
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'encke-type_comet', 'sssb_data_encke-type_comet')
local object = sharedSssb.createSssbGroupObject('sssb_data_encke-type_comet.csv', "Encke-type Comets", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 2
object.Renderable.TrailFade = 23
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'halley-type_comet', 'sssb_data_halley-type_comet')
local object = sharedSssb.createSssbGroupObject('sssb_data_halley-type_comet.csv', "Halley-type Comets", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 2
object.Renderable.TrailFade = 18
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'inner_main_belt_asteroid', 'sssb_data_inner_main_belt_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_inner_main_belt_asteroid.csv', "Inner Main Asteroid Belt", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 0.5
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter-family_comet', 'sssb_data_jupiter-family_comet')
local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter-family_comet.csv', "Jupiter-family Comets", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 500
object.Renderable.SegmentQuality = 10
object.Renderable.TrailFade = 28
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter_trojan_asteroid', 'sssb_data_jupiter_trojan_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter_trojan_asteroid.csv', "Jupiter Trojan Asteroids", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 5
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main_belt_asteroid', 'sssb_data_main_belt_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_main_belt_asteroid.csv', "Main Asteroid Belt", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 0.1
object.Renderable.UpperLimit = 50000

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'mars-crossing_asteroid', 'sssb_data_mars-crossing_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_mars-crossing_asteroid.csv', "Mars-crossing Asteroids", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 13
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'outer_main_belt_asteroid', 'sssb_data_outer_main_belt_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_outer_main_belt_asteroid.csv', "Outer Main Asteroid Belt", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 50
object.Renderable.SegmentQuality = 1
object.Renderable.TrailFade = 2
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'pha', 'sssb_data_pha')
local object = sharedSssb.createSssbGroupObject('sssb_data_pha.csv', "Potentially Hazardous Asteroids", filepath, { 0.75, 0.2, 0.2 })
object.Renderable.Enabled = false
object.Renderable.Segments = 100
object.Renderable.SegmentQuality = 3
object.Renderable.TrailFade = 17
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared')
local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'transneptunian_object_asteroid', 'sssb_data_transneptunian_object_asteroid')
local object = sharedSssb.createSssbGroupObject('sssb_data_transneptunian_object_asteroid.csv', "Transneptunian Object Asteroids", filepath, { 0.9, 0.3, 0.1 })
object.Renderable.Enabled = false
object.Renderable.Segments = 150
object.Renderable.SegmentQuality = 3
object.Renderable.TrailFade = 10
assetHelper.registerSceneGraphNodesAndExport(asset, { object })

View File

@@ -53,10 +53,13 @@ namespace {
"Path",
"The file path to the data file to read"
};
static const openspace::properties::Property::PropertyInfo SegmentsInfo = {
"Segments",
"Segments",
"The number of segments to use for each orbit ellipse"
static const openspace::properties::Property::PropertyInfo SegmentQualityInfo = {
"SegmentQuality",
"Segment Quality",
"A segment quality value for the orbital trail. A value from 1 (lowest) to "
"100 (highest) that controls the number of line segments in the rendering of the "
"orbital trail. This does not control the direct number of segments because "
"these automatically increase according to the eccentricity of the orbit."
};
constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = {
"LineWidth",
@@ -350,7 +353,7 @@ int RenderableOrbitalKepler::daysIntoGivenYear(int month, int dayOfMonth) {
RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _path(PathInfo)
, _nSegments(SegmentsInfo, 120, 4, 1024)
, _segmentQuality(SegmentQualityInfo, 10, 1, 100)
, _upperLimit(UpperLimitInfo, 1000, 1, 1000000)
{
documentation::testSpecificationAndThrow(
@@ -360,7 +363,8 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio
);
_path = dictionary.value<std::string>(PathInfo.identifier);
_nSegments = static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
_segmentQuality = static_cast<int>(
dictionary.value<double>(SegmentQualityInfo.identifier));
if (dictionary.hasKeyAndValue<glm::vec3>(LineColorInfo.identifier)) {
_appearance.lineColor = dictionary.value<glm::vec3>(LineColorInfo.identifier);
@@ -393,11 +397,11 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio
}
reinitializeTrailBuffers = std::function<void()>([this] { initializeGL(); });
_path.onChange(reinitializeTrailBuffers);
_nSegments.onChange(reinitializeTrailBuffers);
_segmentQuality.onChange(reinitializeTrailBuffers);
addPropertySubOwner(_appearance);
addProperty(_path);
addProperty(_nSegments);
addProperty(_segmentQuality);
addProperty(_opacity);
setRenderBin(Renderable::RenderBin::Overlay);
@@ -481,11 +485,11 @@ void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) {
glBindVertexArray(_vertexArray);
for (size_t i = 0; i < nrOrbits; ++i) {
glDrawArrays(GL_LINE_STRIP, vertices, _nSegments + 1);
vertices = vertices + _nSegments + 1;
glDrawArrays(GL_LINE_STRIP, vertices, _segmentSize[i] + 1);
vertices = vertices + _segmentSize[i] + 1;
}
glBindVertexArray(0);
_programObject->deactivate();
}
@@ -493,11 +497,18 @@ void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) {
void RenderableOrbitalKepler::updateBuffers() {
readDataFile(_path);
const size_t nVerticesPerOrbit = _nSegments + 1;
_vertexBufferData.resize(_data.size() * nVerticesPerOrbit);
size_t orbitindex = 0;
size_t nVerticesPerOrbit = 0;
int numOrbits = _data.size();
for (size_t i = 0; i < numOrbits; ++i) {
nVerticesPerOrbit += _segmentSize[i] + 1;
}
_vertexBufferData.resize(nVerticesPerOrbit);
size_t vertexBufIdx = 0;
for (size_t orbitIdx = 0; orbitIdx < numOrbits; ++orbitIdx) {
openspace::RenderableOrbitalKepler::KeplerParameters orbit = _data[orbitIdx];
for (const auto& orbit : _data) {
_keplerTranslator.setKeplerElements(
orbit.eccentricity,
orbit.semiMajorAxis,
@@ -509,32 +520,30 @@ void RenderableOrbitalKepler::updateBuffers() {
orbit.epoch
);
for (size_t i=0 ; i < nVerticesPerOrbit; ++i) {
size_t index = orbitindex * nVerticesPerOrbit + i;
for (size_t j = 0 ; j < _segmentSize[orbitIdx]; ++j) {
double timeOffset = orbit.period *
static_cast<double>(i)/ static_cast<double>(_nSegments);
static_cast<double>(j)/ static_cast<double>(_segmentSize[orbitIdx]);
glm::dvec3 position = _keplerTranslator.position({
{},
Time(timeOffset + orbit.epoch),
Time(0.0),
false
});
double positionX = position.x;
double positionY = position.y;
double positionZ = position.z;
_vertexBufferData[index].x = static_cast<float>(positionX);
_vertexBufferData[index].y = static_cast<float>(positionY);
_vertexBufferData[index].z = static_cast<float>(positionZ);
_vertexBufferData[index].time = static_cast<float>(timeOffset);
_vertexBufferData[index].epoch = orbit.epoch;
_vertexBufferData[index].period = orbit.period;
_vertexBufferData[vertexBufIdx].x = static_cast<float>(positionX);
_vertexBufferData[vertexBufIdx].y = static_cast<float>(positionY);
_vertexBufferData[vertexBufIdx].z = static_cast<float>(positionZ);
_vertexBufferData[vertexBufIdx].time = static_cast<float>(timeOffset);
_vertexBufferData[vertexBufIdx].epoch = orbit.epoch;
_vertexBufferData[vertexBufIdx].period = orbit.period;
vertexBufIdx++;
}
++orbitindex;
}
glBindVertexArray(_vertexArray);
@@ -553,7 +562,6 @@ void RenderableOrbitalKepler::updateBuffers() {
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_DOUBLE, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4 * sizeof(GL_FLOAT)));
glBindVertexArray(0);
}

View File

@@ -106,7 +106,9 @@ protected:
const double convertAuToKm = 1.496e8;
const double convertDaysToSecs = 86400.;
std::vector<KeplerParameters> _data;
std::vector<size_t> _segmentSize;
properties::UIntProperty _upperLimit;
properties::UIntProperty _segmentQuality;
properties::Property::OnChangeHandle _upperLimitCallbackHandle;
private:
@@ -144,7 +146,6 @@ private:
ghoul::opengl::ProgramObject* _programObject;
properties::StringProperty _path;
properties::UIntProperty _nSegments;
RenderableTrail::Appearance _appearance;
glm::vec3 _position = glm::vec3(0.f);

View File

@@ -130,6 +130,8 @@ void RenderableSatellites::readDataFile(const std::string& filename) {
"Satellite TLE file {} does not exist.", filename
));
}
_data.clear();
_segmentSize.clear();
std::ifstream file;
file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
@@ -235,7 +237,7 @@ void RenderableSatellites::readDataFile(const std::string& filename) {
keplerElements.period = period;
_data.push_back(keplerElements);
_segmentSize.push_back(_segmentQuality * 10);
}
file.close();
}

View File

@@ -54,10 +54,13 @@ namespace {
"Path",
"The file path to the SBDB .csv file to read"
};
static const openspace::properties::Property::PropertyInfo SegmentsInfo = {
"Segments",
"Segments",
"The number of segments to use for each orbit ellipse"
static const openspace::properties::Property::PropertyInfo SegmentQualityInfo = {
"SegmentQuality",
"Segment Quality",
"A segment quality value for the orbital trail. A value from 1 (lowest) to "
"100 (highest) that controls the number of line segments in the rendering of the "
"orbital trail. This does not control the direct number of segments because "
"these automatically increase according to the eccentricity of the orbit."
};
constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = {
"LineWidth",
@@ -93,10 +96,10 @@ documentation::Documentation RenderableSmallBody::Documentation() {
"space_renderable_small_body",
{
{
SegmentsInfo.identifier,
SegmentQualityInfo.identifier,
new DoubleVerifier,
Optional::No,
SegmentsInfo.description
SegmentQualityInfo.description
},
{
UpperLimitInfo.identifier,
@@ -155,6 +158,7 @@ void RenderableSmallBody::readDataFile(const std::string& filename) {
file.seekg(std::ios_base::beg); // reset iterator to beginning of file
_data.clear();
_sbNames.clear();
_segmentSize.clear();
std::string line;
std::streamoff csvLine = -1;
@@ -332,6 +336,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount,
_data.push_back(keplerElements);
_sbNames.push_back(name);
_segmentSize.push_back(_segmentQuality * 10 * (keplerElements.eccentricity / 0.05));
}
static double importAngleValue(const std::string& angle) {