mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-08 12:39:49 -06:00
started adding on calculatePosition. Does not complie yet
This commit is contained in:
@@ -63,16 +63,17 @@ local addSatelliteGroupObjects = function(group, tleFolder, shouldAddDuplicates)
|
||||
-- File = file
|
||||
-- },
|
||||
|
||||
PathInfo = "bubbis",
|
||||
SegmentsInfo = 1,
|
||||
EccentricityColumnInfo = "bubbis",
|
||||
SemiMajorAxisColumnInfo = "bubbis",
|
||||
SemiMajorAxisUnitInfo = 1,
|
||||
InclinationColumnInfo = "bubbis",
|
||||
AscendingNodeColumnInfo = "bubbis",
|
||||
ArgumentOfPeriapsisColumnInfo = "bubbis",
|
||||
MeanAnomalyAtEpochColumnInfo = "bubbis",
|
||||
EpochColumnInfo = "bubbis",
|
||||
Path = file,
|
||||
|
||||
Segments = 160,
|
||||
EccentricityColumn = "bubbis",
|
||||
SemiMajorAxisColumn = "bubbis",
|
||||
SemiMajorAxisUnit = 1,
|
||||
InclinationColumn = "bubbis",
|
||||
AscendingNodeColumn = "bubbis",
|
||||
ArgumentOfPeriapsisColumn = "bubbis",
|
||||
MeanAnomalyAtEpochColumn = "bubbis",
|
||||
EpochColumn = "bubbis",
|
||||
|
||||
},
|
||||
GUI = {
|
||||
|
||||
@@ -4,15 +4,15 @@ local propertyHelper = asset.require('util/property_helper')
|
||||
|
||||
-- Specifying which other assets should be loaded in this scene
|
||||
asset.require('spice/base')
|
||||
assetHelper.requestAll(asset, 'scene/solarsystem/sun')
|
||||
--assetHelper.requestAll(asset, 'scene/solarsystem/sun')
|
||||
asset.require('scene/solarsystem/planets/earth/earth')
|
||||
assetHelper.requestAll(asset, 'scene/digitaluniverse')
|
||||
--assetHelper.requestAll(asset, 'scene/digitaluniverse')
|
||||
-- Load default key bindings applicable to most scenes
|
||||
asset.require('util/default_keybindings')
|
||||
asset.require('util/default_dashboard')
|
||||
asset.require('util/default_joystick')
|
||||
--asset.require('util/default_dashboard')
|
||||
--asset.require('util/default_joystick')
|
||||
|
||||
asset.require('util/webgui')
|
||||
--asset.require('util/webgui')
|
||||
|
||||
--asset.request('customization/globebrowsing')
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
|
||||
#include <fstream>
|
||||
@@ -102,7 +104,7 @@ namespace {
|
||||
"The header of the column where the epoch is stored"
|
||||
};
|
||||
|
||||
constexpr const char* KeyFile = "File";
|
||||
constexpr const char* KeyFile = "Path";
|
||||
constexpr const char* KeyLineNumber = "LineNumber";
|
||||
|
||||
|
||||
@@ -118,6 +120,7 @@ namespace openspace {
|
||||
2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040,
|
||||
2044, 2048, 2052, 2056
|
||||
};
|
||||
|
||||
|
||||
// Count the number of full days since the beginning of 2000 to the beginning of
|
||||
// the parameter 'year'
|
||||
@@ -302,7 +305,7 @@ namespace openspace {
|
||||
// We need the semi major axis in km instead of m
|
||||
return semiMajorAxis / 1000.0;
|
||||
}
|
||||
|
||||
|
||||
documentation::Documentation ElonsTest::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
@@ -416,6 +419,7 @@ namespace openspace {
|
||||
addProperty(_path);
|
||||
addProperty(_nSegments);
|
||||
// addProperty(_semiMajorAxisUnit);
|
||||
// addPropertySubOwner(_appearance);
|
||||
|
||||
|
||||
const std::string& file = dictionary.value<std::string>(KeyFile);
|
||||
@@ -431,20 +435,6 @@ namespace openspace {
|
||||
std::ifstream file;
|
||||
file.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
||||
file.open(filename);
|
||||
|
||||
// All of the Kepler element information
|
||||
struct KeplerParameters{
|
||||
double inclination = 0.0;
|
||||
double semiMajorAxis = 0.0;
|
||||
double ascendingNode = 0.0;
|
||||
double eccentricity = 0.0;
|
||||
double argumentOfPeriapsis = 0.0;
|
||||
double meanAnomaly = 0.0;
|
||||
double meanMotion = 0.0;
|
||||
double epoch = 0.0;
|
||||
};
|
||||
|
||||
std::vector<KeplerParameters> TLEData;
|
||||
|
||||
// int numberOfLines = std::count(std::istreambuf_iterator<char>(file),
|
||||
// std::istreambuf_iterator<char>(), '\n' );
|
||||
@@ -452,17 +442,13 @@ namespace openspace {
|
||||
// int numberOfObjects = numberOfLines/3;
|
||||
// LINFO("Number of data elements: " + numberOfObjects);
|
||||
|
||||
// for(int i=0 ; i<numberOfObjects; ++i){
|
||||
|
||||
|
||||
// TLEData.push_back();
|
||||
|
||||
// }
|
||||
|
||||
|
||||
std::string line;
|
||||
while(std::getline(file, line)) {
|
||||
while(true) {
|
||||
|
||||
if(file.eof())
|
||||
break;
|
||||
|
||||
std::getline(file, line); // get rid of title
|
||||
KeplerParameters keplerElements;
|
||||
|
||||
std::getline(file, line);
|
||||
@@ -544,22 +530,19 @@ namespace openspace {
|
||||
// Calculate the semi major axis based on the mean motion using kepler's laws
|
||||
keplerElements.semiMajorAxis = calculateSemiMajorAxis(keplerElements.meanMotion);
|
||||
|
||||
// Converting the mean motion (revolutions per day) to period (seconds per revolution)
|
||||
using namespace std::chrono;
|
||||
double period = seconds(hours(24)).count() / keplerElements.meanMotion;
|
||||
|
||||
// _keplerTranslator.setKeplerElements(
|
||||
// keplerElements.eccentricity,
|
||||
// keplerElements.semiMajorAxis,
|
||||
// keplerElements.inclination,
|
||||
// keplerElements.ascendingNode,
|
||||
// keplerElements.argumentOfPeriapsis,
|
||||
// keplerElements.meanAnomaly,
|
||||
// period,
|
||||
// keplerElements.epoch
|
||||
// );
|
||||
|
||||
_keplerTranslator.setKeplerElements(
|
||||
keplerElements.eccentricity,
|
||||
keplerElements.semiMajorAxis,
|
||||
keplerElements.inclination,
|
||||
keplerElements.ascendingNode,
|
||||
keplerElements.argumentOfPeriapsis,
|
||||
keplerElements.meanAnomaly,
|
||||
period,
|
||||
keplerElements.epoch
|
||||
);
|
||||
|
||||
TLEData.push_back(keplerElements);
|
||||
_TLEData.push_back(keplerElements);
|
||||
} // !while loop
|
||||
|
||||
file.close();
|
||||
@@ -568,18 +551,17 @@ namespace openspace {
|
||||
void ElonsTest::initialize(){
|
||||
//Fyll _vertexArray i init och
|
||||
// rendera bara orbits, inga rörliga delar.
|
||||
// eventuella callback functions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
updateBuffers();
|
||||
|
||||
}
|
||||
|
||||
void ElonsTest::initializeGL() {
|
||||
glGenVertexArrays(1, &_vertexArray);
|
||||
glGenBuffers(1, &_vertexBuffer);
|
||||
glGenBuffers(1, &_indexBuffer);
|
||||
|
||||
_programObject = SpaceModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
@@ -593,17 +575,21 @@ namespace openspace {
|
||||
|
||||
}
|
||||
|
||||
void ElonsTest::deinitializeGL() {
|
||||
|
||||
|
||||
void ElonsTest::deinitializeGL() {
|
||||
|
||||
// todo. release object
|
||||
|
||||
glDeleteBuffers(1, &_vertexBuffer);
|
||||
glDeleteBuffers(1, &_indexBuffer);
|
||||
glDeleteVertexArrays(1, &_vertexArray);
|
||||
}
|
||||
|
||||
void ElonsTest::render(const RenderData& data, RendererTasks& rendererTask) {
|
||||
_programObject->activate();
|
||||
LINFO("render data: ", data);
|
||||
// LINFO("render data: ");
|
||||
|
||||
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
void ElonsTest::update(const UpdateData& data) {
|
||||
@@ -614,4 +600,86 @@ namespace openspace {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ElonsTest::updateBuffers(){
|
||||
|
||||
const size_t nVerticesPerOrbit = _nSegments + 1;
|
||||
_vertexBufferData.resize(_TLEData.size() * nVerticesPerOrbit);
|
||||
_indexBufferData.resize(_TLEData.size() * _nSegments * 2);
|
||||
|
||||
size_t orbitIndex = 0;
|
||||
size_t elementIndex = 0;
|
||||
|
||||
for (const auto& orbit : _TLEData) {
|
||||
// Converting the mean motion (revolutions per day) to period (seconds per revolution)
|
||||
using namespace std::chrono;
|
||||
double period = seconds(hours(24)).count() / orbit.meanMotion;
|
||||
|
||||
// // KeplerTranslation setKeplerElements(orbit);
|
||||
// _keplerTranslator.setKeplerElements(
|
||||
// orbit.eccentricity,
|
||||
// orbit.semiMajorAxis,
|
||||
// orbit.inclination,
|
||||
// orbit.ascendingNode,
|
||||
// orbit.argumentOfPeriapsis,
|
||||
// orbit.meanAnomaly,
|
||||
// period,
|
||||
// orbit.epoch
|
||||
// );
|
||||
// // KeplerTranslation keplerTranslation(orbit);
|
||||
// const double period = orbit.period();
|
||||
for (size_t i = 0; i <= _nSegments; ++i) {
|
||||
size_t index = orbitIndex * nVerticesPerOrbit + i;
|
||||
|
||||
double timeOffset = period *
|
||||
static_cast<float>(i) / static_cast<float>(_nSegments);
|
||||
|
||||
// positionAtTime.time = Time(orbit.epoch + timeOffset);
|
||||
|
||||
glm::vec3 position = calculatePosition(Time(orbit.epoch + timeOffset), orbit.epoch);
|
||||
|
||||
_vertexBufferData[index].x = position.x;
|
||||
_vertexBufferData[index].y = position.y;
|
||||
_vertexBufferData[index].z = position.z;
|
||||
_vertexBufferData[index].time = timeOffset;
|
||||
if (i > 0) {
|
||||
_indexBufferData[elementIndex++] = static_cast<unsigned int>(index) - 1;
|
||||
_indexBufferData[elementIndex++] = static_cast<unsigned int>(index);
|
||||
}
|
||||
}
|
||||
++orbitIndex;
|
||||
}
|
||||
|
||||
// glBindVertexArray(_vertexArray);
|
||||
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
|
||||
// glBufferData(GL_ARRAY_BUFFER,
|
||||
// _vertexBufferData.size() * sizeof(TrailVBOLayout),
|
||||
// _vertexBufferData.data(),
|
||||
// GL_STATIC_DRAW
|
||||
// );
|
||||
|
||||
|
||||
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
|
||||
// glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
||||
// _indexBufferData.size() * sizeof(int),
|
||||
// _indexBufferData.data(),
|
||||
// GL_STATIC_DRAW
|
||||
// );
|
||||
|
||||
// glBindVertexArray(0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
glm::dvec3 ElonsTest::calculatePosition(const Time& time, double epoch) const {
|
||||
if (_orbitPlaneDirty) {
|
||||
_keplerTranslator.computeOrbitPlane();
|
||||
_orbitPlaneDirty = false;
|
||||
}
|
||||
const double t = time.j2000Seconds() - epoch;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,12 +32,33 @@
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/uintproperty.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/misc/exception.h>
|
||||
|
||||
|
||||
|
||||
namespace ghoul::opengl {
|
||||
class ProgramObject;
|
||||
class Texture;
|
||||
} // namespace ghoul::opengl
|
||||
|
||||
namespace openspace {
|
||||
// The layout of the VBOs
|
||||
struct TrailVBOLayout {
|
||||
float x, y, z, time;
|
||||
};
|
||||
// All of the Kepler element information
|
||||
struct KeplerParameters{
|
||||
double inclination = 0.0;
|
||||
double semiMajorAxis = 0.0;
|
||||
double ascendingNode = 0.0;
|
||||
double eccentricity = 0.0;
|
||||
double argumentOfPeriapsis = 0.0;
|
||||
double meanAnomaly = 0.0;
|
||||
double meanMotion = 0.0;
|
||||
double epoch = 0.0;
|
||||
};
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
@@ -62,12 +83,28 @@ public:
|
||||
|
||||
protected:
|
||||
private:
|
||||
TLETranslation _tleTranslator;
|
||||
|
||||
|
||||
// TLETranslation _tleTranslator;
|
||||
// std::vector<KeplerTranslation::KeplerOrbit> _orbits;
|
||||
ghoul::opengl::ProgramObject* _programObject;
|
||||
|
||||
KeplerTranslation _keplerTranslator;
|
||||
|
||||
std::vector<KeplerParameters> _TLEData;
|
||||
|
||||
|
||||
/// The backend storage for the vertex buffer object containing all points for this
|
||||
/// trail.
|
||||
std::vector<TrailVBOLayout> _vertexBufferData;
|
||||
/// The index array that is potentially used in the draw call. If this is empty, no
|
||||
/// element draw call is used.
|
||||
std::vector<unsigned int> _indexBufferData;
|
||||
|
||||
GLuint _vertexArray;
|
||||
GLuint _vertexBuffer;
|
||||
GLuint _indexBuffer;
|
||||
|
||||
properties::StringProperty _path;
|
||||
properties::UIntProperty _nSegments;
|
||||
|
||||
@@ -80,7 +117,13 @@ private:
|
||||
properties::StringProperty _meanAnomalyAtEpochColumnName;
|
||||
properties::StringProperty _epochColumnName;
|
||||
|
||||
|
||||
void readTLEFile(const std::string& filename);
|
||||
void updateBuffers();
|
||||
|
||||
/// Dirty flag for the _orbitPlaneRotation parameters
|
||||
mutable bool _orbitPlaneDirty = true;
|
||||
glm::dvec3 calculatePosition(const Time& time, double epoch) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -143,12 +143,14 @@ public:
|
||||
/// Default construct that initializes all the properties and member variables
|
||||
KeplerTranslation();
|
||||
|
||||
/// Recombutes the rotation matrix used in the update method
|
||||
void computeOrbitPlane() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
/// Recombutes the rotation matrix used in the update method
|
||||
void computeOrbitPlane() const;
|
||||
|
||||
|
||||
/**
|
||||
* This method computes the eccentric anomaly (location of the space craft taking the
|
||||
|
||||
Reference in New Issue
Block a user