This commit is contained in:
Elon
2019-05-08 10:48:33 -06:00
parent fee36349e8
commit 10e9991820
31 changed files with 6254 additions and 174 deletions
+37
View File
@@ -0,0 +1,37 @@
// /****************************************************************************************
// * *
// * OpenSpace *
// * *
// * Copyright (c) 2014-2018 *
// * *
// * 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. *
// ****************************************************************************************/
#include <openspace/rendering/renderable.h>
namespace openspace {
class RenderableGrid : Renderable {
public:
protected:
private:
};
}
+13 -139
View File
@@ -59,6 +59,10 @@ namespace {
constexpr const char* ProgramName = "RenderableSatellites";
constexpr const char* _loggerCat = "SpaceDebris";
// constexpr const std::array<const char*, 6> UniformNames = {
// "modelViewTransform", "projectionTransform",
// "lineFade", "inGameTime", "color", "opacity"
// };
static const openspace::properties::Property::PropertyInfo PathInfo = {
@@ -72,67 +76,14 @@ namespace {
"Segments",
"The number of segments to use for each orbit ellipse"
};
static const openspace::properties::Property::PropertyInfo EccentricityColumnInfo = {
"EccentricityColumn",
"EccentricityColumn",
"The header of the column where the eccentricity is stored"
};
static const openspace::properties::Property::PropertyInfo SemiMajorAxisColumnInfo = {
"SemiMajorAxisColumn",
"SemiMajorAxisColumn",
"The header of the column where the semi-major axis is stored"
};
static const openspace::properties::Property::PropertyInfo SemiMajorAxisUnitInfo = {
"SemiMajorAxisUnit",
"SemiMajorAxisUnit",
"The unit of the semi major axis. For example: If specified in km, set this to 1000."
};
static const openspace::properties::Property::PropertyInfo InclinationColumnInfo = {
"InclinationColumn",
"InclinationColumn",
"The header of the column where the inclination is stored"
};
static const openspace::properties::Property::PropertyInfo AscendingNodeColumnInfo = {
"AscendingNodeColumn",
"AscendingNodeColumn",
"The header of the column where the ascending node is stored"
};
static const openspace::properties::Property::PropertyInfo ArgumentOfPeriapsisColumnInfo = {
"ArgumentOfPeriapsisColumn",
"ArgumentOfPeriapsisColumn",
"The header of the column where the argument of periapsis is stored"
};
static const openspace::properties::Property::PropertyInfo MeanAnomalyAtEpochColumnInfo = {
"MeanAnomalyAtEpochColumn",
"MeanAnomalyAtEpochColumn",
"The header of the column where the mean anomaly at epoch is stored"
};
static const openspace::properties::Property::PropertyInfo EpochColumnInfo = {
"EpochColumn",
"EpochColumn",
"The header of the column where the epoch is stored"
};
constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = {
"LineWidth",
"Line Width",
"This value specifies the line width of the trail if the selected rendering "
"method includes lines. If the rendering mode is set to Points, this value is "
"ignored."
};
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
"Color",
"Color",
"Färg."
};
constexpr openspace::properties::Property::PropertyInfo FadeInfo = {
constexpr openspace::properties::Property::PropertyInfo FadeInfo = {
"Fade",
"Line fade",
"The fading factor that is applied to the trail if the 'EnableFade' value is "
@@ -440,66 +391,13 @@ documentation::Documentation RenderableSatellites::Documentation() {
Optional::No,
PathInfo.description
},
{
EccentricityColumnInfo.identifier,
new StringVerifier,
Optional::No,
EccentricityColumnInfo.description
},
{
SemiMajorAxisColumnInfo.identifier,
new StringVerifier,
Optional::No,
SemiMajorAxisColumnInfo.description
},
{
SemiMajorAxisUnitInfo.identifier,
new DoubleVerifier,
Optional::No,
SemiMajorAxisUnitInfo.description
},
{
InclinationColumnInfo.identifier,
new StringVerifier,
Optional::No,
InclinationColumnInfo.description
},
{
AscendingNodeColumnInfo.identifier,
new StringVerifier,
Optional::No,
AscendingNodeColumnInfo.description
},
{
ArgumentOfPeriapsisColumnInfo.identifier,
new StringVerifier,
Optional::No,
ArgumentOfPeriapsisColumnInfo.description
},
{
MeanAnomalyAtEpochColumnInfo.identifier,
new StringVerifier,
Optional::No,
MeanAnomalyAtEpochColumnInfo.description
},
{
EpochColumnInfo.identifier,
new StringVerifier,
Optional::No,
EpochColumnInfo.description
},
{
LineWidthInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LineWidthInfo.description
},
{
ColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
ColorInfo.description
},
{
FadeInfo.identifier,
new DoubleVerifier,
@@ -514,15 +412,6 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _path(PathInfo)
, _nSegments(SegmentsInfo)
, _eccentricityColumnName(EccentricityColumnInfo)
, _semiMajorAxisColumnName(SemiMajorAxisColumnInfo)
, _semiMajorAxisUnit(SemiMajorAxisUnitInfo)
, _inclinationColumnName(InclinationColumnInfo)
, _ascendingNodeColumnName(AscendingNodeColumnInfo)
, _argumentOfPeriapsisColumnName(ArgumentOfPeriapsisColumnInfo)
, _meanAnomalyAtEpochColumnName(MeanAnomalyAtEpochColumnInfo)
, _epochColumnName(EpochColumnInfo)
, _color(ColorInfo)
, _lineFade(FadeInfo)
{
@@ -536,34 +425,17 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
dictionary.value<std::string>(PathInfo.identifier);
_nSegments =
static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
_eccentricityColumnName =
dictionary.value<std::string>(EccentricityColumnInfo.identifier);
_semiMajorAxisColumnName =
dictionary.value<std::string>(SemiMajorAxisColumnInfo.identifier);
_semiMajorAxisUnit =
dictionary.value<double>(SemiMajorAxisUnitInfo.identifier);
_inclinationColumnName =
dictionary.value<std::string>(InclinationColumnInfo.identifier);
_ascendingNodeColumnName =
dictionary.value<std::string>(AscendingNodeColumnInfo.identifier);
_argumentOfPeriapsisColumnName =
dictionary.value<std::string>(ArgumentOfPeriapsisColumnInfo.identifier);
_meanAnomalyAtEpochColumnName =
dictionary.value<std::string>(MeanAnomalyAtEpochColumnInfo.identifier);
_epochColumnName =
dictionary.value<std::string>(EpochColumnInfo.identifier);
_color =
dictionary.value<glm::vec3>(ColorInfo.identifier);
_lineFade =
static_cast<float>(dictionary.value<double>(FadeInfo.identifier));
addPropertySubOwner(_appearance);
addProperty(_path);
addProperty(_nSegments);
addProperty(_lineFade);
}
void RenderableSatellites::readTLEFile(const std::string& filename) {
std::vector<KeplerParameters> RenderableSatellites::readTLEFile(const std::string& filename) {
ghoul_assert(FileSys.fileExists(filename), "The filename must exist");
std::ifstream file;
@@ -674,7 +546,7 @@ void RenderableSatellites::readTLEFile(const std::string& filename) {
} // !for loop
file.close();
return _TLEData;
}
@@ -686,7 +558,6 @@ RenderableSatellites::~RenderableSatellites() {
void RenderableSatellites::initialize() {
readTLEFile(_path);
updateBuffers();
//_path.onChange([this]() {
@@ -733,6 +604,8 @@ void RenderableSatellites::initializeGL() {
updateBuffers();
//ghoul::opengl::updateUniformLocations(*_programObject, _uniformCache, UniformNames);
setRenderBin(Renderable::RenderBin::Overlay);
}
@@ -778,7 +651,7 @@ void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
_programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix());
_programObject->setUniform(_uniformCache.color, _appearance.lineColor);
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade); //!!! WHY DOES _lineFade NOT WORK?
glLineWidth(_appearance.lineWidth);
@@ -801,6 +674,7 @@ void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
}
void RenderableSatellites::updateBuffers() {
_TLEData = readTLEFile(_path);
const size_t nVerticesPerOrbit = _nSegments + 1;
_vertexBufferData.resize(_TLEData.size() * nVerticesPerOrbit);
+18 -28
View File
@@ -75,6 +75,22 @@ namespace openspace {
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
/**
* Reads the provided TLE file and calles the KeplerTranslation::setKeplerElments
* method with the correct values. If \p filename is a valid TLE file but contains
* disallowed values (see KeplerTranslation::setKeplerElements), a
* KeplerTranslation::RangeError is thrown.
*
* \param filename The path to the file that contains the TLE file.
* \param lineNum The line number in the file where the set of 3 TLE lines starts
*
* \throw std::system_error if the TLE file is malformed (does not contain at least
* two lines that start with \c 1 and \c 2.
* \throw KeplerTranslation::RangeError If the Keplerian elements are outside of
* the valid range supported by Kepler::setKeplerElements
* \pre The \p filename must exist
*/
std::vector<KeplerParameters> readTLEFile(const std::string& filename);
private:
/// The layout of the VBOs
@@ -109,15 +125,6 @@ namespace openspace {
properties::StringProperty _path;
properties::UIntProperty _nSegments;
properties::StringProperty _eccentricityColumnName;
properties::StringProperty _semiMajorAxisColumnName;
properties::DoubleProperty _semiMajorAxisUnit;
properties::StringProperty _inclinationColumnName;
properties::StringProperty _ascendingNodeColumnName;
properties::StringProperty _argumentOfPeriapsisColumnName;
properties::StringProperty _meanAnomalyAtEpochColumnName;
properties::StringProperty _epochColumnName;
properties::Vec3Property _color;
properties::DoubleProperty _lineFade;
RenderableTrail::Appearance _appearance;
@@ -126,28 +133,11 @@ namespace openspace {
double _inGameTime = 0.0;
UniformCache(opacity, modelView, projection, color, useLineFade, lineFade,
segments, position, vertexIDs, numberOfOrbits, inGameTime)
UniformCache(modelView, projection, lineFade, inGameTime, color, opacity)
_uniformCache;
/**
* Reads the provided TLE file and calles the KeplerTranslation::setKeplerElments
* method with the correct values. If \p filename is a valid TLE file but contains
* disallowed values (see KeplerTranslation::setKeplerElements), a
* KeplerTranslation::RangeError is thrown.
*
* \param filename The path to the file that contains the TLE file.
* \param lineNum The line number in the file where the set of 3 TLE lines starts
*
* \throw std::system_error if the TLE file is malformed (does not contain at least
* two lines that start with \c 1 and \c 2.
* \throw KeplerTranslation::RangeError If the Keplerian elements are outside of
* the valid range supported by Kepler::setKeplerElements
* \pre The \p filename must exist
*/
void readTLEFile(const std::string& filename);
};
}
#endif // __OPENSPACE_MODULE_BASE___RenderableSatellites___H__
}