From 4f67a649b9678182e62b0edee2f7d2ac8696189f Mon Sep 17 00:00:00 2001 From: ElonOlsson Date: Fri, 12 Mar 2021 12:27:01 -0500 Subject: [PATCH] mirror backside parameter of renderableplane, renamed renderabletimevaryingplaneimagelocal to renderableplanetimevaryingimage. mm. --- .../scene/solarsystem/sun/EUV_layer.asset | 2 +- .../bastille_day/density_volume.asset | 10 +- .../heliosphere/bastille_day/fieldlines.asset | 9 ++ .../bastille_day/streamnodes.asset | 27 ++--- .../solarsystem/sun/streamnodes_sphere.asset | 2 +- .../solarsystem/sun/streamnodescutplane.asset | 97 +++++++--------- data/profiles/bastille-day.profile | 5 +- modules/base/rendering/renderableplane.cpp | 15 +++ modules/base/rendering/renderableplane.h | 1 + modules/base/shaders/plane_fs.glsl | 8 +- ...pp => renderableplanetimevaryingimage.cpp} | 104 +++++++++--------- ...al.h => renderableplanetimevaryingimage.h} | 4 +- .../rendering/renderablestreamnodes.cpp | 65 +++++++---- .../rendering/renderablestreamnodes.h | 1 + .../rendering/renderabletimevaryingsphere.cpp | 2 + modules/streamnodes/streamnodesmodule.cpp | 5 +- 16 files changed, 191 insertions(+), 166 deletions(-) rename modules/streamnodes/rendering/{renderabletimevaryingplaneimagelocal.cpp => renderableplanetimevaryingimage.cpp} (84%) rename modules/streamnodes/rendering/{renderabletimevaryingplaneimagelocal.h => renderableplanetimevaryingimage.h} (96%) diff --git a/data/assets/scene/solarsystem/sun/EUV_layer.asset b/data/assets/scene/solarsystem/sun/EUV_layer.asset index 0168347220..e76aa69e6c 100644 --- a/data/assets/scene/solarsystem/sun/EUV_layer.asset +++ b/data/assets/scene/solarsystem/sun/EUV_layer.asset @@ -1,5 +1,5 @@ asset.meta = { - Name = "Predictive Science Inc. Stream nodes Bastille Days", + Name = "Predictive Science Inc. EUV texture sequence Bastille Days", Version = "1.0", Description = "EUV simulation, texture sequence", Author = "CCMC, OpenSpace team", diff --git a/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/density_volume.asset b/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/density_volume.asset index a4194b7cc2..852f312b35 100644 --- a/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/density_volume.asset +++ b/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/density_volume.asset @@ -59,15 +59,7 @@ local densityVolume = { XAxis = {-1.0, 0.0, 0.0}, YAxis = {0.0, 1.0, 0.0}, ZAxis = {0.0, 0.0, -1.0} - - --XAxis = {1.0, 0.0, 0.0}, - --YAxis = {0.0, 1.0, 0.0}, - --ZAxis = {0.0, 0.0, -1.0} - - --XAxis = {1.0, 0.0, 0.0}, - --YAxis = {0.0, 1.0, 0.0}, - --ZAxis = {0.0, 0.0, -1.0} - + --Script = asset.localResource("kernels/carringtonRotation.lua") } }, diff --git a/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/fieldlines.asset b/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/fieldlines.asset index 8858291912..c1fbb8d06f 100644 --- a/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/fieldlines.asset +++ b/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/fieldlines.asset @@ -65,6 +65,15 @@ local fieldlines = { Scale = sunRadius }, Rotation = { + --This is a rotation matrix to go from Carrington longitude referens frame to HEEQ180 + --which is what the renderables paretn transforms.HNMReferenceFrame.Identifier is + --refering to. At the referens time, MAS_seq = 0, 2000-07-14T08:33:37.105 the Carrington + --longitude was 309.3 degrees. + --Difference from HEEQ => 360-309.3=50.7 + --(or 0-309.3 = -309.3 However this leads to the same rotation matrix in the end) + --Since OpenSpace supports HEEQ180 and not HEEQ, 180 was added or subtracted + -- => a1 = -129.3 and a2 = 230.7 + --Rotation matrix: (cos a, -sin a, 0)(sin a, cos a, 0)(0, 0, 1) leads to the result. Type = "FixedRotation", XAxis = {-0.63338087262755016203262119192353, -0.77384020972650618518999944537717, 0.0}, YAxis = {0.77384020972650618518999944537717, -0.63338087262755016203262119192353, 0.0}, diff --git a/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/streamnodes.asset b/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/streamnodes.asset index ad9be585ba..4556c51eaa 100644 --- a/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/streamnodes.asset +++ b/data/assets/scene/solarsystem/sun/heliosphere/bastille_day/streamnodes.asset @@ -2,7 +2,7 @@ asset.info = { Name = "Predictive Science Inc. Stream nodes Bastille Day", Version = "1.0", Description = " Stream nodes for the bastille day CME event ", - Author = "Christian Adamsson, Emilie Ho", + Author = "CCMC, Christian Adamsson, Emilie Ho", URL = "https://dx.doi.org/10.3847/1538-4357/aab36d", License = "" } @@ -11,11 +11,6 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') local sunTransforms = asset.require('scene/solarsystem/sun/transforms') -openspace.setPropertyValueSingle("Modules.Space.ShowExceptions", false) ---openspace.setPropertyValueSingle("Scene.NeptuneTrail.Renderable.Enabled", false) ---openspace.setPropertyValueSingle("Scene.UranusTrail.Renderable.Enabled", false) ---openspace.setPropertyValueSingle("Scene.SaturnTrail.Renderable.Enabled", false) - local transferFunctions = asset.localResource("transferfunctions") local streamnodeColorTable = transferFunctions .. "/stream_nodes.txt" local streamnodeColorTableCMR = transferFunctions .. "/CMR.txt" @@ -45,7 +40,7 @@ local Streamnodes = { Parent = transforms.HNMReferenceFrame.Identifier, --Parent = sunTransforms.SunIAU.Identifier, --Parent = sunTransforms.SolarSystemBarycenter.Identifier, - --transforms.asset, referens till suntransforms.solarsystemBarycenter.identifier + --transforms.asset, referens to suntransforms.solarsystemBarycenter.identifier Renderable = { Type = "RenderableStreamNodes", --SourceFolder = streamnodesDirectory, @@ -62,18 +57,11 @@ local Streamnodes = { --streamnodeColorTableIlluminance, --streamnodeColorTableIlluminance2, }, - --ColorTableMinMax = { - -- { 0, 1000000 }, - -- { 100, 2000 } - --}, LoadAtRuntime = true, ScaleToMeters = 1.0, SecondsBefore = 24*60*60, SecondsAfter = 24*60*60, - --SimulationModel = "mas", - -- Color = { - -- Uniform = {0, 0.725, 0.75, 1} - -- } + --SimulationModel = "mas" }, GUI = { Path = "/Solar System/Heliosphere", @@ -85,6 +73,15 @@ local Streamnodes = { Scale = 1 }, Rotation = { + --This is a rotation matrix to go from Carrington longitude referens frame to HEEQ180 + --which is what the renderables paretn transforms.HNMReferenceFrame.Identifier is + --refering to. At the referens time, MAS_seq = 0, 2000-07-14T08:33:37.105 the Carrington + --longitude was 309.3 degrees. + --Difference from HEEQ => 360-309.3=50.7 + --(or 0-309.3 = -309.3 However this leads to the same rotation matrix in the end) + --Since OpenSpace supports HEEQ180 and not HEEQ, 180 was added or subtracted + -- => a1 = -129.3 and a2 = 230.7 + --Rotation matrix: (cos a, -sin a, 0)(sin a, cos a, 0)(0, 0, 1) leads to the result. Type = "FixedRotation", XAxis = {-0.63338087262755016203262119192353, -0.77384020972650618518999944537717, 0.0}, YAxis = {0.77384020972650618518999944537717, -0.63338087262755016203262119192353, 0.0}, diff --git a/data/assets/scene/solarsystem/sun/streamnodes_sphere.asset b/data/assets/scene/solarsystem/sun/streamnodes_sphere.asset index 3720d8f71a..fe9c26b851 100644 --- a/data/assets/scene/solarsystem/sun/streamnodes_sphere.asset +++ b/data/assets/scene/solarsystem/sun/streamnodes_sphere.asset @@ -16,7 +16,7 @@ local assetHelper = asset.require("util/asset_helper") local transforms = asset.require("./transforms") local default_opacity = 0.99 --textureversion 1 has purple for low flux, 2 has transparent. 3 for new, 4 for emin01 -2 - 4, 5 for emin01 -2 -4.5, 6 for emin03 cmr -2 -4.5. 7 with -2 - 4 cmr emin03. 8 emin01 transparent, 9 emin03 transparent -local textureversion = 8 +local textureversion = 1 local TexturesPathEarth = asset.syncedResource({ Type = "HttpSynchronization", diff --git a/data/assets/scene/solarsystem/sun/streamnodescutplane.asset b/data/assets/scene/solarsystem/sun/streamnodescutplane.asset index 6690d8a8b5..f05637c2bd 100644 --- a/data/assets/scene/solarsystem/sun/streamnodescutplane.asset +++ b/data/assets/scene/solarsystem/sun/streamnodescutplane.asset @@ -16,13 +16,13 @@ local TexturesPathEquitorial = asset.syncedResource({ Type = "HttpSynchronization", Name = "cutplanes_textures", Identifier = "cutplanes_textures", - Version = 16 + Version = 1 }) local TexturesPathMeridial = asset.syncedResource({ Type = "HttpSynchronization", Name = "cutplane_meridial_textures", Identifier = "cutplane_meridial_textures", - Version = 6 + Version = 1 }) local Cutplane = { @@ -31,6 +31,15 @@ local Cutplane = { --Parent = transforms.SunIAU.Identifier, Transform = { Rotation = { + --This is a rotation matrix to go from Carrington longitude referens frame to HEEQ180 + --which is what the renderables paretn transforms.HNMReferenceFrame.Identifier is + --refering to. At the referens time, MAS_seq = 0, 2000-07-14T08:33:37.105 the Carrington + --longitude was 309.3 degrees. + --Difference from HEEQ => 360-309.3=50.7 + --(or 0-309.3 = -309.3 However this leads to the same rotation matrix in the end) + --Since OpenSpace supports HEEQ180 and not HEEQ, 180 was added or subtracted + -- => a1 = -129.3 and a2 = 230.7 + --Rotation matrix: (cos a, -sin a, 0)(sin a, cos a, 0)(0, 0, 1) leads to the result. Type = "FixedRotation", XAxis = {-0.63338087262755016203262119192353, -0.77384020972650618518999944537717, 0.0}, YAxis = {0.77384020972650618518999944537717, -0.63338087262755016203262119192353, 0.0}, @@ -38,67 +47,43 @@ local Cutplane = { } }, Renderable = { - Type = "RenderableTimeVaryingPlaneImageLocal", + Type = "RenderablePlaneTimeVaryingImage", Size = 1.57*10^11, - Enabled = true, + Enabled = false, Texture = TexturesPathEquitorial, BlendMode = "Normal", - Opacity = 0, - }, + MirrorBackside = false, + Opacity = 0.7 + }, GUI = { Name = "Cutplane Equitorial", Path = "/Solar System/Heliosphere" }, }; ---local Cutplane2 = { - -- Identifier = "Cutplane2", - -- Parent = transformssun.HNMReferenceFrame.Identifier, - -- Transform = { - --Rotation = { - --Type = "StaticRotation", - --Rotation = {-1.5707965, -3.141593, 0} - --} +local Cutplane2 = { + Identifier = "Cutplane2", + Parent = transformssun.HNMReferenceFrame.Identifier, + Transform = { + Rotation = { + Type = "StaticRotation", + Rotation = {-1.5707965, -3.141593, 0} + } + }, + Renderable = { + Type = "RenderablePlaneTimeVaryingImage", + Size = 1.57*10^11, + Enabled = false, + Texture = TexturesPathMeridial, + BlendMode = "Normal", + MirrorBackside = false, + Opacity = 0.7 + }, + GUI = { + Name = "Cutplane Meridial", + Path = "/Solar System/Heliosphere" + }, +}; - - --Rotation = { - -- Type = "FixedRotation", - -- XAxis = {-0.63338087262755016203262119192353, -0.77384020972650618518999944537717, 0.0}, - -- YAxis = {0.77384020972650618518999944537717, -0.63338087262755016203262119192353, 0.0}, - --ZAxis = {0.0, 0.0, 1.0} - -- } - --Rotation = { - --Type = "FixedRotation", - -- XAxis = {0.95741409339769648946, 1.1697314441411185352, 0.0}, - -- YAxis = {-2.4310909859953234782, 1.9898249157806033154, 0.0}, - -- ZAxis = {0.0, 0.0, 2.178407} - --} - -- Rotation = { - -- Type = "FixedRotation", - -- XAxis = {0, 0, 1}, - -- YAxis = {0.7738402097265061, -0.6333808726275502, 0.0}, - -- ZAxis = {0.6333808726275502, 0.7738402097265061, 1} - --} - -- Rotation = { - -- Type = "FixedRotation", - -- XAxis = {0, 0, 1}, - -- YAxis = {-0.6333808726275502, -0.7738402097265061, 0}, - -- ZAxis = {0.7738402097265061, -0.6333808726275502, 1} - --} ---}, - --Renderable = { - -- Type = "RenderableTimeVaryingPlaneImageLocal", - -- Size = 1.57*10^11, - -- Enabled = true, - -- Texture = TexturesPathMeridial, - -- BlendMode = "Normal", - -- Opacity = 1, - --}, - --GUI = { - --Name = "Cutplane Meridial", - -- Path = "/Solar System/Heliosphere" - --}, ---}; - ---assetHelper.registerSceneGraphNodesAndExport(asset, { Cutplane, Cutplane2}) -assetHelper.registerSceneGraphNodesAndExport(asset, { Cutplane}) +assetHelper.registerSceneGraphNodesAndExport(asset, { Cutplane, Cutplane2}) +--assetHelper.registerSceneGraphNodesAndExport(asset, { Cutplane}) diff --git a/data/profiles/bastille-day.profile b/data/profiles/bastille-day.profile index a70577e501..87121c6455 100644 --- a/data/profiles/bastille-day.profile +++ b/data/profiles/bastille-day.profile @@ -23,9 +23,10 @@ "scene/solarsystem/planets/earth/satellites/misc/iss" ], "camera": { + "altitude": 3400000000.0, "anchor": "Sun", - "latitude": 58.5877, - "longitude": 16.1924, + "latitude": 20.5877, + "longitude": -35.1924, "type": "goToGeo" }, "delta_times": [ diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index b718506c3e..746193d4db 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -58,6 +58,14 @@ namespace { "transformations." }; + constexpr openspace::properties::Property::PropertyInfo MirrorBacksideInfo = { + "MirrorBackside", + "Mirror backside of image plane", + "If this value is set to false, the image plane will not be mirrored when " + "looking from the backside. This is usually desirable when the image shows " + "data at a specific location, but not if it is desplaying text for example." + }; + constexpr openspace::properties::Property::PropertyInfo SizeInfo = { "Size", "Size (in meters)", @@ -74,6 +82,9 @@ namespace { // [[codegen::verbatim(BillboardInfo.description)]] std::optional billboard; + // [[codegen::verbatim(MirrorBacksideInfo.description)]] + std::optional mirrorBackside; + // [[codegen::verbatim(SizeInfo.description)]] float size; @@ -99,6 +110,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown) , _billboard(BillboardInfo, false) + , _mirrorBackside(MirrorBacksideInfo, true) , _size(SizeInfo, 10.f, 0.f, 1e25f) { Parameters p = codegen::bake(dictionary); @@ -108,6 +120,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) _size = p.size; _billboard = p.billboard.value_or(_billboard); + _mirrorBackside = p.mirrorBackside.value_or(_mirrorBackside); _blendMode.addOptions({ { BlendModeNormal, "Normal" }, @@ -196,6 +209,8 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) { _shader->activate(); _shader->setUniform("opacity", _opacity); + _shader->setUniform("mirrorBackside", _mirrorBackside); + glm::dvec3 objectPositionWorld = glm::dvec3( glm::translate( glm::dmat4(1.0), diff --git a/modules/base/rendering/renderableplane.h b/modules/base/rendering/renderableplane.h index 12d9d50ab1..0e98c077e8 100644 --- a/modules/base/rendering/renderableplane.h +++ b/modules/base/rendering/renderableplane.h @@ -74,6 +74,7 @@ private: void createPlane(); properties::BoolProperty _billboard; + properties::BoolProperty _mirrorBackside; properties::FloatProperty _size; ghoul::opengl::ProgramObject* _shader = nullptr; diff --git a/modules/base/shaders/plane_fs.glsl b/modules/base/shaders/plane_fs.glsl index f739d6ac32..1bbd3a2beb 100644 --- a/modules/base/shaders/plane_fs.glsl +++ b/modules/base/shaders/plane_fs.glsl @@ -32,6 +32,7 @@ in vec3 vs_gNormal; uniform sampler2D texture1; uniform bool additiveBlending; uniform float opacity = 1.0; +uniform bool mirrorBackside = true; Fragment getFragment() { @@ -40,7 +41,12 @@ Fragment getFragment() { frag.color = texture(texture1, vs_st); } else { - frag.color = texture(texture1, vec2(1 - vs_st.s, vs_st.t)); + if (mirrorBackside){ + frag.color = texture(texture1, vec2(1 - vs_st.s, vs_st.t)); + } + else { + frag.color = texture(texture1, vs_st); + } } frag.color.a *= opacity; diff --git a/modules/streamnodes/rendering/renderabletimevaryingplaneimagelocal.cpp b/modules/streamnodes/rendering/renderableplanetimevaryingimage.cpp similarity index 84% rename from modules/streamnodes/rendering/renderabletimevaryingplaneimagelocal.cpp rename to modules/streamnodes/rendering/renderableplanetimevaryingimage.cpp index 4ceb1fa299..3b799630b5 100644 --- a/modules/streamnodes/rendering/renderabletimevaryingplaneimagelocal.cpp +++ b/modules/streamnodes/rendering/renderableplanetimevaryingimage.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -57,7 +57,7 @@ namespace { namespace openspace { - documentation::Documentation RenderableTimeVaryingPlaneImageLocal::Documentation() { + documentation::Documentation RenderablePlaneTimeVaryingImage::Documentation() { using namespace documentation; return { "Renderable Plane Image Local", @@ -88,7 +88,7 @@ namespace openspace { }; } - RenderableTimeVaryingPlaneImageLocal::RenderableTimeVaryingPlaneImageLocal(const ghoul::Dictionary& dictionary) + RenderablePlaneTimeVaryingImage::RenderablePlaneTimeVaryingImage(const ghoul::Dictionary& dictionary) : RenderablePlane(dictionary) , _texturePath(TextureInfo) { @@ -150,13 +150,13 @@ namespace openspace { } } - bool RenderableTimeVaryingPlaneImageLocal::isReady() const { + bool RenderablePlaneTimeVaryingImage::isReady() const { return RenderablePlane::isReady(); } #pragma optimize ("", off) - void RenderableTimeVaryingPlaneImageLocal::initializeGL() { + void RenderablePlaneTimeVaryingImage::initializeGL() { RenderablePlane::initializeGL(); LDEBUG("sourcefiles size:" + std::to_string(_sourceFiles.size())); @@ -254,9 +254,10 @@ namespace openspace { if (!_isLoadingLazily) { loadTexture(); } + } - bool RenderableTimeVaryingPlaneImageLocal::extractMandatoryInfoFromDictionary() + bool RenderablePlaneTimeVaryingImage::extractMandatoryInfoFromDictionary() { // Ensure that the source folder exists and then extract // the files with the same extension as @@ -288,24 +289,21 @@ namespace openspace { LDEBUG("returning true"); return true; } - void RenderableTimeVaryingPlaneImageLocal::deinitializeGL() { + void RenderablePlaneTimeVaryingImage::deinitializeGL() { _textureFile = nullptr; BaseModule::TextureManager.release(_texture); - // for (int i = 0; i < _textureFiles.size(); ++i) { - // BaseModule::TextureManager.release(_textureFiles[i]); - // } + _textureFiles.clear(); RenderablePlane::deinitializeGL(); } - void RenderableTimeVaryingPlaneImageLocal::bindTexture() { + void RenderablePlaneTimeVaryingImage::bindTexture() { _texture->bind(); - // _textureFiles[_activeTriggerTimeIndex]->bind(); } - void RenderableTimeVaryingPlaneImageLocal::update(const UpdateData& data) { + void RenderablePlaneTimeVaryingImage::update(const UpdateData& data) { ZoneScoped RenderablePlane::update(data); @@ -313,49 +311,49 @@ namespace openspace { return; } - - const double currentTime = data.time.j2000Seconds(); - const bool isInInterval = (currentTime >= _startTimes[0]) && - (currentTime < _sequenceEndTime); - //const bool isInInterval = true; - if (isInInterval) { - ZoneScopedN("isInInterval") - const size_t nextIdx = _activeTriggerTimeIndex + 1; - if ( - // true => Previous frame was not within the sequence interval - //_activeTriggerTimeIndex < 0 || - // true => We stepped back to a time represented by another state - currentTime < _startTimes[_activeTriggerTimeIndex] || - // true => We stepped forward to a time represented by another state - (nextIdx < _nStates && currentTime >= _startTimes[nextIdx])) - { - updateActiveTriggerTimeIndex(currentTime); - //LDEBUG("Vi borde uppdatera1"); + const double currentTime = data.time.j2000Seconds(); + const bool isInInterval = (currentTime >= _startTimes[0]) && + (currentTime < _sequenceEndTime); + //const bool isInInterval = true; + if (isInInterval) { + ZoneScopedN("isInInterval") + const size_t nextIdx = _activeTriggerTimeIndex + 1; + if ( + // true => Previous frame was not within the sequence interval + //_activeTriggerTimeIndex < 0 || + // true => We stepped back to a time represented by another state + currentTime < _startTimes[_activeTriggerTimeIndex] || + // true => We stepped forward to a time represented by another state + (nextIdx < _nStates && currentTime >= _startTimes[nextIdx])) + { + updateActiveTriggerTimeIndex(currentTime); + //LDEBUG("Vi borde uppdatera1"); - // _mustLoadNewStateFromDisk = true; - //LDEBUG("vi borde uppdatera"); - _needsUpdate = true; + // _mustLoadNewStateFromDisk = true; + //LDEBUG("vi borde uppdatera"); + _needsUpdate = true; - } // else {we're still in same state as previous frame (no changes needed)} - } - else { - ZoneScopedN("else") - //not in interval => set everything to false - //LDEBUG("not in interval"); - _activeTriggerTimeIndex = 0; - _needsUpdate = false; - } + } // else we're still in same state as previous frame (no changes needed) + } + else { + ZoneScopedN("else") + //not in interval => set everything to false + //LDEBUG("not in interval"); + _activeTriggerTimeIndex = 0; + _needsUpdate = false; + } - if ((_needsUpdate || _textureIsDirty) && !_isLoadingTexture) { - ZoneScopedN("needsupdate") - _isLoadingTexture = true; - loadTexture(); - _textureIsDirty = false; - } + if ((_needsUpdate || _textureIsDirty) && !_isLoadingTexture) { + ZoneScopedN("needsupdate") + _isLoadingTexture = true; + loadTexture(); + _textureIsDirty = false; + } + glFrontFace(GL_CCW); } // Extract J2000 time from file names // Requires files to be named as such: 'YYYY-MM-DDTHH-MM-SS-XXX.json' - void RenderableTimeVaryingPlaneImageLocal::extractTriggerTimesFromFileNames() { + void RenderablePlaneTimeVaryingImage::extractTriggerTimesFromFileNames() { // number of characters in filename (excluding '.json') constexpr const int FilenameSize = 23; // size(".json") @@ -380,7 +378,7 @@ namespace openspace { _startTimes.push_back(triggerTime); } } - void RenderableTimeVaryingPlaneImageLocal::updateActiveTriggerTimeIndex(double currentTime) { + void RenderablePlaneTimeVaryingImage::updateActiveTriggerTimeIndex(double currentTime) { auto iter = std::upper_bound(_startTimes.begin(), _startTimes.end(), currentTime); if (iter != _startTimes.end()) { if (iter != _startTimes.begin()) { @@ -396,7 +394,7 @@ namespace openspace { _activeTriggerTimeIndex = static_cast(_nStates) - 1; } } - void RenderableTimeVaryingPlaneImageLocal::computeSequenceEndTime() { + void RenderablePlaneTimeVaryingImage::computeSequenceEndTime() { if (_nStates > 1) { const double lastTriggerTime = _startTimes[_nStates - 1]; const double sequenceDuration = lastTriggerTime - _startTimes[0]; @@ -409,7 +407,7 @@ namespace openspace { _sequenceEndTime = DBL_MAX; } } - void RenderableTimeVaryingPlaneImageLocal::loadTexture() { + void RenderablePlaneTimeVaryingImage::loadTexture() { if (_activeTriggerTimeIndex != -1) { // ghoul::opengl::Texture* t = _texture; //std::unique_ptr t = _texture; diff --git a/modules/streamnodes/rendering/renderabletimevaryingplaneimagelocal.h b/modules/streamnodes/rendering/renderableplanetimevaryingimage.h similarity index 96% rename from modules/streamnodes/rendering/renderabletimevaryingplaneimagelocal.h rename to modules/streamnodes/rendering/renderableplanetimevaryingimage.h index 10140e30f1..f9d24d50c0 100644 --- a/modules/streamnodes/rendering/renderabletimevaryingplaneimagelocal.h +++ b/modules/streamnodes/rendering/renderableplanetimevaryingimage.h @@ -37,9 +37,9 @@ namespace openspace { namespace documentation { struct Documentation; } - class RenderableTimeVaryingPlaneImageLocal : public RenderablePlane { + class RenderablePlaneTimeVaryingImage : public RenderablePlane { public: - RenderableTimeVaryingPlaneImageLocal(const ghoul::Dictionary& dictionary); + RenderablePlaneTimeVaryingImage(const ghoul::Dictionary& dictionary); void initializeGL() override; void deinitializeGL() override; diff --git a/modules/streamnodes/rendering/renderablestreamnodes.cpp b/modules/streamnodes/rendering/renderablestreamnodes.cpp index bc730e826f..826ee11105 100644 --- a/modules/streamnodes/rendering/renderablestreamnodes.cpp +++ b/modules/streamnodes/rendering/renderablestreamnodes.cpp @@ -50,10 +50,11 @@ #include #include #include -// This is a call to use the nlohmann json file #pragma +// This is a call to use the nlohmann json file using json = nlohmann::json; + #pragma optimize("", off) namespace { @@ -75,9 +76,9 @@ namespace { "filterLower", "filterUpper", "scalingMode", "colorTableRange", "domainLimZ", "nodeSkip", "nodeSkipDefault", "nodeSkipEarth", "nodeSkipMethod", "nodeSkipFluxThreshold", "nodeSkipRadiusThreshold", "fluxColorAlpha", - "fluxColorAlphaIlluminance", "earthPos", "distanceThreshold", "activeStreamNumber", - "enhanceMethod", "flowColor", "usingParticles", "usingInterestingStreams", - "particleSize", "particleSpacing", "particleSpeed" + "fluxColorAlphaIlluminance", "earthPos", "distanceThreshold", + "activeStreamNumber", "enhanceMethod", "flowColor", "usingParticles", + "usingInterestingStreams","particleSize", "particleSpacing", "particleSpeed" }; constexpr const std::array UniformNames2 = { "time", "flowColoring", "maxNodeDistanceSize", "usingCameraPerspective", @@ -209,7 +210,9 @@ namespace { "Flux Color Alpha", "The value of alpha for the flux color mode." }; - constexpr openspace::properties::Property::PropertyInfo FluxColorAlphaIlluminanceInfo = { + constexpr openspace::properties::Property::PropertyInfo + FluxColorAlphaIlluminanceInfo = + { "fluxColorAlphaIlluminance", "Flux Color Alpha for illuminance", "The value of alpha for the flux color mode." @@ -219,7 +222,9 @@ namespace { "Skipping Nodes By Flux", "Select nodes to skip depending on flux value." }; - constexpr openspace::properties::Property::PropertyInfo RadiusNodeSkipThresholdInfo = { + constexpr openspace::properties::Property::PropertyInfo + RadiusNodeSkipThresholdInfo = + { "skippingNodesByRadius", "Skipping Nodes By Radius", "Select nodes to skip depending on Radius." @@ -305,10 +310,13 @@ namespace { "Node Distance Threshold", "Threshold for where to interpolate between the max and min node distance." }; - constexpr openspace::properties::Property::PropertyInfo CameraPerspectiveEnabledInfo = { + constexpr openspace::properties::Property::PropertyInfo + CameraPerspectiveEnabledInfo = + { "cameraPerspectiveEnabled", "Use Camera perspective", - "Camera perspective changes the size of the nodes dependent on distance from camera." + "Camera perspective changes the size of the nodes dependent on " + "distance from camera." }; constexpr openspace::properties::Property::PropertyInfo DrawingCirclesInfo = { "renderingcircles", @@ -326,15 +334,21 @@ namespace { "Using fragment shader to draw nodes with Gaussian filter for alpha value." }; - constexpr openspace::properties::Property::PropertyInfo RadiusPerspectiveEnabledInfo = { + constexpr openspace::properties::Property::PropertyInfo + RadiusPerspectiveEnabledInfo = + { "radiusPerspectiveEnabled", "Include radius with cameraperspective", - "If false, then nodes closer to the sun will not be larger regardless of distance to camera." + "If false, then nodes closer to the sun will not be larger " + "regardless of distance to camera." }; - constexpr openspace::properties::Property::PropertyInfo PerspectiveDistanceFactorInfo = { + constexpr openspace::properties::Property::PropertyInfo + PerspectiveDistanceFactorInfo = + { "perspectiveDistanceFactor", "Perspective Distance factor", - "This value decides how far away the camera must be to start impacting the node size." + "This value decides how far away the camera must be to start " + "impacting the node size." }; constexpr openspace::properties::Property::PropertyInfo MinNodeSizeInfo = { "minNodeSize", @@ -472,15 +486,15 @@ void RenderableStreamNodes::definePropertyCallbackFunctions() { }); _pGoesEnergyBins.onChange([this] { - if (_pGoesEnergyBins == 1) { // 1 == Emin03 == Mev > 100 + if (_pGoesEnergyBins.option().value == 1) { // 1 == Emin03 == Mev > 100 if (_shouldreadBinariesDirectly) { - bool success = loadBinaryfilesDirectly("_emin03"); + bool success = loadBinaryfilesDirectly(""); // empty string == emin03 for default if (success) return; } } - else if(_pGoesEnergyBins == 0) { // 0 == Emin01 == Mev > 10 + else if(_pGoesEnergyBins.option().value == 0) { // 0 == Emin01 == Mev > 10 if (_shouldreadBinariesDirectly) { - bool success = loadBinaryfilesDirectly(""); + bool success = loadBinaryfilesDirectly("_emin01"); if (success) return; } } @@ -509,10 +523,13 @@ void RenderableStreamNodes::setModelDependentConstants() { _pDomainZ.setMaxValue(glm::vec2(limitZMax)); _pDomainZ = glm::vec2(limitZMin, limitZMax); } + +void RenderableStreamNodes::initialize() { + +} void RenderableStreamNodes::initializeGL() { // EXTRACT MANDATORY INFORMATION FROM DICTIONARY - // std::string filepath = "C:/Users/chrad171//openspace/OpenSpace/sync/http/bastille_day_streamnodes/1/datawithoutprettyprint_newmethod.json"; if (!extractMandatoryInfoFromDictionary()) { return; @@ -606,11 +623,11 @@ void RenderableStreamNodes::loadNodeData() { if (_shouldreadBinariesDirectly) { bool success = false; if(_shouldloademin03directly){ - success = loadBinaryfilesDirectly("_emin03"); - _pGoesEnergyBins = 1; + success = loadBinaryfilesDirectly(""); + //_pGoesEnergyBins.addOption(1,""); } else { - success = loadBinaryfilesDirectly(""); + success = loadBinaryfilesDirectly("_emin01"); } if(success) return; } @@ -655,7 +672,7 @@ void RenderableStreamNodes::loadNodeData() { cachedFile, _file )); //Read in the data from the cached file - bool success = loadBinaryfilesDirectly("_emin03"); //readCachedFile(cachedfile, "") + bool success = loadBinaryfilesDirectly(""); //readCachedFile(cachedfile, "") if (!success) { // If something went wrong it is probably because we changed // the cache version or some file was not found. @@ -849,9 +866,9 @@ bool RenderableStreamNodes::loadBinaryfilesDirectly(const std::string& energybin //std::string _file2 = _binarySourceFilePath + "\\StreamnodesCacheColorv3" + energybin; //std::string _file3 = _binarySourceFilePath + "\\StreamnodesCacheRadiusv3" + energybin; - std::string _file = _binarySourceFilePath + "\\positions"; - std::string _file2 = _binarySourceFilePath + "\\fluxes"; - std::string _file3 = _binarySourceFilePath + "\\radiuses"; + std::string _file = _binarySourceFilePath + "\\positions" + energybin; + std::string _file2 = _binarySourceFilePath + "\\fluxes" + energybin; + std::string _file3 = _binarySourceFilePath + "\\radiuses" + energybin; //ghoul::filesystem::File file(_file); //std::string cachedFile = FileSys.cacheManager()->cachedFilename( diff --git a/modules/streamnodes/rendering/renderablestreamnodes.h b/modules/streamnodes/rendering/renderablestreamnodes.h index 53842f4ecb..15539c4721 100644 --- a/modules/streamnodes/rendering/renderablestreamnodes.h +++ b/modules/streamnodes/rendering/renderablestreamnodes.h @@ -43,6 +43,7 @@ class RenderableStreamNodes : public Renderable { public: RenderableStreamNodes(const ghoul::Dictionary& dictionary); + void initialize() override; void initializeGL() override; void deinitializeGL() override; diff --git a/modules/streamnodes/rendering/renderabletimevaryingsphere.cpp b/modules/streamnodes/rendering/renderabletimevaryingsphere.cpp index 425cf489c2..a577e4ce74 100644 --- a/modules/streamnodes/rendering/renderabletimevaryingsphere.cpp +++ b/modules/streamnodes/rendering/renderabletimevaryingsphere.cpp @@ -479,6 +479,8 @@ void RenderableTimeVaryingSphere::render(const RenderData& data, RendererTasks&) else if (orientation == Orientation::Both) { glEnable(GL_CULL_FACE); } + glDisable(GL_CULL_FACE); + } bool RenderableTimeVaryingSphere::extractMandatoryInfoFromDictionary() { diff --git a/modules/streamnodes/streamnodesmodule.cpp b/modules/streamnodes/streamnodesmodule.cpp index 35c2c0c5af..b147ae7b93 100644 --- a/modules/streamnodes/streamnodesmodule.cpp +++ b/modules/streamnodes/streamnodesmodule.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -64,7 +64,8 @@ void StreamNodesModule::internalInitialize(const ghoul::Dictionary&) { factory->registerClass("RenderableStreamNodes"); factory->registerClass("RenderableLightTravel"); - factory->registerClass("RenderableTimeVaryingPlaneImageLocal"); + factory->registerClass + ("RenderablePlaneTimeVaryingImage"); factory->registerClass("RenderableTimeVaryingSphere"); }