mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 04:58:59 -05:00
Merged with master before pull request
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
GLuint _vertexPositionBuffer = 0;
|
||||
bool _planeIsDirty = false;
|
||||
|
||||
glm::vec3 _sunPosition;
|
||||
glm::vec3 _sunPosition = glm::vec3(0.f);
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -66,18 +66,16 @@ namespace {
|
||||
"method includes lines. If the rendering mode is set to Points, this value is "
|
||||
"ignored."
|
||||
};
|
||||
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 openspace::properties::Property::PropertyInfo LineColorInfo = {
|
||||
"Color",
|
||||
"Color",
|
||||
"This value determines the RGB main color for the lines and points of the trail."
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo TrailFadeInfo = {
|
||||
"TrailFade",
|
||||
"Trail Fade",
|
||||
"This value determines how fast the trail fades and is an appearance property. "
|
||||
};
|
||||
|
||||
constexpr const char* KeyFile = "Path";
|
||||
constexpr const char* KeyLineNum = "LineNumber";
|
||||
@@ -293,12 +291,6 @@ documentation::Documentation RenderableSatellites::Documentation() {
|
||||
Optional::Yes,
|
||||
LineWidthInfo.description
|
||||
},
|
||||
{
|
||||
FadeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FadeInfo.description
|
||||
},
|
||||
{
|
||||
LineColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
@@ -312,9 +304,7 @@ documentation::Documentation RenderableSatellites::Documentation() {
|
||||
RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _path(PathInfo)
|
||||
, _nSegments(SegmentsInfo)
|
||||
, _lineFade(FadeInfo)
|
||||
|
||||
, _nSegments(SegmentsInfo, 120, 4, 1024)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
@@ -324,16 +314,41 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
|
||||
|
||||
_path = dictionary.value<std::string>(PathInfo.identifier);
|
||||
_nSegments = static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
|
||||
_lineFade = static_cast<float>(dictionary.value<double>(FadeInfo.identifier));
|
||||
|
||||
if (dictionary.hasKeyAndValue<glm::vec3>(LineColorInfo.identifier)) {
|
||||
_appearance.lineColor = dictionary.value<glm::vec3>(LineColorInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKeyAndValue<double>(TrailFadeInfo.identifier)) {
|
||||
_appearance.lineFade = static_cast<float>(
|
||||
dictionary.value<double>(TrailFadeInfo.identifier)
|
||||
);
|
||||
}
|
||||
else {
|
||||
_appearance.lineFade = 20;
|
||||
}
|
||||
|
||||
if (dictionary.hasKeyAndValue<double>(LineWidthInfo.identifier)) {
|
||||
_appearance.lineWidth = static_cast<float>(
|
||||
dictionary.value<double>(LineWidthInfo.identifier)
|
||||
);
|
||||
}
|
||||
else {
|
||||
_appearance.lineWidth = 2.0;
|
||||
}
|
||||
|
||||
auto reinitializeTrailBuffers = [this]() {
|
||||
initializeGL();
|
||||
};
|
||||
|
||||
_path.onChange(reinitializeTrailBuffers);
|
||||
_nSegments.onChange(reinitializeTrailBuffers);
|
||||
|
||||
addPropertySubOwner(_appearance);
|
||||
addProperty(_path);
|
||||
addProperty(_nSegments);
|
||||
addProperty(_lineFade);
|
||||
addProperty(_opacity);
|
||||
|
||||
setRenderBin(Renderable::RenderBin::Overlay);
|
||||
}
|
||||
|
||||
|
||||
@@ -476,7 +491,6 @@ void RenderableSatellites::initializeGL() {
|
||||
_uniformCache.opacity = _programObject->uniformLocation("opacity");
|
||||
|
||||
updateBuffers();
|
||||
setRenderBin(Renderable::RenderBin::Overlay);
|
||||
}
|
||||
|
||||
void RenderableSatellites::deinitializeGL() {
|
||||
@@ -515,9 +529,12 @@ void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
|
||||
data.camera.combinedViewMatrix() * modelTransform
|
||||
);
|
||||
|
||||
// Because we want the property to work similar to the planet trails
|
||||
float fade = static_cast<float>(pow(_appearance.lineFade.maxValue() - _appearance.lineFade, 2.0));
|
||||
|
||||
_programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix());
|
||||
_programObject->setUniform(_uniformCache.color, _appearance.lineColor);
|
||||
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
|
||||
_programObject->setUniform(_uniformCache.lineFade, fade);
|
||||
|
||||
glLineWidth(_appearance.lineWidth);
|
||||
|
||||
@@ -596,10 +613,10 @@ void RenderableSatellites::updateBuffers() {
|
||||
);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)0); // stride : 4*sizeof(GL_FLOAT) + 2*sizeof(GL_DOUBLE)
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), nullptr);
|
||||
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_DOUBLE, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4*sizeof(GL_FLOAT)) );
|
||||
glVertexAttribPointer(1, 2, GL_DOUBLE, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4 * sizeof(GL_FLOAT)));
|
||||
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
@@ -74,9 +74,9 @@ public:
|
||||
|
||||
private:
|
||||
struct Vertex {
|
||||
glm::vec3 position;
|
||||
glm::vec3 color;
|
||||
glm::vec2 texcoord;
|
||||
glm::vec3 position = glm::vec3(0.f);
|
||||
glm::vec3 color = glm::vec3(0.f);
|
||||
glm::vec2 texcoord = glm::vec2(0.f);
|
||||
};
|
||||
|
||||
struct KeplerParameters {
|
||||
@@ -93,8 +93,12 @@ private:
|
||||
|
||||
/// The layout of the VBOs
|
||||
struct TrailVBOLayout {
|
||||
float x, y, z, time;
|
||||
double epoch, period;
|
||||
float x = 0.f;
|
||||
float y = 0.f;
|
||||
float z = 0.f;
|
||||
float time = 0.f;
|
||||
double epoch = 0.0;
|
||||
double period = 0.0;
|
||||
};
|
||||
|
||||
KeplerTranslation _keplerTranslator;
|
||||
@@ -104,10 +108,6 @@ private:
|
||||
/// trail.
|
||||
std::vector<TrailVBOLayout> _vertexBufferData;
|
||||
|
||||
/// The index array that is potentially used in the draw call. If this is empty, no
|
||||
/// element draw call is used.
|
||||
std::vector<unsigned int> _indexBufferData;
|
||||
|
||||
GLuint _vertexArray;
|
||||
GLuint _vertexBuffer;
|
||||
GLuint _indexBuffer;
|
||||
@@ -123,11 +123,9 @@ private:
|
||||
properties::StringProperty _path;
|
||||
properties::UIntProperty _nSegments;
|
||||
|
||||
properties::DoubleProperty _lineFade;
|
||||
|
||||
RenderableTrail::Appearance _appearance;
|
||||
|
||||
glm::vec3 _position;
|
||||
glm::vec3 _position = glm::vec3(0.f);
|
||||
|
||||
UniformCache(modelView, projection, lineFade, inGameTime, color, opacity,
|
||||
numberOfSegments) _uniformCache;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
@@ -25,9 +25,9 @@
|
||||
#include <modules/space/rendering/simplespheregeometry.h>
|
||||
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/powerscaledsphere.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/sphere.h>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo RadiusInfo = {
|
||||
@@ -124,7 +124,7 @@ void SimpleSphereGeometry::createSphere() {
|
||||
const glm::vec3 radius = _radius.value();
|
||||
|
||||
delete _sphere;
|
||||
_sphere = new PowerScaledSphere(radius, _segments);
|
||||
_sphere = new Sphere(radius, _segments);
|
||||
_sphere->initialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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 *
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
namespace openspace {
|
||||
class Renderable;
|
||||
class PowerScaledSphere;
|
||||
class Sphere;
|
||||
} // namespace openspace
|
||||
|
||||
namespace openspace::documentation { struct Documentation; }
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
|
||||
properties::Vec3Property _radius;
|
||||
properties::IntProperty _segments;
|
||||
PowerScaledSphere* _sphere;
|
||||
Sphere* _sphere;
|
||||
};
|
||||
|
||||
} // namespace openspace::planetgeometry
|
||||
|
||||
Reference in New Issue
Block a user