mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 10:40:09 -06:00
Added property for distance factor
This commit is contained in:
@@ -299,6 +299,11 @@ namespace {
|
||||
"Include radius with cameraperspective",
|
||||
"If false, then nodes closer to the sun will not be larger regardless of distance to camera."
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo perspectiveDistanceFactorInfo = {
|
||||
"perspectiveDistanceFactor",
|
||||
"Distance factor",
|
||||
"This value decides how far away the camera must be to start impacting the nodesize"
|
||||
};
|
||||
enum class SourceFileType : int {
|
||||
Json = 0,
|
||||
Invalid
|
||||
@@ -404,6 +409,7 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary
|
||||
, _pDrawingHollow(DrawingHollowInfo, false)
|
||||
, _pGaussianAlphaFilter(GaussiandAlphaFilterInfo, false)
|
||||
, _pRadiusPerspective(RadiusPerspectiveInfo, true)
|
||||
, _pPerspectiveDistanceFactor(perspectiveDistanceFactorInfo, 6.f, 1.f, 20.f)
|
||||
|
||||
{
|
||||
_dictionary = std::make_unique<ghoul::Dictionary>(dictionary);
|
||||
@@ -1153,10 +1159,12 @@ void RenderableStreamNodes::setupProperties() {
|
||||
_pEnhancemethod.addOption(static_cast<int>(EnhanceMethod::test), "test");
|
||||
|
||||
_pCameraPerspectiveGroup.addProperty(_pCameraPerspective);
|
||||
_pCameraPerspectiveGroup.addProperty(_pPerspectiveDistanceFactor);
|
||||
_pCameraPerspectiveGroup.addProperty(_pDrawingCircles);
|
||||
_pCameraPerspectiveGroup.addProperty(_pDrawingHollow);
|
||||
_pCameraPerspectiveGroup.addProperty(_pGaussianAlphaFilter);
|
||||
_pCameraPerspectiveGroup.addProperty(_pRadiusPerspective);
|
||||
|
||||
|
||||
definePropertyCallbackFunctions();
|
||||
// Set default
|
||||
@@ -1312,6 +1320,7 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
|
||||
_shaderProgram->setUniform("drawHollow", _pDrawingHollow);
|
||||
_shaderProgram->setUniform("useGaussian", _pGaussianAlphaFilter);
|
||||
_shaderProgram->setUniform("usingRadiusPerspective", _pRadiusPerspective);
|
||||
_shaderProgram->setUniform("PerspectiveDistanceFactor", _pPerspectiveDistanceFactor);
|
||||
|
||||
//////// test for camera perspective:
|
||||
/*
|
||||
@@ -1340,11 +1349,11 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
|
||||
}
|
||||
glm::dvec3 orthoUp = glm::normalize(glm::cross(cameraViewDirectionWorld, orthoRight));
|
||||
*/
|
||||
glm::vec3 cameraPos = data.camera.positionVec3();
|
||||
glm::vec3 cameraPos = data.camera.positionVec3() * data.modelTransform.rotation;
|
||||
|
||||
//this gives the same referenceframe as the nodes and makes it possible to see the
|
||||
//the distance between the camera and the nodes.
|
||||
cameraPos = cameraPos * data.modelTransform.rotation;
|
||||
//cameraPos = cameraPos * data.modelTransform.rotation;
|
||||
|
||||
_shaderProgram->setUniform("cameraPos", cameraPos);
|
||||
//glm::vec3 cameraPos = data.camera.unsynchedPositionVec3();
|
||||
|
||||
@@ -281,6 +281,7 @@ private:
|
||||
properties::BoolProperty _pDrawingHollow;
|
||||
properties::BoolProperty _pGaussianAlphaFilter;
|
||||
properties::BoolProperty _pRadiusPerspective;
|
||||
properties::FloatProperty _pPerspectiveDistanceFactor;
|
||||
|
||||
// initialization
|
||||
std::vector<std::string> _sourceFiles;
|
||||
|
||||
@@ -98,6 +98,7 @@ uniform vec3 cameraPos;
|
||||
//uniform vec2 screenSize;
|
||||
uniform bool usingCameraPerspective;
|
||||
uniform bool usingRadiusPerspective;
|
||||
uniform float PerspectiveDistanceFactor;
|
||||
|
||||
// Inputs
|
||||
// Should be provided in meters
|
||||
@@ -394,7 +395,7 @@ void main() {
|
||||
rtemp = rValue;
|
||||
}
|
||||
|
||||
float maxdist = 600000000000.f;
|
||||
float maxdist = 100000000000.f * PerspectiveDistanceFactor;
|
||||
float distancevec = distance(cameraPos, in_position.xyz);
|
||||
|
||||
if(distancevec < maxdist){
|
||||
|
||||
Reference in New Issue
Block a user