positions now work, but pause at vertex

This commit is contained in:
Elon
2019-05-23 16:55:44 -06:00
committed by ElonOlsson
parent a555e9e4b2
commit fe8f3115cc
5 changed files with 36 additions and 11 deletions
@@ -59,7 +59,7 @@ local registerSatelliteGroupObjects = function(containingAsset, group, tleFolder
-- The initialization with "-" is just a placeholder.
-- (needed to be initialized)
Segments = 4,
Segments = 260,
EccentricityColumn = "-",
SemiMajorAxisColumn = "-",
SemiMajorAxisUnit = 1,
@@ -602,6 +602,8 @@ void RenderableSatellites::initializeGL() {
_uniformCache.color = _programObject->uniformLocation("color");
_uniformCache.opacity = _programObject->uniformLocation("opacity");
_uniformCache.numberOfSegments = _programObject->uniformLocation("numberOfSegments");
updateBuffers();
//ghoul::opengl::updateUniformLocations(*_programObject, _uniformCache, UniformNames);
@@ -653,6 +655,8 @@ 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.numberOfSegments, static_cast<int>(_nSegments));
//glEnableVertexAttribArray(0); // We like submitting vertices on stream 0 for no special reason
//glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), 0);
@@ -667,8 +671,8 @@ void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
glBindVertexArray(_vertexArray);
for (size_t i = 0; i < nrOrbits; ++i) {
//glDrawArrays(GL_LINE_STRIP, 0, static_cast<GLsizei>(_vertexBufferData.size()));
glDrawArrays(GL_LINE_LOOP, vertices, _nSegments);
vertices = vertices + _nSegments;
glDrawArrays(GL_LINE_STRIP, vertices, _nSegments + 1);
vertices = vertices + _nSegments + 1;
}
glBindVertexArray(0);
@@ -680,7 +684,7 @@ void RenderableSatellites::updateBuffers() {
_TLEData = readTLEFile(_path);
LINFO(fmt::format("Pathpath: {} ", _path));
const size_t nVerticesPerOrbit = _nSegments;
const size_t nVerticesPerOrbit = _nSegments + 1;
_vertexBufferData.resize(_TLEData.size() * nVerticesPerOrbit);
size_t orbitindex = 0;
@@ -697,12 +701,19 @@ void RenderableSatellites::updateBuffers() {
);
for (size_t i = 0; i < nVerticesPerOrbit; ++i) {
size_t index = orbitindex * nVerticesPerOrbit + i;
for (size_t i=0 ; i < nVerticesPerOrbit; ++i) {
size_t index = orbitindex * nVerticesPerOrbit + i;
float timeOffset = orbit.period *
float timeOffset;
if(i == nVerticesPerOrbit -1){
timeOffset = orbit.period *
static_cast<float>(0)/ static_cast<float>(_nSegments);
}
else {
timeOffset = orbit.period *
static_cast<float>(i)/ static_cast<float>(_nSegments);
}
glm::vec3 position = _keplerTranslator.debrisPos(static_cast<float>(orbit.epoch) + timeOffset);
_vertexBufferData[index].x = position.x;
@@ -133,7 +133,7 @@ namespace openspace {
double _inGameTime = 0.0;
UniformCache(modelView, projection, lineFade, inGameTime, color, opacity)
UniformCache(modelView, projection, lineFade, inGameTime, color, opacity, numberOfSegments)
_uniformCache;
};
+7 -1
View File
@@ -33,6 +33,8 @@ uniform float opacity = 1.0;
uniform float lineFade;
//uniform double inGameTime;
uniform int numberOfSegments;
in vec4 viewSpacePosition;
@@ -44,6 +46,7 @@ in vec4 vs_position;
//in vec2 orbit_data_out;
in float periodFraction_f;
in float offsetPeriods;
in float vertexID_f;
Fragment getFragment() {
@@ -58,7 +61,10 @@ Fragment getFragment() {
float offsetPeriods = vertex_data_out.w / orbit_data_out.y;
// check difference of these two locations
*/
float vertexDistance = periodFraction_f - offsetPeriods;
// float vertexDistance = periodFraction_f - offsetPeriods;
float vertexID_perOrbit = mod(vertexID_f, numberOfSegments);
float vertexDistance = periodFraction_f - (vertexID_perOrbit/numberOfSegments) ;
if (vertexDistance < 0.0) {
vertexDistance += 1.0;
+9 -1
View File
@@ -34,6 +34,8 @@ uniform mat4 projectionTransform;
//uniform float lineFade;
uniform double inGameTime;
// uniform int numberOfSegments;
out vec4 viewSpacePosition;
out vec4 vs_position;
@@ -43,6 +45,7 @@ out vec4 vs_position;
//out vec2 orbit_data_out;
out float periodFraction_f;
out float offsetPeriods;
out float vertexID_f;
void main() {
@@ -55,8 +58,13 @@ void main() {
// same procedure for the current vertex
offsetPeriods = vertex_data.w / orbit_data.y;
vertexID_f = float(gl_VertexID);
/*// check difference of these two locations
float vertexDistance = periodFraction_f - offsetPeriods;
float vertexDistance = periodFraction_f - offsetPeriods;
if(vertexDistance < 0.0) {
vertexDistance += 1.0;