mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 11:39:49 -06:00
Merge branch 'master' into feature/multitexturing
* Resolve conflicts
This commit is contained in:
@@ -55,36 +55,26 @@ namespace {
|
||||
"Grid Size",
|
||||
"This value species the size of each dimensions of the box"
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableBoxGrid)]] Parameters {
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
std::optional<glm::vec3> size;
|
||||
};
|
||||
#include "renderableboxgrid_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableBoxGrid::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"RenderableBoxGrid",
|
||||
"base_renderable_boxgrid",
|
||||
{
|
||||
{
|
||||
ColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
ColorInfo.description
|
||||
},
|
||||
{
|
||||
LineWidthInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LineWidthInfo.description
|
||||
},
|
||||
{
|
||||
SizeInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
SizeInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_boxgrid";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
|
||||
@@ -93,31 +83,19 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
|
||||
, _size(SizeInfo, glm::vec3(1.f), glm::vec3(1.f), glm::vec3(100.f))
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableBoxGrid"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
|
||||
if (dictionary.hasKey(ColorInfo.identifier)) {
|
||||
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
|
||||
}
|
||||
_color = p.color.value_or(_color);
|
||||
_color.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_color);
|
||||
|
||||
if (dictionary.hasKey(LineWidthInfo.identifier)) {
|
||||
_lineWidth = static_cast<float>(
|
||||
dictionary.value<double>(LineWidthInfo.identifier)
|
||||
);
|
||||
}
|
||||
_lineWidth = p.lineWidth.value_or(_lineWidth);
|
||||
addProperty(_lineWidth);
|
||||
|
||||
if (dictionary.hasKey(SizeInfo.identifier)) {
|
||||
_size = dictionary.value<glm::dvec3>(SizeInfo.identifier);
|
||||
}
|
||||
_size = p.size.value_or(_size);
|
||||
_size.onChange([&]() { _gridIsDirty = true; });
|
||||
addProperty(_size);
|
||||
}
|
||||
|
||||
@@ -62,43 +62,29 @@ namespace {
|
||||
"Grid Size",
|
||||
"This value species the size of each dimensions of the grid"
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableGrid)]] Parameters {
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(SegmentsInfo.description)]]
|
||||
std::optional<glm::ivec2> segments;
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
std::optional<glm::vec2> size;
|
||||
};
|
||||
#include "renderablegrid_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableGrid::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"RenderableGrid",
|
||||
"base_renderable_grid",
|
||||
{
|
||||
{
|
||||
ColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
ColorInfo.description
|
||||
},
|
||||
{
|
||||
SegmentsInfo.identifier,
|
||||
// @TODO (emmbr 2020-07-07): should be Int, but specification test fails..
|
||||
new DoubleVector2Verifier,
|
||||
Optional::Yes,
|
||||
SegmentsInfo.description
|
||||
},
|
||||
{
|
||||
LineWidthInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LineWidthInfo.description
|
||||
},
|
||||
{
|
||||
SizeInfo.identifier,
|
||||
new DoubleVector2Verifier,
|
||||
Optional::Yes,
|
||||
SizeInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_grid";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
|
||||
@@ -108,39 +94,23 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
|
||||
, _size(SizeInfo, glm::vec2(1e20f), glm::vec2(1.f), glm::vec2(1e35f))
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableGrid"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
|
||||
if (dictionary.hasKey(ColorInfo.identifier)) {
|
||||
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
|
||||
}
|
||||
_color = p.color.value_or(_color);
|
||||
_color.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_color);
|
||||
|
||||
if (dictionary.hasKey(SegmentsInfo.identifier)) {
|
||||
_segments = static_cast<glm::uvec2>(
|
||||
dictionary.value<glm::dvec2>(SegmentsInfo.identifier)
|
||||
);
|
||||
}
|
||||
_segments = p.segments.value_or(_segments);
|
||||
_segments.onChange([&]() { _gridIsDirty = true; });
|
||||
addProperty(_segments);
|
||||
|
||||
if (dictionary.hasKey(LineWidthInfo.identifier)) {
|
||||
_lineWidth = static_cast<float>(
|
||||
dictionary.value<double>(LineWidthInfo.identifier)
|
||||
);
|
||||
}
|
||||
_lineWidth = p.lineWidth.value_or(_lineWidth);
|
||||
addProperty(_lineWidth);
|
||||
|
||||
if (dictionary.hasKey(SizeInfo.identifier)) {
|
||||
_size = dictionary.value<glm::dvec2>(SizeInfo.identifier);
|
||||
}
|
||||
_size = p.size.value_or(_size);
|
||||
_size.onChange([&]() { _gridIsDirty = true; });
|
||||
addProperty(_size);
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/vector/ivec2property.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/vector/uvec2property.h>
|
||||
#include <openspace/properties/vector/vec2property.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
@@ -61,7 +61,9 @@ protected:
|
||||
ghoul::opengl::ProgramObject* _gridProgram = nullptr;
|
||||
|
||||
properties::Vec3Property _color;
|
||||
properties::UVec2Property _segments;
|
||||
// @TODO (abock, 2021-01-28) This was a UVec2Property before, but it wasn't supported
|
||||
// be the codegen. As soon as it does, this should be changed back
|
||||
properties::IVec2Property _segments;
|
||||
properties::FloatProperty _lineWidth;
|
||||
properties::Vec2Property _size;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "GridProgram";
|
||||
@@ -76,54 +77,35 @@ namespace {
|
||||
"The inner radius of the circular grid, that is the radius of the inmost ring. "
|
||||
"Must be smaller than the outer radius."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableRadialGrid)]] Parameters {
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(GridSegmentsInfo.description)]]
|
||||
std::optional<glm::ivec2> gridSegments;
|
||||
|
||||
// [[codegen::verbatim(CircleSegmentsInfo.description)]]
|
||||
std::optional<int> circleSegments;
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
|
||||
// [[codegen::verbatim(OuterRadiusInfo.description)]]
|
||||
std::optional<float> outerRadius;
|
||||
|
||||
// [[codegen::verbatim(InnerRadiusInfo.description)]]
|
||||
std::optional<float> innerRadius;
|
||||
};
|
||||
#include "renderableradialgrid_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableRadialGrid::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"RenderableRadialGrid",
|
||||
"base_renderable_radialgrid",
|
||||
{
|
||||
{
|
||||
ColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
ColorInfo.description
|
||||
},
|
||||
{
|
||||
GridSegmentsInfo.identifier,
|
||||
new DoubleVector2Verifier,
|
||||
Optional::Yes,
|
||||
GridSegmentsInfo.description
|
||||
},
|
||||
{
|
||||
CircleSegmentsInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
CircleSegmentsInfo.description
|
||||
},
|
||||
{
|
||||
LineWidthInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LineWidthInfo.description
|
||||
},
|
||||
{
|
||||
OuterRadiusInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
OuterRadiusInfo.description
|
||||
},
|
||||
{
|
||||
InnerRadiusInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
InnerRadiusInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_radialgrid";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
|
||||
@@ -135,34 +117,20 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
|
||||
, _maxRadius(OuterRadiusInfo, 1.f, 0.f, 20.f)
|
||||
, _minRadius(InnerRadiusInfo, 0.f, 0.f, 20.f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableRadialGrid"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
|
||||
if (dictionary.hasKey(ColorInfo.identifier)) {
|
||||
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
|
||||
}
|
||||
_color = p.color.value_or(_color);
|
||||
_color.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_color);
|
||||
|
||||
if (dictionary.hasKey(GridSegmentsInfo.identifier)) {
|
||||
_gridSegments = static_cast<glm::ivec2>(
|
||||
dictionary.value<glm::dvec2>(GridSegmentsInfo.identifier)
|
||||
);
|
||||
}
|
||||
_gridSegments = p.gridSegments.value_or(_gridSegments);
|
||||
_gridSegments.onChange([&]() { _gridIsDirty = true; });
|
||||
addProperty(_gridSegments);
|
||||
|
||||
if (dictionary.hasKey(CircleSegmentsInfo.identifier)) {
|
||||
_circleSegments = static_cast<int>(
|
||||
dictionary.value<double>(CircleSegmentsInfo.identifier)
|
||||
);
|
||||
}
|
||||
_circleSegments = p.circleSegments.value_or(_circleSegments);
|
||||
_circleSegments.onChange([&]() {
|
||||
if (_circleSegments.value() % 2 == 1) {
|
||||
_circleSegments = _circleSegments - 1;
|
||||
@@ -171,24 +139,11 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
|
||||
});
|
||||
addProperty(_circleSegments);
|
||||
|
||||
if (dictionary.hasKey(LineWidthInfo.identifier)) {
|
||||
_lineWidth = static_cast<float>(
|
||||
dictionary.value<double>(LineWidthInfo.identifier)
|
||||
);
|
||||
}
|
||||
_lineWidth = p.lineWidth.value_or(_lineWidth);
|
||||
addProperty(_lineWidth);
|
||||
|
||||
if (dictionary.hasKey(OuterRadiusInfo.identifier)) {
|
||||
_maxRadius = static_cast<float>(
|
||||
dictionary.value<double>(OuterRadiusInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(InnerRadiusInfo.identifier)) {
|
||||
_minRadius = static_cast<float>(
|
||||
dictionary.value<double>(InnerRadiusInfo.identifier)
|
||||
);
|
||||
}
|
||||
_minRadius = p.innerRadius.value_or(_minRadius);
|
||||
_maxRadius = p.outerRadius.value_or(_maxRadius);
|
||||
|
||||
_maxRadius.setMinValue(_minRadius);
|
||||
_minRadius.setMaxValue(_maxRadius);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "GridProgram";
|
||||
@@ -55,36 +56,26 @@ namespace {
|
||||
"Line Width",
|
||||
"This value specifies the line width of the spherical grid."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableSphericalGrid)]] Parameters {
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(SegmentsInfo.description)]]
|
||||
std::optional<int> segments;
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
};
|
||||
#include "renderablesphericalgrid_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableSphericalGrid::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"RenderableSphericalGrid",
|
||||
"base_renderable_sphericalgrid",
|
||||
{
|
||||
{
|
||||
ColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
ColorInfo.description
|
||||
},
|
||||
{
|
||||
SegmentsInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
SegmentsInfo.description
|
||||
},
|
||||
{
|
||||
LineWidthInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LineWidthInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_sphericalgrid";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary)
|
||||
@@ -94,24 +85,16 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
, _segments(SegmentsInfo, 36, 4, 200)
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableSphericalGrid"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
|
||||
if (dictionary.hasKey(ColorInfo.identifier)) {
|
||||
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
|
||||
}
|
||||
_color = p.color.value_or(_color);
|
||||
_color.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_color);
|
||||
|
||||
if (dictionary.hasKey(SegmentsInfo.identifier)) {
|
||||
_segments = static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
|
||||
}
|
||||
_segments = p.segments.value_or(_segments);
|
||||
_segments.onChange([&]() {
|
||||
if (_segments.value() % 2 == 1) {
|
||||
_segments = _segments - 1;
|
||||
@@ -120,11 +103,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
});
|
||||
addProperty(_segments);
|
||||
|
||||
if (dictionary.hasKey(LineWidthInfo.identifier)) {
|
||||
_lineWidth = static_cast<float>(
|
||||
dictionary.value<double>(LineWidthInfo.identifier)
|
||||
);
|
||||
}
|
||||
_lineWidth = p.lineWidth.value_or(_lineWidth);
|
||||
addProperty(_lineWidth);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "CartesianAxesProgram";
|
||||
@@ -56,82 +57,46 @@ namespace {
|
||||
"Z Color",
|
||||
"This value determines the color of the z axis."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableCartesianAxes)]] Parameters {
|
||||
// [[codegen::verbatim(XColorInfo.description)]]
|
||||
std::optional<glm::vec3> xColor [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(YColorInfo.description)]]
|
||||
std::optional<glm::vec3> yColor [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(ZColorInfo.description)]]
|
||||
std::optional<glm::vec3> zColor [[codegen::color()]];
|
||||
|
||||
};
|
||||
#include "renderablecartesianaxes_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableCartesianAxes::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"CartesianAxesProgram",
|
||||
"base_renderable_cartesianaxes",
|
||||
{
|
||||
{
|
||||
XColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
XColorInfo.description
|
||||
},
|
||||
{
|
||||
YColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
YColorInfo.description
|
||||
},
|
||||
{
|
||||
ZColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
ZColorInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_cartesianaxes";
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
RenderableCartesianAxes::RenderableCartesianAxes(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _program(nullptr)
|
||||
, _xColor(
|
||||
XColorInfo,
|
||||
glm::vec3(1.f, 0.f, 0.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
)
|
||||
, _yColor(
|
||||
YColorInfo,
|
||||
glm::vec3(0.f, 1.f, 0.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
)
|
||||
, _zColor(
|
||||
ZColorInfo,
|
||||
glm::vec3(0.f, 0.f, 1.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
)
|
||||
, _xColor(XColorInfo, glm::vec3(1.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _yColor(YColorInfo, glm::vec3(0.f, 1.f, 0.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _zColor(ZColorInfo, glm::vec3(0.f, 0.f, 1.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableCartesianAxes"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(XColorInfo.identifier)) {
|
||||
_xColor = dictionary.value<glm::dvec3>(XColorInfo.identifier);
|
||||
}
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
_xColor = p.xColor.value_or(_xColor);
|
||||
_xColor.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_xColor);
|
||||
|
||||
if (dictionary.hasKey(XColorInfo.identifier)) {
|
||||
_yColor = dictionary.value<glm::dvec3>(YColorInfo.identifier);
|
||||
}
|
||||
_yColor = p.yColor.value_or(_yColor);
|
||||
_yColor.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_yColor);
|
||||
|
||||
if (dictionary.hasKey(ZColorInfo.identifier)) {
|
||||
_zColor = dictionary.value<glm::dvec3>(ZColorInfo.identifier);
|
||||
}
|
||||
_zColor = p.zColor.value_or(_zColor);
|
||||
_zColor.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_zColor);
|
||||
}
|
||||
|
||||
214
modules/base/rendering/renderabledisc.cpp
Normal file
214
modules/base/rendering/renderabledisc.cpp
Normal file
@@ -0,0 +1,214 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* 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 <modules/base/rendering/renderabledisc.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char _loggerCat[] = "RenderableDisc";
|
||||
|
||||
constexpr const std::array<const char*, 4> UniformNames = {
|
||||
"modelViewProjectionTransform", "opacity", "width", "colorTexture"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"Texture",
|
||||
"Texture",
|
||||
"This value is the path to a texture on disk that contains a one-dimensional "
|
||||
"texture to be used for the color."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SizeInfo = {
|
||||
"Size",
|
||||
"Size",
|
||||
"This value specifies the outer radius of the disc in meter."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo WidthInfo = {
|
||||
"Width",
|
||||
"Width",
|
||||
"This value is used to set the width of the disc. The actual width is set "
|
||||
"based on the given size and this value should be set between 0 and 1. A value "
|
||||
"of 1 results in a full circle and 0.5 a disc with an inner radius of 0.5*size."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableDisc)]] Parameters {
|
||||
// [[codegen::verbatim(TextureInfo.description)]]
|
||||
std::filesystem::path texture;
|
||||
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
std::optional<float> size;
|
||||
|
||||
// [[codegen::verbatim(WidthInfo.description)]]
|
||||
std::optional<float> width;
|
||||
};
|
||||
#include "renderabledisc_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableDisc::Documentation() {
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_disc";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderableDisc::RenderableDisc(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _texturePath(TextureInfo)
|
||||
, _size(SizeInfo, 1.f, 0.f, 1e13f)
|
||||
, _width(WidthInfo, 0.5f, 0.f, 1.f)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
_texturePath = p.texture.string();
|
||||
_texturePath.onChange([&]() { _texture->loadFromFile(_texturePath); });
|
||||
addProperty(_texturePath);
|
||||
|
||||
_size = p.size.value_or(_size);
|
||||
setBoundingSphere(_size);
|
||||
_size.onChange([&]() { _planeIsDirty = true; });
|
||||
addProperty(_size);
|
||||
|
||||
_width = p.width.value_or(_width);
|
||||
addProperty(_width);
|
||||
|
||||
addProperty(_opacity);
|
||||
|
||||
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
|
||||
}
|
||||
|
||||
bool RenderableDisc::isReady() const {
|
||||
return _shader && _texture && _plane;
|
||||
}
|
||||
|
||||
void RenderableDisc::initialize() {
|
||||
_texture = std::make_unique<TextureComponent>();
|
||||
_texture->setFilterMode(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
|
||||
_texture->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToEdge);
|
||||
_texture->setShouldWatchFileForChanges(true);
|
||||
|
||||
_plane = std::make_unique<PlaneGeometry>(planeSize());
|
||||
}
|
||||
|
||||
void RenderableDisc::initializeGL() {
|
||||
initializeShader();
|
||||
|
||||
_texture->loadFromFile(_texturePath);
|
||||
_texture->uploadToGpu();
|
||||
|
||||
_plane->initialize();
|
||||
}
|
||||
|
||||
void RenderableDisc::deinitializeGL() {
|
||||
_plane->deinitialize();
|
||||
_plane = nullptr;
|
||||
_texture = nullptr;
|
||||
|
||||
global::renderEngine->removeRenderProgram(_shader.get());
|
||||
_shader = nullptr;
|
||||
}
|
||||
|
||||
void RenderableDisc::render(const RenderData& data, RendererTasks&) {
|
||||
_shader->activate();
|
||||
|
||||
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));
|
||||
|
||||
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
|
||||
|
||||
_shader->setUniform(
|
||||
_uniformCache.modelViewProjection,
|
||||
data.camera.projectionMatrix() * glm::mat4(modelViewTransform)
|
||||
);
|
||||
_shader->setUniform(_uniformCache.width, _width);
|
||||
_shader->setUniform(_uniformCache.opacity, _opacity);
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
_texture->bind();
|
||||
_shader->setUniform(_uniformCache.texture, unit);
|
||||
|
||||
glEnablei(GL_BLEND, 0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthMask(false);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
_plane->render();
|
||||
|
||||
_shader->deactivate();
|
||||
|
||||
// Restores GL State
|
||||
global::renderEngine->openglStateCache().resetBlendState();
|
||||
global::renderEngine->openglStateCache().resetDepthState();
|
||||
global::renderEngine->openglStateCache().resetPolygonAndClippingState();
|
||||
}
|
||||
|
||||
void RenderableDisc::update(const UpdateData&) {
|
||||
if (_shader->isDirty()) {
|
||||
_shader->rebuildFromFile();
|
||||
updateUniformLocations();
|
||||
}
|
||||
|
||||
if (_planeIsDirty) {
|
||||
_plane->updateSize(planeSize());
|
||||
_planeIsDirty = false;
|
||||
}
|
||||
|
||||
_texture->update();
|
||||
}
|
||||
|
||||
void RenderableDisc::initializeShader() {
|
||||
_shader = global::renderEngine->buildRenderProgram(
|
||||
"DiscProgram",
|
||||
absPath("${MODULE_BASE}/shaders/disc_vs.glsl"),
|
||||
absPath("${MODULE_BASE}/shaders/disc_fs.glsl")
|
||||
);
|
||||
updateUniformLocations();
|
||||
}
|
||||
|
||||
void RenderableDisc::updateUniformLocations() {
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
}
|
||||
|
||||
float RenderableDisc::planeSize() const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
81
modules/base/rendering/renderabledisc.h
Normal file
81
modules/base/rendering/renderabledisc.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_BASE___RENDERABLEDISC___H__
|
||||
#define __OPENSPACE_MODULE_BASE___RENDERABLEDISC___H__
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/texturecomponent.h>
|
||||
#include <openspace/util/planegeometry.h>
|
||||
#include <ghoul/opengl/uniformcache.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
namespace ghoul::filesystem { class File; }
|
||||
namespace ghoul::opengl { class ProgramObject; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class RenderableDisc : public Renderable {
|
||||
public:
|
||||
RenderableDisc(const ghoul::Dictionary& dictionary);
|
||||
|
||||
void initialize() override;
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data, RendererTasks& rendererTask) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
protected:
|
||||
virtual void initializeShader();
|
||||
virtual void updateUniformLocations();
|
||||
|
||||
virtual float planeSize() const;
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
properties::FloatProperty _size;
|
||||
properties::FloatProperty _width;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
|
||||
std::unique_ptr<PlaneGeometry> _plane;
|
||||
std::unique_ptr<TextureComponent> _texture;
|
||||
|
||||
private:
|
||||
UniformCache(modelViewProjection, opacity, width, texture) _uniformCache;
|
||||
|
||||
bool _planeIsDirty = false;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_BASE___RENDERABLEDISC___H__
|
||||
@@ -46,10 +46,9 @@
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "base::RenderableLabels";
|
||||
|
||||
constexpr const char* MeterUnit = "m";
|
||||
constexpr const char* KilometerUnit = "Km";
|
||||
constexpr const char* MegameterUnit = "Mm";
|
||||
@@ -176,122 +175,91 @@ namespace {
|
||||
"Fade-In/-Out ending speed.",
|
||||
"Fade-In/-Out ending speed."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableLabels)]] Parameters {
|
||||
enum class BlendMode {
|
||||
Normal,
|
||||
Additive
|
||||
};
|
||||
|
||||
// [[codegen::verbatim(BlendModeInfo.description)]]
|
||||
std::optional<BlendMode> blendMode;
|
||||
|
||||
enum class Orientation {
|
||||
ViewDirection [[codegen::key("Camera View Direction")]],
|
||||
PositionNormal [[codegen::key("Camera Position Normal")]]
|
||||
};
|
||||
|
||||
// [[codegen::verbatim(LabelOrientationOptionInfo.description)]]
|
||||
std::optional<Orientation> labelOrientationOption;
|
||||
|
||||
// [[codegen::verbatim(LabelColorInfo.description)]]
|
||||
std::optional<glm::vec3> labelColor [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(LabelTextInfo.description)]]
|
||||
std::optional<std::string> labelText;
|
||||
|
||||
// [[codegen::verbatim(FontSizeInfo.description)]]
|
||||
std::optional<float> fontSize;
|
||||
|
||||
// [[codegen::verbatim(LabelSizeInfo.description)]]
|
||||
std::optional<float> labelSize;
|
||||
|
||||
// [[codegen::verbatim(LabelMinSizeInfo.description)]]
|
||||
std::optional<float> labelMinSize;
|
||||
|
||||
// [[codegen::verbatim(LabelMaxSizeInfo.description)]]
|
||||
std::optional<float> labelMaxSize;
|
||||
|
||||
// [[codegen::verbatim(EnableFadingEffectInfo.description)]]
|
||||
std::optional<bool> enableFading;
|
||||
|
||||
// [[codegen::verbatim(PixelSizeControlInfo.description)]]
|
||||
std::optional<bool> enablePixelControl;
|
||||
|
||||
// [[codegen::verbatim(TransformationMatrixInfo.description)]]
|
||||
std::optional<glm::dmat4x4> transformationMatrix;
|
||||
|
||||
enum class Unit {
|
||||
Meter [[codegen::key("m")]],
|
||||
Kilometer [[codegen::key("Km")]],
|
||||
Megameter [[codegen::key("Mm")]],
|
||||
Gigameter [[codegen::key("Gm")]],
|
||||
Terameter [[codegen::key("Tm")]],
|
||||
Petameter [[codegen::key("Pm")]],
|
||||
AstronomicalUnit [[codegen::key("au")]],
|
||||
Parsec [[codegen::key("pc")]],
|
||||
KiloParsec [[codegen::key("Kpc")]],
|
||||
MegaParsec [[codgen::key("Mpc")]],
|
||||
GigaParsec [[codegen::key("Gpc")]],
|
||||
GigaLightyear [[codegen::key("Gly")]]
|
||||
};
|
||||
|
||||
// [[codegen::verbatim(FadeStartUnitOptionInfo.description)]]
|
||||
std::optional<Unit> fadeStartUnit;
|
||||
|
||||
// [[codegen::verbatim(FadeEndUnitOptionInfo.description)]]
|
||||
std::optional<Unit> fadeEndUnit;
|
||||
|
||||
// [[codegen::verbatim(FadeStartDistInfo.description)]]
|
||||
std::optional<float> fadeStartDistance;
|
||||
|
||||
// [[codegen::verbatim(FadeEndDistInfo.description)]]
|
||||
std::optional<float> fadeEndDistance;
|
||||
|
||||
// [[codegen::verbatim(FadeStartSpeedInfo.description)]]
|
||||
std::optional<float> fadeStartSpeed;
|
||||
|
||||
// [[codegen::verbatim(FadeEndSpeedInfo.description)]]
|
||||
std::optional<float> fadeEndSpeed;
|
||||
};
|
||||
#include "renderablelabels_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableLabels::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"Renderable Labels",
|
||||
"base_renderable_labels",
|
||||
{
|
||||
{
|
||||
BlendModeInfo.identifier,
|
||||
new StringInListVerifier({ "Normal", "Additive" }),
|
||||
Optional::Yes,
|
||||
BlendModeInfo.description, // + " The default value is 'Normal'.",
|
||||
},
|
||||
{
|
||||
LabelOrientationOptionInfo.identifier,
|
||||
new StringInListVerifier(
|
||||
{ "Camera View Direction", "Camera Position Normal" }
|
||||
),
|
||||
Optional::Yes,
|
||||
LabelOrientationOptionInfo.description,
|
||||
},
|
||||
{
|
||||
LabelColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
LabelColorInfo.description,
|
||||
},
|
||||
{
|
||||
LabelTextInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
LabelTextInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
},
|
||||
{
|
||||
LabelSizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LabelSizeInfo.description
|
||||
},
|
||||
{
|
||||
LabelMinSizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LabelMinSizeInfo.description
|
||||
},
|
||||
{
|
||||
LabelMaxSizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LabelMaxSizeInfo.description
|
||||
},
|
||||
{
|
||||
EnableFadingEffectInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
EnableFadingEffectInfo.description
|
||||
},
|
||||
{
|
||||
PixelSizeControlInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
PixelSizeControlInfo.description
|
||||
},
|
||||
{
|
||||
FadeStartUnitOptionInfo.identifier,
|
||||
new StringInListVerifier(
|
||||
{ "m", "Km", "Mm", "Gm", "au", "Tm", "Pm", "pc", "Kpc", "Mpc",
|
||||
"Gpc", "Gly"}
|
||||
),
|
||||
Optional::Yes,
|
||||
FadeStartUnitOptionInfo.description,
|
||||
},
|
||||
{
|
||||
FadeEndUnitOptionInfo.identifier,
|
||||
new StringInListVerifier(
|
||||
{"m", "Km", "Mm", "Gm", "au", "Tm", "Pm", "pc", "Kpc", "Mpc",
|
||||
"Gpc", "Gly"}
|
||||
),
|
||||
Optional::Yes,
|
||||
FadeEndUnitOptionInfo.description,
|
||||
},
|
||||
{
|
||||
FadeStartDistInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FadeStartDistInfo.description
|
||||
},
|
||||
{
|
||||
FadeEndDistInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FadeEndDistInfo.description
|
||||
},
|
||||
{
|
||||
FadeStartSpeedInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FadeStartSpeedInfo.description
|
||||
},
|
||||
{
|
||||
FadeEndSpeedInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FadeEndSpeedInfo.description
|
||||
},
|
||||
}
|
||||
};
|
||||
return codegen::doc<Parameters>();
|
||||
}
|
||||
|
||||
RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
@@ -327,11 +295,7 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
properties::OptionProperty::DisplayType::Dropdown
|
||||
)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableLabels"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
@@ -353,13 +317,14 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
});
|
||||
|
||||
if (dictionary.hasKey(BlendModeInfo.identifier)) {
|
||||
const std::string v = dictionary.value<std::string>(BlendModeInfo.identifier);
|
||||
if (v == "Normal") {
|
||||
_blendMode = BlendModeNormal;
|
||||
}
|
||||
else if (v == "Additive") {
|
||||
_blendMode = BlendModeAdditive;
|
||||
if (p.blendMode.has_value()) {
|
||||
switch (*p.blendMode) {
|
||||
case Parameters::BlendMode::Normal:
|
||||
_blendMode = BlendModeNormal;
|
||||
break;
|
||||
case Parameters::BlendMode::Additive:
|
||||
_blendMode = BlendModeAdditive;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,35 +334,26 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
_labelOrientationOption.addOption(NormalDirection, "Camera Position Normal");
|
||||
|
||||
_labelOrientationOption = NormalDirection;
|
||||
if (dictionary.hasValue<std::string>(LabelOrientationOptionInfo.identifier)) {
|
||||
const std::string o = dictionary.value<std::string>(
|
||||
LabelOrientationOptionInfo.identifier
|
||||
);
|
||||
|
||||
if (o == "Camera View Direction") {
|
||||
_labelOrientationOption = ViewDirection;
|
||||
}
|
||||
else if (o == "Camera Position Normal") {
|
||||
_labelOrientationOption = NormalDirection;
|
||||
if (p.labelOrientationOption.has_value()) {
|
||||
switch (*p.labelOrientationOption) {
|
||||
case Parameters::Orientation::ViewDirection:
|
||||
_labelOrientationOption = ViewDirection;
|
||||
break;
|
||||
case Parameters::Orientation::PositionNormal:
|
||||
_labelOrientationOption = NormalDirection;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(LabelTextInfo.identifier)) {
|
||||
_labelText = dictionary.value<std::string>(LabelTextInfo.identifier);
|
||||
}
|
||||
addProperty(_labelText);
|
||||
|
||||
addProperty(_labelOrientationOption);
|
||||
|
||||
_labelText = p.labelText.value_or(_labelText);
|
||||
addProperty(_labelText);
|
||||
|
||||
_labelColor = p.labelColor.value_or(_labelColor);
|
||||
_labelColor.setViewOption(properties::Property::ViewOptions::Color);
|
||||
if (dictionary.hasKey(LabelColorInfo.identifier)) {
|
||||
_labelColor = dictionary.value<glm::dvec3>(LabelColorInfo.identifier);
|
||||
}
|
||||
addProperty(_labelColor);
|
||||
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
_fontSize = p.fontSize.value_or(_fontSize);
|
||||
_fontSize.onChange([&]() {
|
||||
_font = global::fontManager->font(
|
||||
"Mono",
|
||||
@@ -408,49 +364,28 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
if (dictionary.hasKey(LabelSizeInfo.identifier)) {
|
||||
_labelSize = static_cast<float>(
|
||||
dictionary.value<double>(LabelSizeInfo.identifier)
|
||||
);
|
||||
}
|
||||
_labelSize = p.labelSize.value_or(_labelSize);
|
||||
addProperty(_labelSize);
|
||||
|
||||
if (dictionary.hasKey(LabelMinSizeInfo.identifier)) {
|
||||
_labelMinSize = static_cast<float>(
|
||||
dictionary.value<double>(LabelMinSizeInfo.identifier)
|
||||
);
|
||||
}
|
||||
_labelMinSize = p.labelMinSize.value_or(_labelMinSize);
|
||||
addProperty(_labelMinSize);
|
||||
|
||||
if (dictionary.hasKey(LabelMaxSizeInfo.identifier)) {
|
||||
_labelMaxSize = static_cast<float>(
|
||||
dictionary.value<double>(LabelMaxSizeInfo.identifier)
|
||||
);
|
||||
}
|
||||
_labelMaxSize = p.labelMaxSize.value_or(_labelMaxSize);
|
||||
addProperty(_labelMaxSize);
|
||||
|
||||
if (dictionary.hasKey(TransformationMatrixInfo.identifier)) {
|
||||
_transformationMatrix = dictionary.value<glm::dmat4>(
|
||||
TransformationMatrixInfo.identifier
|
||||
);
|
||||
}
|
||||
_transformationMatrix = p.transformationMatrix.value_or(_transformationMatrix);
|
||||
|
||||
if (dictionary.hasKey(PixelSizeControlInfo.identifier)) {
|
||||
_pixelSizeControl = dictionary.value<bool>(PixelSizeControlInfo.identifier);
|
||||
_pixelSizeControl = p.enablePixelControl.value_or(_pixelSizeControl);
|
||||
if (_pixelSizeControl) {
|
||||
// @TODO (abock, 2021-01-28) I don't know why we only add the property if the
|
||||
// pixel control is enabled, but I think this is an error
|
||||
addProperty(_pixelSizeControl);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(EnableFadingEffectInfo.identifier)) {
|
||||
_enableFadingEffect = dictionary.value<bool>(EnableFadingEffectInfo.identifier);
|
||||
}
|
||||
_enableFadingEffect = p.enableFading.value_or(_enableFadingEffect);
|
||||
addProperty(_enableFadingEffect);
|
||||
|
||||
if (dictionary.hasKey(FadeStartDistInfo.identifier)) {
|
||||
_fadeStartDistance = static_cast<float>(
|
||||
dictionary.value<double>(FadeStartDistInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
_fadeStartDistance = p.fadeStartDistance.value_or(_fadeStartDistance);
|
||||
addProperty(_fadeStartDistance);
|
||||
|
||||
_fadeStartUnitOption.addOption(Meter, MeterUnit);
|
||||
@@ -466,72 +401,56 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
_fadeStartUnitOption.addOption(Gigaparsec, GigaparsecUnit);
|
||||
_fadeStartUnitOption.addOption(GigalightYears, GigalightyearUnit);
|
||||
|
||||
_fadeStartUnitOption = AU;
|
||||
|
||||
if (dictionary.hasKey(FadeStartUnitOptionInfo.identifier)) {
|
||||
std::string unit = dictionary.value<std::string>(
|
||||
FadeStartUnitOptionInfo.identifier
|
||||
);
|
||||
if (unit == MeterUnit) {
|
||||
_fadeStartUnitOption = Meter;
|
||||
}
|
||||
else if (unit == KilometerUnit) {
|
||||
_fadeStartUnitOption = Kilometer;
|
||||
}
|
||||
else if (unit == MegameterUnit) {
|
||||
_fadeStartUnitOption = Megameter;
|
||||
}
|
||||
else if (unit == GigameterUnit) {
|
||||
_fadeStartUnitOption = Gigameter;
|
||||
}
|
||||
else if (unit == AstronomicalUnit) {
|
||||
_fadeStartUnitOption = AU;
|
||||
}
|
||||
else if (unit == TerameterUnit) {
|
||||
_fadeStartUnitOption = Terameter;
|
||||
}
|
||||
else if (unit == PetameterUnit) {
|
||||
_fadeStartUnitOption = Petameter;
|
||||
}
|
||||
else if (unit == ParsecUnit) {
|
||||
_fadeStartUnitOption = Parsec;
|
||||
}
|
||||
else if (unit == KiloparsecUnit) {
|
||||
_fadeStartUnitOption = Kiloparsec;
|
||||
}
|
||||
else if (unit == MegaparsecUnit) {
|
||||
_fadeStartUnitOption = Megaparsec;
|
||||
}
|
||||
else if (unit == GigaparsecUnit) {
|
||||
_fadeStartUnitOption = Gigaparsec;
|
||||
}
|
||||
else if (unit == GigalightyearUnit) {
|
||||
_fadeStartUnitOption = GigalightYears;
|
||||
}
|
||||
else {
|
||||
LWARNING(
|
||||
"No unit given for RenderableLabels. Using kilometer as units."
|
||||
);
|
||||
_fadeStartUnitOption = Kilometer;
|
||||
if (p.fadeStartUnit.has_value()) {
|
||||
switch (*p.fadeStartUnit) {
|
||||
case Parameters::Unit::Meter:
|
||||
_fadeStartUnitOption = Meter;
|
||||
break;
|
||||
case Parameters::Unit::Kilometer:
|
||||
_fadeStartUnitOption = Kilometer;
|
||||
break;
|
||||
case Parameters::Unit::Megameter:
|
||||
_fadeStartUnitOption = Megameter;
|
||||
break;
|
||||
case Parameters::Unit::Gigameter:
|
||||
_fadeStartUnitOption = Gigameter;
|
||||
break;
|
||||
case Parameters::Unit::Terameter:
|
||||
_fadeStartUnitOption = Terameter;
|
||||
break;
|
||||
case Parameters::Unit::Petameter:
|
||||
_fadeStartUnitOption = Petameter;
|
||||
break;
|
||||
case Parameters::Unit::AstronomicalUnit:
|
||||
_fadeStartUnitOption = AU;
|
||||
break;
|
||||
case Parameters::Unit::Parsec:
|
||||
_fadeStartUnitOption = Parsec;
|
||||
break;
|
||||
case Parameters::Unit::KiloParsec:
|
||||
_fadeStartUnitOption = Kiloparsec;
|
||||
break;
|
||||
case Parameters::Unit::MegaParsec:
|
||||
_fadeStartUnitOption = Megaparsec;
|
||||
break;
|
||||
case Parameters::Unit::GigaParsec:
|
||||
_fadeStartUnitOption = Gigaparsec;
|
||||
break;
|
||||
case Parameters::Unit::GigaLightyear:
|
||||
_fadeStartUnitOption = GigalightYears;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
_fadeStartUnitOption = AU;
|
||||
}
|
||||
addProperty(_fadeStartUnitOption);
|
||||
|
||||
if (dictionary.hasKey(FadeStartSpeedInfo.identifier)) {
|
||||
_fadeStartSpeed = static_cast<float>(
|
||||
dictionary.value<double>(FadeStartSpeedInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
_fadeStartSpeed = p.fadeStartSpeed.value_or(_fadeStartSpeed);
|
||||
addProperty(_fadeStartSpeed);
|
||||
|
||||
if (dictionary.hasKey(FadeEndDistInfo.identifier)) {
|
||||
_fadeEndDistance = static_cast<float>(
|
||||
dictionary.value<double>(FadeEndDistInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
_fadeEndDistance = p.fadeEndDistance.value_or(_fadeEndDistance);
|
||||
addProperty(_fadeEndDistance);
|
||||
|
||||
_fadeEndUnitOption.addOption(Meter, MeterUnit);
|
||||
@@ -547,64 +466,53 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
_fadeEndUnitOption.addOption(Gigaparsec, GigaparsecUnit);
|
||||
_fadeEndUnitOption.addOption(GigalightYears, GigalightyearUnit);
|
||||
|
||||
_fadeEndUnitOption = AU;
|
||||
|
||||
if (dictionary.hasKey(FadeEndUnitOptionInfo.identifier)) {
|
||||
std::string unit = dictionary.value<std::string>(
|
||||
FadeEndUnitOptionInfo.identifier
|
||||
);
|
||||
if (unit == MeterUnit) {
|
||||
_fadeEndUnitOption = Meter;
|
||||
}
|
||||
else if (unit == KilometerUnit) {
|
||||
_fadeEndUnitOption = Kilometer;
|
||||
}
|
||||
else if (unit == MegameterUnit) {
|
||||
_fadeEndUnitOption = Megameter;
|
||||
}
|
||||
else if (unit == GigameterUnit) {
|
||||
_fadeEndUnitOption = Gigameter;
|
||||
}
|
||||
else if (unit == AstronomicalUnit) {
|
||||
_fadeEndUnitOption = AU;
|
||||
}
|
||||
else if (unit == TerameterUnit) {
|
||||
_fadeEndUnitOption = Terameter;
|
||||
}
|
||||
else if (unit == PetameterUnit) {
|
||||
_fadeEndUnitOption = Petameter;
|
||||
}
|
||||
else if (unit == ParsecUnit) {
|
||||
_fadeEndUnitOption = Parsec;
|
||||
}
|
||||
else if (unit == KiloparsecUnit) {
|
||||
_fadeEndUnitOption = Kiloparsec;
|
||||
}
|
||||
else if (unit == MegaparsecUnit) {
|
||||
_fadeEndUnitOption = Megaparsec;
|
||||
}
|
||||
else if (unit == GigaparsecUnit) {
|
||||
_fadeEndUnitOption = Gigaparsec;
|
||||
}
|
||||
else if (unit == GigalightyearUnit) {
|
||||
_fadeEndUnitOption = GigalightYears;
|
||||
}
|
||||
else {
|
||||
LWARNING(
|
||||
"No unit given for RenderableLabels. Using kilometer as units."
|
||||
);
|
||||
_fadeEndUnitOption = Kilometer;
|
||||
if (p.fadeEndUnit.has_value()) {
|
||||
switch (*p.fadeEndUnit) {
|
||||
case Parameters::Unit::Meter:
|
||||
_fadeStartUnitOption = Meter;
|
||||
break;
|
||||
case Parameters::Unit::Kilometer:
|
||||
_fadeStartUnitOption = Kilometer;
|
||||
break;
|
||||
case Parameters::Unit::Megameter:
|
||||
_fadeStartUnitOption = Megameter;
|
||||
break;
|
||||
case Parameters::Unit::Gigameter:
|
||||
_fadeStartUnitOption = Gigameter;
|
||||
break;
|
||||
case Parameters::Unit::Terameter:
|
||||
_fadeStartUnitOption = Terameter;
|
||||
break;
|
||||
case Parameters::Unit::Petameter:
|
||||
_fadeStartUnitOption = Petameter;
|
||||
break;
|
||||
case Parameters::Unit::AstronomicalUnit:
|
||||
_fadeStartUnitOption = AU;
|
||||
break;
|
||||
case Parameters::Unit::Parsec:
|
||||
_fadeStartUnitOption = Parsec;
|
||||
break;
|
||||
case Parameters::Unit::KiloParsec:
|
||||
_fadeEndUnitOption = Kiloparsec;
|
||||
break;
|
||||
case Parameters::Unit::MegaParsec:
|
||||
_fadeEndUnitOption = Megaparsec;
|
||||
break;
|
||||
case Parameters::Unit::GigaParsec:
|
||||
_fadeEndUnitOption = Gigaparsec;
|
||||
break;
|
||||
case Parameters::Unit::GigaLightyear:
|
||||
_fadeEndUnitOption = GigalightYears;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
_fadeEndUnitOption = AU;
|
||||
}
|
||||
addProperty(_fadeEndUnitOption);
|
||||
|
||||
if (dictionary.hasKey(FadeEndSpeedInfo.identifier)) {
|
||||
_fadeEndSpeed = static_cast<float>(
|
||||
dictionary.value<double>(FadeEndSpeedInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
_fadeEndSpeed = p.fadeEndSpeed.value_or(_fadeEndSpeed);
|
||||
addProperty(_fadeEndSpeed);
|
||||
}
|
||||
|
||||
|
||||
@@ -500,13 +500,11 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
);
|
||||
_program->setUniform(
|
||||
_uniformCache.lightIntensities,
|
||||
_lightIntensitiesBuffer.data(),
|
||||
nLightSources
|
||||
_lightIntensitiesBuffer
|
||||
);
|
||||
_program->setUniform(
|
||||
_uniformCache.lightDirectionsViewSpace,
|
||||
_lightDirectionsViewSpaceBuffer.data(),
|
||||
nLightSources
|
||||
_lightDirectionsViewSpaceBuffer
|
||||
);
|
||||
_program->setUniform(
|
||||
_uniformCache.modelViewTransform,
|
||||
|
||||
@@ -84,42 +84,29 @@ namespace {
|
||||
glm::dvec3 diffPos = worldPos - anchorNodePos;
|
||||
return diffPos;
|
||||
}
|
||||
|
||||
struct [[codegen::Dictionary(RenderableNodeLine)]] Parameters {
|
||||
// [[codegen::verbatim(StartNodeInfo.description)]]
|
||||
std::optional<std::string> startNode;
|
||||
|
||||
// [[codegen::verbatim(EndNodeInfo.description)]]
|
||||
std::optional<std::string> endNode;
|
||||
|
||||
// [[codegen::verbatim(LineColorInfo.description)]]
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
};
|
||||
#include "renderablenodeline_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableNodeLine::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"Renderable Node Line",
|
||||
"base_renderable_renderablenodeline",
|
||||
{
|
||||
{
|
||||
StartNodeInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
StartNodeInfo.description
|
||||
},
|
||||
{
|
||||
EndNodeInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
EndNodeInfo.description
|
||||
},
|
||||
{
|
||||
LineColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
LineColorInfo.description
|
||||
},
|
||||
{
|
||||
LineWidthInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LineWidthInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_renderablenodeline";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
|
||||
@@ -129,36 +116,22 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
|
||||
, _lineColor(LineColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _lineWidth(LineWidthInfo, 2.f, 1.f, 20.f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableNodeLine"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(StartNodeInfo.identifier)) {
|
||||
_start = dictionary.value<std::string>(StartNodeInfo.identifier);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(EndNodeInfo.identifier)) {
|
||||
_end = dictionary.value<std::string>(EndNodeInfo.identifier);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(LineColorInfo.identifier)) {
|
||||
_lineColor = dictionary.value<glm::dvec3>(LineColorInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKey(LineWidthInfo.identifier)) {
|
||||
_lineWidth = static_cast<float>(
|
||||
dictionary.value<double>(LineWidthInfo.identifier)
|
||||
);
|
||||
}
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
_start = p.startNode.value_or(_start);
|
||||
_start.onChange([&]() { validateNodes(); });
|
||||
_end.onChange([&]() { validateNodes(); });
|
||||
|
||||
addProperty(_start);
|
||||
|
||||
_end = p.endNode.value_or(_end);
|
||||
_end.onChange([&]() { validateNodes(); });
|
||||
addProperty(_end);
|
||||
|
||||
_lineColor = p.color.value_or(_lineColor);
|
||||
addProperty(_lineColor);
|
||||
|
||||
_lineWidth = p.lineWidth.value_or(_lineWidth);
|
||||
addProperty(_lineWidth);
|
||||
|
||||
addProperty(_opacity);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "Plane";
|
||||
@@ -68,36 +69,40 @@ namespace {
|
||||
"Blending Mode",
|
||||
"This determines the blending mode that is applied to this plane."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MultiplyColorInfo = {
|
||||
"MultiplyColor",
|
||||
"Multiply Color",
|
||||
"If set, the plane's texture is multiplied with this color. "
|
||||
"Useful for applying a color grayscale images."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderablePlane)]] Parameters {
|
||||
// [[codegen::verbatim(BillboardInfo.description)]]
|
||||
std::optional<bool> billboard;
|
||||
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
float size;
|
||||
|
||||
enum class BlendMode {
|
||||
Normal,
|
||||
Additive
|
||||
};
|
||||
// [[codegen::verbatim(BlendModeInfo.description)]]
|
||||
std::optional<BlendMode> blendMode;
|
||||
|
||||
// [[codegen::verbatim(BlendModeInfo.description)]]
|
||||
std::optional<glm::vec3> multiplyColor [[codegen::color()]];
|
||||
};
|
||||
#include "renderableplane_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderablePlane::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"Renderable Plane",
|
||||
"base_renderable_plane",
|
||||
{
|
||||
{
|
||||
SizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::No,
|
||||
SizeInfo.description
|
||||
},
|
||||
{
|
||||
BillboardInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
BillboardInfo.description
|
||||
},
|
||||
{
|
||||
BlendModeInfo.identifier,
|
||||
new StringInListVerifier({ "Normal", "Additive" }),
|
||||
Optional::Yes,
|
||||
BlendModeInfo.description, // + " The default value is 'Normal'.",
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_plane";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
|
||||
@@ -105,21 +110,15 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
|
||||
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _billboard(BillboardInfo, false)
|
||||
, _size(SizeInfo, 10.f, 0.f, 1e25f)
|
||||
, _multiplyColor(MultiplyColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderablePlane"
|
||||
);
|
||||
Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
|
||||
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
|
||||
|
||||
if (dictionary.hasKey(BillboardInfo.identifier)) {
|
||||
_billboard = dictionary.value<bool>(BillboardInfo.identifier);
|
||||
}
|
||||
_size = p.size;
|
||||
_billboard = p.billboard.value_or(_billboard);
|
||||
|
||||
_blendMode.addOptions({
|
||||
{ BlendModeNormal, "Normal" },
|
||||
@@ -144,21 +143,24 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
});
|
||||
|
||||
if (dictionary.hasKey(BlendModeInfo.identifier)) {
|
||||
const std::string v = dictionary.value<std::string>(BlendModeInfo.identifier);
|
||||
if (v == "Normal") {
|
||||
if (p.blendMode.has_value()) {
|
||||
if (*p.blendMode == Parameters::BlendMode::Normal) {
|
||||
_blendMode = BlendModeNormal;
|
||||
}
|
||||
else if (v == "Additive") {
|
||||
else if (*p.blendMode == Parameters::BlendMode::Additive) {
|
||||
_blendMode = BlendModeAdditive;
|
||||
}
|
||||
}
|
||||
|
||||
_multiplyColor = p.multiplyColor.value_or(_multiplyColor);
|
||||
|
||||
addProperty(_billboard);
|
||||
|
||||
addProperty(_size);
|
||||
_size.onChange([this](){ _planeIsDirty = true; });
|
||||
|
||||
addProperty(_multiplyColor);
|
||||
|
||||
setBoundingSphere(_size);
|
||||
}
|
||||
|
||||
@@ -251,6 +253,8 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) {
|
||||
|
||||
_shader->setUniform("texture1", unit);
|
||||
|
||||
_shader->setUniform("multiplyColor", _multiplyColor);
|
||||
|
||||
bool usingFramebufferRenderer = global::renderEngine->rendererImplementation() ==
|
||||
RenderEngine::RendererImplementation::Framebuffer;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
namespace ghoul::filesystem { class File; }
|
||||
@@ -75,6 +76,7 @@ private:
|
||||
|
||||
properties::BoolProperty _billboard;
|
||||
properties::FloatProperty _size;
|
||||
properties::Vec3Property _multiplyColor;
|
||||
|
||||
ghoul::opengl::ProgramObject* _shader = nullptr;
|
||||
|
||||
|
||||
@@ -35,10 +35,9 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyLazyLoading = "LazyLoading";
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"Texture",
|
||||
"Texture",
|
||||
@@ -47,105 +46,104 @@ namespace {
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo RenderableTypeInfo = {
|
||||
"RenderableType",
|
||||
"RenderableType",
|
||||
"This value specifies if the plane should be rendered in the Background,"
|
||||
"Opaque, Transparent, or Overlay rendering step."
|
||||
"RenderableType",
|
||||
"RenderableType",
|
||||
"This value specifies if the plane should be rendered in the Background,"
|
||||
"Opaque, Transparent, or Overlay rendering step."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderablePlaneImageLocal)]] Parameters {
|
||||
// [[codegen::verbatim(TextureInfo.description)]]
|
||||
std::string texture;
|
||||
|
||||
enum class RenderType {
|
||||
Background,
|
||||
Opaque,
|
||||
PreDeferredTransparency,
|
||||
PostDeferredTransparency,
|
||||
Overlay
|
||||
};
|
||||
|
||||
// [[codegen::verbatim(RenderableTypeInfo.description)]]
|
||||
std::optional<RenderType> renderType [[codegen::key("RenderableType")]];
|
||||
|
||||
// If this value is set to 'true', the image for this plane will not be loaded at
|
||||
// startup but rather when image is shown for the first time. Additionally, if the
|
||||
// plane is hidden, the image will automatically be unloaded
|
||||
std::optional<bool> lazyLoading;
|
||||
};
|
||||
#include "renderableplaneimagelocal_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderablePlaneImageLocal::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"Renderable Plane Image Local",
|
||||
"base_renderable_plane_image_local",
|
||||
{
|
||||
{
|
||||
TextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::No,
|
||||
TextureInfo.description
|
||||
},
|
||||
{
|
||||
RenderableTypeInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
RenderableTypeInfo.description
|
||||
},
|
||||
{
|
||||
KeyLazyLoading,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
"If this value is set to 'true', the image for this plane will not be "
|
||||
"loaded at startup but rather when image is shown for the first time. "
|
||||
"Additionally, if the plane is hidden, the image will automatically be "
|
||||
"unloaded"
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_plane_image_local";
|
||||
|
||||
// @TODO cleanup
|
||||
// Insert the parents documentation entries until we have a verifier that can deal
|
||||
// with class hierarchy
|
||||
documentation::Documentation parentDoc = RenderablePlane::Documentation();
|
||||
doc.entries.insert(
|
||||
doc.entries.end(),
|
||||
parentDoc.entries.begin(),
|
||||
parentDoc.entries.end()
|
||||
);
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderablePlaneImageLocal::RenderablePlaneImageLocal(const ghoul::Dictionary& dictionary)
|
||||
: RenderablePlane(dictionary)
|
||||
, _texturePath(TextureInfo)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderablePlaneImageLocal"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_blendMode);
|
||||
|
||||
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
|
||||
_texturePath = absPath(p.texture);
|
||||
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath);
|
||||
|
||||
addProperty(_texturePath);
|
||||
_texturePath.onChange([this]() {loadTexture(); });
|
||||
_texturePath.onChange([this]() { loadTexture(); });
|
||||
_textureFile->setCallback(
|
||||
[this](const ghoul::filesystem::File&) { _textureIsDirty = true; }
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(RenderableTypeInfo.identifier)) {
|
||||
std::string renderType = dictionary.value<std::string>(
|
||||
RenderableTypeInfo.identifier
|
||||
);
|
||||
if (renderType == "Background") {
|
||||
setRenderBin(Renderable::RenderBin::Background);
|
||||
}
|
||||
else if (renderType == "Opaque") {
|
||||
setRenderBin(Renderable::RenderBin::Opaque);
|
||||
}
|
||||
else if (renderType == "PreDeferredTransparent") {
|
||||
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
|
||||
}
|
||||
else if (renderType == "PostDeferredTransparent") {
|
||||
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
|
||||
}
|
||||
else if (renderType == "Overlay") {
|
||||
setRenderBin(Renderable::RenderBin::Overlay);
|
||||
if (p.renderType.has_value()) {
|
||||
switch (*p.renderType) {
|
||||
case Parameters::RenderType::Background:
|
||||
setRenderBin(Renderable::RenderBin::Background);
|
||||
break;
|
||||
case Parameters::RenderType::Opaque:
|
||||
setRenderBin(Renderable::RenderBin::Opaque);
|
||||
break;
|
||||
case Parameters::RenderType::PreDeferredTransparency:
|
||||
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
|
||||
break;
|
||||
case Parameters::RenderType::PostDeferredTransparency:
|
||||
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
|
||||
break;
|
||||
case Parameters::RenderType::Overlay:
|
||||
setRenderBin(Renderable::RenderBin::Overlay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
setRenderBin(Renderable::RenderBin::Opaque);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(KeyLazyLoading)) {
|
||||
_isLoadingLazily = dictionary.value<bool>(KeyLazyLoading);
|
||||
|
||||
if (_isLoadingLazily) {
|
||||
_enabled.onChange([this]() {
|
||||
if (!_enabled) {
|
||||
BaseModule::TextureManager.release(_texture);
|
||||
_texture = nullptr;
|
||||
}
|
||||
if (_enabled) {
|
||||
_textureIsDirty = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
_isLoadingLazily = p.lazyLoading.value_or(_isLoadingLazily);
|
||||
if (_isLoadingLazily) {
|
||||
_enabled.onChange([this]() {
|
||||
if (!_enabled) {
|
||||
BaseModule::TextureManager.release(_texture);
|
||||
_texture = nullptr;
|
||||
}
|
||||
if (_enabled) {
|
||||
_textureIsDirty = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,24 +41,30 @@ namespace {
|
||||
"this value is changed, the image at the new path will automatically be loaded "
|
||||
"and displayed."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderablePlaneImageOnline)]] Parameters {
|
||||
// [[codegen::verbatim(TextureInfo.description)]]
|
||||
std::string url [[codegen::key("URL")]];
|
||||
};
|
||||
#include "renderableplaneimageonline_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderablePlaneImageOnline::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"Renderable Plane Image Online",
|
||||
"base_renderable_plane_image_online",
|
||||
{
|
||||
{
|
||||
TextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::No,
|
||||
TextureInfo.description,
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_plane_image_online";
|
||||
|
||||
// @TODO cleanup
|
||||
// Insert the parents documentation entries until we have a verifier that can deal
|
||||
// with class hierarchy
|
||||
documentation::Documentation parentDoc = RenderablePlane::Documentation();
|
||||
doc.entries.insert(
|
||||
doc.entries.end(),
|
||||
parentDoc.entries.begin(),
|
||||
parentDoc.entries.end()
|
||||
);
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderablePlaneImageOnline::RenderablePlaneImageOnline(
|
||||
@@ -66,20 +72,12 @@ RenderablePlaneImageOnline::RenderablePlaneImageOnline(
|
||||
: RenderablePlane(dictionary)
|
||||
, _texturePath(TextureInfo)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderablePlaneImageOnline"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
_texturePath.onChange([this]() { _textureIsDirty = true; });
|
||||
addProperty(_texturePath);
|
||||
|
||||
std::string texturePath;
|
||||
if (dictionary.hasKey(TextureInfo.identifier)) {
|
||||
_texturePath = dictionary.value<std::string>(TextureInfo.identifier);
|
||||
}
|
||||
|
||||
_texturePath = p.url;
|
||||
addProperty(_texturePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "Sphere";
|
||||
@@ -117,81 +118,55 @@ namespace {
|
||||
"Sets the current sphere rendering as a background rendering type",
|
||||
"Enables/Disables background rendering."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableSphere)]] Parameters {
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
float size;
|
||||
|
||||
// [[codegen::verbatim(SegmentsInfo.description)]]
|
||||
int segments;
|
||||
|
||||
// [[codegen::verbatim(TextureInfo.description)]]
|
||||
std::string texture;
|
||||
|
||||
enum class Orientation {
|
||||
Outside,
|
||||
Inside,
|
||||
Both
|
||||
};
|
||||
|
||||
// [[codegen::verbatim(OrientationInfo.description)]]
|
||||
std::optional<Orientation> orientation;
|
||||
|
||||
// [[codegen::verbatim(UseAdditiveBlendingInfo.description)]]
|
||||
std::optional<bool> useAdditiveBlending;
|
||||
|
||||
// [[codegen::verbatim(MirrorTextureInfo.description)]]
|
||||
std::optional<bool> mirrorTexture;
|
||||
|
||||
// [[codegen::verbatim(FadeOutThresholdInfo.description)]]
|
||||
std::optional<float> fadeOutThreshold [[codegen::inrange(0.0, 1.0)]];
|
||||
|
||||
// [[codegen::verbatim(FadeInThresholdInfo.description)]]
|
||||
std::optional<float> fadeInThreshold;
|
||||
|
||||
// [[codegen::verbatim(DisableFadeInOutInfo.description)]]
|
||||
std::optional<bool> disableFadeInOut;
|
||||
|
||||
// [[codegen::verbatim(BackgroundInfo.description)]]
|
||||
std::optional<bool> background;
|
||||
};
|
||||
#include "renderablesphere_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableSphere::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"RenderableSphere",
|
||||
"base_renderable_sphere",
|
||||
{
|
||||
{
|
||||
SizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::No,
|
||||
SizeInfo.description
|
||||
},
|
||||
{
|
||||
SegmentsInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::No,
|
||||
SegmentsInfo.description
|
||||
},
|
||||
{
|
||||
TextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::No,
|
||||
TextureInfo.description
|
||||
},
|
||||
{
|
||||
OrientationInfo.identifier,
|
||||
new StringInListVerifier({ "Inside", "Outside", "Both" }),
|
||||
Optional::Yes,
|
||||
OrientationInfo.description
|
||||
},
|
||||
{
|
||||
UseAdditiveBlendingInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
UseAdditiveBlendingInfo.description
|
||||
},
|
||||
{
|
||||
MirrorTextureInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
MirrorTextureInfo.description
|
||||
},
|
||||
{
|
||||
FadeOutThresholdInfo.identifier,
|
||||
new DoubleInRangeVerifier(0.0, 1.0),
|
||||
Optional::Yes,
|
||||
FadeOutThresholdInfo.description
|
||||
},
|
||||
{
|
||||
FadeInThresholdInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FadeInThresholdInfo.description
|
||||
},
|
||||
{
|
||||
DisableFadeInOutInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
DisableFadeInOutInfo.description
|
||||
},
|
||||
{
|
||||
BackgroundInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
BackgroundInfo.description
|
||||
},
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_sphere";
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _texturePath(TextureInfo)
|
||||
@@ -205,18 +180,14 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
|
||||
, _fadeInThreshold(FadeInThresholdInfo, -1.f, 0.f, 1.f)
|
||||
, _fadeOutThreshold(FadeOutThresholdInfo, -1.f, 0.f, 1.f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableSphere"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
|
||||
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
|
||||
_segments = static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
|
||||
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
|
||||
_size = p.size;
|
||||
_segments = p.segments;
|
||||
_texturePath = p.texture;
|
||||
|
||||
_orientation.addOptions({
|
||||
{ static_cast<int>(Orientation::Outside), "Outside" },
|
||||
@@ -224,19 +195,19 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
|
||||
{ static_cast<int>(Orientation::Both), "Both" }
|
||||
});
|
||||
|
||||
if (dictionary.hasKey(OrientationInfo.identifier)) {
|
||||
const std::string& v = dictionary.value<std::string>(OrientationInfo.identifier);
|
||||
if (v == "Inside") {
|
||||
_orientation = static_cast<int>(Orientation::Inside);
|
||||
}
|
||||
else if (v == "Outside") {
|
||||
_orientation = static_cast<int>(Orientation::Outside);
|
||||
}
|
||||
else if (v == "Both") {
|
||||
_orientation = static_cast<int>(Orientation::Both);
|
||||
}
|
||||
else {
|
||||
throw ghoul::MissingCaseException();
|
||||
if (p.orientation.has_value()) {
|
||||
switch (*p.orientation) {
|
||||
case Parameters::Orientation::Inside:
|
||||
_orientation = static_cast<int>(Orientation::Inside);
|
||||
break;
|
||||
case Parameters::Orientation::Outside:
|
||||
_orientation = static_cast<int>(Orientation::Outside);
|
||||
break;
|
||||
case Parameters::Orientation::Both:
|
||||
_orientation = static_cast<int>(Orientation::Both);
|
||||
break;
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -256,44 +227,34 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_mirrorTexture);
|
||||
addProperty(_useAdditiveBlending);
|
||||
|
||||
_mirrorTexture = p.mirrorTexture.value_or(_mirrorTexture);
|
||||
_useAdditiveBlending = p.useAdditiveBlending.value_or(_useAdditiveBlending);
|
||||
|
||||
if (dictionary.hasKey(MirrorTextureInfo.identifier)) {
|
||||
_mirrorTexture = dictionary.value<bool>(MirrorTextureInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKey(UseAdditiveBlendingInfo.identifier)) {
|
||||
_useAdditiveBlending = dictionary.value<bool>(UseAdditiveBlendingInfo.identifier);
|
||||
|
||||
if (_useAdditiveBlending) {
|
||||
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
|
||||
}
|
||||
if (_useAdditiveBlending) {
|
||||
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(FadeOutThresholdInfo.identifier)) {
|
||||
_fadeOutThreshold = static_cast<float>(
|
||||
dictionary.value<double>(FadeOutThresholdInfo.identifier)
|
||||
);
|
||||
bool hasGivenFadeOut = p.fadeOutThreshold.has_value();
|
||||
if (hasGivenFadeOut) {
|
||||
_fadeOutThreshold = *p.fadeOutThreshold;
|
||||
addProperty(_fadeOutThreshold);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(FadeInThresholdInfo.identifier)) {
|
||||
_fadeInThreshold = static_cast<float>(
|
||||
dictionary.value<double>(FadeInThresholdInfo.identifier)
|
||||
);
|
||||
bool hasGivenFadeIn = p.fadeInThreshold.has_value();
|
||||
if (hasGivenFadeIn) {
|
||||
_fadeInThreshold = *p.fadeInThreshold;
|
||||
addProperty(_fadeInThreshold);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(FadeInThresholdInfo.identifier) ||
|
||||
dictionary.hasKey(FadeOutThresholdInfo.identifier)) {
|
||||
_disableFadeInDistance.set(false);
|
||||
if (hasGivenFadeIn || hasGivenFadeOut) {
|
||||
_disableFadeInDistance = false;
|
||||
addProperty(_disableFadeInDistance);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(BackgroundInfo.identifier)) {
|
||||
_backgroundRendering = dictionary.value<bool>(BackgroundInfo.identifier);
|
||||
_backgroundRendering = p.background.value_or(_backgroundRendering);
|
||||
|
||||
if (_backgroundRendering) {
|
||||
setRenderBin(Renderable::RenderBin::Background);
|
||||
}
|
||||
if (_backgroundRendering) {
|
||||
setRenderBin(Renderable::RenderBin::Background);
|
||||
}
|
||||
|
||||
setRenderBinFromOpacity();
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "EphemerisProgram";
|
||||
@@ -145,64 +145,44 @@ namespace {
|
||||
"atmospheres if needed."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableTrail)]] Parameters {
|
||||
// This object is used to compute locations along the path. Any Translation object
|
||||
// can be used here
|
||||
std::monostate translation [[codegen::reference("core_transform_translation")]];
|
||||
|
||||
// [[codegen::verbatim(LineColorInfo.description)]]
|
||||
glm::vec3 color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(EnableFadeInfo.description)]]
|
||||
std::optional<bool> enableFade;
|
||||
|
||||
// [[codegen::verbatim(FadeInfo.description)]]
|
||||
std::optional<float> fade;
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
|
||||
// [[codegen::verbatim(PointSizeInfo.description)]]
|
||||
std::optional<int> pointSize;
|
||||
|
||||
enum class RenderingMode {
|
||||
Lines,
|
||||
Points,
|
||||
LinesPoints [[codegen::key("Lines+Points")]],
|
||||
PointsLines [[codegen::key("Lines+Points")]]
|
||||
};
|
||||
// [[codegen::verbatim(RenderingModeInfo.description)]]
|
||||
std::optional<RenderingMode> renderingMode [[codegen::key("Rendering")]];
|
||||
};
|
||||
#include "renderabletrail_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableTrail::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"RenderableTrail",
|
||||
"base_renderable_renderabletrail",
|
||||
{
|
||||
{
|
||||
KeyTranslation,
|
||||
new ReferencingVerifier("core_transform_translation"),
|
||||
Optional::No,
|
||||
"This object is used to compute locations along the path. Any "
|
||||
"Translation object can be used here."
|
||||
},
|
||||
{
|
||||
LineColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::No,
|
||||
LineColorInfo.description
|
||||
},
|
||||
{
|
||||
EnableFadeInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
EnableFadeInfo.description
|
||||
},
|
||||
{
|
||||
FadeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FadeInfo.description
|
||||
},
|
||||
{
|
||||
LineWidthInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
LineWidthInfo.description
|
||||
},
|
||||
{
|
||||
PointSizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
PointSizeInfo.description
|
||||
},
|
||||
{
|
||||
RenderingModeInfo.identifier,
|
||||
new StringInListVerifier(
|
||||
// Taken from the RenderingModeConversion map above
|
||||
{ "Lines", "Points", "Lines+Points", "Points+Lines" }
|
||||
),
|
||||
Optional::Yes,
|
||||
RenderingModeInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_renderabletrail";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderableTrail::Appearance::Appearance()
|
||||
@@ -234,6 +214,8 @@ RenderableTrail::Appearance::Appearance()
|
||||
RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
setRenderBin(RenderBin::Overlay);
|
||||
addProperty(_opacity);
|
||||
|
||||
@@ -242,36 +224,25 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
|
||||
);
|
||||
addPropertySubOwner(_translation.get());
|
||||
|
||||
_appearance.lineColor = dictionary.value<glm::dvec3>(LineColorInfo.identifier);
|
||||
_appearance.lineColor = p.color;
|
||||
_appearance.useLineFade = p.enableFade.value_or(_appearance.useLineFade);
|
||||
_appearance.lineFade = p.fade.value_or(_appearance.lineFade);
|
||||
_appearance.lineWidth = p.lineWidth.value_or(_appearance.lineWidth);
|
||||
_appearance.pointSize = p.pointSize.value_or(_appearance.pointSize);
|
||||
|
||||
if (dictionary.hasValue<bool>(EnableFadeInfo.identifier)) {
|
||||
_appearance.useLineFade = dictionary.value<bool>(EnableFadeInfo.identifier);
|
||||
}
|
||||
|
||||
if (dictionary.hasValue<double>(FadeInfo.identifier)) {
|
||||
_appearance.lineFade = static_cast<float>(
|
||||
dictionary.value<double>(FadeInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
if (dictionary.hasValue<double>(LineWidthInfo.identifier)) {
|
||||
_appearance.lineWidth = static_cast<float>(dictionary.value<double>(
|
||||
LineWidthInfo.identifier
|
||||
));
|
||||
}
|
||||
|
||||
if (dictionary.hasValue<double>(PointSizeInfo.identifier)) {
|
||||
_appearance.pointSize = static_cast<int>(
|
||||
dictionary.value<double>(PointSizeInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
// 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.hasValue<std::string>(RenderingModeInfo.identifier)) {
|
||||
_appearance.renderingModes = RenderingModeConversion.at(
|
||||
dictionary.value<std::string>(RenderingModeInfo.identifier)
|
||||
);
|
||||
if (p.renderingMode.has_value()) {
|
||||
switch (*p.renderingMode) {
|
||||
case Parameters::RenderingMode::Lines:
|
||||
_appearance.renderingModes = RenderingModeLines;
|
||||
break;
|
||||
case Parameters::RenderingMode::Points:
|
||||
_appearance.renderingModes = RenderingModePoints;
|
||||
break;
|
||||
case Parameters::RenderingMode::LinesPoints:
|
||||
case Parameters::RenderingMode::PointsLines:
|
||||
_appearance.renderingModes = RenderingModeLinesPoints;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_appearance.renderingModes = RenderingModeLines;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo UseMainInfo = {
|
||||
@@ -42,6 +43,15 @@ namespace {
|
||||
"If this value is set to 'true', this ScreenSpaceDashboard will use the "
|
||||
"main dashboard instead of creating an independent one."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(ScreenSpaceDashboard)]] Parameters {
|
||||
// Specifies the GUI name of the ScreenSpaceDashboard
|
||||
std::optional<std::string> name;
|
||||
|
||||
// [[codegen::verbatim(UseMainInfo.description)]]
|
||||
std::optional<bool> useMainDashboard;
|
||||
};
|
||||
#include "screenspacedashboard_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -115,42 +125,22 @@ int removeDashboardItemsFromScreenSpace(lua_State* L) {
|
||||
dash->dashboard().clearDashboardItems();
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace luascriptfunctions
|
||||
|
||||
|
||||
documentation::Documentation ScreenSpaceDashboard::Documentation() {
|
||||
using namespace openspace::documentation;
|
||||
return {
|
||||
"ScreenSpace Dashboard",
|
||||
"base_screenspace_dashboard",
|
||||
{
|
||||
{
|
||||
KeyName,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
"Specifies the GUI name of the ScreenSpaceDashboard"
|
||||
},
|
||||
{
|
||||
UseMainInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
UseMainInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_screenspace_dashboard";
|
||||
return doc;
|
||||
}
|
||||
|
||||
ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary)
|
||||
: ScreenSpaceFramebuffer(dictionary)
|
||||
, _useMainDashboard(UseMainInfo, false)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"ScreenSpaceDashboard"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
// @TODO (abock, 2021-01-29) Should this be the name variable? The identifier wasn't
|
||||
// declared in the documentation
|
||||
std::string identifier;
|
||||
if (dictionary.hasValue<std::string>(KeyIdentifier)) {
|
||||
identifier = dictionary.value<std::string>(KeyIdentifier);
|
||||
@@ -161,9 +151,7 @@ ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary)
|
||||
identifier = makeUniqueIdentifier(identifier);
|
||||
setIdentifier(std::move(identifier));
|
||||
|
||||
if (dictionary.hasKey(UseMainInfo.identifier)) {
|
||||
_useMainDashboard = dictionary.value<bool>(UseMainInfo.identifier);
|
||||
}
|
||||
_useMainDashboard = p.useMainDashboard.value_or(_useMainDashboard);
|
||||
addProperty(_useMainDashboard);
|
||||
|
||||
_scale = 1.f;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureconversion.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo TexturePathInfo = {
|
||||
@@ -42,42 +43,33 @@ namespace {
|
||||
"and displayed. The size of the image will also automatically set the default "
|
||||
"size of this plane."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(ScreenSpaceImageLocal)]] Parameters {
|
||||
// Specifies the GUI name of the ScreenspaceImage
|
||||
std::optional<std::string> name;
|
||||
|
||||
// [[codegen::verbatim(TexturePathInfo.description)]]
|
||||
std::optional<std::string> texturePath;
|
||||
};
|
||||
#include "screenspaceimagelocal_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation ScreenSpaceImageLocal::Documentation() {
|
||||
using namespace openspace::documentation;
|
||||
return {
|
||||
"ScreenSpace Local Image",
|
||||
"base_screenspace_image_local",
|
||||
{
|
||||
{
|
||||
KeyName,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
"Specifies the GUI name of the ScreenspaceImage"
|
||||
},
|
||||
{
|
||||
TexturePathInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
TexturePathInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_screenspace_image_local";
|
||||
return doc;
|
||||
}
|
||||
|
||||
ScreenSpaceImageLocal::ScreenSpaceImageLocal(const ghoul::Dictionary& dictionary)
|
||||
: ScreenSpaceRenderable(dictionary)
|
||||
, _texturePath(TexturePathInfo)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"ScreenSpaceImageLocal"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
// @TODO (abock, 2021-02-02) Should this be the name variable? The identifier wasn't
|
||||
// declared in the documentation
|
||||
std::string identifier;
|
||||
if (dictionary.hasValue<std::string>(KeyIdentifier)) {
|
||||
identifier = dictionary.value<std::string>(KeyIdentifier);
|
||||
@@ -101,16 +93,15 @@ ScreenSpaceImageLocal::ScreenSpaceImageLocal(const ghoul::Dictionary& dictionary
|
||||
});
|
||||
addProperty(_texturePath);
|
||||
|
||||
if (dictionary.hasKey(TexturePathInfo.identifier)) {
|
||||
std::string path = dictionary.value<std::string>(TexturePathInfo.identifier);
|
||||
if (!FileSys.fileExists(FileSys.absolutePath(path))) {
|
||||
LWARNINGC(
|
||||
"ScreenSpaceImageLocal",
|
||||
fmt::format("Image {} did not exist for {}", path, _identifier)
|
||||
);
|
||||
if (p.texturePath.has_value()) {
|
||||
if (FileSys.fileExists(FileSys.absolutePath(*p.texturePath))) {
|
||||
_texturePath = FileSys.absolutePath(*p.texturePath);
|
||||
}
|
||||
else {
|
||||
_texturePath = path;
|
||||
LWARNINGC(
|
||||
"ScreenSpaceImageLocal",
|
||||
fmt::format("Image {} did not exist for {}", *p.texturePath, _identifier)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
@@ -43,30 +44,23 @@ namespace {
|
||||
"and displayed. The size of the image will also automatically set the default "
|
||||
"size of this plane."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(ScreenSpaceImageOnline)]] Parameters {
|
||||
// Specifies the GUI name of the ScreenspaceImage
|
||||
std::optional<std::string> name;
|
||||
|
||||
// [[codegen::verbatim(TextureInfo.description)]]
|
||||
std::optional<std::string> url [[codegen::key("URL")]];
|
||||
};
|
||||
#include "screenspaceimageonline_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation ScreenSpaceImageOnline::Documentation() {
|
||||
using namespace openspace::documentation;
|
||||
return {
|
||||
"ScreenSpace Online Image",
|
||||
"base_screenspace_image_online",
|
||||
{
|
||||
{
|
||||
KeyName,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
"Specifies the GUI name of the ScreenspaceImage"
|
||||
},
|
||||
{
|
||||
TextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
TextureInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_screenspace_image_online";
|
||||
return doc;
|
||||
}
|
||||
|
||||
ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictionary)
|
||||
@@ -74,11 +68,7 @@ ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictiona
|
||||
, _textureIsDirty(false)
|
||||
, _texturePath(TextureInfo)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"ScreenSpaceImageOnline"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
std::string identifier;
|
||||
if (dictionary.hasValue<std::string>(KeyIdentifier)) {
|
||||
@@ -92,11 +82,7 @@ ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictiona
|
||||
|
||||
_texturePath.onChange([this]() { _textureIsDirty = true; });
|
||||
addProperty(_texturePath);
|
||||
|
||||
std::string texturePath;
|
||||
if (dictionary.hasKey(TextureInfo.identifier)) {
|
||||
_texturePath = dictionary.value<std::string>(TextureInfo.identifier);
|
||||
}
|
||||
_texturePath = p.url.value_or(_texturePath);
|
||||
}
|
||||
|
||||
ScreenSpaceImageOnline::~ScreenSpaceImageOnline() {} // NOLINT
|
||||
|
||||
Reference in New Issue
Block a user