mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Feature/numeric slider updates (#1609)
* Remove Logarithmic ViewOption and instead always use exponent of NumericalProperty + set exponent of some renderables' properties * Add MinMaxRange ViewOption for Vec2 properties * Add MinMaxRange viewoption to some existing vec2 properties and combine some other related properties to be able to utilize it. For example Min and Max label sizes, fade in/out distances, inner and outer radius. OBS! Includes renaming several properties (**breaking change**) * Refactor and document labels code. OBS! Includes renaming several properties (**breaking change**) * Add comments for some assets that have labels that are not working correctly Renderables with rename properties: RenderableLabels , GlobeLabelsComponent, RenderableBillboardsCloud, RenderableDUMeshes, RenderableRadialGrid )
This commit is contained in:
@@ -75,105 +75,78 @@ namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo BlendModeInfo = {
|
||||
"BlendMode",
|
||||
"Blending Mode",
|
||||
"This determines the blending mode that is applied to this plane."
|
||||
"This determines the blending mode that is applied to the renderable."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LabelColorInfo = {
|
||||
"LabelColor",
|
||||
"Label Color",
|
||||
"The label color for the astronomical object."
|
||||
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
|
||||
"Color",
|
||||
"Color",
|
||||
"The label text color."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"The font size for the astronomical object labels."
|
||||
"The font size (in points) for the label."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LabelSizeInfo = {
|
||||
"LabelSize",
|
||||
"Label Size",
|
||||
"The label size for the astronomical object labels."
|
||||
constexpr openspace::properties::Property::PropertyInfo SizeInfo = {
|
||||
"Size",
|
||||
"Size",
|
||||
"This value affects the size scale of the label."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LabelTextInfo = {
|
||||
"LabelText",
|
||||
"Label Text",
|
||||
constexpr openspace::properties::Property::PropertyInfo TextInfo = {
|
||||
"Text",
|
||||
"Text",
|
||||
"The text that will be displayed on screen."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LabelMinSizeInfo = {
|
||||
"LabelMinSize",
|
||||
"Label Min Size",
|
||||
"The minimal size (in pixels) of the labels for the astronomical "
|
||||
"objects being rendered."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LabelMaxSizeInfo = {
|
||||
"LabelMaxSize",
|
||||
"Label Max Size",
|
||||
"The maximum size (in pixels) of the labels for the astronomical "
|
||||
"objects being rendered."
|
||||
constexpr openspace::properties::Property::PropertyInfo MinMaxSizeInfo = {
|
||||
"MinMaxSize",
|
||||
"Min and Max Size",
|
||||
"The minimum and maximum size (in pixels) of the label."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TransformationMatrixInfo = {
|
||||
"TransformationMatrix",
|
||||
"Transformation Matrix",
|
||||
"Transformation matrix to be applied to each astronomical object."
|
||||
"Transformation matrix to be applied to the label."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LabelOrientationOptionInfo = {
|
||||
"LabelOrientationOption",
|
||||
"Label Orientation Option",
|
||||
constexpr openspace::properties::Property::PropertyInfo OrientationOptionInfo = {
|
||||
"OrientationOption",
|
||||
"Orientation Option",
|
||||
"Label orientation rendering mode."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo EnableFadingEffectInfo = {
|
||||
"EnableFading",
|
||||
"Enable/Disable Fade-in effect",
|
||||
"Enable/Disable Fade-in Effect",
|
||||
"Enable/Disable the Fade-in effect."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo PixelSizeControlInfo = {
|
||||
"EnablePixelSizeControl",
|
||||
"Enable pixel size control.",
|
||||
"Enable pixel size control for rectangular projections."
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeWidthsInfo = {
|
||||
"FadeWidths",
|
||||
"Fade Widths",
|
||||
"The distances over which the fading takes place, given in the specified unit. "
|
||||
"The first value is the distance before the closest distance and the second "
|
||||
"the one after the furthest distance. For example, with the unit Parsec (pc), "
|
||||
"a value of {1, 2} will make the label being fully faded out 1 Parsec before "
|
||||
"the closest distance and 2 Parsec away from the furthest distance."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeStartUnitOptionInfo = {
|
||||
"FadeStartUnit",
|
||||
"Fade-In/-Out Start Unit.",
|
||||
"Unit for fade-in/-out starting position calculation."
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeDistancesInfo = {
|
||||
"FadeDistances",
|
||||
"Fade Distances",
|
||||
"The distance range in which the labels should be fully opaque, specified in "
|
||||
"the chosen unit. The distance from the position of the label to the camera."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeEndUnitOptionInfo = {
|
||||
"FadeEndUnit",
|
||||
"Fade-In/-Out End Unit.",
|
||||
"Unit for fade-in/-out ending position calculation."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeStartDistInfo = {
|
||||
"FadeStartDistance",
|
||||
"Fade-In/-Out starting distance.",
|
||||
"Fade-In/-Out starting distance."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeEndDistInfo = {
|
||||
"FadeEndDistance",
|
||||
"Fade-In/-Out ending distance.",
|
||||
"Fade-In/-Out ending distance."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeStartSpeedInfo = {
|
||||
"FadeStartSpeed",
|
||||
"Fade-In/-Out starting speed.",
|
||||
"Fade-In/-Out starting speed."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeEndSpeedInfo = {
|
||||
"FadeEndSpeed",
|
||||
"Fade-In/-Out ending speed.",
|
||||
"Fade-In/-Out ending speed."
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeUnitOptionInfo = {
|
||||
"FadeUnit",
|
||||
"Fade Distance Unit",
|
||||
"Distance unit for fade-in/-out distance calculations. Defaults to \"au\"."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableLabels)]] Parameters {
|
||||
@@ -190,33 +163,27 @@ namespace {
|
||||
PositionNormal [[codegen::key("Camera Position Normal")]]
|
||||
};
|
||||
|
||||
// [[codegen::verbatim(LabelOrientationOptionInfo.description)]]
|
||||
std::optional<Orientation> labelOrientationOption;
|
||||
// [[codegen::verbatim(OrientationOptionInfo.description)]]
|
||||
std::optional<Orientation> orientationOption;
|
||||
|
||||
// [[codegen::verbatim(LabelColorInfo.description)]]
|
||||
std::optional<glm::vec3> labelColor [[codegen::color()]];
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(LabelTextInfo.description)]]
|
||||
std::optional<std::string> labelText;
|
||||
// [[codegen::verbatim(TextInfo.description)]]
|
||||
std::optional<std::string> text;
|
||||
|
||||
// [[codegen::verbatim(FontSizeInfo.description)]]
|
||||
std::optional<float> fontSize;
|
||||
|
||||
// [[codegen::verbatim(LabelSizeInfo.description)]]
|
||||
std::optional<float> labelSize;
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
std::optional<float> size;
|
||||
|
||||
// [[codegen::verbatim(LabelMinSizeInfo.description)]]
|
||||
std::optional<float> labelMinSize;
|
||||
|
||||
// [[codegen::verbatim(LabelMaxSizeInfo.description)]]
|
||||
std::optional<float> labelMaxSize;
|
||||
// [[codegen::verbatim(MinMaxSizeInfo.description)]]
|
||||
std::optional<glm::ivec2> minMaxSize;
|
||||
|
||||
// [[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;
|
||||
|
||||
@@ -230,28 +197,19 @@ namespace {
|
||||
AstronomicalUnit [[codegen::key("au")]],
|
||||
Parsec [[codegen::key("pc")]],
|
||||
KiloParsec [[codegen::key("Kpc")]],
|
||||
MegaParsec [[codgen::key("Mpc")]],
|
||||
MegaParsec [[codegen::key("Mpc")]],
|
||||
GigaParsec [[codegen::key("Gpc")]],
|
||||
GigaLightyear [[codegen::key("Gly")]]
|
||||
};
|
||||
|
||||
// [[codegen::verbatim(FadeStartUnitOptionInfo.description)]]
|
||||
std::optional<Unit> fadeStartUnit;
|
||||
// [[codegen::verbatim(FadeUnitOptionInfo.description)]]
|
||||
std::optional<Unit> fadeUnit;
|
||||
|
||||
// [[codegen::verbatim(FadeEndUnitOptionInfo.description)]]
|
||||
std::optional<Unit> fadeEndUnit;
|
||||
// [[codegen::verbatim(FadeDistancesInfo.description)]]
|
||||
std::optional<glm::vec2> fadeDistances;
|
||||
|
||||
// [[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;
|
||||
// [[codegen::verbatim(FadeWidthsInfo.description)]]
|
||||
std::optional<glm::vec2> fadeWidths;
|
||||
};
|
||||
#include "renderablelabels_codegen.cpp"
|
||||
} // namespace
|
||||
@@ -265,33 +223,20 @@ documentation::Documentation RenderableLabels::Documentation() {
|
||||
RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _labelColor(
|
||||
LabelColorInfo,
|
||||
glm::vec3(1.f, 1.f, 1.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
)
|
||||
, _labelSize(LabelSizeInfo, 8.f, 0.5f, 30.f)
|
||||
, _color(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _size(SizeInfo, 8.f, 0.5f, 30.f)
|
||||
, _fontSize(FontSizeInfo, 50.f, 1.f, 100.f)
|
||||
, _labelMinSize(LabelMinSizeInfo, 8.f, 0.5f, 24.f)
|
||||
, _labelMaxSize(LabelMaxSizeInfo, 20.f, 0.5f, 100.f)
|
||||
, _pixelSizeControl(PixelSizeControlInfo, false)
|
||||
, _minMaxSize(MinMaxSizeInfo, glm::ivec2(8, 20), glm::ivec2(0), glm::ivec2(100))
|
||||
, _enableFadingEffect(EnableFadingEffectInfo, false)
|
||||
, _labelText(LabelTextInfo, "")
|
||||
, _fadeStartDistance(FadeStartDistInfo, 1.f, 0.f, 100.f)
|
||||
, _fadeEndDistance(FadeEndDistInfo, 1.f, 0.f, 100.f)
|
||||
, _fadeStartSpeed(FadeStartSpeedInfo, 1.f, 1.f, 100.f)
|
||||
, _fadeEndSpeed(FadeEndSpeedInfo, 1.f, 1.f, 100.f)
|
||||
, _labelOrientationOption(
|
||||
LabelOrientationOptionInfo,
|
||||
, _text(TextInfo, "")
|
||||
, _fadeDistances(FadeDistancesInfo, glm::vec2(1.f), glm::vec2(0.f), glm::vec2(100.f))
|
||||
, _fadeWidths(FadeWidthsInfo, glm::vec2(1.f), glm::vec2(0.f), glm::vec2(100.f))
|
||||
, _orientationOption(
|
||||
OrientationOptionInfo,
|
||||
properties::OptionProperty::DisplayType::Dropdown
|
||||
)
|
||||
, _fadeStartUnitOption(
|
||||
FadeStartUnitOptionInfo,
|
||||
properties::OptionProperty::DisplayType::Dropdown
|
||||
)
|
||||
, _fadeEndUnitOption(
|
||||
FadeEndUnitOptionInfo,
|
||||
, _fadeUnitOption(
|
||||
FadeUnitOptionInfo,
|
||||
properties::OptionProperty::DisplayType::Dropdown
|
||||
)
|
||||
{
|
||||
@@ -330,28 +275,28 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
|
||||
addProperty(_blendMode);
|
||||
|
||||
_labelOrientationOption.addOption(ViewDirection, "Camera View Direction");
|
||||
_labelOrientationOption.addOption(NormalDirection, "Camera Position Normal");
|
||||
_orientationOption.addOption(ViewDirection, "Camera View Direction");
|
||||
_orientationOption.addOption(NormalDirection, "Camera Position Normal");
|
||||
|
||||
_labelOrientationOption = NormalDirection;
|
||||
if (p.labelOrientationOption.has_value()) {
|
||||
switch (*p.labelOrientationOption) {
|
||||
_orientationOption = NormalDirection;
|
||||
if (p.orientationOption.has_value()) {
|
||||
switch (*p.orientationOption) {
|
||||
case Parameters::Orientation::ViewDirection:
|
||||
_labelOrientationOption = ViewDirection;
|
||||
_orientationOption = ViewDirection;
|
||||
break;
|
||||
case Parameters::Orientation::PositionNormal:
|
||||
_labelOrientationOption = NormalDirection;
|
||||
_orientationOption = NormalDirection;
|
||||
break;
|
||||
}
|
||||
}
|
||||
addProperty(_labelOrientationOption);
|
||||
addProperty(_orientationOption);
|
||||
|
||||
_labelText = p.labelText.value_or(_labelText);
|
||||
addProperty(_labelText);
|
||||
_text = p.text.value_or(_text);
|
||||
addProperty(_text);
|
||||
|
||||
_labelColor = p.labelColor.value_or(_labelColor);
|
||||
_labelColor.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_labelColor);
|
||||
_color = p.color.value_or(_color);
|
||||
_color.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_color);
|
||||
|
||||
_fontSize = p.fontSize.value_or(_fontSize);
|
||||
_fontSize.onChange([&]() {
|
||||
@@ -364,156 +309,82 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
_labelSize = p.labelSize.value_or(_labelSize);
|
||||
addProperty(_labelSize);
|
||||
_size = p.size.value_or(_size);
|
||||
addProperty(_size);
|
||||
|
||||
_labelMinSize = p.labelMinSize.value_or(_labelMinSize);
|
||||
addProperty(_labelMinSize);
|
||||
|
||||
_labelMaxSize = p.labelMaxSize.value_or(_labelMaxSize);
|
||||
addProperty(_labelMaxSize);
|
||||
_minMaxSize = p.minMaxSize.value_or(_minMaxSize);
|
||||
_minMaxSize.setViewOption(properties::Property::ViewOptions::MinMaxRange);
|
||||
addProperty(_minMaxSize);
|
||||
|
||||
_transformationMatrix = p.transformationMatrix.value_or(_transformationMatrix);
|
||||
|
||||
_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);
|
||||
}
|
||||
|
||||
_enableFadingEffect = p.enableFading.value_or(_enableFadingEffect);
|
||||
addProperty(_enableFadingEffect);
|
||||
|
||||
_fadeStartDistance = p.fadeStartDistance.value_or(_fadeStartDistance);
|
||||
addProperty(_fadeStartDistance);
|
||||
_fadeUnitOption.addOption(Meter, MeterUnit);
|
||||
_fadeUnitOption.addOption(Kilometer, KilometerUnit);
|
||||
_fadeUnitOption.addOption(Megameter, MegameterUnit);
|
||||
_fadeUnitOption.addOption(Gigameter, GigameterUnit);
|
||||
_fadeUnitOption.addOption(AU, AstronomicalUnit);
|
||||
_fadeUnitOption.addOption(Terameter, TerameterUnit);
|
||||
_fadeUnitOption.addOption(Petameter, PetameterUnit);
|
||||
_fadeUnitOption.addOption(Parsec, ParsecUnit);
|
||||
_fadeUnitOption.addOption(Kiloparsec, KiloparsecUnit);
|
||||
_fadeUnitOption.addOption(Megaparsec, MegaparsecUnit);
|
||||
_fadeUnitOption.addOption(Gigaparsec, GigaparsecUnit);
|
||||
_fadeUnitOption.addOption(GigalightYears, GigalightyearUnit);
|
||||
|
||||
_fadeStartUnitOption.addOption(Meter, MeterUnit);
|
||||
_fadeStartUnitOption.addOption(Kilometer, KilometerUnit);
|
||||
_fadeStartUnitOption.addOption(Megameter, MegameterUnit);
|
||||
_fadeStartUnitOption.addOption(Gigameter, GigameterUnit);
|
||||
_fadeStartUnitOption.addOption(AU, AstronomicalUnit);
|
||||
_fadeStartUnitOption.addOption(Terameter, TerameterUnit);
|
||||
_fadeStartUnitOption.addOption(Petameter, PetameterUnit);
|
||||
_fadeStartUnitOption.addOption(Parsec, ParsecUnit);
|
||||
_fadeStartUnitOption.addOption(Kiloparsec, KiloparsecUnit);
|
||||
_fadeStartUnitOption.addOption(Megaparsec, MegaparsecUnit);
|
||||
_fadeStartUnitOption.addOption(Gigaparsec, GigaparsecUnit);
|
||||
_fadeStartUnitOption.addOption(GigalightYears, GigalightyearUnit);
|
||||
|
||||
|
||||
if (p.fadeStartUnit.has_value()) {
|
||||
switch (*p.fadeStartUnit) {
|
||||
if (p.fadeUnit.has_value()) {
|
||||
switch (*p.fadeUnit) {
|
||||
case Parameters::Unit::Meter:
|
||||
_fadeStartUnitOption = Meter;
|
||||
_fadeUnitOption = Meter;
|
||||
break;
|
||||
case Parameters::Unit::Kilometer:
|
||||
_fadeStartUnitOption = Kilometer;
|
||||
_fadeUnitOption = Kilometer;
|
||||
break;
|
||||
case Parameters::Unit::Megameter:
|
||||
_fadeStartUnitOption = Megameter;
|
||||
_fadeUnitOption = Megameter;
|
||||
break;
|
||||
case Parameters::Unit::Gigameter:
|
||||
_fadeStartUnitOption = Gigameter;
|
||||
_fadeUnitOption = Gigameter;
|
||||
break;
|
||||
case Parameters::Unit::Terameter:
|
||||
_fadeStartUnitOption = Terameter;
|
||||
_fadeUnitOption = Terameter;
|
||||
break;
|
||||
case Parameters::Unit::Petameter:
|
||||
_fadeStartUnitOption = Petameter;
|
||||
_fadeUnitOption = Petameter;
|
||||
break;
|
||||
case Parameters::Unit::AstronomicalUnit:
|
||||
_fadeStartUnitOption = AU;
|
||||
_fadeUnitOption = AU;
|
||||
break;
|
||||
case Parameters::Unit::Parsec:
|
||||
_fadeStartUnitOption = Parsec;
|
||||
_fadeUnitOption = Parsec;
|
||||
break;
|
||||
case Parameters::Unit::KiloParsec:
|
||||
_fadeStartUnitOption = Kiloparsec;
|
||||
_fadeUnitOption = Kiloparsec;
|
||||
break;
|
||||
case Parameters::Unit::MegaParsec:
|
||||
_fadeStartUnitOption = Megaparsec;
|
||||
_fadeUnitOption = Megaparsec;
|
||||
break;
|
||||
case Parameters::Unit::GigaParsec:
|
||||
_fadeStartUnitOption = Gigaparsec;
|
||||
_fadeUnitOption = Gigaparsec;
|
||||
break;
|
||||
case Parameters::Unit::GigaLightyear:
|
||||
_fadeStartUnitOption = GigalightYears;
|
||||
_fadeUnitOption = GigalightYears;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_fadeStartUnitOption = AU;
|
||||
_fadeUnitOption = AU;
|
||||
}
|
||||
addProperty(_fadeStartUnitOption);
|
||||
addProperty(_fadeUnitOption);
|
||||
|
||||
_fadeStartSpeed = p.fadeStartSpeed.value_or(_fadeStartSpeed);
|
||||
addProperty(_fadeStartSpeed);
|
||||
_fadeDistances = p.fadeDistances.value_or(_fadeDistances);
|
||||
_fadeDistances.setViewOption(properties::Property::ViewOptions::MinMaxRange);
|
||||
addProperty(_fadeDistances);
|
||||
|
||||
_fadeEndDistance = p.fadeEndDistance.value_or(_fadeEndDistance);
|
||||
addProperty(_fadeEndDistance);
|
||||
|
||||
_fadeEndUnitOption.addOption(Meter, MeterUnit);
|
||||
_fadeEndUnitOption.addOption(Kilometer, KilometerUnit);
|
||||
_fadeEndUnitOption.addOption(Megameter, MegameterUnit);
|
||||
_fadeEndUnitOption.addOption(Gigameter, GigameterUnit);
|
||||
_fadeEndUnitOption.addOption(AU, AstronomicalUnit);
|
||||
_fadeEndUnitOption.addOption(Terameter, TerameterUnit);
|
||||
_fadeEndUnitOption.addOption(Petameter, PetameterUnit);
|
||||
_fadeEndUnitOption.addOption(Parsec, ParsecUnit);
|
||||
_fadeEndUnitOption.addOption(Kiloparsec, KiloparsecUnit);
|
||||
_fadeEndUnitOption.addOption(Megaparsec, MegaparsecUnit);
|
||||
_fadeEndUnitOption.addOption(Gigaparsec, GigaparsecUnit);
|
||||
_fadeEndUnitOption.addOption(GigalightYears, GigalightyearUnit);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
_fadeEndSpeed = p.fadeEndSpeed.value_or(_fadeEndSpeed);
|
||||
addProperty(_fadeEndSpeed);
|
||||
_fadeWidths = p.fadeWidths.value_or(_fadeWidths);
|
||||
addProperty(_fadeWidths);
|
||||
}
|
||||
|
||||
bool RenderableLabels::isReady() const {
|
||||
@@ -528,7 +399,6 @@ void RenderableLabels::initialize() {
|
||||
|
||||
void RenderableLabels::initializeGL() {
|
||||
if (_font == nullptr) {
|
||||
//size_t _fontSize = 50;
|
||||
_font = global::fontManager->font(
|
||||
"Mono",
|
||||
_fontSize,
|
||||
@@ -554,17 +424,7 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) {
|
||||
float distanceNodeToCamera = static_cast<float>(
|
||||
glm::distance(data.camera.positionVec3(), data.modelTransform.translation)
|
||||
);
|
||||
float sUnit = unit(_fadeStartUnitOption);
|
||||
float eUnit = unit(_fadeEndUnitOption);
|
||||
float startX = _fadeStartDistance * sUnit;
|
||||
float endX = _fadeEndDistance * eUnit;
|
||||
fadeInVariable = linearSmoothStepFunc(
|
||||
distanceNodeToCamera,
|
||||
startX,
|
||||
endX,
|
||||
sUnit,
|
||||
eUnit
|
||||
);
|
||||
fadeInVariable = computeFadeFactor(distanceNodeToCamera);
|
||||
}
|
||||
|
||||
glm::dmat4 modelMatrix(1.0);
|
||||
@@ -598,7 +458,7 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) {
|
||||
|
||||
|
||||
void RenderableLabels::setLabelText(const std::string & newText) {
|
||||
_labelText = newText;
|
||||
_text = newText;
|
||||
}
|
||||
|
||||
void RenderableLabels::renderLabels(const RenderData& data,
|
||||
@@ -606,23 +466,23 @@ void RenderableLabels::renderLabels(const RenderData& data,
|
||||
const glm::dvec3& orthoRight,
|
||||
const glm::dvec3& orthoUp, float fadeInVariable)
|
||||
{
|
||||
glm::vec4 textColor = glm::vec4(glm::vec3(_labelColor), 1.f);
|
||||
glm::vec4 textColor = glm::vec4(glm::vec3(_color), 1.f);
|
||||
|
||||
textColor.a *= fadeInVariable;
|
||||
textColor.a *= _opacity;
|
||||
|
||||
ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo;
|
||||
|
||||
labelInfo.orthoRight = orthoRight;
|
||||
labelInfo.orthoUp = orthoUp;
|
||||
labelInfo.minSize = static_cast<int>(_labelMinSize);
|
||||
labelInfo.maxSize = static_cast<int>(_labelMaxSize);
|
||||
labelInfo.cameraPos = data.camera.positionVec3();
|
||||
labelInfo.cameraLookUp = data.camera.lookUpVectorWorldSpace();
|
||||
labelInfo.renderType = _labelOrientationOption;
|
||||
labelInfo.mvpMatrix = modelViewProjectionMatrix;
|
||||
labelInfo.scale = powf(10.f, _labelSize);
|
||||
labelInfo.enableDepth = true;
|
||||
labelInfo.orthoRight = orthoRight;
|
||||
labelInfo.orthoUp = orthoUp;
|
||||
labelInfo.minSize = _minMaxSize.value().x;
|
||||
labelInfo.maxSize = _minMaxSize.value().y;
|
||||
labelInfo.cameraPos = data.camera.positionVec3();
|
||||
labelInfo.cameraLookUp = data.camera.lookUpVectorWorldSpace();
|
||||
labelInfo.renderType = _orientationOption;
|
||||
labelInfo.mvpMatrix = modelViewProjectionMatrix;
|
||||
labelInfo.scale = powf(10.f, _size);
|
||||
labelInfo.enableDepth = true;
|
||||
labelInfo.enableFalseDepth = false;
|
||||
|
||||
// We don't use spice rotation and scale
|
||||
@@ -633,52 +493,34 @@ void RenderableLabels::renderLabels(const RenderData& data,
|
||||
ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render(
|
||||
*_font,
|
||||
transformedPos,
|
||||
_labelText.value(),
|
||||
_text.value(),
|
||||
textColor,
|
||||
labelInfo
|
||||
);
|
||||
}
|
||||
|
||||
float RenderableLabels::changedPerlinSmoothStepFunc(float x, float startX,
|
||||
float endX) const
|
||||
{
|
||||
float f1 = 6.f * powf((x - startX), 5.f) - 15.f * powf((x - startX), 4.f) +
|
||||
10.f * powf((x - startX), 3.f);
|
||||
float f2 = -6.f * powf((x - endX), 5.f) + 15.f * powf((x - endX), 4.f) -
|
||||
10.f * powf((x - endX), 3.f) + 1.f;
|
||||
float f3 = 1.f;
|
||||
float RenderableLabels::computeFadeFactor(float distanceNodeToCamera) const {
|
||||
float distanceUnit = unit(_fadeUnitOption);
|
||||
|
||||
float x = distanceNodeToCamera;
|
||||
float startX = _fadeDistances.value().x * distanceUnit;
|
||||
float endX = _fadeDistances.value().y * distanceUnit;
|
||||
|
||||
// The distances over which the fading should happen
|
||||
float fadingStartDistance = _fadeWidths.value().x * distanceUnit;
|
||||
float fadingEndDistance = _fadeWidths.value().y * distanceUnit;
|
||||
|
||||
if (x <= startX) {
|
||||
float f1 = 1.f - (startX - x) / fadingStartDistance;
|
||||
return std::clamp(f1, 0.f, 1.f);
|
||||
}
|
||||
else if (x > startX && x < endX) {
|
||||
return f3;
|
||||
return 1.f; // not faded
|
||||
}
|
||||
else if (x >= endX) {
|
||||
else { // x >= endX
|
||||
float f2 = 1.f - (x - endX) / fadingEndDistance;
|
||||
return std::clamp(f2, 0.f, 1.f);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
float RenderableLabels::linearSmoothStepFunc(float x, float startX, float endX,
|
||||
float sUnit, float eUnit) const
|
||||
{
|
||||
float sdiv = 1.f / (sUnit * _fadeStartSpeed);
|
||||
float ediv = -1.f / (eUnit * _fadeEndSpeed);
|
||||
float f1 = sdiv * (x - startX) + 1.f;
|
||||
float f2 = ediv * (x - endX) + 1.f;
|
||||
float f3 = 1.f;
|
||||
|
||||
if (x <= startX) {
|
||||
return std::clamp(f1, 0.f, 1.f);
|
||||
}
|
||||
else if (x > startX && x < endX) {
|
||||
return f3;
|
||||
}
|
||||
else if (x >= endX) {
|
||||
return std::clamp(f2, 0.f, 1.f);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
float RenderableLabels::unit(int unit) const {
|
||||
|
||||
Reference in New Issue
Block a user