mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-15 08:21:23 -06:00
mergeing elonsTest with renderableSatellites
This commit is contained in:
@@ -49,31 +49,25 @@ local addSatelliteGroupObjects = function(group, tleFolder, shouldAddDuplicates)
|
||||
return true
|
||||
end
|
||||
|
||||
function test(title, file)
|
||||
function debris(title, file)
|
||||
return {
|
||||
Identifier = title,
|
||||
Parent = transforms.EarthInertial.Identifier,
|
||||
Renderable = {
|
||||
Type = "RenderableSatellites",
|
||||
--Type = "ElonsTest",
|
||||
|
||||
--Translation = {
|
||||
|
||||
-- Type = "TLETranslation",
|
||||
-- Body = title,
|
||||
-- Observer = transforms.EarthInertial.Identifier,
|
||||
-- File = file
|
||||
-- },
|
||||
Path = file,
|
||||
Segments = 1,
|
||||
EccentricityColumn = "bubbis",
|
||||
SemiMajorAxisColumn = "bubbis",
|
||||
|
||||
-- The initialization with "-" is just a placeholder.
|
||||
-- (needed to be initialized)
|
||||
Segments = 160,
|
||||
EccentricityColumn = "-",
|
||||
SemiMajorAxisColumn = "-",
|
||||
SemiMajorAxisUnit = 1,
|
||||
InclinationColumn = "bubbis",
|
||||
AscendingNodeColumn = "bubbis",
|
||||
ArgumentOfPeriapsisColumn = "bubbis",
|
||||
MeanAnomalyAtEpochColumn = "bubbis",
|
||||
EpochColumn = "bubbis",
|
||||
InclinationColumn = "-",
|
||||
AscendingNodeColumn = "-",
|
||||
ArgumentOfPeriapsisColumn = "-",
|
||||
MeanAnomalyAtEpochColumn = "-",
|
||||
EpochColumn = "-",
|
||||
|
||||
},
|
||||
GUI = {
|
||||
@@ -82,7 +76,7 @@ local addSatelliteGroupObjects = function(group, tleFolder, shouldAddDuplicates)
|
||||
}
|
||||
end
|
||||
|
||||
local Debris = test(filenameSansExt, path)
|
||||
local Debris = debris(filenameSansExt, path)
|
||||
assetHelper.registerSceneGraphNodesAndExport(asset, { Debris })
|
||||
|
||||
-- asset.export("satImageFolder", satImageFolder)
|
||||
|
||||
@@ -130,4 +130,5 @@ private:
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_SPACE___ELONSTEST___H__
|
||||
|
||||
*/
|
||||
|
||||
@@ -439,14 +439,14 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_nSegments);
|
||||
addProperty(_semiMajorAxisUnit);
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> mergeing elonsTest with renderableSatellites
|
||||
LINFO(fmt::format("KeyFile: {} ", KeyFile));
|
||||
const std::string& file = dictionary.value<std::string>(KeyFile);
|
||||
LINFO(fmt::format("file: {} ", file));
|
||||
|
||||
//readTLEFile(file);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -560,8 +560,7 @@ void RenderableSatellites::readTLEFile(const std::string& filename) {
|
||||
|
||||
_TLEData.push_back(keplerElements);
|
||||
|
||||
} // !while loop
|
||||
|
||||
} // !for loop
|
||||
file.close();
|
||||
}
|
||||
/*
|
||||
@@ -603,18 +602,18 @@ void RenderableSatellites::initializeGL() {
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return global::renderEngine.buildRenderProgram(
|
||||
ProgramName,
|
||||
absPath("${MODULE_SPACE}/shaders/RenderableKeplerOrbits_vs.glsl"),
|
||||
absPath("${MODULE_SPACE}/shaders/RenderableKeplerOrbits_fs.glsl")
|
||||
absPath("${MODULE_SPACE}/shaders/debrisViz_vs.glsl"),
|
||||
absPath("${MODULE_SPACE}/shaders/debrisViz_fs.glsl")
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.opacity = _programObject->uniformLocation("opacity");
|
||||
_uniformCache.modelView = _programObject->uniformLocation("modelViewTransform");
|
||||
_uniformCache.projection = _programObject->uniformLocation("projectionTransform");
|
||||
_uniformCache.color = _programObject->uniformLocation("color");
|
||||
_uniformCache.useLineFade = _programObject->uniformLocation("useLineFade");
|
||||
_uniformCache.lineFade = _programObject->uniformLocation("lineFade");
|
||||
// _uniformCache.opacity = _programObject->uniformLocation("opacity");
|
||||
// _uniformCache.modelView = _programObject->uniformLocation("modelViewTransform");
|
||||
// _uniformCache.projection = _programObject->uniformLocation("projectionTransform");
|
||||
// _uniformCache.color = _programObject->uniformLocation("color");
|
||||
// _uniformCache.useLineFade = _programObject->uniformLocation("useLineFade");
|
||||
// _uniformCache.lineFade = _programObject->uniformLocation("lineFade");
|
||||
|
||||
setRenderBin(Renderable::RenderBin::Overlay);
|
||||
|
||||
@@ -624,9 +623,9 @@ void RenderableSatellites::deinitializeGL() {
|
||||
|
||||
SpaceModule::ProgramObjectManager.release(ProgramName);
|
||||
|
||||
glDeleteBuffers(1, &_vertexBuffer);
|
||||
glDeleteBuffers(1, &_indexBuffer);
|
||||
glDeleteVertexArrays(1, &_vertexArray);
|
||||
// glDeleteBuffers(1, &_vertexBuffer);
|
||||
// glDeleteBuffers(1, &_indexBuffer);
|
||||
// glDeleteVertexArrays(1, &_vertexArray);
|
||||
}
|
||||
|
||||
|
||||
@@ -639,37 +638,37 @@ bool RenderableSatellites::isReady() const {
|
||||
void RenderableSatellites::update(const UpdateData&) {}
|
||||
|
||||
void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
|
||||
_programObject->activate();
|
||||
_programObject->setUniform(_uniformCache.opacity, _opacity);
|
||||
// _programObject->activate();
|
||||
// _programObject->setUniform(_uniformCache.opacity, _opacity);
|
||||
|
||||
glm::dmat4 modelTransform =
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
|
||||
glm::dmat4(data.modelTransform.rotation) *
|
||||
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
|
||||
// glm::dmat4 modelTransform =
|
||||
// glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
|
||||
// glm::dmat4(data.modelTransform.rotation) *
|
||||
// glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
|
||||
|
||||
_programObject->setUniform(
|
||||
_uniformCache.modelView,
|
||||
data.camera.combinedViewMatrix() * modelTransform
|
||||
);
|
||||
// _programObject->setUniform(
|
||||
// _uniformCache.modelView,
|
||||
// data.camera.combinedViewMatrix() * modelTransform
|
||||
// );
|
||||
|
||||
_programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix());
|
||||
_programObject->setUniform(_uniformCache.color, _appearance.lineColor);
|
||||
_programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade);
|
||||
// _programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix());
|
||||
// _programObject->setUniform(_uniformCache.color, _appearance.lineColor);
|
||||
//_programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade);
|
||||
|
||||
if (_appearance.useLineFade) {
|
||||
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
|
||||
}
|
||||
|
||||
glDepthMask(false);
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
// glDepthMask(false);
|
||||
// //glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
glBindVertexArray(_vertexArray);
|
||||
glDrawElements(GL_LINES,
|
||||
static_cast<unsigned int>(_indexBufferData.size()),
|
||||
GL_UNSIGNED_INT,
|
||||
0);
|
||||
glBindVertexArray(0);
|
||||
_programObject->deactivate();
|
||||
// glBindVertexArray(_vertexArray);
|
||||
// glDrawElements(GL_LINES,
|
||||
// static_cast<unsigned int>(_indexBufferData.size()),
|
||||
// GL_UNSIGNED_INT,
|
||||
// 0);
|
||||
// glBindVertexArray(0);
|
||||
// _programObject->deactivate();
|
||||
}
|
||||
|
||||
void RenderableSatellites::updateBuffers() {
|
||||
@@ -681,7 +680,7 @@ void RenderableSatellites::updateBuffers() {
|
||||
size_t elementindex = 0;
|
||||
|
||||
for (const auto& orbit : _TLEData) {
|
||||
|
||||
|
||||
_keplerTranslator.setKeplerElements(
|
||||
orbit.eccentricity,
|
||||
orbit.semiMajorAxis,
|
||||
@@ -698,9 +697,9 @@ void RenderableSatellites::updateBuffers() {
|
||||
|
||||
float timeOffset = orbit.period *
|
||||
static_cast<float>(i) / static_cast<float>(_nSegments);
|
||||
|
||||
glm::vec3 position = _keplerTranslator.debrisPos(Time(orbit.epoch + timeOffset));
|
||||
|
||||
|
||||
glm::vec3 position = _keplerTranslator.debrisPos(Time(orbit.epoch + timeOffset));
|
||||
|
||||
_vertexBufferData[index].x = position.x;
|
||||
_vertexBufferData[index].y = position.y;
|
||||
_vertexBufferData[index].z = position.z;
|
||||
@@ -730,7 +729,7 @@ void RenderableSatellites::updateBuffers() {
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
glBindVertexArray(0);
|
||||
// glBindVertexArray(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,20 +22,20 @@
|
||||
// * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
// ****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_BASE___RenderableSatellites___H__
|
||||
#define __OPENSPACE_MODULE_BASE___RenderableSatellites___H__
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <modules/base/rendering/renderabletrail.h>
|
||||
#include <modules/space/translation/keplertranslation.h>
|
||||
|
||||
// #include <openspace/util/circlegeometry.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/uintproperty.h>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/misc/objectmanager.h>
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_BASE___RenderableSatellites___H__
|
||||
#define __OPENSPACE_MODULE_BASE___RenderableSatellites___H__
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -54,7 +54,6 @@ namespace openspace {
|
||||
class RenderableSatellites : public Renderable {
|
||||
public:
|
||||
RenderableSatellites(const ghoul::Dictionary& dictionary);
|
||||
//virtual ~RenderableSatellites();
|
||||
|
||||
void initialize() override;
|
||||
void deinitialize() override;
|
||||
@@ -89,13 +88,9 @@ namespace openspace {
|
||||
GLuint _vertexBuffer;
|
||||
GLuint _indexBuffer;
|
||||
|
||||
void readFromCsvFile();
|
||||
void updateBuffers();
|
||||
|
||||
std::vector<KeplerTranslation::KeplerOrbit> _orbits;
|
||||
ghoul::opengl::ProgramObject* _programObject;
|
||||
//ghoul::ObjectManager* _objectManager;
|
||||
|
||||
|
||||
properties::StringProperty _path;
|
||||
properties::UIntProperty _nSegments;
|
||||
@@ -111,8 +106,8 @@ namespace openspace {
|
||||
|
||||
RenderableTrail::Appearance _appearance;
|
||||
|
||||
UniformCache(opacity, modelView, projection, color, useLineFade, lineFade)
|
||||
_uniformCache;
|
||||
//UniformCache(opacity, modelView, projection, color, useLineFade, lineFade)
|
||||
// _uniformCache;
|
||||
|
||||
/**
|
||||
* Reads the provided TLE file and calles the KeplerTranslation::setKeplerElments
|
||||
|
||||
40
modules/space/shaders/debrisViz_fs.glsl
Normal file
40
modules/space/shaders/debrisViz_fs.glsl
Normal file
@@ -0,0 +1,40 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
in vec3 vs_position;
|
||||
in vec3 vs_color;
|
||||
in vec2 vs_texcoord;
|
||||
|
||||
out vec4 fs_color;
|
||||
|
||||
void main {
|
||||
fs_color = vec4(vs_color, 1.f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
48
modules/space/shaders/debrisViz_vs.glsl
Normal file
48
modules/space/shaders/debrisViz_vs.glsl
Normal file
@@ -0,0 +1,48 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
layout (location = 0) in vec3 vertex_position;
|
||||
layout (location = 1) in vec3 vertex_color;
|
||||
layout (location = 2) in vec2 vertex_texcoord;
|
||||
|
||||
out vec3 vs_position;
|
||||
out vec3 vs_color;
|
||||
out vec2 vs_texcoord;
|
||||
|
||||
void main() {
|
||||
vs_position = vertex_position;
|
||||
vs_color = vertex_color;
|
||||
vs_texcoord - vec2(vertex_texcoord.x, vertex_texcoord.y);
|
||||
|
||||
gl_Position = vec4(vertex_position, 1.f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary&) {
|
||||
fRenderable->registerClass<RenderableRings>("RenderableRings");
|
||||
fRenderable->registerClass<RenderableStars>("RenderableStars");
|
||||
fRenderable->registerClass<RenderableSatellites>("RenderableSatellites");
|
||||
//fRenderable->registerClass<ElonsTest>("ElonsTest");
|
||||
|
||||
|
||||
auto fTranslation = FactoryManager::ref().factory<Translation>();
|
||||
@@ -118,7 +117,6 @@ std::vector<documentation::Documentation> SpaceModule::documentations() const {
|
||||
RenderableRings::Documentation(),
|
||||
RenderableStars::Documentation(),
|
||||
RenderableSatellites::Documentation(),
|
||||
//ElonsTest::Documentation(),
|
||||
SpiceRotation::Documentation(),
|
||||
SpiceTranslation::Documentation(),
|
||||
KeplerTranslation::Documentation(),
|
||||
|
||||
@@ -283,25 +283,6 @@ double KeplerTranslation::eccentricAnomaly(double meanAnomaly) const {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
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<double>() / _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;
|
||||
}
|
||||
|
||||
glm::dvec3 KeplerTranslation::position(const UpdateData& data) const {
|
||||
if (_orbitPlaneDirty) {
|
||||
|
||||
@@ -88,12 +88,9 @@ public:
|
||||
*
|
||||
* \param time The time to use when doing the position lookup
|
||||
*/
|
||||
glm::dvec3 position(const Time& time) const ;
|
||||
glm::dvec3 position(const UpdateData& data) const override;
|
||||
|
||||
// Is only used in renderableDebris so far
|
||||
// glm::dvec3 position(const Time& time) const;
|
||||
|
||||
// Is only used in renderableDebris so far. May rename if needed
|
||||
glm::dvec3 debrisPos(const Time& time) const;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user