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