appearance

This commit is contained in:
Elon
2019-03-25 14:34:56 -06:00
committed by ElonOlsson
parent 5abb86c392
commit a38635b2f0
8 changed files with 237 additions and 65 deletions

View File

@@ -59,6 +59,13 @@ namespace {
{ "Points+Lines", RenderingModeLinesPoints }
};
static const openspace::properties::PropertyOwner::PropertyOwnerInfo
AppearanceInfo = {
"Appearance",
"Appearance",
"The appearance of the trail."
};
constexpr openspace::properties::Property::PropertyInfo LineColorInfo = {
"Color",
"Color",
@@ -166,8 +173,35 @@ documentation::Documentation RenderableTrail::Documentation() {
};
}
RenderableTrail::Appearance::Appearance()
: properties::PropertyOwner(AppearanceInfo)
, lineColor(LineColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, useLineFade(EnableFadeInfo, true)
, lineFade(FadeInfo, 1.f, 0.f, 30.f)
, lineWidth(LineWidthInfo, 2.f, 1.f, 20.f)
, pointSize(PointSizeInfo, 1, 1, 64)
, renderingModes(
RenderingModeInfo,
properties::OptionProperty::DisplayType::Dropdown
)
{
renderingModes.addOptions({
{ RenderingModeLines, "Lines" },
{ RenderingModePoints, "Points" },
{ RenderingModeLinesPoints, "Lines+Points" }
});
addProperty(lineColor);
addProperty(useLineFade);
addProperty(lineFade);
addProperty(lineWidth);
addProperty(pointSize);
addProperty(renderingModes);
}
RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
/*
, _lineColor(LineColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, _useLineFade(EnableFadeInfo, true)
, _lineFade(FadeInfo, 1.f, 0.f, 30.f)
@@ -177,6 +211,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
RenderingModeInfo,
properties::OptionProperty::DisplayType::Dropdown
)
*/
{
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
@@ -186,32 +221,32 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
);
addPropertySubOwner(_translation.get());
_lineColor = dictionary.value<glm::vec3>(LineColorInfo.identifier);
addProperty(_lineColor);
_appearance.lineColor = dictionary.value<glm::vec3>(LineColorInfo.identifier);
addProperty(_appearance.lineColor);
if (dictionary.hasKeyAndValue<bool>(EnableFadeInfo.identifier)) {
_useLineFade = dictionary.value<bool>(EnableFadeInfo.identifier);
_appearance.useLineFade = dictionary.value<bool>(EnableFadeInfo.identifier);
}
addProperty(_useLineFade);
addProperty(_appearance.useLineFade);
if (dictionary.hasKeyAndValue<double>(FadeInfo.identifier)) {
_lineFade = static_cast<float>(dictionary.value<double>(FadeInfo.identifier));
_appearance.lineFade = static_cast<float>(dictionary.value<double>(FadeInfo.identifier));
}
addProperty(_lineFade);
addProperty(_appearance.lineFade);
if (dictionary.hasKeyAndValue<double>(LineWidthInfo.identifier)) {
_lineWidth = static_cast<float>(dictionary.value<double>(
_appearance.lineWidth = static_cast<float>(dictionary.value<double>(
LineWidthInfo.identifier
));
}
addProperty(_lineWidth);
addProperty(_appearance.lineWidth);
if (dictionary.hasKeyAndValue<double>(PointSizeInfo.identifier)) {
_pointSize = static_cast<int>(dictionary.value<double>(PointSizeInfo.identifier));
_appearance.pointSize = static_cast<int>(dictionary.value<double>(PointSizeInfo.identifier));
}
addProperty(_pointSize);
addProperty(_appearance.pointSize);
_renderingModes.addOptions({
_appearance.renderingModes.addOptions({
{ RenderingModeLines, "Lines" },
{ RenderingModePoints, "Points" },
{ RenderingModeLinesPoints, "Lines+Points" }
@@ -220,14 +255,14 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
// This map is not accessed out of order as long as the Documentation is adapted
// whenever the map changes. The documentation will check for valid values
if (dictionary.hasKeyAndValue<std::string>(RenderingModeInfo.identifier)) {
_renderingModes = RenderingModeConversion.at(
_appearance.renderingModes = RenderingModeConversion.at(
dictionary.value<std::string>(RenderingModeInfo.identifier)
);
}
else {
_renderingModes = RenderingModeLines;
_appearance.renderingModes = RenderingModeLines;
}
addProperty(_renderingModes);
addProperty(_appearance.renderingModes);
}
void RenderableTrail::initializeGL() {
@@ -272,10 +307,10 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
_programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix());
_programObject->setUniform(_uniformCache.color, _lineColor);
_programObject->setUniform(_uniformCache.useLineFade, _useLineFade);
if (_useLineFade) {
_programObject->setUniform(_uniformCache.lineFade, _lineFade);
_programObject->setUniform(_uniformCache.color, _appearance.lineColor);
_programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade);
if (_appearance.useLineFade) {
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
}
static std::map<RenderInformation::VertexSorting, int> SortingMapping = {
@@ -294,21 +329,21 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
}
const bool renderLines = (_renderingModes == RenderingModeLines) |
(_renderingModes == RenderingModeLinesPoints);
const bool renderLines = (_appearance.renderingModes == RenderingModeLines) |
(_appearance.renderingModes == RenderingModeLinesPoints);
const bool renderPoints = (_renderingModes == RenderingModePoints) |
(_renderingModes == RenderingModeLinesPoints);
const bool renderPoints = (_appearance.renderingModes == RenderingModePoints) |
(_appearance.renderingModes == RenderingModeLinesPoints);
if (renderLines) {
glLineWidth(_lineWidth);
glLineWidth(_appearance.lineWidth);
}
if (renderPoints) {
glEnable(GL_PROGRAM_POINT_SIZE);
}
auto render = [renderLines, renderPoints, p = _programObject, &data,
&modelTransform, pointSize = _pointSize.value(), c = _uniformCache]
&modelTransform, pointSize = _appearance.pointSize.value(), c = _uniformCache]
(RenderInformation& info, int nVertices, int offset)
{
// We pass in the model view transformation matrix as double in order to maintain

View File

@@ -71,6 +71,23 @@ class Translation;
*/
class RenderableTrail : public Renderable {
public:
struct Appearance : properties::PropertyOwner {
Appearance();
/// Specifies the base color of the line before fading
properties::Vec3Property lineColor;
/// Settings that enables or disables the line fading
properties::BoolProperty useLineFade;
/// Specifies a multiplicative factor that fades out the line
properties::FloatProperty lineFade;
/// Line width for the line rendering part
properties::FloatProperty lineWidth;
/// Point size for the point rendering part
properties::IntProperty pointSize;
/// The option determining which rendering method to use
properties::OptionProperty renderingModes;
};
~RenderableTrail() = default;
void initializeGL() override;
@@ -143,6 +160,8 @@ protected:
RenderInformation _floatingRenderInformation;
private:
/*
/// Specifies the base color of the line before fading
properties::Vec3Property _lineColor;
/// Settings that enables or disables the line fading
@@ -156,6 +175,9 @@ private:
/// The option determining which rendering method to use
properties::OptionProperty _renderingModes;
*/
Appearance _appearance;
/// Program object used to render the data stored in RenderInformation
ghoul::opengl::ProgramObject* _programObject = nullptr;

View File

@@ -25,51 +25,55 @@
include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanet.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablerings.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/keplertranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/spicetranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/tletranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/horizonstranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/rotation/spicerotation.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanet.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesatellites.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablerings.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/keplertranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/spicetranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/tletranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/horizonstranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/rotation/spicerotation.h
)
source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablerings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/keplertranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/spicetranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/tletranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/horizonstranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rotation/spicerotation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesatellites.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablerings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/keplertranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/spicetranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/tletranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/horizonstranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rotation/spicerotation.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})
set(SHADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/shaders/constellationbounds_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/constellationbounds_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/nighttexture_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/nighttexture_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderableplanet_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderableplanet_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/rings_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/rings_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/shadow_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/shadow_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/shadow_nighttexture_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/shadow_nighttexture_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_ge.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/constellationbounds_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/constellationbounds_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/nighttexture_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/nighttexture_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderablekeplerorbits_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderablekeplerorbits_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderableplanet_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderableplanet_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/rings_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/rings_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/shadow_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/shadow_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/shadow_nighttexture_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/shadow_nighttexture_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_ge.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_vs.glsl
)
source_group("Shader Files" FILES ${SHADER_FILES})

View File

@@ -228,16 +228,16 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
* test
*/
const std::string& file = dictionary.value<str::string(KeyFile);
const std::string& file = dictionary.value<std::string>(KeyFile);
int lineNumber = 1;
if (dictionary.hasKeyAndValue)<double>(KeyLineNumber) {
if (dictionary.hasKeyAndValue<double>(KeyLineNumber)) {
lineNumber = static_cast<int>(dictionary.value<double>(KeyLineNumber));
}
readTLEFile(file, lineNumber);
}
void RenderableSatellites::readTLEFile(const std::string& filename, int lineNumber){
void RenderableSatellites::readTLEFile(const std::string& filename, int lineNum){
ghoul_assert(FileSys.fileExists(filename), "The filename must exist");
std::ifstream file;

View File

@@ -27,7 +27,7 @@
#include <modules/base/rendering/renderabletrail.h>
#include <modules/space/translation/keplertranslation.h>
#include <openspace/util/circlegeometry.h>
// #include <openspace/util/circlegeometry.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/uintproperty.h>

View File

@@ -0,0 +1,46 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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 *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include "fragment.glsl"
#include "floatoperations.glsl"
uniform vec3 color;
uniform float opacity = 1.0;
uniform bool useLineFade;
uniform float lineFade;
in vec4 viewSpacePosition;
Fragment getFragment() {
Fragment frag;
frag.color = vec4(color, opacity);
frag.depth = safeLength(viewSpacePosition);
frag.blend = BLEND_MODE_ADDITIVE;
frag.gPosition = viewSpacePosition;
// There is no normal here
frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0);
return frag;
}

View File

@@ -0,0 +1,44 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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 *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
layout(location = 0) in vec4 vertexData;
uniform dmat4 modelViewTransform;
uniform mat4 projectionTransform;
uniform bool useLineFade;
uniform float lineFade;
uniform int vertexSortingMethod;
uniform int pointSize;
out vec4 viewSpacePosition;
void main() {
dvec4 position = dvec4(vertexData.xyz, 1.0);
float timeOffset = vertexData.w;
viewSpacePosition = vec4(modelViewTransform * position);
gl_Position = projectionTransform * viewSpacePosition;
}

View File

@@ -47,6 +47,27 @@ public:
std::string offender;
};
struct KeplerOrbit {
/// The period of the orbit in seconds
double period() const;
/// The eccentricity of the orbit in [0, 1)
double eccentricity;
/// The semi-major axis in km
double semiMajorAxis;
/// The inclination of the orbit in [0, 360]
double inclination;
/// The right ascension of the ascending node in [0, 360]
double ascendingNode;
/// The argument of periapsis in [0, 360]
double argumentOfPeriapsis;
/// The mean anomaly at the epoch in [0, 360]
double meanAnomalyAtEpoch;
/// The epoch in seconds relative to the J2000 epoch
double epoch;
/// The mass of the more massive body
double massiveBodyMass = 1.989E30; // Sun's mass in kg
};
/**
* The constructor that retrieves the required Keplerian elements from the passed
* \p dictionary. These values are then apssed to the setKeplerElements method for