mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-10 21:49:38 -06:00
Added functions to be able to filter nodes
This commit is contained in:
@@ -20,7 +20,7 @@ openspace.setPropertyValueSingle("Modules.Space.ShowExceptions", false)
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "bastille_day_streamnodes",
|
||||
-- Identifier = "bastille_day_mas_fieldlines",
|
||||
Version = 1
|
||||
Version = 2
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace {
|
||||
//gl variables for shaders, probably needed some of them atleast
|
||||
constexpr const GLuint VaPosition = 0; // MUST CORRESPOND TO THE SHADER PROGRAM
|
||||
constexpr const GLuint VaColor = 1; // MUST CORRESPOND TO THE SHADER PROGRAM
|
||||
constexpr const GLuint VaMasking = 2; // MUST CORRESPOND TO THE SHADER PROGRAM
|
||||
constexpr const GLuint VaFiltering = 2; // MUST CORRESPOND TO THE SHADER PROGRAM
|
||||
|
||||
|
||||
// ----- KEYS POSSIBLE IN MODFILE. EXPECTED DATA TYPE OF VALUE IN [BRACKETS] ----- //
|
||||
@@ -120,10 +120,13 @@ namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo ThresholdRadiusInfo = {
|
||||
"thresholdRadius",
|
||||
"Threshold Radius",
|
||||
"This value specifies the threshold that will be changed with the radius "
|
||||
"This value specifies the threshold that will be changed with the radius."
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo FilteringInfo = {
|
||||
"filtering",
|
||||
"Filtering",
|
||||
"Use filtering to show nodes within a given range."
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum class SourceFileType : int {
|
||||
Json = 0,
|
||||
@@ -198,8 +201,10 @@ namespace openspace {
|
||||
, _pStreamGroup({ "Streams" })
|
||||
, _pNodeSize(NodeSizeInfo, 2.f, 1.f, 20.f)
|
||||
, _pLineWidth(LineWidthInfo, 1.f, 1.f, 20.f)
|
||||
, _pThresholdRadius(ThresholdRadiusInfo, -2.f, -5.f, 5.f)
|
||||
|
||||
//, _pThresholdRadius(ThresholdRadiusInfo, -2.f, -5.f, 5.f)
|
||||
, _pThresholdRadius(ThresholdRadiusInfo, 100000000000.f, 500000000.f, 400000000000.f)
|
||||
, _pFiltering(FilteringInfo, 100000.f, 500000000.f, 400000000000.f)
|
||||
|
||||
{
|
||||
_dictionary = std::make_unique<ghoul::Dictionary>(dictionary);
|
||||
}
|
||||
@@ -254,6 +259,7 @@ namespace openspace {
|
||||
glGenVertexArrays(1, &_vertexArrayObject);
|
||||
glGenBuffers(1, &_vertexPositionBuffer);
|
||||
glGenBuffers(1, &_vertexColorBuffer);
|
||||
glGenBuffers(1, &_vertexFilteringBuffer);
|
||||
|
||||
// Probably not needed, seems to be needed for additive blending
|
||||
//setRenderBin(Renderable::RenderBin::Overlay);
|
||||
@@ -378,6 +384,7 @@ namespace openspace {
|
||||
// -------------- Add non-grouped properties (enablers and buttons) -------------- //
|
||||
addProperty(_pStreamsEnabled);
|
||||
addProperty(_pLineWidth);
|
||||
addProperty(_pFiltering);
|
||||
// ----------------------------- Add Property Groups ----------------------------- //
|
||||
addPropertySubOwner(_pStreamGroup);
|
||||
addPropertySubOwner(_pColorGroup);
|
||||
@@ -398,6 +405,9 @@ namespace openspace {
|
||||
glDeleteBuffers(1, &_vertexColorBuffer);
|
||||
_vertexColorBuffer = 0;
|
||||
|
||||
glDeleteBuffers(1, &_vertexFilteringBuffer);
|
||||
_vertexFilteringBuffer = 0;
|
||||
|
||||
if (_shaderProgram) {
|
||||
global::renderEngine.removeRenderProgram(_shaderProgram.get());
|
||||
_shaderProgram = nullptr;
|
||||
@@ -472,7 +482,7 @@ namespace openspace {
|
||||
_shaderProgram->setUniform(_uniformCache.streamColor, _pStreamColor);
|
||||
_shaderProgram->setUniform(_uniformCache.usingParticles, _pStreamsEnabled);
|
||||
_shaderProgram->setUniform(_uniformCache.nodeSize, 1);
|
||||
_shaderProgram->setUniform(_uniformCache.thresholdRadius, 0);
|
||||
_shaderProgram->setUniform(_uniformCache.thresholdRadius, _pThresholdRadius);
|
||||
|
||||
const std::vector<glm::vec3>& vertPos = _vertexPositions;
|
||||
glBindVertexArray(_vertexArrayObject);
|
||||
@@ -586,9 +596,8 @@ namespace openspace {
|
||||
_needsUpdate = false;
|
||||
_newStateIsReady = false;
|
||||
|
||||
|
||||
updateVertexColorBuffer();
|
||||
|
||||
updateVertexFilteringBuffer();
|
||||
unbindGL();
|
||||
|
||||
}
|
||||
@@ -651,7 +660,7 @@ namespace openspace {
|
||||
//LDEBUG("Phi value: " + (*lineIter)["Phi"].get<std::string>());
|
||||
//LDEBUG("Theta value: " + (*lineIter)["Theta"].get<std::string>());
|
||||
//LDEBUG("R value: " + (*lineIter)["R"].get<std::string>());
|
||||
// LDEBUG("Flux value: " + (*lineIter)["Flux"].get<std::string>());
|
||||
//LDEBUG("Flux value: " + (*lineIter)["Flux"].get<std::string>());
|
||||
|
||||
//probably needs some work with types, not loading in strings.
|
||||
std::string r = (*lineIter)["R"].get<std::string>();
|
||||
@@ -680,7 +689,7 @@ namespace openspace {
|
||||
phiValue = phiValue * (180.f / pi);
|
||||
thetaValue = thetaValue * (180.0f / pi);
|
||||
rValue = rValue * AuToMeter;
|
||||
|
||||
|
||||
glm::vec3 sphericalcoordinates =
|
||||
glm::vec3(rValue, phiValue, thetaValue);
|
||||
|
||||
@@ -698,8 +707,8 @@ namespace openspace {
|
||||
//position.x = position.x * AuToMeter;
|
||||
//position.y = position.y * AuToMeter;
|
||||
//position.z = position.z * AuToMeter;
|
||||
_vertexPositions.push_back(
|
||||
position);
|
||||
_vertexPositions.push_back(
|
||||
position);
|
||||
++counter;
|
||||
// coordToMeters * glm::vec3(
|
||||
// stringToFloat((*lineIter)["Phi"].get<std::string>(), 0.0f),
|
||||
@@ -717,14 +726,13 @@ namespace openspace {
|
||||
//float red = 0.1;
|
||||
//float blue = 1;
|
||||
|
||||
/*if (fluxValue < _pThresholdRadius) {
|
||||
_vertexColor.push_back(red);
|
||||
}
|
||||
else {
|
||||
_vertexColor.push_back(blue);
|
||||
}*/
|
||||
//if (rValue >= _pThresholdRadius) {
|
||||
// _vertexRadius.push_back(rValue);
|
||||
//}
|
||||
|
||||
_vertexColor.push_back(fluxValue);
|
||||
_vertexRadius.push_back(rValue);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -771,6 +779,27 @@ namespace openspace {
|
||||
unbindGL();
|
||||
}
|
||||
|
||||
void RenderableStreamNodes::updateVertexFilteringBuffer() {
|
||||
glBindVertexArray(_vertexArrayObject);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexFilteringBuffer);
|
||||
//glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer);
|
||||
|
||||
const std::vector<float>& vertexRadius = _vertexRadius;
|
||||
|
||||
glBufferData(
|
||||
GL_ARRAY_BUFFER,
|
||||
vertexRadius.size() * sizeof(glm::vec3),
|
||||
vertexRadius.data(),
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
glEnableVertexAttribArray(VaFiltering);
|
||||
glVertexAttribPointer(VaFiltering, 1, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
unbindGL();
|
||||
|
||||
}
|
||||
|
||||
const std::vector<GLsizei>& RenderableStreamNodes::lineCount() const {
|
||||
return _lineCount;
|
||||
}
|
||||
|
||||
@@ -105,11 +105,13 @@ namespace openspace {
|
||||
size_t _nStates = 0;
|
||||
|
||||
GLuint _vertexArrayObject = 0;
|
||||
// OpenGL Vertex Buffer Object containing the extraQuantity values used for coloring
|
||||
// the lines
|
||||
GLuint _vertexColorBuffer = 0;
|
||||
// OpenGL Vertex Buffer Object containing the vertex positions
|
||||
GLuint _vertexPositionBuffer = 0;
|
||||
// OpenGL Vertex Buffer Object containing the Flux values used for coloring
|
||||
// the nodes
|
||||
GLuint _vertexColorBuffer = 0;
|
||||
// OpenGL Vertex Buffer Object containing the positions to filter the nodes
|
||||
GLuint _vertexFilteringBuffer = 0;
|
||||
// ---------------------------------- Properties ---------------------------------- //
|
||||
// Group to hold the color properties
|
||||
properties::PropertyOwner _pColorGroup;
|
||||
@@ -125,6 +127,8 @@ namespace openspace {
|
||||
properties::FloatProperty _pLineWidth;
|
||||
/// ///////////
|
||||
properties::FloatProperty _pThresholdRadius;
|
||||
// Filtering nodes within a range
|
||||
properties::FloatProperty _pFiltering;
|
||||
|
||||
|
||||
// initialization
|
||||
@@ -135,8 +139,10 @@ namespace openspace {
|
||||
std::vector<double> _startTimes;
|
||||
// Contains vertexPositions
|
||||
std::vector<glm::vec3> _vertexPositions;
|
||||
|
||||
// Contains vertex flux values for color
|
||||
std::vector<float> _vertexColor;
|
||||
// Contains vertexRedius
|
||||
std::vector<float> _vertexRadius;
|
||||
|
||||
// ----------------------------------- POINTERS ------------------------------------//
|
||||
// The Lua-Modfile-Dictionary used during initialization
|
||||
@@ -153,6 +159,7 @@ namespace openspace {
|
||||
std::vector<std::string> LoadJsonfile(std::string filepath);
|
||||
void setupProperties();
|
||||
void updateVertexColorBuffer();
|
||||
void updateVertexFilteringBuffer();
|
||||
void extractTriggerTimesFromFileNames();
|
||||
void computeSequenceEndTime();
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ in vec4 vs_color;
|
||||
in float vs_depth;
|
||||
|
||||
Fragment getFragment() {
|
||||
//if (vs_color.a == 0) {
|
||||
// discard;
|
||||
//}
|
||||
if (vs_color.a == 0) {
|
||||
discard;
|
||||
}
|
||||
|
||||
vec4 fragColor = vs_color;
|
||||
|
||||
|
||||
@@ -60,13 +60,16 @@ uniform float thresholdRadius;
|
||||
// Inputs
|
||||
// Should be provided in meters
|
||||
layout(location = 0) in vec3 in_position;
|
||||
|
||||
// The extra value used to color lines. Location must correspond to _VA_COLOR in
|
||||
// renderablefieldlinessequence.h
|
||||
layout(location = 1) in float fluxValue;
|
||||
|
||||
// The extra value used to mask out parts of lines. Location must correspond to
|
||||
// _VA_MASKING in renderablefieldlinessequence.h
|
||||
//layout(location = 2)
|
||||
//in float in_masking_scalar;
|
||||
layout(location = 2)
|
||||
in float rValue;
|
||||
|
||||
|
||||
// These should correspond to the enum 'ColorMethod' in renderablefieldlinesequence.cpp
|
||||
const int uniformColor = 0;
|
||||
@@ -95,21 +98,26 @@ void main() {
|
||||
vec4 temp = streamColor;
|
||||
//vs_color = streamColor;
|
||||
|
||||
if(thresholdRadius > fluxValue){
|
||||
//temp.x = 0.2 * streamColor.x;
|
||||
//vs_color = temp;
|
||||
vs_color = vec4(1.0, 0.3, 0.3, 1.0);
|
||||
const int largerFlux = -2;
|
||||
|
||||
//if(thresholdRadius > fluxValue){
|
||||
if(fluxValue > largerFlux){
|
||||
temp.x = 0.8 * streamColor.x;
|
||||
vs_color = temp;
|
||||
vs_color = vec4(8.0, 0.3, 0.3, 1.0);
|
||||
}
|
||||
else{
|
||||
//temp.y = 0.5 * streamColor.y;
|
||||
//vs_color = temp;
|
||||
vs_color = vec4(0.3, 1.0, 0.3, 1.0);
|
||||
vs_color = vec4(0.3, 0.7, 0.3, 1.0);
|
||||
}
|
||||
|
||||
vec4 position_in_meters = vec4(in_position, 1);
|
||||
vec4 positionClipSpace = modelViewProjection * position_in_meters;
|
||||
//vs_gPosition = vec4(modelViewTransform * dvec4(in_point_position, 1));
|
||||
gl_Position = vec4(positionClipSpace.xy, 0, positionClipSpace.w);
|
||||
if(rValue > thresholdRadius){
|
||||
vs_color = vec4(0);
|
||||
}
|
||||
|
||||
vs_depth = gl_Position.w;
|
||||
vec4 position_in_meters = vec4(in_position, 1);
|
||||
vec4 positionClipSpace = modelViewProjection * position_in_meters;
|
||||
//vs_gPosition = vec4(modelViewTransform * dvec4(in_point_position, 1));
|
||||
gl_Position = vec4(positionClipSpace.xy, 0, positionClipSpace.w);
|
||||
|
||||
vs_depth = gl_Position.w;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user