mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 04:49:12 -06:00
line fade now works useing float for orbit and period
This commit is contained in:
@@ -12,12 +12,4 @@ local tle = shared.downloadTLEFile(asset, group.Url, group.Title)
|
||||
|
||||
local objectNames = {}
|
||||
|
||||
asset.onInitialize(function ()
|
||||
objectNames = shared.addSatelliteGroupObjects(group, tle, true)
|
||||
end)
|
||||
|
||||
--asset.onDeinitialize(function ()
|
||||
-- for _, n in ipairs(objectNames) do
|
||||
-- openspace.removeSceneGraphNode(n)
|
||||
-- end
|
||||
--end)
|
||||
shared.registerSatelliteGroupObjects(asset, group, tle, true)
|
||||
|
||||
@@ -59,7 +59,7 @@ local registerSatelliteGroupObjects = function(containingAsset, group, tleFolder
|
||||
|
||||
-- The initialization with "-" is just a placeholder.
|
||||
-- (needed to be initialized)
|
||||
Segments = 160,
|
||||
Segments = 960,
|
||||
EccentricityColumn = "-",
|
||||
SemiMajorAxisColumn = "-",
|
||||
SemiMajorAxisUnit = 1,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--asset.request('./debris/debris_asat')
|
||||
asset.request('./debris/debris_asat')
|
||||
asset.request('./debris/debris_breezem')
|
||||
--asset.request('./debris/debris_fengyun')
|
||||
--asset.request('./debris/debris_iridium33')
|
||||
--asset.request('./debris/debris_kosmos2251')
|
||||
asset.request('./debris/debris_fengyun')
|
||||
asset.request('./debris/debris_iridium33')
|
||||
asset.request('./debris/debris_kosmos2251')
|
||||
|
||||
@@ -177,8 +177,8 @@ RenderableTrail::Appearance::Appearance()
|
||||
: properties::PropertyOwner(AppearanceInfo)
|
||||
, lineColor(LineColorInfo, glm::vec3(0.9f, 0.45f, 0.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, useLineFade(EnableFadeInfo, true)
|
||||
, lineFade(FadeInfo, 1.f, 0.f, 30.f)
|
||||
, lineWidth(LineWidthInfo, 1.35f, 1.f, 20.f)
|
||||
, lineFade(FadeInfo, 0.4f, 0.f, 30.f)
|
||||
, lineWidth(LineWidthInfo, 1.1f, 1.f, 20.f)
|
||||
, pointSize(PointSizeInfo, 1, 1, 64)
|
||||
, renderingModes(
|
||||
RenderingModeInfo,
|
||||
|
||||
@@ -21,136 +21,130 @@
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
|
||||
#include <modules/space/rendering/renderablesatellites.h>
|
||||
#include <modules/space/translation/keplertranslation.h>
|
||||
#include <modules/space/translation/TLEtranslation.h>
|
||||
#include <modules/space/spacemodule.h>
|
||||
|
||||
#include <modules/space/rendering/renderablesatellites.h>
|
||||
#include <modules/space/translation/keplertranslation.h>
|
||||
#include <modules/space/translation/TLEtranslation.h>
|
||||
#include <modules/space/spacemodule.h>
|
||||
#include <modules/base/basemodule.h>
|
||||
|
||||
|
||||
#include <modules/base/basemodule.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
#include <ghoul/misc/csvreader.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
#include <ghoul/misc/csvreader.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <fstream>
|
||||
|
||||
// Todo:
|
||||
// Parse epoch correctly?
|
||||
// read distances using correct unit
|
||||
// Make the linefade go from the closest vertex to the actuall position
|
||||
// instead of to the next vertex
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "RenderableSatellites";
|
||||
constexpr const char* _loggerCat = "SpaceDebris";
|
||||
|
||||
|
||||
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
||||
// Todo:
|
||||
// Parse epoch correctly
|
||||
// read distances using correct unit
|
||||
// ...
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "RenderableSatellites";
|
||||
constexpr const char* _loggerCat = "SpaceDebris";
|
||||
|
||||
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo PathInfo = {
|
||||
"Path",
|
||||
"Path",
|
||||
"The file path to the CSV file to read"
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo SegmentsInfo = {
|
||||
"Segments",
|
||||
"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."
|
||||
static const openspace::properties::Property::PropertyInfo PathInfo = {
|
||||
"Path",
|
||||
"Path",
|
||||
"The file path to the CSV file to read"
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
|
||||
"Color",
|
||||
"Color",
|
||||
"Färg."
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeInfo = {
|
||||
"Fade",
|
||||
"Line fade",
|
||||
"The fading factor that is applied to the trail if the 'EnableFade' value is "
|
||||
"'true'. If it is 'false', this setting has no effect. The higher the number, "
|
||||
"the less fading is applied."
|
||||
};
|
||||
|
||||
constexpr const char* KeyFile = "Path";
|
||||
constexpr const char* KeyLineNum = "LineNumber";
|
||||
|
||||
// LINFO("Keyfile: " + KeyFile);
|
||||
}
|
||||
static const openspace::properties::Property::PropertyInfo SegmentsInfo = {
|
||||
"Segments",
|
||||
"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 = {
|
||||
"Fade",
|
||||
"Line fade",
|
||||
"The fading factor that is applied to the trail if the 'EnableFade' value is "
|
||||
"'true'. If it is 'false', this setting has no effect. The higher the number, "
|
||||
"the less fading is applied."
|
||||
};
|
||||
|
||||
constexpr const char* KeyFile = "Path";
|
||||
constexpr const char* KeyLineNum = "LineNumber";
|
||||
|
||||
// LINFO("Keyfile: " + KeyFile);
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -563,16 +557,9 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
|
||||
_lineFade =
|
||||
static_cast<float>(dictionary.value<double>(FadeInfo.identifier));
|
||||
|
||||
// _appearance.lineColor = _color;
|
||||
addPropertySubOwner(_appearance);
|
||||
addProperty(_path);
|
||||
addProperty(_nSegments);
|
||||
// addProperty(_lineFade);
|
||||
// addProperty(_semiMajorAxisUnit);
|
||||
|
||||
const std::string& file = dictionary.value<std::string>(KeyFile);
|
||||
LINFO(fmt::format("file: {} ", file));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -689,26 +676,27 @@ void RenderableSatellites::readTLEFile(const std::string& filename) {
|
||||
} // !for loop
|
||||
file.close();
|
||||
|
||||
// get max apergee and min perigee
|
||||
// calculateMaxApoAndMinPeri(_TLEData);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
RenderableSatellites::~RenderableSatellites() {
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void RenderableSatellites::initialize() {
|
||||
|
||||
readTLEFile(_path);
|
||||
updateBuffers();
|
||||
|
||||
//_path.onChange([this]() {
|
||||
// readFromCsvFile();
|
||||
// readTLEFile(_path);
|
||||
// updateBuffers();
|
||||
//});
|
||||
//
|
||||
//_semiMajorAxisUnit.onChange([this]() {
|
||||
// readFromCsvFile();
|
||||
// readTLEFile(_path);
|
||||
// updateBuffers();
|
||||
//});
|
||||
|
||||
@@ -736,17 +724,14 @@ void RenderableSatellites::initializeGL() {
|
||||
}
|
||||
);
|
||||
|
||||
_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.segments = _programObject->uniformLocation("numberOfSegments");
|
||||
_uniformCache.position = _programObject->uniformLocation("debrisPosition");
|
||||
_uniformCache.numberOfOrbits = _programObject->uniformLocation("numberOfOrbits");
|
||||
_uniformCache.inGameTime = _programObject->uniformLocation("inGameTime");
|
||||
|
||||
_uniformCache.color = _programObject->uniformLocation("color");
|
||||
_uniformCache.opacity = _programObject->uniformLocation("opacity");
|
||||
|
||||
updateBuffers();
|
||||
|
||||
setRenderBin(Renderable::RenderBin::Overlay);
|
||||
@@ -771,88 +756,15 @@ bool RenderableSatellites::isReady() const {
|
||||
void RenderableSatellites::update(const UpdateData& data) {
|
||||
}
|
||||
|
||||
int getNearestVertexNeighbour(int whatOrbit) {
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
|
||||
//if (_TLEData.empty())
|
||||
// return;
|
||||
if (_TLEData.empty())
|
||||
return;
|
||||
_inGameTime = data.time.j2000Seconds();
|
||||
// -----------------
|
||||
// double nrOfPeriods = (_inGameTime - _vertexBufferData[4].epoch) / _vertexBufferData[4].period;
|
||||
// double periodFraction = std::fmod(nrOfPeriods, 1);
|
||||
|
||||
// float offsetPeriods = _vertexBufferData[4].time / float(_vertexBufferData[4].period);
|
||||
// float offsetFraction = std::fmod(offsetPeriods, 1);
|
||||
|
||||
// float vertexDistance = float(periodFraction) - offsetFraction;
|
||||
|
||||
// if (vertexDistance < 0) {
|
||||
// vertexDistance += 1;
|
||||
// }
|
||||
|
||||
// // int vertexID = gl_VertexID;
|
||||
// // float id = float(vertexID) / float(numberOfSegments*numberOfOrbits);
|
||||
|
||||
// -----------------
|
||||
|
||||
// std::vector<TrailVBOLayout>::iterator it = _vertexBufferData.begin();
|
||||
// std::vector<unsigned int> vertexIDs;
|
||||
// unsigned int whatOrbit = 0;
|
||||
// for (const auto& orbit : _TLEData) {
|
||||
// _keplerTranslator.setKeplerElements(
|
||||
// orbit.eccentricity,
|
||||
// orbit.semiMajorAxis,
|
||||
// orbit.inclination,
|
||||
// orbit.ascendingNode,
|
||||
// orbit.argumentOfPeriapsis,
|
||||
// orbit.meanAnomaly,
|
||||
// orbit.period,
|
||||
// orbit.epoch
|
||||
// );
|
||||
|
||||
// glm::vec3 position = _keplerTranslator.debrisPos(_inGameTime);
|
||||
// _position.x = position.x;
|
||||
// _position.y = position.y;
|
||||
// _position.z = position.z;
|
||||
|
||||
// LINFO(fmt::format("atm position: {} ", position));
|
||||
|
||||
// float closestDistance = 10000000;
|
||||
// unsigned int whatIndex = 0;
|
||||
// for(int i=0 ; i<_nSegments ; ++i) {
|
||||
// float positionDistance = glm::distance(
|
||||
// glm::vec3(_position.x, _position.y, _position.z)
|
||||
// ,glm::vec3(it->x, it->y, it->z));
|
||||
// if( positionDistance < closestDistance )
|
||||
// {
|
||||
// closestDistance = positionDistance;
|
||||
// whatIndex = i;
|
||||
// }
|
||||
// ++it;
|
||||
// }
|
||||
// vertexIDs.push_back(whatIndex + (whatOrbit * _nSegments));
|
||||
// ++whatOrbit;
|
||||
// }
|
||||
|
||||
|
||||
// 1 loopa vertex buffer
|
||||
// 1,5 jämföra positionen på _position med vertexens position.
|
||||
// 2 hitta vilket id i bufferten som positionen har.
|
||||
// 3 skicka vidare det idt
|
||||
|
||||
/////// TEST
|
||||
_programObject->activate();
|
||||
|
||||
//_programObject->setUniform(_uniformCache.vertexIDs, vertexIDs.data());
|
||||
|
||||
//_programObject->setUniform(_uniformCache.numberOfOrbits, _TLEData.size());
|
||||
|
||||
_programObject->setUniform(_uniformCache.opacity, _opacity);
|
||||
_programObject->setUniform(_uniformCache.inGameTime, static_cast<float>(_inGameTime));
|
||||
_programObject->setUniform(_uniformCache.inGameTime, _inGameTime);
|
||||
|
||||
|
||||
glm::dmat4 modelTransform =
|
||||
@@ -867,13 +779,7 @@ 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.segments, _nSegments);
|
||||
// _programObject->setUniform(_uniformCache.position, _position);
|
||||
|
||||
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
|
||||
|
||||
glLineWidth(_appearance.lineWidth);
|
||||
|
||||
@@ -899,9 +805,7 @@ void RenderableSatellites::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) {
|
||||
_keplerTranslator.setKeplerElements(
|
||||
@@ -918,14 +822,11 @@ void RenderableSatellites::updateBuffers() {
|
||||
for (size_t i = 0; i <= _nSegments; ++i) {
|
||||
size_t index = orbitindex * nVerticesPerOrbit + i;
|
||||
|
||||
float timeOffset = orbit.period *
|
||||
static_cast<float>(i) / static_cast<float>(_nSegments);
|
||||
float timeOffset = orbit.period *
|
||||
static_cast<float>(i)/ static_cast<float>(_nSegments);
|
||||
|
||||
glm::vec3 position = _keplerTranslator.debrisPos(static_cast<double>(orbit.epoch + timeOffset));
|
||||
// LINFO(fmt::format("SegmentPosition: {} ", position));
|
||||
glm::vec3 position = _keplerTranslator.debrisPos(static_cast<float>(orbit.epoch) + timeOffset);
|
||||
|
||||
float periodOffset = static_cast<float>(i) / static_cast<float>(_nSegments); // remainder((_inGameTime - orbit.epoch), orbit.period);
|
||||
|
||||
_vertexBufferData[index].x = position.x;
|
||||
_vertexBufferData[index].y = position.y;
|
||||
_vertexBufferData[index].z = position.z;
|
||||
@@ -933,10 +834,6 @@ void RenderableSatellites::updateBuffers() {
|
||||
_vertexBufferData[index].epoch = static_cast<float>(orbit.epoch);
|
||||
_vertexBufferData[index].period = static_cast<float>(orbit.period);
|
||||
|
||||
//if (i > 0) {
|
||||
//_indexBufferData[elementindex++] = static_cast<unsigned int>(index) - 1;
|
||||
//_indexBufferData[elementindex++] = static_cast<unsigned int>(index);
|
||||
//}
|
||||
}
|
||||
++orbitindex;
|
||||
}
|
||||
@@ -954,10 +851,10 @@ void RenderableSatellites::updateBuffers() {
|
||||
);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 6*sizeof(GL_FLOAT), (GLvoid*)0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)0); // stride : 4*sizeof(GL_FLOAT) + 2*sizeof(GL_DOUBLE)
|
||||
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 6*sizeof(GL_FLOAT), (GLvoid*)(4*sizeof(GL_FLOAT)) );
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4*sizeof(GL_FLOAT)) );
|
||||
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
@@ -81,6 +81,7 @@ namespace openspace {
|
||||
struct TrailVBOLayout {
|
||||
float x, y, z, time, epoch, period;
|
||||
};
|
||||
// static_assert(sizeof(struct TrailVBOLayout)==4*sizeof(float)+2*sizeof(double),"Implementation error!");
|
||||
|
||||
KeplerTranslation _keplerTranslator;
|
||||
std::vector<KeplerParameters> _TLEData;
|
||||
|
||||
@@ -23,46 +23,16 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include "fragment.glsl"
|
||||
#include "floatoperations.glsl"
|
||||
|
||||
layout(location = 0) in vec4 vertex; // 1: x, 2: y, 3: z, 4: time
|
||||
// This doesn't work, plz help
|
||||
layout(location = 1) in vec2 orbit; // 1: epoch, 2: period
|
||||
//#include "floatoperations.glsl"
|
||||
|
||||
uniform vec3 color;
|
||||
uniform float opacity = 1.0;
|
||||
|
||||
uniform float lineFade;
|
||||
uniform float inGameTime;
|
||||
|
||||
|
||||
in vec4 viewSpacePosition;
|
||||
in vec4 vs_position;
|
||||
//in float nrOfPeriods;
|
||||
//in float offsetPeriods;
|
||||
//in float fade;
|
||||
//in vec3 vs_color;
|
||||
//in vec2 vs_texcoord;
|
||||
in float fade;
|
||||
|
||||
Fragment getFragment() {
|
||||
|
||||
float nrOfPeriods = (inGameTime - orbit.x) / orbit.y;
|
||||
float periodFraction = fract(nrOfPeriods);
|
||||
|
||||
float offsetPeriods = vertex.w / orbit.y;
|
||||
float offsetFraction = offsetPeriods;
|
||||
|
||||
// check difference of these two locations
|
||||
float vertexDistance = periodFraction - offsetFraction;
|
||||
|
||||
if (vertexDistance < 0.0) {
|
||||
vertexDistance += 1.0;
|
||||
}
|
||||
|
||||
float invert = 1.0 - vertexDistance;
|
||||
|
||||
float fade = clamp(invert * lineFade, 0.0, 1.0);
|
||||
|
||||
|
||||
Fragment frag;
|
||||
frag.color = vec4(color, fade * opacity);
|
||||
|
||||
@@ -24,83 +24,45 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
|
||||
#include "PowerScaling/powerScalingMath.hglsl"
|
||||
// #include "C:\Users\Jonathan\Documents\exjobb\OpenSpace\shaders\PowerScaling\powerScalingMath.hglsl"
|
||||
|
||||
|
||||
layout (location = 0) in vec4 vertex_data; // 1: x, 2: y, 3: z, 4: time
|
||||
// This doesn't work, plz help
|
||||
layout (location = 0) in vec4 vertex_data; // 1: x, 2: y, 3: z, 4: timeOffset
|
||||
layout (location = 1) in vec2 orbit_data; // 1: epoch, 2: period
|
||||
|
||||
|
||||
layout(location = 0) out vec4 vertex; // 1: x, 2: y, 3: z, 4: time
|
||||
// This doesn't work, plz help
|
||||
layout(location = 1) out vec2 orbit; // 1: epoch, 2: period
|
||||
|
||||
|
||||
uniform dmat4 modelViewTransform;
|
||||
uniform mat4 projectionTransform;
|
||||
|
||||
//uniform int numberOfSegments;
|
||||
//uniform float lineFade;
|
||||
//uniform vec3 debrisPosition;
|
||||
//uniform int* VertexIDs;
|
||||
//uniform int numberOfOrbits;
|
||||
//uniform float inGameTime;
|
||||
|
||||
uniform float lineFade;
|
||||
uniform double inGameTime;
|
||||
|
||||
out vec4 viewSpacePosition;
|
||||
out vec4 vs_position;
|
||||
//out float nrOfPeriods;
|
||||
//out float offsetPeriods;
|
||||
//out float fade;
|
||||
|
||||
void main() {
|
||||
out float fade;
|
||||
|
||||
void main() {
|
||||
// calculate nr of periods, get fractional part to know where
|
||||
// the vertex closest to the debris part is right now
|
||||
//float nrOfPeriods = (inGameTime - orbit_data.x) / orbit_data.y;
|
||||
//float periodFraction = fract(nrOfPeriods); //mod(nrOfPeriods, 1.0);
|
||||
double nrOfPeriods = (inGameTime - orbit_data.x) / orbit_data.y;
|
||||
double periodFraction = fract(nrOfPeriods); //mod(nrOfPeriods, 1.0);
|
||||
float periodFraction_f = float(periodFraction);
|
||||
|
||||
// same procedure for the current vertex
|
||||
//float offsetPeriods = vertex_data.w / orbit_data.y;
|
||||
//float offsetFraction = offsetPeriods; //mod(offsetPeriods, 1.0);
|
||||
float offsetPeriods = vertex_data.w / orbit_data.y;
|
||||
|
||||
// check difference of these two locations
|
||||
//float vertexDistance = periodFraction - offsetFraction;
|
||||
float vertexDistance = periodFraction_f - offsetPeriods;
|
||||
|
||||
//if(vertexDistance < 0.0) {
|
||||
// vertexDistance += 1.0;
|
||||
//}
|
||||
if(vertexDistance < 0.0) {
|
||||
vertexDistance += 1.0;
|
||||
}
|
||||
|
||||
// int vertexID = gl_VertexID;
|
||||
// float id = float(vertexID) / float(numberOfSegments*numberOfOrbits);
|
||||
float invert = 1.0 - vertexDistance; // * lineFade;
|
||||
fade = clamp(invert * lineFade, 0.0, 1.0) ;
|
||||
|
||||
//float test = 1.0 - vertexDistance; // * lineFade;
|
||||
// if (test < 1.0 ) {
|
||||
// test = 0.4;
|
||||
// }
|
||||
// if (test >= 1.0) {
|
||||
// test = 1.0;
|
||||
// }
|
||||
|
||||
//fade = clamp(test * lineFade, 0.0, 1.0) ;
|
||||
|
||||
//fade = 0.5 * lineFade;
|
||||
|
||||
// int orbit = vertexID/numberOfSegments;
|
||||
// will this iterate or add onto the value in vertexIDs?: VertexIDs = VertexIDs + orbit;
|
||||
// should it be VertexIDs[orbit] - gl_VertexID, OR gl_VertexID - VertexIDs[orbit]:
|
||||
// int offset = VertexIDs[orbit] - gl_VertexID
|
||||
// to know the direction of the debris
|
||||
// if(debrisPosition == vs_position)
|
||||
vertex = vertex_data;
|
||||
orbit = orbit_data;
|
||||
|
||||
viewSpacePosition = vec4(modelViewTransform * dvec4(vertex_data.xyz, 1));
|
||||
vs_position = z_normalization( projectionTransform * viewSpacePosition);
|
||||
gl_Position = vs_position;
|
||||
gl_Position = vs_position;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user