mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 04:58:59 -05:00
All debris rendered as one scene graph node
This commit is contained in:
@@ -123,6 +123,13 @@
|
||||
"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 const char* KeyFile = "Path";
|
||||
constexpr const char* KeyLineNum = "LineNumber";
|
||||
@@ -389,6 +396,12 @@ documentation::Documentation RenderableSatellites::Documentation() {
|
||||
new StringVerifier,
|
||||
Optional::No,
|
||||
EpochColumnInfo.description
|
||||
},
|
||||
{
|
||||
LineWidthInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LineWidthInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -437,12 +450,9 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
|
||||
//addPropertySubOwner(_appearance);
|
||||
addProperty(_path);
|
||||
addProperty(_nSegments);
|
||||
addProperty(_semiMajorAxisUnit);
|
||||
// addProperty(_semiMajorAxisUnit);
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> General code cleanup
|
||||
|
||||
LINFO(fmt::format("KeyFile: {} ", KeyFile));
|
||||
const std::string& file = dictionary.value<std::string>(KeyFile);
|
||||
LINFO(fmt::format("file: {} ", file));
|
||||
@@ -465,7 +475,7 @@ void RenderableSatellites::readTLEFile(const std::string& filename) {
|
||||
int numberOfObjects = numberOfLines/3;
|
||||
LINFO(fmt::format("Number of data elements: {}", numberOfObjects));
|
||||
|
||||
std::string line = "hej";
|
||||
std::string line = "-";
|
||||
for (int i = 0; i < numberOfObjects; i++) {
|
||||
|
||||
std::getline(file, line); // get rid of title
|
||||
@@ -593,22 +603,17 @@ void RenderableSatellites::deinitialize() {
|
||||
}
|
||||
|
||||
void RenderableSatellites::initializeGL() {
|
||||
|
||||
glGenVertexArrays(1, &_vertexArray);
|
||||
glGenBuffers(1, &_vertexBuffer);
|
||||
glGenBuffers(1, &_indexBuffer);
|
||||
|
||||
_programObject = SpaceModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> 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");
|
||||
@@ -616,6 +621,23 @@ 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);
|
||||
|
||||
setRenderBin(Renderable::RenderBin::Overlay);
|
||||
|
||||
}
|
||||
@@ -626,7 +648,7 @@ void RenderableSatellites::deinitializeGL() {
|
||||
|
||||
glDeleteBuffers(1, &_vertexBuffer);
|
||||
glDeleteBuffers(1, &_indexBuffer);
|
||||
glDeleteVertexArrays(1, &_vertexArray);
|
||||
//glDeleteVertexArrays(1, &_vertexArray);
|
||||
}
|
||||
|
||||
|
||||
@@ -639,15 +661,21 @@ bool RenderableSatellites::isReady() const {
|
||||
void RenderableSatellites::update(const UpdateData&) {}
|
||||
|
||||
void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
|
||||
//if (_TLEData.empty())
|
||||
// return;
|
||||
|
||||
_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));
|
||||
|
||||
_programObject->setUniform(
|
||||
_uniformCache.modelView,
|
||||
data.camera.combinedViewMatrix() * modelTransform
|
||||
_uniformCache.modelView,
|
||||
data.camera.combinedViewMatrix() * modelTransform
|
||||
);
|
||||
|
||||
|
||||
_programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix());
|
||||
_programObject->setUniform(_uniformCache.color, _appearance.lineColor);
|
||||
@@ -656,34 +684,18 @@ void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
|
||||
// _programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
|
||||
//}
|
||||
|
||||
glLineWidth(_appearance.lineWidth);
|
||||
|
||||
glDepthMask(false);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
// Crashes in here
|
||||
glBindVertexArray(_vertexArray);
|
||||
glDrawElements(GL_LINES,
|
||||
//static_cast<unsigned int>(_indexBufferData.size()),
|
||||
20,
|
||||
GL_UNSIGNED_INT,
|
||||
&_indexBufferData.front());
|
||||
//glDrawArrays(GL_LINES,
|
||||
// 0,
|
||||
// 20); //static_cast<unsigned int>(_indexBufferData.size()));
|
||||
/*
|
||||
glBegin (GL_LINES);
|
||||
glVertex3f (_vertexBufferData[0].x, _vertexBufferData[0].y, _vertexBufferData[0].z);
|
||||
glVertex3f (_vertexBufferData[1].x, _vertexBufferData[1].y, _vertexBufferData[1].z);
|
||||
glVertex3f (_vertexBufferData[2].x, _vertexBufferData[2].y, _vertexBufferData[2].z);
|
||||
glVertex3f (_vertexBufferData[3].x, _vertexBufferData[3].y, _vertexBufferData[3].z);
|
||||
glEnd ();
|
||||
*/
|
||||
glDrawArrays(GL_LINE_STRIP, 0, static_cast<GLsizei>(_vertexBufferData.size()));
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
_programObject->deactivate();
|
||||
|
||||
}
|
||||
|
||||
void RenderableSatellites::updateBuffers() {
|
||||
|
||||
const size_t nVerticesPerOrbit = _nSegments + 1;
|
||||
_vertexBufferData.resize(_TLEData.size() * nVerticesPerOrbit);
|
||||
_indexBufferData.resize(_TLEData.size() * _nSegments * 2);
|
||||
@@ -710,6 +722,8 @@ void RenderableSatellites::updateBuffers() {
|
||||
|
||||
glm::vec3 position = _keplerTranslator.debrisPos(Time(orbit.epoch + timeOffset));
|
||||
|
||||
// LINFO(fmt::format("SegmentPosition: {} ", position));
|
||||
|
||||
_vertexBufferData[index].x = position.x;
|
||||
_vertexBufferData[index].y = position.y;
|
||||
_vertexBufferData[index].z = position.z;
|
||||
@@ -721,26 +735,6 @@ void RenderableSatellites::updateBuffers() {
|
||||
}
|
||||
++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);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,9 +36,18 @@
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/misc/objectmanager.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct Vertex {
|
||||
glm::vec3 position;
|
||||
glm::vec3 color;
|
||||
glm::vec2 texcoord;
|
||||
};
|
||||
|
||||
struct KeplerParameters {
|
||||
double inclination = 0.0;
|
||||
double semiMajorAxis = 0.0;
|
||||
@@ -88,6 +97,10 @@ namespace openspace {
|
||||
GLuint _vertexBuffer;
|
||||
GLuint _indexBuffer;
|
||||
|
||||
//GLuint _vaoTest; // vertexArrayObject
|
||||
//GLuint _vboTest; // vertextBufferObject
|
||||
//GLuint _eboTest; // elementBufferObject/ indexBufferObject
|
||||
|
||||
void updateBuffers();
|
||||
|
||||
ghoul::opengl::ProgramObject* _programObject;
|
||||
@@ -106,7 +119,7 @@ namespace openspace {
|
||||
|
||||
RenderableTrail::Appearance _appearance;
|
||||
|
||||
UniformCache(opacity, modelView, projection, color, useLineFade, lineFade)
|
||||
UniformCache(opacity, modelView, projection, color) //, useLineFade, lineFade)
|
||||
_uniformCache;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user