Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cosmoscout/cosmoscout-vr
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: nacholuesia9/cosmoscout-vr
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 14 commits
  • 19 files changed
  • 2 contributors

Commits on Jun 2, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    427d280 View commit details
  2. remove name again

    nacholuesia9 committed Jun 2, 2023
    Copy the full SHA
    ae9671e View commit details

Commits on Jun 26, 2023

  1. Copy the full SHA
    b7c9fed View commit details
  2. 🎉 Add WFS plugin.

    nacholuesia9 committed Jun 26, 2023
    Copy the full SHA
    5e2995a View commit details

Commits on Jul 3, 2023

  1. Copy the full SHA
    ebfab80 View commit details

Commits on Jul 14, 2023

  1. Copy the full SHA
    ffafddd View commit details

Commits on Jul 19, 2023

  1. Copy the full SHA
    0508942 View commit details

Commits on Jul 27, 2023

  1. Copy the full SHA
    b43af4a View commit details

Commits on Aug 9, 2023

  1. Copy the full SHA
    ccc3cf7 View commit details

Commits on Aug 18, 2023

  1. Copy the full SHA
    0a5facf View commit details

Commits on Aug 22, 2023

  1. Copy the full SHA
    28996ae View commit details
  2. Copy the full SHA
    e793eae View commit details

Commits on Aug 24, 2023

  1. Copy the full SHA
    ef717f4 View commit details

Commits on Aug 28, 2023

  1. Copy the full SHA
    4a051e1 View commit details
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@
!/plugins/csp-timings
!/plugins/csp-trajectories
!/plugins/csp-web-api
!/plugins/csp-wfs-overlays
!/plugins/csp-wms-overlays

*.sublime*
198 changes: 191 additions & 7 deletions config/base/scene/simple_desktop.json
Original file line number Diff line number Diff line change
@@ -716,7 +716,7 @@
},
"plugins": {
"csp-timings": {},
"csp-stars": {
"#csp-stars": {
"celestialGridTexture": "../share/resources/textures/celestial_grid.png",
"starFiguresTexture": "../share/resources/textures/constellation_figures.png",
"celestialGridColor": [
@@ -777,7 +777,171 @@
}
},
"csp-measurement-tools": {},
"csp-simple-bodies": {
"csp-lod-bodies": {
"maxGPUTilesColor": 2048,
"maxGPUTilesDEM": 2048,
"mapCache": "map-cache/",
"bodies": {
"Earth": {
"activeImgDataset": "Helgoland + Blue Marble",
"activeDemDataset": "Helgoland + SRTM30",
"imgDatasets": {
"Test Grid": {
"copyright": "DLR, NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.bluemarble.rgb,test.grid.800km.rgb,test.grid.8km.rgb,test.grid.8m.rgb,test.grid.8cm.rgb,test.grid.8mm.rgb",
"maxLevel": 29
},
"Helgoland + Blue Marble": {
"copyright": "DLR, NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.bluemarble.rgb,earth.os.helgoland.rgb",
"maxLevel": 18
},
"MARUM + Blue Marble": {
"copyright": "MARUM, NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.bluemarble.rgb,earth.marum.visions.rgb",
"maxLevel": 24
},
"Sachsen Anhalt + Blue Marble": {
"copyright": "GeoBasis-DE / LVermGeo-LSA, NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.bluemarble.rgb,earth.sachsen-anhalt.dop20.rgb",
"maxLevel": 16
},
"Blue Marble": {
"copyright": "NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.bluemarble.rgb",
"maxLevel": 6
},
"Landsat": {
"copyright": "NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.landsat8.rgb",
"maxLevel": 15
}
},
"demDatasets": {
"Helgoland + SRTM30": {
"copyright": "DLR, NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.srtm30.dem,earth.os.helgoland.dem",
"maxLevel": 17
},
"Sachsen Anhalt + SRTM30": {
"copyright": "GeoBasis-DE / LVermGeo-LSA, NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.srtm30.dem,earth.sachsen-anhalt.cochstedt.bdom20.dem,earth.sachsen-anhalt.brocken.bdom20.dem,earth.sachsen-anhalt.thale.bdom20.dem,earth.sachsen-anhalt.klusfelsen.bdom20.dem,earth.sachsen-anhalt.regenstein.bdom20.dem",
"maxLevel": 16
},
"SRTM30": {
"copyright": "NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.srtm30.dem",
"maxLevel": 12
},
"Blue Marble": {
"copyright": "NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.bluemarble.dem",
"maxLevel": 6
},
"CleanTOPO": {
"copyright": "Tom Patterson, US National Park Service",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.cleantopo.dem",
"maxLevel": 6
},
"ETOPO1": {
"copyright": "NOAA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.etopo1.dem",
"maxLevel": 6
},
"MARUM + GEPCO": {
"copyright": "MARUM",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "earth.gebco.dem,earth.marum.sonne.dem,earth.marum.sentry.dem,earth.marum.visions.dem",
"maxLevel": 24
}
}
},
"Moon": {
"activeImgDataset": "Apollo (LRO NAC+WAC)",
"activeDemDataset": "Apollo (LRO NAC+WAC)",
"brdfHdr": {
"properties": {
"$B_C0": 0.0,
"$B_S0": 1.8,
"$b": 0.24,
"$c": 0.3,
"$h_C": 1.0,
"$h_S": 0.073,
"$phi": 0.3,
"$theta_p": 23.4,
"$w": 0.32
},
"source": "../share/resources/shaders/brdfs/hapke2012.glsl"
},
"brdfNonHdr": {
"properties": {
"$rho": 1.0,
"$sigma": 30.0
},
"source": "../share/resources/shaders/brdfs/oren-nayar_scaled.glsl"
},
"imgDatasets": {
"Apollo (LRO NAC+WAC)": {
"copyright": "NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "moon.lro.wac.gray,moon.lro.nac.apollo11.gray,moon.lro.nac.apollo15.gray,moon.lro.nac.apollo16.gray,moon.lro.nac.apollo17.gray",
"maxLevel": 14
},
"LRO LOLA LDAM": {
"copyright": "NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "moon.lro.lola.north.gray,moon.lro.lola.south.gray",
"maxLevel": 7
},
"Clementine": {
"copyright": "NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "moon.clementine.750nm.gray",
"maxLevel": 9
},
"Kaguya": {
"copyright": "JAXA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "moon.kaguya.gray",
"maxLevel": 9
}
},
"demDatasets": {
"Apollo (LRO NAC+WAC)": {
"copyright": "NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "moon.lro.wac.dem,moon.lro.nac.apollo11.dem,moon.lro.nac.apollo15.dem,moon.lro.nac.apollo16.dem,moon.lro.nac.apollo17.dem",
"maxLevel": 13
},
"LRO LOLA LDEM": {
"copyright": "NASA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "moon.lro.lola.north60.dem,moon.lro.lola.north75.dem,moon.lro.lola.north80.dem,moon.lro.lola.north85.dem,moon.lro.lola.south60.dem,moon.lro.lola.south75.dem,moon.lro.lola.south80.dem,moon.lro.lola.south85.dem",
"maxLevel": 11
},
"Kaguya": {
"copyright": "JAXA",
"url": "http://129.247.34.87/mapserv?service=wms",
"layers": "moon.kaguya.dem",
"maxLevel": 9
}
}
}
}
},
"#csp-simple-bodies": {
"bodies": {
"Sun": {
"texture": "../share/resources/textures/sun.jpg"
@@ -895,7 +1059,7 @@
}
}
},
"csp-rings": {
"#csp-rings": {
"rings": {
"Saturn": {
"texture": "../share/resources/textures/saturn-rings.png",
@@ -904,7 +1068,27 @@
}
}
},
"csp-anchor-labels": {
"csp-wfs-overlays": {
"enabled": true,
"wfs": [
"https://maps.dwd.de/geoserver/dwd/wfs",
"https://geoservice.dlr.de/eoc/basemap/wfs"
],
"interpolation": false
},
"csp-wms-overlays": {
"maxTextureSize": 1024,
"preFetch": 1,
"bodies": {
"Earth": {
"wms": [
"https://maps.dwd.de/geoserver/dwd/wms",
"https://geotest.eoc.dlr.de/eoc/atmosphere/wms"
]
}
}
},
"#csp-anchor-labels": {
"enabled": true,
"enableDepthOverlap": true,
"ignoreOverlapThreshold": 0.1,
@@ -922,7 +1106,7 @@
"Barycenter"
]
},
"csp-trajectories": {
"#csp-trajectories": {
"trajectories": {
"Sun": {
"color": [
@@ -1352,7 +1536,7 @@
}
},
"csp-fly-to-locations": {},
"csp-minimap": {
"#csp-minimap": {
"defaultMap": {
"projection": "equirectangular",
"type": "wms",
@@ -1390,7 +1574,7 @@
}
}
},
"csp-vr-accessibility": {
"#csp-vr-accessibility": {
"grid": {
"enabled": false,
"size": 0.5,
2 changes: 1 addition & 1 deletion plugins/csp-simple-bodies/src/SimpleBody.cpp
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

#include "../../../src/cs-core/Settings.hpp"
#include "../../../src/cs-core/SolarSystem.hpp"
#include "../../../src/cs-graphics/TextureLoader.hpp"
#include "../../../src/cs-graphics/TextureLoader.hpp"
#include "../../../src/cs-utils/FrameStats.hpp"
#include "../../../src/cs-utils/utils.hpp"

48 changes: 48 additions & 0 deletions plugins/csp-wfs-overlays/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ------------------------------------------------------------------------------------------------ #
# This file is part of CosmoScout VR #
# ------------------------------------------------------------------------------------------------ #

# SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
# SPDX-License-Identifier: MIT

option(CSP_WFS_OVERLAYS "Enable compilation of this plugin" ON)

if (NOT CSP_WFS_OVERLAYS)
return()
endif()

# build plugin -------------------------------------------------------------------------------------

file(GLOB SOURCE_FILES src/*.cpp)

# Resoucre files and header files are only added in order to make them available in your IDE.
file(GLOB HEADER_FILES src/*.hpp)
file(GLOB_RECURSE RESOUCRE_FILES gui/*)

add_library(csp-wfs-overlays SHARED
${SOURCE_FILES}
${HEADER_FILES}
${RESOUCRE_FILES}
)

target_link_libraries(csp-wfs-overlays
PUBLIC
cs-core
)

# Add this Plugin to a "plugins" folder in your IDE.
set_property(TARGET csp-wfs-overlays PROPERTY FOLDER "plugins")

# We mark all resource files as "header" in order to make sure that no one tries to compile them.
set_source_files_properties(${RESOUCRE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE)

# Make directory structure available in your IDE.
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES
${SOURCE_FILES} ${HEADER_FILES} ${RESOUCRE_FILES}
)

# install plugin -----------------------------------------------------------------------------------

install(TARGETS csp-wfs-overlays DESTINATION "share/plugins")
install(DIRECTORY "gui" DESTINATION "share/resources")
install(DIRECTORY "textures" DESTINATION "share/resources")
34 changes: 34 additions & 0 deletions plugins/csp-wfs-overlays/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
SPDX-License-Identifier: CC-BY-4.0
-->

# WFS Overlays for CosmoScout VR

A CosmoScout VR plugin which loads data from a server and draws it. The specific options within a certain server are shown in a list so the user can select what to render. Some other features like the size and color of the features can be adjusted.

## Configuration

This plugin can be enabled with the following configuration in your `settings.json`.

```javascript
{
...
"plugins": {
...
"csp-wfs-overlays": {
"enabled": true,
"wfs": [
"https://maps.dwd.de/geoserver/dwd/wfs",
"https://geoservice.dlr.de/eoc/basemap/wfs"
],
"interpolation": false
}
}
}
```
## Usage
Once the plugin is loaded, you can select the server and its specific data to render. For now, only the DWD and DLR geoservers are included, but any other Web Feature Services should work by just adding its URL at the settings.
* The main properties related to the size of the points and lines (maximum and minimum values, step value) can be easily modified through the .html file.
* For points, it is possible to load any texture (image). We use a circled-shape.
* Regarding the lines, there is an option at the settings sidetab that allows us to choose if we want to use an interpolation Bézier-curve based method to get a smoother rendering.
104 changes: 104 additions & 0 deletions plugins/csp-wfs-overlays/gui/js/csp-wfs-overlays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
// SPDX-License-Identifier: MIT

(() => {
/**
* Atmosphere Api
*/
class WfsOverlaysApi extends IApi {
/**
* @inheritDoc
*/
name = 'wfsOverlays';

/**
* @inheritDoc
*/
init() {
this._colorDiv = document.getElementById("bookmark-editor-color");
}

// Here we manage the properties display at the GUI
//-------------------------------------------------
setFeatureProperties (properties) {

const props = JSON.parse(properties);
const tableContainer = document.getElementById("tableContainer");
const tbody = document.getElementById("tableBody");

tbody.innerHTML = " ";

props.featureTypes[0].properties.forEach((item) => {

const row = document.createElement("tr");

// name cell
const nameCell = document.createElement("td");
nameCell.textContent = item.name;
row.appendChild(nameCell);

// type cell
const typeCell = document.createElement("td");
typeCell.textContent = item.localType;
row.appendChild(typeCell);

// color cell
const colorCell = document.createElement("td");
if (item.localType == "string") {
const radioButton = document.createElement("input");
radioButton.type = "radio";
radioButton.name = "selectedColor";
radioButton.value = item.name;
radioButton.style.display = "block";
radioButton.addEventListener("click", () => { CosmoScout.callbacks.wfsOverlays.setColor(item.name)});
colorCell.appendChild(radioButton);
}
row.appendChild(colorCell);

// time cell (note that unlike for the color cell, we do not process dates in the .cpp)
const timeCell = document.createElement("td");
if (item.localType == "date-time") {
const radioButtonTime = document.createElement("input");
radioButtonTime.type = "radio";
radioButtonTime.name = "selectedTime";
radioButtonTime.value = item.name;
radioButtonTime.style.display = "block";
// we could add an event listener here
timeCell.appendChild(radioButtonTime);
}
row.appendChild(timeCell);

// append the whole row containing all the cells above (name, type, color, time)
tbody.appendChild(row);
});
}

// Here we manage the point size selection displayed at the GUI
//-------------------------------------------------------------
setSize () {
const sizeSlider = document.getElementById("size-slider");
sizeSlider.addEventListener('change', function () {
const selectedValue = sizeSlider.value;
CosmoScout.callbacks.wfsOverlays.setSize(selectedValue);
});
}

// Here we manage the line width selection displayed at the GUI
//-------------------------------------------------------------
setWidth () {
const widthSlider = document.getElementById("width-slider");
widthSlider.addEventListener('change', function () {
const selectedValue = widthSlider.value;
CosmoScout.callbacks.wfsOverlays.setWidth(selectedValue);
// console.log("js::Width transmitido al cpp:", typeof selectedValue);
});
}

}

CosmoScout.init(WfsOverlaysApi);
})();
31 changes: 31 additions & 0 deletions plugins/csp-wfs-overlays/gui/wfs_overlays_settings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
SPDX-License-Identifier: MIT
-->

<!------- BUTTON TO ENABLE / DISABLE THE PLUGIN ------->
<div class="row">
<div class="col-5">
<label class="checklabel">
<input type="checkbox" data-callback="wfsOverlays.setEnabled" checked />
<i class="material-icons"></i>
<span>Enabled</span>
</label>
</div>
</div>

<div class="strike">
<span>Line rendering</span>
</div>

<!------- BUTTON TO ENABLE / DISABLE THE INTERPOLATION ------->
<div class="row">
<div class="col-5">
<label class="checklabel">
<input type="checkbox" data-callback="wfsOverlays.setInterpolation" checked />
<i class="material-icons"></i>
<span>Interpolation</span>
</label>
</div>
</div>

78 changes: 78 additions & 0 deletions plugins/csp-wfs-overlays/gui/wfs_overlays_tab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!--
SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
SPDX-License-Identifier: MIT
-->

<div class="strike">
<span>Dataset Selection</span>
</div>

<!------- SERVER SELECTION ------->
<div class="row mb-1">
<div class="col-5">
<label>WFS Server</label>
</div>
<div class="col-6" offset-1>
<select data-callback="wfsOverlays.setServer" data-container="#cosmoscout" data-width="100%"
class="simple-value-dropdown" data-dropdown-align-right="true">
<!-- Filled by JavaScript Function called from Plugin.cpp -->
</select>
</div>
</div>

<!------- FEATURE TYPE SELECTION ------->
<div class="row mb-1">
<div class="col-5">
<label>Feature type</label>
</div>
<div class="col-6" offset-1>
<select data-callback="wfsOverlays.setWFSFeatureType" data-container="#cosmoscout" data-width="100%"
class="simple-value-dropdown" data-dropdown-align-right="true" data-live-search="true">
<!-- Filled by JavaScript Function called from Plugin.cpp -->
</select>
</div>
</div>

<!------- PROPERTIES MANAGEMENT ------->
<div class="row mb-1">
<div class="col-5">
<label>Properties</label>
</div>
</div>
<table id = "tableContainer" style = "width: 100%">
<thead>
<th>Property Name:</th>
<th>Type:</th>
<th>Color:</th>
<th>Time:</th>
</thead>
<tbody id = "tableBody">
<!-- Filled by JavaScript Function called from Plugin.cpp -->
</tbody>
</table>

<div class="strike">
<span>Style</span>
</div>

<!------- POINT SIZE SELECTION ------->
<div class="row mb-1">
<div class="col-5">
<label> Point size: </label>
</div>
<div class="slidecontainer">
<input data-callback="wfsOverlays.setSize" id="size-slider" type="range" min="0.01" max="0.03" step="0.001" value="0.02">
<!-- Filled by JavaScript Function called from Plugin.cpp -->
</div>
</div>

<!------- LINE WIDTH SELECTION ------->
<div class="row mb-1">
<div class="col-5">
<label> Line width: </label>
</div>
<div class="slidecontainer">
<input data-callback="wfsOverlays.setWidth" id="width-slider" type="range" min="1.0" max="3.0" step="0.05" value="2.0">
<!-- Filled by JavaScript Function called from Plugin.cpp -->
</div>
</div>
247 changes: 247 additions & 0 deletions plugins/csp-wfs-overlays/src/LineRenderer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
// SPDX-License-Identifier: MIT

#include "LineRenderer.hpp"
#include "logger.hpp"

#include "../../../src/cs-core/Settings.hpp"

#include <VistaKernel/GraphicsManager/VistaSceneGraph.h>
#include <VistaKernel/GraphicsManager/VistaTransformNode.h>
#include <VistaKernel/VistaSystem.h>
#include <VistaKernelOpenSGExt/VistaOpenSGMaterialTools.h>
#include <VistaMath/VistaBoundingBox.h>
#include <VistaOGLExt/VistaOGLUtils.h>

#include <glm/gtc/constants.hpp>
#include <glm/gtc/type_ptr.hpp>

#include "../../../src/cs-utils/utils.hpp"

namespace csp::wfsoverlays {

const char* LineRenderer::FEATURE_VERT = R"(
#version 330 core
layout (location=0) in vec3 aPos;
layout (location=1) in vec3 aColor;
out vec3 vertexColor;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main(){
gl_Position = projection * view * model * vec4(aPos, 1.0);
vertexColor = aColor;
}
)";

const char* LineRenderer::FEATURE_FRAG = R"(
in vec3 vertexColor;
uniform float uAmbientBrightness;
uniform float uSunIlluminance;
uniform vec3 uSunDirection;
out vec4 FragColor;
const float PI = 3.14159265359;
// ===========================================================================
vec3 SRGBtoLINEAR(vec3 srgbIn)
{
vec3 bLess = step(vec3(0.04045),srgbIn);
return mix( srgbIn/vec3(12.92), pow((srgbIn+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
}
void main(){
vec3 result = vertexColor.rgb;
#ifdef ENABLE_HDR
result = SRGBtoLINEAR(result) * uSunIlluminance / PI;
#else
result = result * uSunIlluminance;
#endif
FragColor = vec4(result, 1.0);
}
)";

LineRenderer::LineRenderer (std::vector<glm::vec3> coordinates, std::shared_ptr<cs::core::SolarSystem> solarSystem,
std::shared_ptr<cs::core::Settings> settings, double lineWidth, std::shared_ptr<Settings> pluginSettings) {
mSolarSystem = solarSystem;
mCoordinates = coordinates;
mSettings = settings;
mPluginSettings = pluginSettings;
mLineWidthInput = lineWidth;
mShaderDirty = true;

VistaSceneGraph* pSG = GetVistaSystem()->GetGraphicsManager()->GetSceneGraph();
mGLNode.reset(pSG->NewOpenGLNode(pSG->GetRoot(), this));
VistaOpenSGMaterialTools::SetSortKeyOnSubtree(mGLNode.get(), static_cast<int>(cs::utils::DrawOrder::eOpaqueItems));

glGenVertexArrays(1, &mVAO);

// Generating the VBO to manage the memory of the input vertex
unsigned int VBO;
glGenBuffers(1, &VBO);

// Binding the mVAO
glBindVertexArray(mVAO);
// Binding the VBO
glBindBuffer(GL_ARRAY_BUFFER, VBO);

// Copying user-defined data into the current bound buffer
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * mCoordinates.size(), mCoordinates.data(), GL_STATIC_DRAW);

// Setting the vertex coordinates attribute pointers
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);

// Setting the vertex colors attributes pointers
glVertexAttribPointer(1, 3, GL_FLOAT, GL_TRUE, 6 * sizeof(float), (void*)(3 * sizeof(float))); // color vertex attribute pointers
glEnableVertexAttribArray(1);

glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);

// Recreate the shader if HDR rendering mode are toggled.
mHDRConnection = mSettings->mGraphics.pEnableHDR.connect([this](bool /*unused*/) { mShaderDirty = true; });
}
////////////////////////////////////////////////////////////////////////////////////////////////////

LineRenderer::~LineRenderer() {

mSettings->mGraphics.pEnableHDR.disconnect(mHDRConnection);

VistaSceneGraph* pSG = GetVistaSystem()->GetGraphicsManager()->GetSceneGraph();
pSG->GetRoot()->DisconnectChild(mGLNode.get());
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////

bool LineRenderer::Do() {

if (!mPluginSettings->mEnabled.get()) {
return true;
}

if (mShaderDirty) {

// building and compiling the vertex Shader
//-----------------------------------------
unsigned int vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, &FEATURE_VERT, NULL);
glCompileShader(vertexShader);
// check for shader compile errors
int success;
char infoLog[512];
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
if (!success) {
glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// HDR settings
std::string defines = "#version 330\n";
if (mSettings->mGraphics.pEnableHDR.get()) {
defines += "#define ENABLE_HDR\n";
}
std::string fragmentShaderCode = defines + FEATURE_FRAG;
const char * fragmentShadercStr = fragmentShaderCode.c_str();

// building and compiling the fragment Shader
//-------------------------------------------
unsigned int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, &fragmentShadercStr, NULL);
glCompileShader(fragmentShader);
// check for shader compile errors
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
if (!success) {
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
logger().info("{}", defines + FEATURE_FRAG);
}

// linking shaders
//----------------
mShaderProgram = glCreateProgram();
glAttachShader(mShaderProgram, vertexShader);
glAttachShader(mShaderProgram, fragmentShader);
glLinkProgram(mShaderProgram);
// check for linking errors
glGetProgramiv(mShaderProgram, GL_LINK_STATUS, &success);
if (!success) {
glGetProgramInfoLog(mShaderProgram, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
}
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
mShaderDirty = false;
}

auto earth = mSolarSystem->getObject("Earth");
if (!earth || !earth->getIsBodyVisible()) {
return true;
}

glUseProgram(mShaderProgram);
auto transform = earth->getObserverRelativeTransform();

glEnable(GL_PROGRAM_POINT_SIZE);

// Dealing with the different uniform matrices.
//---------------------------------------------
std::array<GLfloat, 16> glMatV{};
std::array<GLfloat, 16> glMatP{};
glGetFloatv(GL_MODELVIEW_MATRIX, glMatV.data());
glGetFloatv(GL_PROJECTION_MATRIX, glMatP.data());
auto matM = glm::mat4(transform);
auto matV = glm::make_mat4x4(glMatV.data());
// Getting the uniform matrices location
GLuint model = glGetUniformLocation(mShaderProgram, "model");
GLuint view = glGetUniformLocation(mShaderProgram, "view");
GLuint projection = glGetUniformLocation(mShaderProgram, "projection");
// Doing the uniform matrices location assignment
glUniformMatrix4fv(model, 1, GL_FALSE, glm::value_ptr(matM));
glUniformMatrix4fv(view, 1, GL_FALSE, glm::value_ptr(matV));
glUniformMatrix4fv(projection, 1, GL_FALSE, glMatP.data());

// HDR settings
//-------------
glm::vec3 sunDirection(1, 0, 0);
float sunIlluminance(1.F);
float ambientBrightness(mSettings->mGraphics.pAmbientBrightness.get());

if (mSettings->mGraphics.pEnableHDR.get()) {
sunIlluminance = static_cast<float>(mSolarSystem->getSunIlluminance(transform[3]));
}
sunDirection = glm::normalize(glm::inverse(transform) * glm::dvec4(mSolarSystem->getSunDirection(transform[3]), 0.0));
// HDR uniform locations
GLint uSunDirectionLocation = glGetUniformLocation(mShaderProgram, "uSunDirection");
GLint uSunIlluminanceLocation = glGetUniformLocation(mShaderProgram, "uSunIlluminance");
GLint uAmbientBrightnessLocation = glGetUniformLocation(mShaderProgram, "uAmbientBrightness");
// HDR uniform assignment
glUniform1f (uAmbientBrightnessLocation, ambientBrightness);
glUniform1f (uSunIlluminanceLocation, sunIlluminance);
glUniform3fv (uSunDirectionLocation, 1, glm::value_ptr(sunDirection));

// Draw
glBindVertexArray(mVAO);
GLfloat lineWidthGL = static_cast<GLfloat>(mLineWidthInput);
glLineWidth(lineWidthGL);
glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(3 * mCoordinates.size()));
glBindVertexArray(0);

return true;
}

bool LineRenderer::GetBoundingBox(VistaBoundingBox& bb) {
return false;
}
}
50 changes: 50 additions & 0 deletions plugins/csp-wfs-overlays/src/LineRenderer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
// SPDX-License-Identifier: MIT

#ifndef CSP_WFS_OVERLAYS_LINE_RENDERER_HPP
#define CSP_WFS_OVERLAYS_LINE_RENDERER_HPP

#include <VistaKernel/GraphicsManager/VistaOpenGLDraw.h>
#include <VistaKernel/GraphicsManager/VistaOpenGLNode.h>
#include <vector>
#include <memory>
#include "WFSTypes.hpp"
#include <glm/glm.hpp>
#include "../../../src/cs-core/SolarSystem.hpp"

namespace csp::wfsoverlays {
class LineRenderer : public IVistaOpenGLDraw {

public:

LineRenderer (std::vector<glm::vec3> coordinates, std::shared_ptr<cs::core::SolarSystem> solarSystem, std::shared_ptr<cs::core::Settings> settings,
double lineWidth, std::shared_ptr<Settings> pluginSettings);
~LineRenderer();
bool Do() override;
bool GetBoundingBox(VistaBoundingBox& bb) override;

private:

std::vector<glm::vec3> mCoordinates;
std::unique_ptr<VistaOpenGLNode> mGLNode;
std::shared_ptr<cs::core::SolarSystem> mSolarSystem;
std::shared_ptr<cs::core::Settings> mSettings;
std::shared_ptr<Settings> mPluginSettings;
double mLineWidthInput;
int mHDRConnection;
bool mShaderDirty;

unsigned int mVAO;
unsigned int mShaderProgram;

static const char* FEATURE_VERT;
static const char* FEATURE_FRAG;
};
}


#endif // CSP_WFS_OVERLAYS_LINE_RENDERER_HPP
1,143 changes: 1,143 additions & 0 deletions plugins/csp-wfs-overlays/src/Plugin.cpp

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions plugins/csp-wfs-overlays/src/Plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
// SPDX-License-Identifier: MIT

#ifndef CSP_WFS_OVERLAYS_PLUGIN_HPP
#define CSP_WFS_OVERLAYS_PLUGIN_HPP

#include "../../../src/cs-core/PluginBase.hpp"
#include "../../../src/cs-core/Settings.hpp"
#include "../../../src/cs-utils/Property.hpp"
#include <memory>
#include <unordered_set>
#include "LineRenderer.hpp"
#include "PointRenderer.hpp"
#include "WFSTypes.hpp"

namespace csp::wfsoverlays {

/// This plugin represents Web Feature Servivces data in space. The plugin is configurable via the application
/// config file. See README.md for details.

struct InfoStruct {
glm::dvec2 mLongLatDegrees;
glm::dvec2 mLongLatRadians;
glm::dvec3 mCartesian;
double mOverSurfaceHeight;
bool mHeightComesFromJson;
};

class Plugin : public cs::core::PluginBase {

public:

void init() override;
void deInit() override;
void update() override;

void setWFSServer(std::string URL);
void setWFSFeatureType(std::string featureType);
void setRendering(double pointSize, double lineWidth);
double calculateDistance(InfoStruct const& p1, InfoStruct const& p2, glm::vec3 earthRadius);
void correctHeight (InfoStruct const& struct1, InfoStruct const& struct2, InfoStruct& temporaryStruct, std::shared_ptr<const cs::scene::CelestialObject> earth);
double calculateAngle (InfoStruct const& previousPoint, InfoStruct const& middlePoint, InfoStruct const& nextPoint);
std::vector<InfoStruct> interpolation (std::vector<InfoStruct> const& structsIn, double thresholdAngle, glm::vec3 earthRadius, std::shared_ptr<const cs::scene::CelestialObject> earth);
std::vector<glm::dvec3> generateMidPoint (std::vector <InfoStruct> const& structIn, float threshold, glm::vec3 earthRadius, std::shared_ptr<const cs::scene::CelestialObject> earth, glm::vec3 featureColor);

private:

void onLoad();
void onSave();

std::shared_ptr<Settings> mPluginSettings = std::make_shared<Settings>();
std::string mBaseUrl;
WFSFeatureCollection mFeatureLocation;
DescribeFeatureType mPropertiesStruct;
std::stringstream mJsonStream;
std::unique_ptr<PointRenderer> mPointRenderer;
std::unique_ptr<LineRenderer> mLineStringRenderer;
std::unique_ptr<LineRenderer> mPolygonRenderer;
std::string mColor;
std::string mTime;
std::string mSelectedFeature;

int mOnLoadConnection = -1;
int mOnSaveConnection = -1;
};

} // namespace csp::wfsoverlays

#endif // CSP_WFS_OVERLAYS_PLUGIN_HPP
339 changes: 339 additions & 0 deletions plugins/csp-wfs-overlays/src/PointRenderer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,339 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
// SPDX-License-Identifier: MIT

#include "PointRenderer.hpp"
#include "logger.hpp"

#include "../../../src/cs-core/Settings.hpp"

#include <VistaKernel/GraphicsManager/VistaSceneGraph.h>
#include <VistaKernel/GraphicsManager/VistaTransformNode.h>
#include <VistaKernel/VistaSystem.h>
#include <VistaKernel/DisplayManager/VistaDisplayManager.h>
#include <VistaKernel/DisplayManager/VistaViewport.h>
#include <VistaKernelOpenSGExt/VistaOpenSGMaterialTools.h>
#include <VistaMath/VistaBoundingBox.h>
#include <VistaOGLExt/VistaOGLUtils.h>
#include "../../../src/cs-graphics/TextureLoader.hpp"

#include <glm/gtc/constants.hpp>
#include <glm/gtc/type_ptr.hpp>

#include "../../../src/cs-utils/utils.hpp"

namespace csp::wfsoverlays {

const char* PointRenderer::FEATURE_VERT = R"(
#version 330 core
layout (location=0) in vec3 aPos;
layout (location=1) in vec3 aColor;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
out vec3 vertexColor;
out VS_OUT {
vec3 color;
} vs_out;
void main(){
gl_Position = projection * view * model * vec4(aPos, 1.0);
vs_out.color = aColor;
}
)";

const char* PointRenderer::FEATURE_GEOM = R"(
#version 330 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in VS_OUT {
vec3 color;
} gs_in[];
uniform vec2 circleSize;
out vec3 vertexColor;
out vec2 fragTexCoords;
void build_square(vec4 position) { // for each point, it will create 4 vertices (which will be later used as texture coordinates)
vertexColor = gs_in[0].color;
gl_Position = position + vec4(-circleSize.x, -circleSize.y, 0.1, 0.0); // 1:bottom-left
fragTexCoords = vec2(0.0, 0.0);
EmitVertex();
gl_Position = position + vec4(circleSize.x, -circleSize.y, 0.1, 0.0); // 2:bottom-right
fragTexCoords = vec2(1.0, 0.0);
EmitVertex();
gl_Position = position + vec4(-circleSize.x, circleSize.y, 0.1, 0.0); // 3:top-left
fragTexCoords = vec2(0.0, 1.0);
EmitVertex();
gl_Position = position + vec4(circleSize.x, circleSize.y, 0.1, 0.0); // 4:top-right
fragTexCoords = vec2(1.0, 1.0);
EmitVertex();
EndPrimitive();
}
void main() {
build_square(gl_in[0].gl_Position);
}
)";

const char* PointRenderer::FEATURE_FRAG = R"(
in vec3 vertexColor;
in vec2 fragTexCoords;
uniform float uAmbientBrightness;
uniform float uSunIlluminance;
uniform vec3 uSunDirection;
uniform sampler2D ourTexture;
out vec4 FragColor;
const float PI = 3.14159265359;
// ===========================================================================
vec3 SRGBtoLINEAR(vec3 srgbIn)
{
vec3 bLess = step(vec3(0.04045),srgbIn);
return mix( srgbIn/vec3(12.92), pow((srgbIn+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
}
void main(){
vec3 result = vertexColor.rgb;
#ifdef ENABLE_HDR
result = SRGBtoLINEAR(result) * uSunIlluminance / PI;
#else
result = result * uSunIlluminance;
#endif
FragColor = texture(ourTexture, fragTexCoords) * vec4(result, 1.0);
}
)";

PointRenderer::PointRenderer (std::vector<glm::vec3> coordinates, std::shared_ptr<cs::core::SolarSystem> solarSystem,
std::shared_ptr<cs::core::Settings> settings, double pointSize, std::shared_ptr<Settings> pluginSettings) {

mSolarSystem = solarSystem;
mCoordinates = coordinates;
mSettings = settings;
mPluginSettings = pluginSettings;
mPointSizeInput = pointSize;
mShaderDirty = true;

VistaSceneGraph* pSG = GetVistaSystem()->GetGraphicsManager()->GetSceneGraph();
mGLNode.reset(pSG->NewOpenGLNode(pSG->GetRoot(), this));
VistaOpenSGMaterialTools::SetSortKeyOnSubtree(mGLNode.get(), static_cast<int>(cs::utils::DrawOrder::eOpaqueItems));

glGenVertexArrays(1, &mVAO);

// Generating the VBO to manage the memory of the input vertex
unsigned int VBO;
glGenBuffers(1, &VBO);

// Binding the mVAO
glBindVertexArray(mVAO);
// Binding the VBO
glBindBuffer(GL_ARRAY_BUFFER, VBO);

// Copying user-defined data into the current bound buffer
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * mCoordinates.size(), mCoordinates.data(), GL_STATIC_DRAW);

// Setting the vertex coordinates attribute pointers
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);

// Setting the vertex colors attribute pointers
glVertexAttribPointer(1, 3, GL_FLOAT, GL_TRUE, 6 * sizeof(float), (void*)(3 * sizeof(float)));
glEnableVertexAttribArray(1);

glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);

// Recreate the shader if HDR rendering mode are toggled.
mHDRConnection = mSettings->mGraphics.pEnableHDR.connect([this](bool /*unused*/) { mShaderDirty = true; });

// load and create a texture
mTexture = cs::graphics::TextureLoader::loadFromFile("../share/resources/textures/Circle.png");
}

////////////////////////////////////////////////////////////////////////////////////////////////////

PointRenderer::~PointRenderer() {

mSettings->mGraphics.pEnableHDR.disconnect(mHDRConnection);

VistaSceneGraph* pSG = GetVistaSystem()->GetGraphicsManager()->GetSceneGraph();
pSG->GetRoot()->DisconnectChild(mGLNode.get());
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////

bool PointRenderer::Do() {

if (!mPluginSettings->mEnabled.get()) {
return true;
}

if (mShaderDirty) {

// building and compiling the vertex Shader
//-----------------------------------------
unsigned int vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, &FEATURE_VERT, NULL);
glCompileShader(vertexShader);
// check for shader compile errors
int success;
char infoLog[512];
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
if (!success) {
glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// HDR settings
std::string defines = "#version 330\n";
if (mSettings->mGraphics.pEnableHDR.get()) {
defines += "#define ENABLE_HDR\n";
}
std::string fragmentShaderCode = defines + FEATURE_FRAG;
const char * fragmentShadercStr = fragmentShaderCode.c_str();

// building and compiling the fragment Shader
//-------------------------------------------
unsigned int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, &fragmentShadercStr, NULL);
glCompileShader(fragmentShader);
// check for shader compile errors
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
if (!success) {
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
logger().info("{}", defines + FEATURE_FRAG);
}

// building and compiling the geometry Shader
//-------------------------------------------
unsigned int geometryShader = glCreateShader(GL_GEOMETRY_SHADER);
glShaderSource(geometryShader, 1, &FEATURE_GEOM, NULL);
glCompileShader(geometryShader);
// check for shader compile errors
glGetShaderiv(geometryShader, GL_COMPILE_STATUS, &success);
if (!success) {
glGetShaderInfoLog(geometryShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::GEOMETRY::COMPILATION_FAILED\n" << infoLog << std::endl;
}

// linking shaders
//----------------
mShaderProgram = glCreateProgram();
glAttachShader(mShaderProgram, vertexShader);
glAttachShader(mShaderProgram, geometryShader);
glAttachShader(mShaderProgram, fragmentShader);
glLinkProgram(mShaderProgram);
// check for linking errors
glGetProgramiv(mShaderProgram, GL_LINK_STATUS, &success);
if (!success) {
glGetProgramInfoLog(mShaderProgram, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
}
glDeleteShader(vertexShader);
glDeleteShader(geometryShader);
glDeleteShader(fragmentShader);
mShaderDirty = false;
}

auto earth = mSolarSystem->getObject("Earth");
if (!earth || !earth->getIsBodyVisible()) {
return true;
}

glUseProgram(mShaderProgram);
auto transform = earth->getObserverRelativeTransform();

// Dealing with the different uniform matrices.
//---------------------------------------------
std::array<GLfloat, 16> glMatV{};
std::array<GLfloat, 16> glMatP{};
glGetFloatv(GL_MODELVIEW_MATRIX, glMatV.data());
glGetFloatv(GL_PROJECTION_MATRIX, glMatP.data());
auto matM = glm::mat4(transform);
auto matV = glm::make_mat4x4(glMatV.data());
// Getting the uniform matrices location
GLuint model = glGetUniformLocation(mShaderProgram, "model");
GLuint view = glGetUniformLocation(mShaderProgram, "view");
GLuint projection = glGetUniformLocation(mShaderProgram, "projection");
// Doing the uniform matrices location assignment
glUniformMatrix4fv(model, 1, GL_FALSE, glm::value_ptr(matM));
glUniformMatrix4fv(view, 1, GL_FALSE, glm::value_ptr(matV));
glUniformMatrix4fv(projection, 1, GL_FALSE, glMatP.data());

// Normalizing in terms of the CS windows size in order to have the texture coordinates within the (0,1) interval
//---------------------------------------------------------------------------------------------------------------
int width, height;
VistaViewport* pViewport(GetVistaSystem()->GetDisplayManager()->GetViewports().begin()->second);
pViewport->GetViewportProperties()->GetSize(width, height);
float aspectRatio = static_cast<float>(width) / height;
GLuint circleSize = glGetUniformLocation(mShaderProgram, "circleSize");
GLfloat pointSizeGL = static_cast<GLfloat>(mPointSizeInput);
glUniform2f (circleSize, pointSizeGL, pointSizeGL * aspectRatio);

// HDR settings
//-------------
glm::vec3 sunDirection(1, 0, 0);
float sunIlluminance(1.F);
float ambientBrightness(mSettings->mGraphics.pAmbientBrightness.get());

if (mSettings->mGraphics.pEnableHDR.get()) {
sunIlluminance = static_cast<float>(mSolarSystem->getSunIlluminance(transform[3]));
}
sunDirection = glm::normalize(glm::inverse(transform) * glm::dvec4(mSolarSystem->getSunDirection(transform[3]), 0.0));
// HDR uniform locations
GLint uSunDirectionLocation = glGetUniformLocation(mShaderProgram, "uSunDirection");
GLint uSunIlluminanceLocation = glGetUniformLocation(mShaderProgram, "uSunIlluminance");
GLint uAmbientBrightnessLocation = glGetUniformLocation(mShaderProgram, "uAmbientBrightness");
// HDR uniform assignment
glUniform1f (uAmbientBrightnessLocation, ambientBrightness);
glUniform1f (uSunIlluminanceLocation, sunIlluminance);
glUniform3fv (uSunDirectionLocation, 1, glm::value_ptr(sunDirection));

// Texture settings
//-----------------
glPushAttrib(GL_BLEND);
glPushAttrib(GL_ENABLE_BIT);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Texture location and assignment
GLuint ourTexture = glGetUniformLocation(mShaderProgram, "ourTexture");
glUniform1i(ourTexture, 0);
mTexture->Bind(GL_TEXTURE0);

// Draw
glBindVertexArray(mVAO);
glDisable(GL_CULL_FACE);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(3 * mCoordinates.size()));
glBindVertexArray(0);
glEnable(GL_CULL_FACE);
mTexture->Unbind(GL_TEXTURE0);
glPopAttrib();
glPopAttrib();

return true;
}

bool PointRenderer::GetBoundingBox(VistaBoundingBox& bb) {
return false;
}
}
53 changes: 53 additions & 0 deletions plugins/csp-wfs-overlays/src/PointRenderer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
// SPDX-License-Identifier: MIT

#ifndef CSP_WFS_OVERLAYS_POINT_RENDERER_HPP
#define CSP_WFS_OVERLAYS_POINT_RENDERER_HPP

#include <VistaKernel/GraphicsManager/VistaOpenGLDraw.h>
#include <VistaKernel/GraphicsManager/VistaOpenGLNode.h>
#include <vector>
#include <memory>
#include "WFSTypes.hpp"
#include <glm/glm.hpp>
#include "../../../src/cs-core/SolarSystem.hpp"
#include <VistaOGLExt/VistaTexture.h>

namespace csp::wfsoverlays {
class PointRenderer : public IVistaOpenGLDraw {

public:

PointRenderer (std::vector<glm::vec3> coordinates, std::shared_ptr<cs::core::SolarSystem> solarSystem, std::shared_ptr<cs::core::Settings> settings,
double pointSize, std::shared_ptr<Settings> pluginSettings);
~PointRenderer();
bool Do() override;
bool GetBoundingBox(VistaBoundingBox& bb) override;

private:

std::vector<glm::vec3> mCoordinates;
std::unique_ptr<VistaOpenGLNode> mGLNode;
std::shared_ptr<cs::core::SolarSystem> mSolarSystem;
std::shared_ptr<cs::core::Settings> mSettings;
std::shared_ptr<Settings> mPluginSettings;
std::unique_ptr<VistaTexture> mTexture;
double mPointSizeInput;
int mHDRConnection;
bool mShaderDirty;

unsigned int mVAO;
unsigned int mShaderProgram;

static const char* FEATURE_VERT;
static const char* FEATURE_GEOM;
static const char* FEATURE_FRAG;
};
}


#endif // CSP_WFS_OVERLAYS_POINT_RENDERER_HPP
123 changes: 123 additions & 0 deletions plugins/csp-wfs-overlays/src/WFSTypes.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
// SPDX-License-Identifier: MIT

#ifndef CSP_WFS_OVERLAYS_WFS_TYPES_HPP
#define CSP_WFS_OVERLAYS_WFS_TYPES_HPP

#include <vector>
#include <string>
#include <array>
#include <unordered_map>
#include <nlohmann/json.hpp>
#include "../../../src/cs-utils/Property.hpp"
#include "../../../src/cs-core/Settings.hpp"


namespace csp::wfsoverlays {
struct Settings {
cs::utils::DefaultProperty<bool> mEnabled{true};
std::vector<std::string> mWfs;
cs::utils::DefaultProperty<bool> mInterpolation{false};
};

// defining the vectors we will later use (just for a tidy code)
using PointCoordinates = std::vector<double>; // for points
using LineStringCoordinates = std::vector<std::vector<double>>; // for lineStrings and multiPoints
using PolygonCoordinates = std::vector <std::vector <std::vector<double>>>; // for polygons MultiLineString
using MultiPolygonCoordinates = std::vector <std::vector <std::vector <std::vector<double>>>>; // for multiPolygons

struct GeometryBase {
std::string mType;
GeometryBase(std::string type) : mType(type) {}
virtual ~GeometryBase() = default;
};

struct Point : public GeometryBase {
PointCoordinates mCoordinates;
Point (PointCoordinates coordinates) : GeometryBase("Point"), mCoordinates(coordinates) {}
};

struct MultiPoint : public GeometryBase {
LineStringCoordinates mCoordinates;
MultiPoint (LineStringCoordinates coordinates) : GeometryBase("MultiPoint"), mCoordinates(coordinates) {}
};

struct LineString : public GeometryBase {
LineStringCoordinates mCoordinates;
LineString (LineStringCoordinates coordinates) : GeometryBase("LineString"), mCoordinates(coordinates) {}
};

struct MultiLineString : public GeometryBase {
PolygonCoordinates mCoordinates;
MultiLineString (PolygonCoordinates coordinates) : GeometryBase("MultiLineString"), mCoordinates(coordinates) {}
};

struct Polygon : public GeometryBase {
PolygonCoordinates mCoordinates;
Polygon (PolygonCoordinates coordinates) : GeometryBase("Polygon"), mCoordinates(coordinates) {}
} ;

struct MultiPolygon : public GeometryBase {
MultiPolygonCoordinates mCoordinates;
MultiPolygon (MultiPolygonCoordinates coordinates) : GeometryBase("MultiPolygon"), mCoordinates(coordinates) {}
};

struct Feature {
std::string mType;
std::string mId;
std::shared_ptr<GeometryBase> mGeometry;
std::string mGeometry_name;
std::unordered_map<std::string, nlohmann::json> mProperties;
// std::array<float, 4> mBbox;
};

struct CRS {
std::string mType;
//std::unordered_map<std::string, std::string> mProperties;
};

struct WFSFeatureCollection {
std::string mType;
std::vector<Feature> mFeatures;
int mTotalFeatures;
int mNumberMatched;
int mNumberReturned;
std::string mTimeStamp;
CRS mCrs;
// std::array<float, 4> mBbox;
};

/////////////////////////////

struct Property {
std::string mName;
int mMaxOccurs;
int mMinOccurs;
bool mNillable;
std::string mType;
std::string mLocalType;
};

struct FeatureType {
std::string mTypeName;
std::vector<Property> mProperties;
};

struct DescribeFeatureType {
std::string mElementFormDefault;
std::string mTargetNamespace;
std::string mTargetPrefix;
std::vector<FeatureType> mFeatureTypes;
};

double mPointSize;
double mLineWidth;

}


#endif // CSP_WFS_OVERLAYS_WFS_TYPES_HPP
23 changes: 23 additions & 0 deletions plugins/csp-wfs-overlays/src/logger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
// SPDX-License-Identifier: MIT

#include "logger.hpp"

#include "../../../src/cs-utils/logger.hpp"

namespace csp::wfsoverlays {

////////////////////////////////////////////////////////////////////////////////////////////////////

spdlog::logger& logger() {
static auto logger = cs::utils::createLogger("csp-wfs-overlays");
return *logger;
}

////////////////////////////////////////////////////////////////////////////////////////////////////

} // csp::wfsoverlays
21 changes: 21 additions & 0 deletions plugins/csp-wfs-overlays/src/logger.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: German Aerospace Center (DLR) <cosmoscout@dlr.de>
// SPDX-License-Identifier: MIT

#ifndef CSP_WFS_OVERLAYS_HPP
#define CSP_WFS_OVERLAYS_HPP

#include <spdlog/spdlog.h>

namespace csp::wfsoverlays {

/// This creates the default singleton logger for "csp-wfs-overlays" when called for the first time
/// and returns it. See cs-utils/logger.hpp for more logging details.
spdlog::logger& logger();

} // namespace csp::wfsoverlays

#endif // CSP_WFS_OVERLAYS_HPP
Binary file added plugins/csp-wfs-overlays/textures/Circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.