This commit is contained in:
Jonathan Fransson
2019-04-17 14:26:10 -06:00
4 changed files with 61 additions and 41 deletions

View File

@@ -152,6 +152,25 @@ namespace openspace {
2044, 2048, 2052, 2056
};
void calculateMaxApoAndMinPeri(std::vector<KeplerParameters> fileVector){
//int n = fileVector.size();
double maxApogee = 0;
double minPerigee = 5000;
for (const auto& dataElement : fileVector){ //(int i=0 ; i < n ; ++i ) {
double ph = dataElement.semiMajorAxis * (1 - dataElement.eccentricity);
double ah = dataElement.semiMajorAxis *(1 + dataElement.eccentricity);
if (ph < minPerigee)
minPerigee = ph;
if (ah > maxApogee)
maxApogee = ah;
}
LINFO(fmt::format("Min Perigee: {} ", minPerigee));
LINFO(fmt::format("Max Apogee: {} ", maxApogee));
}
// Count the number of full days since the beginning of 2000 to the beginning of
// the parameter 'year'
int countDays(int year) {
@@ -461,7 +480,6 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
_color =
dictionary.value<glm::vec3>(ColorInfo.identifier);
//_appearance.lineColor = _color;
addPropertySubOwner(_appearance);
addProperty(_path);
@@ -586,6 +604,10 @@ void RenderableSatellites::readTLEFile(const std::string& filename) {
} // !for loop
file.close();
// get max apergee and min perigee
calculateMaxApoAndMinPeri(_TLEData);
}
/*
RenderableSatellites::~RenderableSatellites() {
@@ -617,6 +639,9 @@ void RenderableSatellites::deinitialize() {
}
void RenderableSatellites::initializeGL() {
glGenVertexArrays(1, &_vertexArray);
glGenBuffers(1, &_vertexBuffer);
_programObject = SpaceModule::ProgramObjectManager.request(
ProgramName,
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
@@ -635,25 +660,9 @@ void RenderableSatellites::initializeGL() {
_uniformCache.useLineFade = _programObject->uniformLocation("useLineFade");
_uniformCache.lineFade = _programObject->uniformLocation("lineFade");
glGenVertexArrays(1, &_vertexArray);
glBindVertexArray(_vertexArray);
glGenBuffers(1, &_vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glBufferData(
GL_ARRAY_BUFFER,
_vertexBufferData.size() * sizeof(TrailVBOLayout),
_vertexBufferData.data(),
GL_STATIC_DRAW
);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), nullptr);
glBindVertexArray(0);
updateBuffers();
setRenderBin(Renderable::RenderBin::Overlay);
glBindVertexArray(0);
}
void RenderableSatellites::deinitializeGL() {
@@ -675,8 +684,8 @@ bool RenderableSatellites::isReady() const {
void RenderableSatellites::update(const UpdateData&) {}
void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
//if (_TLEData.empty())
// return;
if (_TLEData.empty())
return;
_programObject->activate();
_programObject->setUniform(_uniformCache.opacity, _opacity);
@@ -693,10 +702,10 @@ void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
_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);
//}
_programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade);
if (_appearance.useLineFade) {
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
}
glLineWidth(_appearance.lineWidth);
@@ -759,6 +768,22 @@ void RenderableSatellites::updateBuffers() {
}
++orbitindex;
}
glBindVertexArray(_vertexArray);
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glBufferData(
GL_ARRAY_BUFFER,
_vertexBufferData.size() * sizeof(TrailVBOLayout),
_vertexBufferData.data(),
GL_STATIC_DRAW
);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), nullptr);
glBindVertexArray(0);
}
}

View File

@@ -29,17 +29,16 @@ uniform vec3 color;
uniform float opacity = 1.0;
in vec4 viewSpacePosition;
in vec4 vs_position;
in vec3 vs_color;
in vec2 vs_texcoord;
//in vec3 vs_color;
//in vec2 vs_texcoord;
Fragment getFragment() {
Fragment frag;
frag.color = vec4(color, opacity);
frag.depth = vs_position.w;
frag.gPosition = viewSpacePosition;
frag.gNormal = vec4(-viewSpacePosition.xyz, 0);
frag.gNormal = vec4(1, 1, 1 , 0);
return frag;
}

View File

@@ -24,11 +24,9 @@
#version __CONTEXT__
//#include "D:\OpenSpace\shaders\PowerScaling\powerScalingMath.hglsl"
#include "C:\Users\Jonathan\Documents\exjobb\OpenSpace\shaders\PowerScaling\powerScalingMath.hglsl"
#include "D:\OpenSpace\shaders\PowerScaling\powerScalingMath.hglsl"
layout(location = 0) in vec4 vertex_data;
layout (location = 0) in vec4 vertex_data;
uniform dmat4 modelViewTransform;
uniform mat4 projectionTransform;
@@ -36,14 +34,12 @@ uniform mat4 projectionTransform;
out vec4 viewSpacePosition;
out vec4 vs_position;
void main() {
vec4 position = vec4(vertex_data.xyz, 1.0);
viewSpacePosition = vec4(modelViewTransform * position);
vs_position = z_normalization(projectionTransform * viewSpacePosition);
//vec4 vs_position = z_normalization(position);
gl_Position = vs_position;
// float timeOffset = vertex_data.w;
//gl_Position = projectionTransform * viewSpacePosition;
void main() {
viewSpacePosition = vec4(modelViewTransform * dvec4(vertex_data.xyz, 1));
vs_position = z_normalization( projectionTransform * viewSpacePosition);
gl_Position = vs_position;
}

View File

@@ -303,7 +303,7 @@ glm::dvec3 KeplerTranslation::position(const UpdateData& data) const {
};
return _orbitPlaneRotation * p;
}
// !!! is only used in module/space/rendering/renderablesatellites
glm::dvec3 KeplerTranslation::debrisPos(const Time& time) const {
if (_orbitPlaneDirty) {
computeOrbitPlane();