Disable labels on default

Some small code cleanup
This commit is contained in:
Alexander Bock
2019-12-16 10:26:42 +01:00
parent 87b79c1d8c
commit dfa25b28e6
12 changed files with 129 additions and 268 deletions

View File

@@ -62,18 +62,6 @@ local Pluto = {
local PlutoLabel = {
Identifier = "PlutoLabel",
Parent = Pluto.Identifier,
-- Transform = {
-- Translation = {
-- Type = "SpiceTranslation",
-- Target = "EARTH",
-- Observer = "EARTH BARYCENTER"
-- },
-- -- Rotation = {
-- -- Type = "SpiceRotation",
-- -- SourceFrame = "IAU_MOON",
-- -- DestinationFrame = "GALACTIC"
-- -- }
-- },
Renderable = {
Enabled = true,
Type = "RenderableLabels",
@@ -83,13 +71,7 @@ local PlutoLabel = {
LabelMaxSize = 100.0,
LabelMinSize = 1.0,
BlendMode = "Additive",
LabelOrientationOption = "Camera View Direction",
TransformationMatrix = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
LabelOrientationOption = "Camera View Direction"
},
GUI = {
Name = "Pluto Label",

View File

@@ -303,7 +303,7 @@ local EarthLabel = {
-- -- }
-- },
Renderable = {
Enabled = true,
Enabled = false,
Type = "RenderableLabels",
LabelText = "Earth",
FontSize = 100.0,
@@ -318,13 +318,7 @@ local EarthLabel = {
FadeStartSpeed = 1.0,
FadeEndUnit = "au",
FadeEndDistance = 15.0,
FadeEndSpeed = 25.0,
TransformationMatrix = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
FadeEndSpeed = 25.0
},
GUI = {
Name = "Earth Label",

View File

@@ -45,20 +45,8 @@ local Jupiter = {
local JupiterLabel = {
Identifier = "JupiterLabel",
Parent = Jupiter.Identifier,
-- Transform = {
-- Translation = {
-- Type = "SpiceTranslation",
-- Target = "EARTH",
-- Observer = "EARTH BARYCENTER"
-- },
-- -- Rotation = {
-- -- Type = "SpiceRotation",
-- -- SourceFrame = "IAU_MOON",
-- -- DestinationFrame = "GALACTIC"
-- -- }
-- },
Renderable = {
Enabled = true,
Enabled = false,
Type = "RenderableLabels",
LabelText = "Jupiter",
FontSize = 100.0,
@@ -66,13 +54,7 @@ local JupiterLabel = {
LabelMaxSize = 100.0,
LabelMinSize = 1.0,
LabelOrientationOption = "Camera View Direction",
BlendMode = "Additive",
TransformationMatrix = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
BlendMode = "Additive"
},
GUI = {
Name = "Jupiter Label",

View File

@@ -190,20 +190,8 @@ local Mars = {
local MarsLabel = {
Identifier = "MarsLabel",
Parent = Mars.Identifier,
-- Transform = {
-- Translation = {
-- Type = "SpiceTranslation",
-- Target = "EARTH",
-- Observer = "EARTH BARYCENTER"
-- },
-- -- Rotation = {
-- -- Type = "SpiceRotation",
-- -- SourceFrame = "IAU_MOON",
-- -- DestinationFrame = "GALACTIC"
-- -- }
-- },
Renderable = {
Enabled = true,
Enabled = false,
Type = "RenderableLabels",
LabelText = "Mars",
FontSize = 100.0,

View File

@@ -226,20 +226,8 @@ local Mercury = {
local MercuryLabel = {
Identifier = "MercuryLabel",
Parent = Mercury.Identifier,
-- Transform = {
-- Translation = {
-- Type = "SpiceTranslation",
-- Target = "EARTH",
-- Observer = "EARTH BARYCENTER"
-- },
-- -- Rotation = {
-- -- Type = "SpiceRotation",
-- -- SourceFrame = "IAU_MOON",
-- -- DestinationFrame = "GALACTIC"
-- -- }
-- },
Renderable = {
Enabled = true,
Enabled = false,
Type = "RenderableLabels",
LabelText = "Mercury",
FontSize = 100.0,
@@ -247,13 +235,7 @@ local MercuryLabel = {
LabelMaxSize = 100.0,
LabelMinSize = 1.0,
LabelOrientationOption = "Camera View Direction",
BlendMode = "Additive",
TransformationMatrix = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
BlendMode = "Additive"
},
GUI = {
Name = "Mercury Label",

View File

@@ -43,20 +43,8 @@ local Neptune = {
local NeptuneLabel = {
Identifier = "NeptuneLabel",
Parent = Neptune.Identifier,
-- Transform = {
-- Translation = {
-- Type = "SpiceTranslation",
-- Target = "EARTH",
-- Observer = "EARTH BARYCENTER"
-- },
-- -- Rotation = {
-- -- Type = "SpiceRotation",
-- -- SourceFrame = "IAU_MOON",
-- -- DestinationFrame = "GALACTIC"
-- -- }
-- },
Renderable = {
Enabled = true,
Enabled = false,
Type = "RenderableLabels",
LabelText = "Neptune",
FontSize = 100.0,
@@ -64,13 +52,7 @@ local NeptuneLabel = {
LabelMaxSize = 100.0,
LabelMinSize = 1.0,
LabelOrientationOption = "Camera View Direction",
BlendMode = "Additive",
TransformationMatrix = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
BlendMode = "Additive"
},
GUI = {
Name = "Neptune Label",

View File

@@ -60,20 +60,8 @@ local SaturnRings = {
local SaturnLabel = {
Identifier = "SaturnLabel",
Parent = Saturn.Identifier,
-- Transform = {
-- Translation = {
-- Type = "SpiceTranslation",
-- Target = "EARTH",
-- Observer = "EARTH BARYCENTER"
-- },
-- -- Rotation = {
-- -- Type = "SpiceRotation",
-- -- SourceFrame = "IAU_MOON",
-- -- DestinationFrame = "GALACTIC"
-- -- }
-- },
Renderable = {
Enabled = true,
Enabled = false,
Type = "RenderableLabels",
LabelText = "Saturn",
FontSize = 100.0,
@@ -81,13 +69,7 @@ local SaturnLabel = {
LabelMaxSize = 100.0,
LabelMinSize = 1.0,
BlendMode = "Additive",
LabelOrientationOption = "Camera View Direction",
TransformationMatrix = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
LabelOrientationOption = "Camera View Direction"
},
GUI = {
Name = "Saturn Label",

View File

@@ -45,20 +45,8 @@ local Uranus = {
local UranusLabel = {
Identifier = "UranusLabel",
Parent = Uranus.Identifier,
-- Transform = {
-- Translation = {
-- Type = "SpiceTranslation",
-- Target = "EARTH",
-- Observer = "EARTH BARYCENTER"
-- },
-- -- Rotation = {
-- -- Type = "SpiceRotation",
-- -- SourceFrame = "IAU_MOON",
-- -- DestinationFrame = "GALACTIC"
-- -- }
-- },
Renderable = {
Enabled = true,
Enabled = false,
Type = "RenderableLabels",
LabelText = "Uranus",
FontSize = 100.0,
@@ -66,13 +54,7 @@ local UranusLabel = {
LabelMaxSize = 100.0,
LabelMinSize = 1.0,
LabelOrientationOption = "Camera View Direction",
BlendMode = "Additive",
TransformationMatrix = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
BlendMode = "Additive"
},
GUI = {
Name = "Neptune Label",

View File

@@ -67,20 +67,8 @@ local Venus = {
local VenusLabel = {
Identifier = "VenusLabel",
Parent = Venus.Identifier,
-- Transform = {
-- Translation = {
-- Type = "SpiceTranslation",
-- Target = "EARTH",
-- Observer = "EARTH BARYCENTER"
-- },
-- -- Rotation = {
-- -- Type = "SpiceRotation",
-- -- SourceFrame = "IAU_MOON",
-- -- DestinationFrame = "GALACTIC"
-- -- }
-- },
Renderable = {
Enabled = true,
Enabled = false,
Type = "RenderableLabels",
LabelText = "Venus",
FontSize = 100.0,
@@ -88,13 +76,7 @@ local VenusLabel = {
LabelMaxSize = 100.0,
LabelMinSize = 1.0,
LabelOrientationOption = "Camera View Direction",
BlendMode = "Additive",
TransformationMatrix = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
BlendMode = "Additive"
},
GUI = {
Name = "Venus Label",

View File

@@ -31,7 +31,7 @@ local SunLabel = {
Identifier = "SunLabel",
Parent = Sun.Identifier,
Renderable = {
Enabled = true,
Enabled = false,
Type = "RenderableLabels",
LabelText = "Sun",
FontSize = 100.0,
@@ -46,13 +46,7 @@ local SunLabel = {
FadeStartSpeed = 1.375,
FadeEndUnit = "pc",
FadeEndDistance = 1.326,
FadeEndSpeed = 1.0,
TransformationMatrix = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
FadeEndSpeed = 1.0
},
GUI = {
Name = "Sun Label",

View File

@@ -193,7 +193,9 @@ documentation::Documentation RenderableLabels::Documentation() {
},
{
LabelOrientationOptionInfo.identifier,
new StringInListVerifier({ "Camera View Direction", "Camera Position Normal" }),
new StringInListVerifier(
{ "Camera View Direction", "Camera Position Normal" }
),
Optional::Yes,
LabelOrientationOptionInfo.description,
},
@@ -253,13 +255,19 @@ documentation::Documentation RenderableLabels::Documentation() {
},
{
FadeStartUnitOptionInfo.identifier,
new StringInListVerifier({"m", "Km", "Mm", "Gm", "au", "Tm", "Pm", "pc", "Kpc", "Mpc", "Gpc", "Gly"}),
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"}),
new StringInListVerifier(
{"m", "Km", "Mm", "Gm", "au", "Tm", "Pm", "pc", "Kpc", "Mpc",
"Gpc", "Gly"}
),
Optional::Yes,
FadeEndUnitOptionInfo.description,
},
@@ -311,9 +319,18 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
, _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, properties::OptionProperty::DisplayType::Dropdown)
, _fadeStartUnitOption(FadeStartUnitOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
, _fadeEndUnitOption(FadeEndUnitOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
, _labelOrientationOption(
LabelOrientationOptionInfo,
properties::OptionProperty::DisplayType::Dropdown
)
, _fadeStartUnitOption(
FadeStartUnitOptionInfo,
properties::OptionProperty::DisplayType::Dropdown
)
, _fadeEndUnitOption(
FadeEndUnitOptionInfo,
properties::OptionProperty::DisplayType::Dropdown
)
{
documentation::testSpecificationAndThrow(
Documentation(),
@@ -357,7 +374,9 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
_labelOrientationOption = NormalDirection;
if (dictionary.hasKeyAndValue<std::string>(LabelOrientationOptionInfo.identifier)) {
const std::string o = dictionary.value<std::string>(LabelOrientationOptionInfo.identifier);
const std::string o = dictionary.value<std::string>(
LabelOrientationOptionInfo.identifier
);
if (o == "Camera View Direction") {
_labelOrientationOption = ViewDirection;
@@ -446,7 +465,9 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
_fadeStartUnitOption = AU;
if (dictionary.hasKey(FadeStartUnitOptionInfo.identifier)) {
std::string unit = dictionary.value<std::string>(FadeStartUnitOptionInfo.identifier);
std::string unit = dictionary.value<std::string>(
FadeStartUnitOptionInfo.identifier
);
if (unit == MeterUnit) {
_fadeStartUnitOption = Meter;
}
@@ -521,7 +542,9 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
_fadeEndUnitOption = AU;
if (dictionary.hasKey(FadeEndUnitOptionInfo.identifier)) {
std::string unit = dictionary.value<std::string>(FadeEndUnitOptionInfo.identifier);
std::string unit = dictionary.value<std::string>(
FadeEndUnitOptionInfo.identifier
);
if (unit == MeterUnit) {
_fadeEndUnitOption = Meter;
}
@@ -573,9 +596,6 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
}
addProperty(_fadeEndSpeed);
//setBoundingSphere(_size);
}
bool RenderableLabels::isReady() const {
@@ -603,8 +623,7 @@ void RenderableLabels::initializeGL() {
}
}
void RenderableLabels::deinitializeGL() {
}
void RenderableLabels::deinitializeGL() {}
void RenderableLabels::render(const RenderData& data, RendererTasks&) {
@@ -626,7 +645,13 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) {
float startX = _fadeStartDistance * sUnit;
float endX = _fadeEndDistance * eUnit;
//fadeInVariable = changedPerlinSmoothStepFunc(distanceNodeToCamera, startX, endX);
fadeInVariable = linearSmoothStepFunc(distanceNodeToCamera, startX, endX, sUnit, eUnit);
fadeInVariable = linearSmoothStepFunc(
distanceNodeToCamera,
startX,
endX,
sUnit,
eUnit
);
}
glm::dmat4 modelMatrix(1.0);
@@ -668,8 +693,7 @@ void RenderableLabels::setLabelText(const std::string & newText) {
void RenderableLabels::renderLabels(const RenderData& data,
const glm::dmat4& modelViewProjectionMatrix,
const glm::dvec3& orthoRight,
const glm::dvec3& orthoUp,
float fadeInVariable)
const glm::dvec3& orthoUp, float fadeInVariable)
{
glm::vec4 textColor = _labelColor;
@@ -704,9 +728,8 @@ void RenderableLabels::renderLabels(const RenderData& data,
);
}
float RenderableLabels::changedPerlinSmoothStepFunc(const float x,
const float startX,
const float endX) const
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);
@@ -725,11 +748,8 @@ float RenderableLabels::changedPerlinSmoothStepFunc(const float x,
}
}
float RenderableLabels::linearSmoothStepFunc(const float x,
const float startX,
const float endX,
const float sUnit,
const float eUnit) const
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);
@@ -752,44 +772,45 @@ float RenderableLabels::getUnit(int unit) const {
float scale = 0.f;
switch (static_cast<Unit>(unit)) {
case Meter:
scale = 1.f;
break;
case Kilometer:
scale = 1e3;
break;
case Megameter:
scale = 1e6;
break;
case Gigameter:
scale = 1e9;
break;
case AU:
scale = 149597870700.f;
break;
case Terameter:
scale = 1e12;
break;
case Petameter:
scale = 1e15;
break;
case Parsec:
scale = static_cast<float>(PARSEC);
break;
case Kiloparsec:
scale = static_cast<float>(1e3 * PARSEC);
break;
case Megaparsec:
scale = static_cast<float>(1e6 * PARSEC);
break;
case Gigaparsec:
scale = static_cast<float>(1e9 * PARSEC);
break;
case GigalightYears:
scale = static_cast<float>(306391534.73091 * PARSEC);
break;
case Meter:
scale = 1.f;
break;
case Kilometer:
scale = 1e3;
break;
case Megameter:
scale = 1e6;
break;
case Gigameter:
scale = 1e9;
break;
case AU:
scale = 149597870700.f;
break;
case Terameter:
scale = 1e12;
break;
case Petameter:
scale = 1e15;
break;
case Parsec:
scale = static_cast<float>(PARSEC);
break;
case Kiloparsec:
scale = static_cast<float>(1e3 * PARSEC);
break;
case Megaparsec:
scale = static_cast<float>(1e6 * PARSEC);
break;
case Gigaparsec:
scale = static_cast<float>(1e9 * PARSEC);
break;
case GigalightYears:
scale = static_cast<float>(306391534.73091 * PARSEC);
break;
}
return scale;
}
} // namespace openspace

View File

@@ -54,22 +54,6 @@ namespace documentation { struct Documentation; }
struct LinePoint;
class RenderableLabels : public Renderable {
private:
enum Unit {
Meter = 0,
Kilometer = 1,
Megameter = 2,
Gigameter = 3,
AU = 4,
Terameter = 5,
Petameter = 6,
Parsec = 7,
Kiloparsec = 8,
Megaparsec = 9,
Gigaparsec = 10,
GigalightYears = 11
};
public:
RenderableLabels(const ghoul::Dictionary& dictionary);
@@ -90,37 +74,43 @@ protected:
properties::OptionProperty _blendMode;
private:
enum Unit {
Meter = 0,
Kilometer,
Megameter,
Gigameter,
AU,
Terameter,
Petameter,
Parsec,
Kiloparsec,
Megaparsec,
Gigaparsec,
GigalightYears
};
void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable);
float changedPerlinSmoothStepFunc(
const float x,
const float startX,
const float endX
) const;
float changedPerlinSmoothStepFunc(float x, float startX, float endX) const;
float linearSmoothStepFunc(
const float x,
const float startX,
const float endX,
const float sUnit,
const float eUnit
) const;
float linearSmoothStepFunc(float x, float startX, float endX, float sUnit,
float eUnit) const;
float getUnit(int unit) const;
properties::Vec4Property _labelColor;
properties::FloatProperty _labelSize;
properties::FloatProperty _fontSize;
properties::FloatProperty _labelMinSize;
properties::FloatProperty _labelMaxSize;
properties::BoolProperty _pixelSizeControl;
properties::BoolProperty _enableFadingEffect;
properties::Vec4Property _labelColor;
properties::FloatProperty _labelSize;
properties::FloatProperty _fontSize;
properties::FloatProperty _labelMinSize;
properties::FloatProperty _labelMaxSize;
properties::BoolProperty _pixelSizeControl;
properties::BoolProperty _enableFadingEffect;
properties::StringProperty _labelText;
properties::FloatProperty _fadeStartDistance;
properties::FloatProperty _fadeEndDistance;
properties::FloatProperty _fadeStartSpeed;
properties::FloatProperty _fadeEndSpeed;
properties::FloatProperty _fadeStartDistance;
properties::FloatProperty _fadeEndDistance;
properties::FloatProperty _fadeStartSpeed;
properties::FloatProperty _fadeEndSpeed;
properties::OptionProperty _labelOrientationOption;
properties::OptionProperty _fadeStartUnitOption;