From 70424290b7cba2151bce8f0e8f9b59af6fa292bc Mon Sep 17 00:00:00 2001 From: ElonOlsson Date: Wed, 8 Sep 2021 09:50:58 -0400 Subject: [PATCH] some edits from PR comments --- .../bastille_day/density_volume.asset | 6 +- .../heliosphere/bastille_day/fieldlines.asset | 12 ++- .../heliosphere/bastille_day/fluxnodes.asset | 34 +++--- .../bastille_day/fluxnodescutplane.asset | 16 +-- .../bastille_day/fluxnodeslegend.asset | 6 +- .../bastille_day/lightindicator.asset | 3 +- .../bastille_day/magnetogram_textures.asset | 25 +++-- .../planets/earth/magnetosphere.asset | 2 +- .../planets/earth/transforms.asset | 4 +- .../scene/solarsystem/sun/EUV_layer.asset | 4 +- .../sun/transforms_heliosphere.asset | 4 +- data/assets/util/streamnodes_textures.asset | 8 +- modules/base/rendering/renderableplane.cpp | 2 +- .../renderableplanetimevaryingimage.cpp | 102 ++++++++---------- .../renderableplanetimevaryingimage.h | 18 +--- .../rendering/renderabletimevaryingsphere.cpp | 13 ++- .../rendering/renderabletimevaryingsphere.h | 6 +- 17 files changed, 127 insertions(+), 138 deletions(-) diff --git a/data/assets/scene/solarsystem/heliosphere/bastille_day/density_volume.asset b/data/assets/scene/solarsystem/heliosphere/bastille_day/density_volume.asset index b97ce3fbc5..a7470d8096 100644 --- a/data/assets/scene/solarsystem/heliosphere/bastille_day/density_volume.asset +++ b/data/assets/scene/solarsystem/heliosphere/bastille_day/density_volume.asset @@ -20,9 +20,9 @@ local densityVolume = { }, Rotation = { Type = "FixedRotation", - 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 } } }, Renderable = { diff --git a/data/assets/scene/solarsystem/heliosphere/bastille_day/fieldlines.asset b/data/assets/scene/solarsystem/heliosphere/bastille_day/fieldlines.asset index 9496c2f8e2..352d29f24f 100644 --- a/data/assets/scene/solarsystem/heliosphere/bastille_day/fieldlines.asset +++ b/data/assets/scene/solarsystem/heliosphere/bastille_day/fieldlines.asset @@ -1,9 +1,9 @@ local assetHelper = asset.require('util/asset_helper') local heliosphereTransforms = asset.require('scene/solarsystem/sun/transforms_heliosphere') -local transferFunctions = asset.localResource("transferfunctions") -local masVelocityColorTable = transferFunctions .. "/velocity-fieldlines.txt" -local masDensityColorTable = transferFunctions .. "/density-fieldlines.txt" +--local transferFunctions = asset.localResource("transferfunctions") +--local masVelocityColorTable = transferFunctions .. "/velocity-fieldlines.txt" +--local masDensityColorTable = transferFunctions .. "/density-fieldlines.txt" local fieldlinesDirectory = asset.syncedResource({ Name = "Bastille Day MAS Fieldlines", @@ -45,8 +45,10 @@ local fieldlines = { AlphaBlendlingEnabled = false, InputFileType = "osfls", ColorTablePaths = { - masDensityColorTable, - masVelocityColorTable, + asset.localResource("transferfunctions/density-fieldlines.txt"), + asset.localResource("transferfunctions/velocity-fieldlines.txt") + --masDensityColorTable, + --masVelocityColorTable, }, ColorTableMinMax = { { 0, 1000000 }, diff --git a/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodes.asset b/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodes.asset index 3ca4cdd509..c9d854cc4e 100644 --- a/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodes.asset +++ b/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodes.asset @@ -1,11 +1,11 @@ local assetHelper = asset.require('util/asset_helper') local heliosphereTransforms = asset.require('scene/solarsystem/sun/transforms_heliosphere') -local transferFunctions = asset.localResource("transferfunctions") -local fluxnodeColorTable = transferFunctions .. "/flux-nodes.txt" -local fluxnodeColorTableCMR = transferFunctions .. "/CMR.txt" -local fluxnodeColorTableEarth = transferFunctions .. "/flux-nodes-grey-scale.txt" -local fluxnodeColorTableFlow = transferFunctions .. "/flux-nodes-flow.txt" +--local transferFunctions = asset.localResource("transferfunctions") +local fluxnodeColorTable = asset.localResource("transferfunctions/flux-nodes.txt") +local fluxnodeColorTableCMR = asset.localResource("transferfunctions/CMR.txt") +local fluxnodeColorTableEarth = asset.localResource("transferfunctions/flux-nodes-grey-scale.txt") +local fluxnodeColorTableFlow = asset.localResource("transferfunctions/flux-nodes-flow.txt") local fluxnodesBinaries = asset.syncedResource({ Name = "Bastille day Flux nodes binaries", @@ -19,10 +19,6 @@ local Fluxnodes = { Identifier = "MAS_MHD_FluxNodes", Parent = heliosphereTransforms.HEEQ180ReferenceFrame.Identifier, Transform = { - Scale = { - Type = "StaticScale", - Scale = 1 - }, Rotation = { -- This is a rotation matrix to go from Carrington longitude referens frame to HEEQ180 -- which is what the renderables parent transforms.HEEQ180ReferenceFrame. Identifier is @@ -34,26 +30,30 @@ local Fluxnodes = { -- => 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 }, - ZAxis = { 0.0, 0.0, 1.0 } + XAxis = { -0.63338087262755016203262119192353, -0.77384020972650618518999944537717, 0.0 }, + YAxis = { 0.77384020972650618518999944537717, -0.63338087262755016203262119192353, 0.0 }, + ZAxis = { 0.0, 0.0, 1.0 } } }, Renderable = { Type = "RenderableFluxNodes", SourceFolder = fluxnodesBinaries, ColorTablePaths = { - Standard = fluxnodeColorTable, - CMR = fluxnodeColorTableCMR, - Earth = fluxnodeColorTableEarth, - Flow = fluxnodeColorTableFlow, + --Standard = fluxnodeColorTable, + Standard = asset.localResource("transferfunctions/flux-nodes.txt"), + --CMR = fluxnodeColorTableCMR, + CMR = asset.localResource("transferfunctions/CMR.txt"), + --Earth = fluxnodeColorTableEarth, + Earth = asset.localResource("transferfunctions/flux-nodes-grey-scale.txt"), + --Flow = fluxnodeColorTableFlow, + Flow = asset.localResource("transferfunctions/flux-nodes-flow.txt") }, LoadAtRuntime = true, ScaleToMeters = 1.0, SecondsBefore = 24*60*60, SecondsAfter = 24*60*60, - Enabled = false + Enabled = true }, GUI = { Path = "/Solar System/Heliosphere", diff --git a/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodescutplane.asset b/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodescutplane.asset index 192e7ea286..9a11c86163 100644 --- a/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodescutplane.asset +++ b/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodescutplane.asset @@ -29,7 +29,7 @@ local EquatorialCutplane = { -- 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", + Type = "FixedRotation", XAxis = { -0.63338087262755016203262119192353, -0.77384020972650618518999944537717, 0.0 }, YAxis = { 0.77384020972650618518999944537717, -0.63338087262755016203262119192353, 0.0 }, ZAxis = { 0.0, 0.0, 1.0 } @@ -37,9 +37,9 @@ local EquatorialCutplane = { }, Renderable = { Type = "RenderablePlaneTimeVaryingImage", - Size = 1.57*10^11, - Enabled = false, - Texture = TexturesPathEquitorial, + Size = 1.57E11, + Enabled = true, + SourceFolder = TexturesPathEquitorial, BlendMode = "Normal", MirrorBackside = false, Opacity = 0.7 @@ -61,9 +61,9 @@ local MeridialCutplane = { }, Renderable = { Type = "RenderablePlaneTimeVaryingImage", - Size = 1.57*10^11, - Enabled = false, - Texture = TexturesPathMeridial, + Size = 1.57E11, + Enabled = true, + SourceFolder = TexturesPathMeridial, BlendMode = "Normal", MirrorBackside = false, Opacity = 0.7 @@ -71,7 +71,7 @@ local MeridialCutplane = { GUI = { Name = "Cutplane Meridial", Path = "/Solar System/Heliosphere" - }, + } } assetHelper.registerSceneGraphNodesAndExport(asset, { EquatorialCutplane, MeridialCutplane}) diff --git a/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodeslegend.asset b/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodeslegend.asset index 15d3335770..5e26364178 100644 --- a/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodeslegend.asset +++ b/data/assets/scene/solarsystem/heliosphere/bastille_day/fluxnodeslegend.asset @@ -11,13 +11,13 @@ local TexturesPath = asset.syncedResource({ local legend = { Identifier = "Legendfluxnodes", Type = "ScreenSpaceImageLocal", - TexturePath = TexturesPath .. "/CMR_transparent_vittext.png", + TexturePath = TexturesPath .. "/CMR_transparent_white_text.png", } openspace.addScreenSpaceRenderable(legend) -- These numbers are there to put the legend on the side of the screen. -openspace.setPropertyValueSingle('ScreenSpace.Legendfluxnodes.CartesianPosition', {0.677970, 0.0,-1.049180}); -openspace.setPropertyValueSingle('ScreenSpace.Legendfluxnodes.Rotation', {0.000000,0.000000,0.56652}); +openspace.setPropertyValueSingle('ScreenSpace.Legendfluxnodes.CartesianPosition', { 0.677970, 0.0, -1.049180 }); +openspace.setPropertyValueSingle('ScreenSpace.Legendfluxnodes.Rotation', { 0.000000, 0.000000, 0.56652 }); openspace.setPropertyValueSingle('ScreenSpace.Legendfluxnodes.Scale', 0.15); openspace.setPropertyValueSingle('ScreenSpace.Legendfluxnodes.Enabled', false); diff --git a/data/assets/scene/solarsystem/heliosphere/bastille_day/lightindicator.asset b/data/assets/scene/solarsystem/heliosphere/bastille_day/lightindicator.asset index 36c54860b0..658e313304 100644 --- a/data/assets/scene/solarsystem/heliosphere/bastille_day/lightindicator.asset +++ b/data/assets/scene/solarsystem/heliosphere/bastille_day/lightindicator.asset @@ -1,5 +1,6 @@ local assetHelper = asset.require('util/asset_helper') local sunTransforms = asset.require('scene/solarsystem/sun/transforms') +local earthTransforms = asset.require('scene/solarsystem/planets/earth/transforms') local travelSpeedIndicator = { Identifier = "travelSpeedIndicator", @@ -14,7 +15,7 @@ local travelSpeedIndicator = { }, Renderable = { Type = "RenderableTravelSpeed", - Target = "Earth", --name of scene graph node. Earth by default + Target = earthTransforms.EarthCenter.Identifier, --name of scene graph node. Earth by default LineWidth = 4, IndicatorLength = 10, FadeLength = 10 diff --git a/data/assets/scene/solarsystem/heliosphere/bastille_day/magnetogram_textures.asset b/data/assets/scene/solarsystem/heliosphere/bastille_day/magnetogram_textures.asset index db1bc5a020..9f0c87b341 100644 --- a/data/assets/scene/solarsystem/heliosphere/bastille_day/magnetogram_textures.asset +++ b/data/assets/scene/solarsystem/heliosphere/bastille_day/magnetogram_textures.asset @@ -5,16 +5,17 @@ local sun = asset.require('scene/solarsystem/sun/sun') local textureDirectory = asset.require('./bastille_day_sun_textures').TexturesPath; local magnetogramDirectory = asset.require('./magnetogram').TexturesPath; --- lists of paths -local magnetograms = openspace.walkDirectoryFiles(magnetogramDirectory); -local textures = openspace.walkDirectoryFiles(textureDirectory); - --- put elements from textures into magnetograms -for _, v in ipairs(textures) do - table.insert(magnetograms, v) -end asset.onInitialize(function () + -- lists of paths + local magnetograms = openspace.walkDirectoryFiles(magnetogramDirectory); + local textures = openspace.walkDirectoryFiles(textureDirectory); + + -- put elements from textures into magnetograms + for _, v in ipairs(textures) do + table.insert(magnetograms, v) + end + -- add all all elements in magnetograms as layers for i, imagename in ipairs(magnetograms) do @@ -32,3 +33,11 @@ asset.onInitialize(function () end end) + +asset.onDeinitialize(function () + --for i, imagename in ipairs(magnetograms) do + -- openspace.globebrowsing.removeLayer( + -- ? + -- ) + --end +end) \ No newline at end of file diff --git a/data/assets/scene/solarsystem/planets/earth/magnetosphere.asset b/data/assets/scene/solarsystem/planets/earth/magnetosphere.asset index 0cefb50251..4d8b459a9d 100644 --- a/data/assets/scene/solarsystem/planets/earth/magnetosphere.asset +++ b/data/assets/scene/solarsystem/planets/earth/magnetosphere.asset @@ -31,7 +31,7 @@ local earthMagnetosphere = { SecondsBefore = 24*60*60*365*100, SecondsAfter = 24*60*60*365*100, Color = { - Uniform = {1.0, 0.725, 0.75, 1} + Uniform = { 1.0, 0.725, 0.75, 1.0 } } }, GUI = { diff --git a/data/assets/scene/solarsystem/planets/earth/transforms.asset b/data/assets/scene/solarsystem/planets/earth/transforms.asset index 168f9e7681..f0a0bc16cb 100644 --- a/data/assets/scene/solarsystem/planets/earth/transforms.asset +++ b/data/assets/scene/solarsystem/planets/earth/transforms.asset @@ -77,14 +77,14 @@ assetHelper.registerSceneGraphNodesAndExport(asset, { EarthBarycenter, EarthCenter, EarthInertial, - EarthIAU, + EarthIAU }) asset.meta = { Name = "Earth Transforms", Version = "1.0", - Description = [[ Earth transforms: Earth Barycenter, Earth Center, Earth Inertial, + Description = [[ Earth transforms: Earth Barycenter, Earth Center, Earth Inertial, Earth IAU. A scene graph node is created for each transform.]], Author = "OpenSpace Team", URL = "http://openspaceproject.com", diff --git a/data/assets/scene/solarsystem/sun/EUV_layer.asset b/data/assets/scene/solarsystem/sun/EUV_layer.asset index 4d011476ef..8bf47b3234 100644 --- a/data/assets/scene/solarsystem/sun/EUV_layer.asset +++ b/data/assets/scene/solarsystem/sun/EUV_layer.asset @@ -15,7 +15,7 @@ local EUV_Layer = { Renderable = { Type = "RenderableTimeVaryingSphere", Size = 6.96E8, -- Slightly bigger than the sun renderable, - Enabled = false, + Enabled = true, TextureSource = textureSourcePath, --BlendMode = "Additive", Opacity = 1, @@ -24,7 +24,7 @@ local EUV_Layer = { GUI = { Name = "EUV_Layer", Path = "/Solar System/Sun" - }, + } } assetHelper.registerSceneGraphNodesAndExport(asset, { EUV_Layer }) diff --git a/data/assets/scene/solarsystem/sun/transforms_heliosphere.asset b/data/assets/scene/solarsystem/sun/transforms_heliosphere.asset index a71f517956..7262083c83 100644 --- a/data/assets/scene/solarsystem/sun/transforms_heliosphere.asset +++ b/data/assets/scene/solarsystem/sun/transforms_heliosphere.asset @@ -5,9 +5,9 @@ local HEEQ180Kernel = asset.localResource("./kernels/HEEQ180.tf") local HEEQ180ReferenceFrame = { Identifier = "HEEQ180ReferenceFrame", - -- The heeq180 reference frame should have Sun_IAU as parent + -- The HEEQ180 reference frame should have Sun_IAU as parent -- instead of Solar center, however the Sun_IAU adds - -- an unwanter rotation which is difficult to cancel out + -- an unwanted rotation which is difficult to cancel out -- since it is using SpiceRotation. Sun center -- is used instead. Parent = sunTransforms.SunCenter.Identifier, diff --git a/data/assets/util/streamnodes_textures.asset b/data/assets/util/streamnodes_textures.asset index 3352ff818d..2c44e83e7a 100644 --- a/data/assets/util/streamnodes_textures.asset +++ b/data/assets/util/streamnodes_textures.asset @@ -1,8 +1,8 @@ local TexturesPath = asset.syncedResource({ - Type = "HttpSynchronization", - Name = "Streamnodes textures", - Identifier = "streamnodes_textures", - Version = 4 + Type = "HttpSynchronization", + Name = "Streamnodes textures", + Identifier = "streamnodes_textures", + Version = 4 }) asset.export("TexturesPath", TexturesPath) diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index ac05d5c74b..7683c43537 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -63,7 +63,7 @@ namespace { "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." + "data at a specific location, but not if it is displaying text for example." }; constexpr openspace::properties::Property::PropertyInfo SizeInfo = { diff --git a/modules/base/rendering/renderableplanetimevaryingimage.cpp b/modules/base/rendering/renderableplanetimevaryingimage.cpp index 4432939880..e8b3271d31 100644 --- a/modules/base/rendering/renderableplanetimevaryingimage.cpp +++ b/modules/base/rendering/renderableplanetimevaryingimage.cpp @@ -25,7 +25,6 @@ #include #include - #include #include #include @@ -33,10 +32,9 @@ #include #include #include - #include #include -// Test debugging tools more then logmanager + #include #include @@ -45,22 +43,22 @@ namespace { constexpr const char* _loggerCat = "RenderablePlaneTimeVaryingImage"; constexpr openspace::properties::Property::PropertyInfo TextureInfo = { - "Texture", - "Texture", - "This value specifies an image that is loaded from disk and is used as a texture " - "that is applied to this plane. This image has to be square." + "SourceFolder", + "Texture Directory", + "This value specifies the image directory that is loaded from disk and " + "is used as a texture that is applied to this plane." }; constexpr openspace::properties::Property::PropertyInfo RenderTypeInfo = { "RenderType", "RenderType", - "This value specifies if the plane should be rendered in the Background," + "This value specifies if the plane should be rendered in the Background, " "Opaque, Transparent, or Overlay rendering step." }; struct [[codegen::Dictionary(RenderablePlaneTimeVaryingImage)]] Parameters { // [[codegen::verbatim(TextureInfo.description)]] - std::string texture; + std::string sourceFolder; enum class RenderType { Background, @@ -104,14 +102,17 @@ RenderablePlaneTimeVaryingImage::RenderablePlaneTimeVaryingImage( addProperty(_blendMode); - _texturePath = absPath(p.texture).string(); - _textureFile = std::make_unique(_texturePath.value()); + _texturePath = p.sourceFolder; + std::filesystem::path textureDirectory = absPath(_texturePath); + if (!std::filesystem::is_directory(textureDirectory)) { + LERROR(fmt::format( + "Time varying image, {} is not a valid directory", + _texturePath + )); + } addProperty(_texturePath); _texturePath.onChange([this]() {loadTexture(); }); - _textureFile->setCallback( - [this]() { _textureIsDirty = true; } - ); if (p.renderType.has_value()) { switch (*p.renderType) { @@ -153,11 +154,8 @@ RenderablePlaneTimeVaryingImage::RenderablePlaneTimeVaryingImage( } } -bool RenderablePlaneTimeVaryingImage::isReady() const { - return RenderablePlane::isReady(); -} - -void RenderablePlaneTimeVaryingImage::initialize() { +void RenderablePlaneTimeVaryingImage::initialize() { + RenderablePlane::initialize(); bool success = extractMandatoryInfoFromDictionary(); if (!success) { return; @@ -188,39 +186,29 @@ bool RenderablePlaneTimeVaryingImage::extractMandatoryInfoFromDictionary() { // Ensure that the source folder exists and then extract // the files with the same extension as namespace fs = std::filesystem; - fs::path sourceFolder = _texturePath.value(); - if (std::filesystem::is_directory(sourceFolder)) { - // Extract all file paths from the provided folder - _sourceFiles.clear(); - namespace fs = std::filesystem; - for (const fs::directory_entry& e : fs::directory_iterator(sourceFolder)) { - if (e.is_regular_file()) { - _sourceFiles.push_back(e.path().string()); - } - } - std::sort(_sourceFiles.begin(), _sourceFiles.end()); - // Ensure that there are available and valid source files left - if (_sourceFiles.empty()) { - LERROR(fmt::format( - "{}: Plane sequence filepath {} was empty", - _identifier, _texturePath - )); - return false; + fs::path sourceFolder = absPath(_texturePath); + // Extract all file paths from the provided folder + _sourceFiles.clear(); + namespace fs = std::filesystem; + for (const fs::directory_entry& e : fs::directory_iterator(sourceFolder)) { + if (e.is_regular_file()) { + _sourceFiles.push_back(e.path().string()); } } - else { + std::sort(_sourceFiles.begin(), _sourceFiles.end()); + // Ensure that there are available and valid source files left + if (_sourceFiles.empty()) { LERROR(fmt::format( - "{}: Plane sequence filepath {} is not a valid directory", + "{}: Plane sequence filepath {} was empty", _identifier, _texturePath )); return false; } - _nStates = _sourceFiles.size(); + return true; } void RenderablePlaneTimeVaryingImage::deinitializeGL() { - _textureFile = nullptr; BaseModule::TextureManager.release(_texture); @@ -241,7 +229,7 @@ void RenderablePlaneTimeVaryingImage::update(const UpdateData& data) { if (!_enabled || _startTimes.size() == 0) { return; } - + bool needsUpdate = false; const double currentTime = data.time.j2000Seconds(); bool isInInterval = (currentTime >= _startTimes[0]) && (currentTime < _sequenceEndTime); @@ -251,35 +239,35 @@ void RenderablePlaneTimeVaryingImage::update(const UpdateData& data) { // 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])) + (nextIdx < _sourceFiles.size() && currentTime >= _startTimes[nextIdx])) { updateActiveTriggerTimeIndex(currentTime); - _needsUpdate = true; + needsUpdate = true; } // else we're still in same state as previous frame (no changes needed) } else { // not in interval => set everything to false _activeTriggerTimeIndex = -1; - _needsUpdate = false; + needsUpdate = false; } - if ((_needsUpdate || _textureIsDirty) && !_isLoadingTexture) { - _isLoadingTexture = true; + if (needsUpdate || _textureIsDirty) { loadTexture(); _textureIsDirty = false; } } void RenderablePlaneTimeVaryingImage::render(const RenderData& data, RendererTasks& t) { - glDisable(GL_CULL_FACE); - RenderablePlane::render(data, t); + if (data.time.j2000Seconds() < _sequenceEndTime) { + glDisable(GL_CULL_FACE); + RenderablePlane::render(data, t); + } } // Requires time to be formated as such: 'YYYY-MM-DDTHH-MM-SS-XXX' void RenderablePlaneTimeVaryingImage::extractTriggerTimesFromFileNames() { for (const std::string& filePath : _sourceFiles) { - LDEBUG("filepath " + filePath); // Extract the filename from the path (without extension) std::string timeString = std::filesystem::path(filePath).stem().string(); @@ -298,24 +286,23 @@ void RenderablePlaneTimeVaryingImage::updateActiveTriggerTimeIndex(double curren auto iter = std::upper_bound(_startTimes.begin(), _startTimes.end(), currentTime); if (iter != _startTimes.end()) { if (iter != _startTimes.begin()) { - _activeTriggerTimeIndex = static_cast( - std::distance(_startTimes.begin(), iter) - ) - 1; + std::ptrdiff_t idx = std::distance(_startTimes.begin(), iter); + _activeTriggerTimeIndex = static_cast(idx) - 1; } else { _activeTriggerTimeIndex = 0; } } else { - _activeTriggerTimeIndex = static_cast(_nStates) - 1; + _activeTriggerTimeIndex = static_cast(_sourceFiles.size() - 1); } } void RenderablePlaneTimeVaryingImage::computeSequenceEndTime() { - if (_nStates > 1) { - const double lastTriggerTime = _startTimes[_nStates - 1]; + if (_sourceFiles.size() > 1) { + const double lastTriggerTime = _startTimes[_sourceFiles.size() - 1]; const double sequenceDuration = lastTriggerTime - _startTimes[0]; const double averageStateDuration = sequenceDuration / - (static_cast(_nStates) - 1.0); + (static_cast(_sourceFiles.size() - 1.0)); _sequenceEndTime = lastTriggerTime + averageStateDuration; } else { @@ -326,7 +313,6 @@ void RenderablePlaneTimeVaryingImage::computeSequenceEndTime() { void RenderablePlaneTimeVaryingImage::loadTexture() { if (_activeTriggerTimeIndex != -1) { _texture = _textureFiles[_activeTriggerTimeIndex].get(); - _isLoadingTexture = false; } } } // namespace openspace diff --git a/modules/base/rendering/renderableplanetimevaryingimage.h b/modules/base/rendering/renderableplanetimevaryingimage.h index e564857438..17c2ef6af5 100644 --- a/modules/base/rendering/renderableplanetimevaryingimage.h +++ b/modules/base/rendering/renderableplanetimevaryingimage.h @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_BASE___RenderablePlaneTimeVaryingImage___H__ -#define __OPENSPACE_MODULE_BASE___RenderablePlaneTimeVaryingImage___H__ +#ifndef __OPENSPACE_MODULE_BASE___RENDERABLEPLANETIMEVARYINGIMAGE___H__ +#define __OPENSPACE_MODULE_BASE___RENDERABLEPLANETIMEVARYINGIMAGE___H__ #include @@ -45,10 +45,8 @@ public: void initializeGL() override; void deinitializeGL() override; - bool isReady() const override; - void update(const UpdateData& data) override; - void render(const RenderData& data, RendererTasks&); + void render(const RenderData& data, RendererTasks&) override; static documentation::Documentation Documentation(); @@ -61,24 +59,18 @@ private: bool extractMandatoryInfoFromDictionary(); void updateActiveTriggerTimeIndex(double currenttime); void computeSequenceEndTime(); - // Estimated end of sequence. + double _sequenceEndTime; - bool _needsUpdate = false; std::vector _sourceFiles; std::vector _startTimes; int _activeTriggerTimeIndex = 0; - // Number of states in the sequence/ number of images. - size_t _nStates; properties::StringProperty _texturePath; ghoul::opengl::Texture* _texture = nullptr; - // std::unique_ptr _texture; std::vector> _textureFiles; - std::unique_ptr _textureFile; - bool _isLoadingTexture = false; bool _isLoadingLazily = false; bool _textureIsDirty = false; }; } // namespace openspace -#endif // __OPENSPACE_MODULE_BASE___RenderablePlaneTimeVaryingImage___H__ +#endif // __OPENSPACE_MODULE_BASE___RENDERABLEPLANETIMEVARYINGIMAGE___H__ diff --git a/modules/base/rendering/renderabletimevaryingsphere.cpp b/modules/base/rendering/renderabletimevaryingsphere.cpp index 66f3252142..6379d913f0 100644 --- a/modules/base/rendering/renderabletimevaryingsphere.cpp +++ b/modules/base/rendering/renderabletimevaryingsphere.cpp @@ -31,15 +31,14 @@ #include #include #include -#include #include -#include +#include #include +#include +#include #include #include #include -#include - #include #include @@ -60,9 +59,9 @@ namespace { constexpr openspace::properties::Property::PropertyInfo TextureSourceInfo = { "TextureSource", "Texture Source", - "This value specifies a directory of images that are loaded from disk and is used" - "as a texture that is applied to this sphere. The images are expected to be an" - "equirectangular projection." + "This value specifies a directory of images that are loaded from disk and is " + "used as a texture that is applied to this sphere. The images are expected to " + "be an equirectangular projection." }; constexpr openspace::properties::Property::PropertyInfo MirrorTextureInfo = { diff --git a/modules/base/rendering/renderabletimevaryingsphere.h b/modules/base/rendering/renderabletimevaryingsphere.h index 2df51c1bfd..f59f0b23c4 100644 --- a/modules/base/rendering/renderabletimevaryingsphere.h +++ b/modules/base/rendering/renderabletimevaryingsphere.h @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_BASE___RenderableTimeVaryingSphere___H__ -#define __OPENSPACE_MODULE_BASE___RenderableTimeVaryingSphere___H__ +#ifndef __OPENSPACE_MODULE_BASE___RENDERABLETIMEVARYINGSPHERE___H__ +#define __OPENSPACE_MODULE_BASE___RENDERABLETIMEVARYINGSPHERE___H__ #include @@ -108,4 +108,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_BASE___RenderableTimeVaryingSphere___H__ +#endif // __OPENSPACE_MODULE_BASE___RENDERABLETIMEVARYINGSPHERE___H__