Nodesize dependent on earthposition, not working properly

This commit is contained in:
Christian Adamsson
2020-06-29 15:14:00 +02:00
parent b943b9a04b
commit 6a2c9db77b
3 changed files with 75 additions and 13 deletions

View File

@@ -188,8 +188,18 @@ namespace {
"Skipping Nodes By Radius",
"Select nodes to skip depending on Radius."
};
constexpr openspace::properties::Property::PropertyInfo DistanceMethodInfo = {
"DistanceMethod",
"Decide how to check distance",
"Deciding how to check distance."
};
constexpr openspace::properties::Property::PropertyInfo DistanceplanetInfo = {
"Distanceplanet",
"Decide what planet to check distance to",
"Deciding what planet to check distance to."
};
constexpr openspace::properties::Property::PropertyInfo DistanceThresholdInfo = {
"Slider for distance to another planet",
"distancePlanetThreshold",
"Deciding how far the values will start to ",
"Enhance the size of nodes dependent on distance to planet"
};
@@ -251,6 +261,7 @@ namespace openspace {
, _pScalingmethod(ScalingmethodInfo, OptionProperty::DisplayType::Radio)
, _pNodeskipMethod(NodeskipMethodInfo, OptionProperty::DisplayType::Radio)
, _pColorFlux(ColorFluxInfo, OptionProperty::DisplayType::Dropdown)
, _pDistancemethod(DistanceMethodInfo, OptionProperty::DisplayType::Dropdown)
, _pColorTablePath(ColorTablePathInfo)
, _pStreamColor(StreamColorInfo,
glm::vec4(0.96f, 0.88f, 0.8f, 0.5f),
@@ -779,7 +790,9 @@ namespace openspace {
// -------------- Add non-grouped properties (enablers and buttons) -------------- //
addProperty(_pLineWidth);
addProperty(_pDistancemethod);
addProperty(_pDistanceThreshold);
//addProperty(_pDomainZ);
// ----------------------------- Add Property Groups ----------------------------- //
@@ -821,6 +834,12 @@ namespace openspace {
_pNodeskipMethod.addOption(static_cast<int>(NodeskipMethod::Uniform), "Uniform");
_pNodeskipMethod.addOption(static_cast<int>(NodeskipMethod::Flux), "Flux");
_pNodeskipMethod.addOption(static_cast<int>(NodeskipMethod::Radius), "Radius");
_pDistancemethod.addOption(static_cast<int>(DistanceMethod::Eucledian), "Eucledian");
_pDistancemethod.addOption(static_cast<int>(DistanceMethod::x), "x");
_pDistancemethod.addOption(static_cast<int>(DistanceMethod::y), "y");
_pDistancemethod.addOption(static_cast<int>(DistanceMethod::z), "z");
definePropertyCallbackFunctions();
// Set default
@@ -920,10 +939,17 @@ namespace openspace {
_shaderProgram->setUniform("modelViewProjection",
data.camera.sgctInternal.projectionMatrix() * glm::mat4(modelViewMat));
const std::string earth = "Earth";
const std::string earth = "Earth";
SceneGraphNode* earthnode = sceneGraphNode(earth);
glm::dvec3 earthpos = earthnode->worldPosition();
// LDEBUG("earthpos x: " + std::to_string(earthpos.x));
glm::vec3 earthpos = earthnode->worldPosition();
//const std::string Sun = "Sun";
//SceneGraphNode* SunNode = sceneGraphNode(Sun);
//glm::dvec3 Sunpos = SunNode->worldPosition();
// earthpos = earthpos - Sunpos;
//LDEBUG("Suns position: " + std::to_string(Sunpos.x) + ", " + std::to_string(Sunpos.x) + ", " + std::to_string(Sunpos.x));
// LDEBUG("earthpos x: " + std::to_string(earthpos.x) + " ," + std::to_string(earthpos.y) + ", " + std::to_string(earthpos.z));
// Flow/Particles
_shaderProgram->setUniform(_uniformCache.streamColor, _pStreamColor);
_shaderProgram->setUniform(_uniformCache.nodeSize, _pNodeSize);
@@ -943,6 +969,7 @@ namespace openspace {
_shaderProgram->setUniform("fluxColorAlpha", _pFluxColorAlpha);
_shaderProgram->setUniform("earthPos", earthpos);
_shaderProgram->setUniform("DistanceThreshold", _pDistanceThreshold);
_shaderProgram->setUniform("DistanceMethod", _pDistancemethod);
if (_pColorMode == static_cast<int>(ColorMethod::ByFluxValue)) {
ghoul::opengl::TextureUnit textureUnit;

View File

@@ -77,6 +77,12 @@ namespace openspace {
Flux = 1,
Radius = 2
};
enum class DistanceMethod : int {
Eucledian = 0,
x = 1,
y = 2,
z = 3
};
UniformCache(streamColor, nodeSize, nodeSizeLargerFlux, thresholdFlux)
_uniformCache;
@@ -97,8 +103,6 @@ namespace openspace {
// Used for 'in-RAM-states' : True if new 'in-RAM-state' must be loaded.
// False => the previous frame's state should still be shown
bool _needsUpdate = false;
//
bool _loadingcachedfile = true;
// --------------------------------- NUMERICALS ----------------------------------- //
// Active index of _states. If(==-1)=>no state available for current time. Always the
@@ -108,7 +112,7 @@ namespace openspace {
// Active index of _startTimes
int _activeTriggerTimeIndex = -1;
// Number of states in the sequence
size_t _nStates = 4;
size_t _nStates = 274;
// In setup it is used to scale JSON coordinates. During runtime it is used to scale
// domain limits.
float _scalingFactor = 1.f;
@@ -166,6 +170,8 @@ namespace openspace {
properties::Vec4Property _pStreamColor;
// Index of the flux value to color lines by
properties::OptionProperty _pColorFlux;
// Chose different distant measurements:
properties::OptionProperty _pDistancemethod;
// Color table/transfer function for "By Flux value" coloring
properties::StringProperty _pColorTablePath;
// Valid range for the color table
@@ -199,11 +205,13 @@ namespace openspace {
properties::IntProperty _pAmountofNodes;
// Nodeskipping options
properties::OptionProperty _pNodeskipMethod;
//
// amount of nodes to show outside of filterrange
properties::IntProperty _pDefaultNodeSkip;
//
// The Flux threshold to decide the line between
//_pDefaultNodeSkip and _pAmountofNodes
properties::FloatProperty _pFluxNodeskipThreshold;
//
// The Radius threshold to decide the line between
//_pDefaultNodeSkip and _pAmountofNodes
properties::FloatProperty _pRadiusNodeSkipThreshold;
// initialization

View File

@@ -68,6 +68,7 @@ uniform float NodeskipRadiusThreshold;
uniform float fluxColorAlpha;
uniform vec3 earthPos;
uniform float DistanceThreshold;
uniform int DistanceMethod;
// Inputs
// Should be provided in meters
@@ -207,9 +208,35 @@ void main() {
else{
gl_PointSize = nodeSizeLargerFlux;
}
if(distance(earthPos, in_position) < DistanceThreshold){
vec3 vertexPosRelativetoEarth;
vertexPosRelativetoEarth.x = in_position.x; // + earthPos.x;
vertexPosRelativetoEarth.y = in_position.y;// + earthPos.y;
vertexPosRelativetoEarth.z = in_position.z;// + earthPos.z;
// + in_position;
if(DistanceMethod == 0){
if(distance(earthPos, vertexPosRelativetoEarth) < DistanceThreshold){
//if(earthPos.x - vertexPosRelativetoEarth.x < DistanceThreshold){
gl_PointSize = 10;
}
}
}
else if(DistanceMethod == 1){
if(abs(earthPos.x - vertexPosRelativetoEarth.x) < DistanceThreshold){
gl_PointSize = 10;
}
}
else if(DistanceMethod == 2){
if(abs(earthPos.y - vertexPosRelativetoEarth.y) < DistanceThreshold){
gl_PointSize = 10;
}
}
else if(DistanceMethod == 3){
if(abs(earthPos.z - vertexPosRelativetoEarth.z) < DistanceThreshold){
gl_PointSize = 10;
}
}
vec4 position_in_meters = vec4(in_position, 1);
vec4 positionClipSpace = modelViewProjection * position_in_meters;
@@ -217,6 +244,6 @@ void main() {
//gl_PointSize = nodeSize;
gl_Position = vec4(positionClipSpace.xy, 0, positionClipSpace.w);
vs_depth = gl_Position.w;
}