From 15533a76662c924d1f9c30fe8949665c36a7e79b Mon Sep 17 00:00:00 2001 From: Malin E Date: Mon, 15 Aug 2022 18:09:22 +0200 Subject: [PATCH 01/21] Initial working version --- .../solarsystem/missions/jwst/trail.asset | 40 ++++++++++++++++++- .../planets/earth/lagrange_points/L2.asset | 36 +++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index 15fb544305..b91a92288e 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -7,7 +7,7 @@ local kernels = asset.syncedResource({ Name = "JWST Kernel", Type = "HttpSynchronization", Identifier = "jwst_kernels", - Version = 2 + Version = 3 }) local launchTime = "2021 DEC 25 12:20:00" @@ -85,7 +85,7 @@ local JWSTTrailCruise = { -- Gives a better trail history of the orbit around L2 than if it was relative to Earth local JWSTTrailOrbit = { Identifier = "JWSTTrailOrbit", - Parent = transforms.L2.Identifier, + Parent = transforms.L2Position.Identifier, TimeFrame = { Type = "TimeFrameInterval", Start = L2orbitInsertionTime, @@ -113,6 +113,39 @@ local JWSTTrailOrbit = { } } +local JWSTTrailCoOrbit = { + Identifier = "JWSTTrailCoOrbit", + Parent = transforms.L2CoRotFrame.Identifier, + TimeFrame = { + Type = "TimeFrameInterval", + Start = L2orbitInsertionTime, + End = endTime + }, + Renderable = { + Type = "RenderableTrailOrbit", + Translation = { + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 392, -- L2 + Frame = 'L2_COROT', + Kernels = { + kernels .. "webb.bsp", + kernels .. "l2_corot.tf" + } + }, + Color = { 0.0, 0.9, 0.9 }, + Period = 182.621099, -- About 6 months + Resolution = 183 -- About a sample rate of once per day + }, + GUI = { + Name = "JWST L2 Co Orbit Trail", + Path = "/Solar System/Missions/JWST/Trails", + Description = [[ + James Webb Space Telescope Orbit Trail co-revolving with L2. + ]], + } +} + local JWSTSunTrail = { Identifier = "JWSTSunTrail", Parent = sunTransforms.SolarSystemBarycenter.Identifier, @@ -147,11 +180,13 @@ asset.onInitialize(function() openspace.addSceneGraphNode(JWSTTrailLaunch) openspace.addSceneGraphNode(JWSTTrailCruise) openspace.addSceneGraphNode(JWSTTrailOrbit) + openspace.addSceneGraphNode(JWSTTrailCoOrbit) openspace.addSceneGraphNode(JWSTSunTrail) end) asset.onDeinitialize(function() openspace.removeSceneGraphNode(JWSTSunTrail) + openspace.removeSceneGraphNode(JWSTTrailCoOrbit) openspace.removeSceneGraphNode(JWSTTrailOrbit) openspace.removeSceneGraphNode(JWSTTrailCruise) openspace.removeSceneGraphNode(JWSTTrailLaunch) @@ -160,6 +195,7 @@ end) asset.export(JWSTTrailLaunch) asset.export(JWSTTrailCruise) asset.export(JWSTTrailOrbit) +asset.export(JWSTTrailCoOrbit) asset.export(JWSTSunTrail) diff --git a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset index 62a317284a..39ad74349e 100644 --- a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset +++ b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset @@ -15,6 +15,13 @@ local kernels = asset.syncedResource({ Version = 1 }) +local corotkernels = asset.syncedResource({ + Name = "JWST Kernel", + Type = "HttpSynchronization", + Identifier = "jwst_kernels", + Version = 3 +}) + local L2Position = { Identifier = "L2Position", Parent = transforms.SolarSystemBarycenter.Identifier, @@ -34,6 +41,34 @@ local L2Position = { } } +local L2CoRotFrame = { + Identifier = "L2CoRotFrame", + Parent = transforms.SolarSystemBarycenter.Identifier, + Transform = { + Translation = { + Type = "SpiceTranslation", + Target = 392, -- L2 + Observer = "SSB", + Kernels = kernels .. "L2_de431.bsp" + }, + Rotation = { + Type = "SpiceRotation", + SourceFrame = "L2_COROT", + DestinationFrame = 'GALACTIC', + Kernels = { + kernels .. "L2_de431.bsp", + corotkernels .. "l2_corot.tf" + } + } + }, + Tag = { "lagrange_points_earth", "lagrange_points_earth_l2" }, + GUI = { + Name = "L2 CoRot Position", + Path = "/Solar System/Planets/Earth/Lagrange points", + Hidden = true + } +} + local L2Small = { Identifier = "L2Small", Parent = L2Position.Identifier, @@ -131,6 +166,7 @@ local L2SunLine = { local nodes = { L2Position, + L2CoRotFrame, L2Small, L2, L2SunLine, From 8a865bde1032137f938a78faa93895f46c2042f7 Mon Sep 17 00:00:00 2001 From: Malin E Date: Tue, 16 Aug 2022 11:16:05 +0200 Subject: [PATCH 02/21] Clean up --- .../solarsystem/missions/jwst/trail.asset | 23 ++++++++----------- .../planets/earth/lagrange_points/L2.asset | 13 +++-------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index b91a92288e..a3adf09bde 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -7,7 +7,7 @@ local kernels = asset.syncedResource({ Name = "JWST Kernel", Type = "HttpSynchronization", Identifier = "jwst_kernels", - Version = 3 + Version = 2 }) local launchTime = "2021 DEC 25 12:20:00" @@ -113,8 +113,8 @@ local JWSTTrailOrbit = { } } -local JWSTTrailCoOrbit = { - Identifier = "JWSTTrailCoOrbit", +local JWSTTrailCoRotOrbit = { + Identifier = "JWSTTrailCoRotOrbit", Parent = transforms.L2CoRotFrame.Identifier, TimeFrame = { Type = "TimeFrameInterval", @@ -128,20 +128,17 @@ local JWSTTrailCoOrbit = { Target = 170, -- JWST Observer = 392, -- L2 Frame = 'L2_COROT', - Kernels = { - kernels .. "webb.bsp", - kernels .. "l2_corot.tf" - } + Kernels = { kernels .. "webb.bsp" } }, Color = { 0.0, 0.9, 0.9 }, Period = 182.621099, -- About 6 months Resolution = 183 -- About a sample rate of once per day }, GUI = { - Name = "JWST L2 Co Orbit Trail", + Name = "JWST L2 Co-rotating Orbit Trail", Path = "/Solar System/Missions/JWST/Trails", Description = [[ - James Webb Space Telescope Orbit Trail co-revolving with L2. + James Webb Space Telescope Orbit Trail that Co-rotates with L2. ]], } } @@ -180,13 +177,13 @@ asset.onInitialize(function() openspace.addSceneGraphNode(JWSTTrailLaunch) openspace.addSceneGraphNode(JWSTTrailCruise) openspace.addSceneGraphNode(JWSTTrailOrbit) - openspace.addSceneGraphNode(JWSTTrailCoOrbit) + openspace.addSceneGraphNode(JWSTTrailCoRotOrbit) openspace.addSceneGraphNode(JWSTSunTrail) end) asset.onDeinitialize(function() openspace.removeSceneGraphNode(JWSTSunTrail) - openspace.removeSceneGraphNode(JWSTTrailCoOrbit) + openspace.removeSceneGraphNode(JWSTTrailCoRotOrbit) openspace.removeSceneGraphNode(JWSTTrailOrbit) openspace.removeSceneGraphNode(JWSTTrailCruise) openspace.removeSceneGraphNode(JWSTTrailLaunch) @@ -195,7 +192,7 @@ end) asset.export(JWSTTrailLaunch) asset.export(JWSTTrailCruise) asset.export(JWSTTrailOrbit) -asset.export(JWSTTrailCoOrbit) +asset.export(JWSTTrailCoRotOrbit) asset.export(JWSTSunTrail) @@ -203,7 +200,7 @@ asset.meta = { Name = "James Webb Space Telescope Trails", Version = "1.0", Description = [[ - Trail of James Webb Space Telescope in respect to Earth, L2 and the Sun + Trail of James Webb Space Telescope in respect to Earth, L2, and the Sun ]], Author = "OpenSpace Team", URL = "http://openspaceproject.com", diff --git a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset index 39ad74349e..85a87561dd 100644 --- a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset +++ b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset @@ -12,14 +12,7 @@ local kernels = asset.syncedResource({ Name = "Lagrange Kernels", Type = "HttpSynchronization", Identifier = "earth_lagrange_kernels", - Version = 1 -}) - -local corotkernels = asset.syncedResource({ - Name = "JWST Kernel", - Type = "HttpSynchronization", - Identifier = "jwst_kernels", - Version = 3 + Version = 2 }) local L2Position = { @@ -57,13 +50,13 @@ local L2CoRotFrame = { DestinationFrame = 'GALACTIC', Kernels = { kernels .. "L2_de431.bsp", - corotkernels .. "l2_corot.tf" + kernels .. "L2_corot.tf" } } }, Tag = { "lagrange_points_earth", "lagrange_points_earth_l2" }, GUI = { - Name = "L2 CoRot Position", + Name = "L2 Co-rotation Frame", Path = "/Solar System/Planets/Earth/Lagrange points", Hidden = true } From 460b849361250a7f695662abbbc7faa55bc74e2f Mon Sep 17 00:00:00 2001 From: Malin E Date: Tue, 16 Aug 2022 11:45:36 +0200 Subject: [PATCH 03/21] Make L2 co-rot trail turn on/off together with the other JWST trails --- .../scene/solarsystem/missions/jwst/toggle_trail.asset | 8 +++++++- .../assets/scene/solarsystem/missions/jwst/trail.asset | 5 ++++- .../solarsystem/planets/earth/lagrange_points/L2.asset | 10 +++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset index 9f8d42dc16..6360f6283c 100644 --- a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset @@ -17,6 +17,7 @@ local toggle_trail = { local launchTrail = "JWSTTrailLaunch" local cruiseTrail = "JWSTTrailCruise" local orbitTrail = "JWSTTrailOrbit" + local coOrbitTrail = "JWSTTrailCoRotOrbit" local visibility if is_declared("args") then @@ -31,7 +32,8 @@ local toggle_trail = { visibility = not ( openspace.getPropertyValue("Scene." .. launchTrail .. ".Renderable.Enabled") or openspace.getPropertyValue("Scene." .. cruiseTrail .. ".Renderable.Enabled") or - openspace.getPropertyValue("Scene." .. orbitTrail .. ".Renderable.Enabled") + openspace.getPropertyValue("Scene." .. orbitTrail .. ".Renderable.Enabled") or + openspace.getPropertyValue("Scene." .. coOrbitTrail .. ".Renderable.Enabled") ) end @@ -47,6 +49,10 @@ local toggle_trail = { "Scene." .. orbitTrail .. ".Renderable.Enabled", visibility ) + openspace.setPropertyValueSingle( + "Scene." .. coOrbitTrail .. ".Renderable.Enabled", + visibility + ) ]], Documentation = [[Toggles the visibility of the JWST trail with an approaching/exiting event. This action takes optional arguments to 1) determine which diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index a3adf09bde..09aee9de85 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -83,6 +83,7 @@ local JWSTTrailCruise = { -- Trail of JWST relative to L2 after first month to reach L2 -- Gives a better trail history of the orbit around L2 than if it was relative to Earth +-- This does NOT co-rotate withe L2 and gives a saddle look of the trail local JWSTTrailOrbit = { Identifier = "JWSTTrailOrbit", Parent = transforms.L2Position.Identifier, @@ -113,6 +114,8 @@ local JWSTTrailOrbit = { } } +-- Trail of JWST in orbit around L2 that co-rotates with L2 around the Sun +-- This gives the trail a look of a wheel going along L2 around the Sun local JWSTTrailCoRotOrbit = { Identifier = "JWSTTrailCoRotOrbit", Parent = transforms.L2CoRotFrame.Identifier, @@ -130,7 +133,7 @@ local JWSTTrailCoRotOrbit = { Frame = 'L2_COROT', Kernels = { kernels .. "webb.bsp" } }, - Color = { 0.0, 0.9, 0.9 }, + Color = { 0.9, 0.0, 0.9 }, Period = 182.621099, -- About 6 months Resolution = 183 -- About a sample rate of once per day }, diff --git a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset index 85a87561dd..98a835c794 100644 --- a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset +++ b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset @@ -34,16 +34,12 @@ local L2Position = { } } +-- This ref. frame co-rotates with L2 and is needed for a more intuitive trail of JWST in +-- relation to L2 local L2CoRotFrame = { Identifier = "L2CoRotFrame", - Parent = transforms.SolarSystemBarycenter.Identifier, + Parent = L2Position.Identifier, Transform = { - Translation = { - Type = "SpiceTranslation", - Target = 392, -- L2 - Observer = "SSB", - Kernels = kernels .. "L2_de431.bsp" - }, Rotation = { Type = "SpiceRotation", SourceFrame = "L2_COROT", From b8a36c984533e79553d8d12b5fb658479af54260 Mon Sep 17 00:00:00 2001 From: Malin E Date: Tue, 16 Aug 2022 13:24:18 +0200 Subject: [PATCH 04/21] Some small clean up --- .../scene/solarsystem/missions/jwst/toggle_trail.asset | 6 +++--- data/assets/scene/solarsystem/missions/jwst/trail.asset | 4 ++-- .../solarsystem/planets/earth/lagrange_points/L2.asset | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset index 6360f6283c..91b11e8ace 100644 --- a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset @@ -17,7 +17,7 @@ local toggle_trail = { local launchTrail = "JWSTTrailLaunch" local cruiseTrail = "JWSTTrailCruise" local orbitTrail = "JWSTTrailOrbit" - local coOrbitTrail = "JWSTTrailCoRotOrbit" + local coRotOrbitTrail = "JWSTTrailCoRotOrbit" local visibility if is_declared("args") then @@ -33,7 +33,7 @@ local toggle_trail = { openspace.getPropertyValue("Scene." .. launchTrail .. ".Renderable.Enabled") or openspace.getPropertyValue("Scene." .. cruiseTrail .. ".Renderable.Enabled") or openspace.getPropertyValue("Scene." .. orbitTrail .. ".Renderable.Enabled") or - openspace.getPropertyValue("Scene." .. coOrbitTrail .. ".Renderable.Enabled") + openspace.getPropertyValue("Scene." .. coRotOrbitTrail .. ".Renderable.Enabled") ) end @@ -50,7 +50,7 @@ local toggle_trail = { visibility ) openspace.setPropertyValueSingle( - "Scene." .. coOrbitTrail .. ".Renderable.Enabled", + "Scene." .. coRotOrbitTrail .. ".Renderable.Enabled", visibility ) ]], diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index 09aee9de85..fe213d316b 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -83,7 +83,7 @@ local JWSTTrailCruise = { -- Trail of JWST relative to L2 after first month to reach L2 -- Gives a better trail history of the orbit around L2 than if it was relative to Earth --- This does NOT co-rotate withe L2 and gives a saddle look of the trail +-- This does NOT co-rotate with L2 and gives a saddle look of the trail local JWSTTrailOrbit = { Identifier = "JWSTTrailOrbit", Parent = transforms.L2Position.Identifier, @@ -203,7 +203,7 @@ asset.meta = { Name = "James Webb Space Telescope Trails", Version = "1.0", Description = [[ - Trail of James Webb Space Telescope in respect to Earth, L2, and the Sun + Trail of James Webb Space Telescope in respect to Earth, L2 and the Sun ]], Author = "OpenSpace Team", URL = "http://openspaceproject.com", diff --git a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset index 98a835c794..05c4724d5e 100644 --- a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset +++ b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset @@ -52,7 +52,7 @@ local L2CoRotFrame = { }, Tag = { "lagrange_points_earth", "lagrange_points_earth_l2" }, GUI = { - Name = "L2 Co-rotation Frame", + Name = "L2 Co-rotating Reference Frame", Path = "/Solar System/Planets/Earth/Lagrange points", Hidden = true } From 91513fafca3b4a24a2fc3d9d450d92ee7ac57faa Mon Sep 17 00:00:00 2001 From: Malin E Date: Tue, 16 Aug 2022 16:50:23 +0200 Subject: [PATCH 05/21] Make new trail default and change the colors --- .../scene/solarsystem/missions/jwst/toggle_trail.asset | 6 ------ data/assets/scene/solarsystem/missions/jwst/trail.asset | 4 ++-- data/profiles/jwst.profile | 5 +++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset index 91b11e8ace..8f9ed79db2 100644 --- a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset @@ -16,7 +16,6 @@ local toggle_trail = { local launchTrail = "JWSTTrailLaunch" local cruiseTrail = "JWSTTrailCruise" - local orbitTrail = "JWSTTrailOrbit" local coRotOrbitTrail = "JWSTTrailCoRotOrbit" local visibility @@ -32,7 +31,6 @@ local toggle_trail = { visibility = not ( openspace.getPropertyValue("Scene." .. launchTrail .. ".Renderable.Enabled") or openspace.getPropertyValue("Scene." .. cruiseTrail .. ".Renderable.Enabled") or - openspace.getPropertyValue("Scene." .. orbitTrail .. ".Renderable.Enabled") or openspace.getPropertyValue("Scene." .. coRotOrbitTrail .. ".Renderable.Enabled") ) end @@ -45,10 +43,6 @@ local toggle_trail = { "Scene." .. cruiseTrail .. ".Renderable.Enabled", visibility ) - openspace.setPropertyValueSingle( - "Scene." .. orbitTrail .. ".Renderable.Enabled", - visibility - ) openspace.setPropertyValueSingle( "Scene." .. coRotOrbitTrail .. ".Renderable.Enabled", visibility diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index fe213d316b..313f66b67b 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -101,7 +101,7 @@ local JWSTTrailOrbit = { Frame = 'GALACTIC', Kernels = { kernels .. "webb.bsp" } }, - Color = { 0.9, 0.9, 0.0 }, + Color = { 0.863, 0.0, 0.902 }, Period = 182.621099, -- About 6 months Resolution = 183 -- About a sample rate of once per day }, @@ -133,7 +133,7 @@ local JWSTTrailCoRotOrbit = { Frame = 'L2_COROT', Kernels = { kernels .. "webb.bsp" } }, - Color = { 0.9, 0.0, 0.9 }, + Color = { 1.0, 0.663, 0.157 }, Period = 182.621099, -- About 6 months Resolution = 183 -- About a sample rate of once per day }, diff --git a/data/profiles/jwst.profile b/data/profiles/jwst.profile index 38fb91dbd1..336b97ae82 100644 --- a/data/profiles/jwst.profile +++ b/data/profiles/jwst.profile @@ -294,6 +294,11 @@ "type": "setPropertyValueSingle", "value": "false" }, + { + "name": "Scene.JWSTTrailOrbit.Renderable.Enabled", + "type": "setPropertyValueSingle", + "value": "false" + }, { "name": "Scene.JWSTSunTrail.Renderable.Enabled", "type": "setPropertyValueSingle", From 08fa825381e972a6d14a3e1e8c0af5d4bb2e1e54 Mon Sep 17 00:00:00 2001 From: Malin E Date: Wed, 17 Aug 2022 09:02:36 +0200 Subject: [PATCH 06/21] Make the co-rotating trail longer --- data/assets/scene/solarsystem/missions/jwst/trail.asset | 4 ++-- data/profiles/jwst.profile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index 313f66b67b..5c2709b446 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -134,8 +134,8 @@ local JWSTTrailCoRotOrbit = { Kernels = { kernels .. "webb.bsp" } }, Color = { 1.0, 0.663, 0.157 }, - Period = 182.621099, -- About 6 months - Resolution = 183 -- About a sample rate of once per day + Period = 365.242198, -- About a year, 2 orbits. 1 orbit would be 182.621099 (6 months) + Resolution = 365 -- About a sample rate of once per day }, GUI = { Name = "JWST L2 Co-rotating Orbit Trail", diff --git a/data/profiles/jwst.profile b/data/profiles/jwst.profile index 336b97ae82..9ccf2cf029 100644 --- a/data/profiles/jwst.profile +++ b/data/profiles/jwst.profile @@ -73,12 +73,12 @@ "script": "local list = openspace.getProperty('{planetTrail_solarSystem}.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end local moonlist = openspace.getProperty('{moonTrail_solarSystem}.Renderable.Enabled') for _,v in pairs(moonlist) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end openspace.setPropertyValueSingle('Scene.MoonTrail.Renderable.Enabled', true)" }, { - "documentation": "Toggle JWST launch, cruise and orbit trails, not the Sun trail", + "documentation": "Toggle JWST launch, cruise and L2 co-revolving orbit trails, not the Sun trail", "gui_path": "/JWST", "identifier": "profile.toggle.jwst_trails", "is_local": false, "name": "Toggle JWST trail", - "script": "local list = {'Scene.JWSTTrailLaunch.Renderable.Enabled', 'Scene.JWSTTrailCruise.Renderable.Enabled', 'Scene.JWSTTrailOrbit.Renderable.Enabled'}; for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)); end" + "script": "local list = {'Scene.JWSTTrailLaunch.Renderable.Enabled', 'Scene.JWSTTrailCruise.Renderable.Enabled', 'Scene.JWSTTrailCoRotOrbit.Renderable.Enabled'}; for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)); end" } ], "additional_scripts": [ From 44aa45d36f85e97fdefda0bd0eaaf0fdcba635d8 Mon Sep 17 00:00:00 2001 From: Malin E Date: Wed, 17 Aug 2022 09:26:21 +0200 Subject: [PATCH 07/21] Change name from co-rotating to co-revolving --- .../missions/jwst/toggle_trail.asset | 6 +++--- .../solarsystem/missions/jwst/trail.asset | 20 +++++++++---------- .../planets/earth/lagrange_points/L2.asset | 14 ++++++------- data/profiles/jwst.profile | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset index 8f9ed79db2..37c8900d1c 100644 --- a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset @@ -16,7 +16,7 @@ local toggle_trail = { local launchTrail = "JWSTTrailLaunch" local cruiseTrail = "JWSTTrailCruise" - local coRotOrbitTrail = "JWSTTrailCoRotOrbit" + local coRevOrbitTrail = "JWSTTrailCoRevOrbit" local visibility if is_declared("args") then @@ -31,7 +31,7 @@ local toggle_trail = { visibility = not ( openspace.getPropertyValue("Scene." .. launchTrail .. ".Renderable.Enabled") or openspace.getPropertyValue("Scene." .. cruiseTrail .. ".Renderable.Enabled") or - openspace.getPropertyValue("Scene." .. coRotOrbitTrail .. ".Renderable.Enabled") + openspace.getPropertyValue("Scene." .. coRevOrbitTrail .. ".Renderable.Enabled") ) end @@ -44,7 +44,7 @@ local toggle_trail = { visibility ) openspace.setPropertyValueSingle( - "Scene." .. coRotOrbitTrail .. ".Renderable.Enabled", + "Scene." .. coRevOrbitTrail .. ".Renderable.Enabled", visibility ) ]], diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index 5c2709b446..0f91d4caca 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -114,11 +114,11 @@ local JWSTTrailOrbit = { } } --- Trail of JWST in orbit around L2 that co-rotates with L2 around the Sun +-- Trail of JWST in orbit around L2 that co-revolves with L2 around the Sun -- This gives the trail a look of a wheel going along L2 around the Sun -local JWSTTrailCoRotOrbit = { - Identifier = "JWSTTrailCoRotOrbit", - Parent = transforms.L2CoRotFrame.Identifier, +local JWSTTrailCoRevOrbit = { + Identifier = "JWSTTrailCoRevOrbit", + Parent = transforms.L2CoRevFrame.Identifier, TimeFrame = { Type = "TimeFrameInterval", Start = L2orbitInsertionTime, @@ -130,7 +130,7 @@ local JWSTTrailCoRotOrbit = { Type = 'SpiceTranslation', Target = 170, -- JWST Observer = 392, -- L2 - Frame = 'L2_COROT', + Frame = 'L2_COREV', Kernels = { kernels .. "webb.bsp" } }, Color = { 1.0, 0.663, 0.157 }, @@ -138,10 +138,10 @@ local JWSTTrailCoRotOrbit = { Resolution = 365 -- About a sample rate of once per day }, GUI = { - Name = "JWST L2 Co-rotating Orbit Trail", + Name = "JWST L2 Co-revolving Orbit Trail", Path = "/Solar System/Missions/JWST/Trails", Description = [[ - James Webb Space Telescope Orbit Trail that Co-rotates with L2. + James Webb Space Telescope Orbit Trail that Co-revolves with L2. ]], } } @@ -180,13 +180,13 @@ asset.onInitialize(function() openspace.addSceneGraphNode(JWSTTrailLaunch) openspace.addSceneGraphNode(JWSTTrailCruise) openspace.addSceneGraphNode(JWSTTrailOrbit) - openspace.addSceneGraphNode(JWSTTrailCoRotOrbit) + openspace.addSceneGraphNode(JWSTTrailCoRevOrbit) openspace.addSceneGraphNode(JWSTSunTrail) end) asset.onDeinitialize(function() openspace.removeSceneGraphNode(JWSTSunTrail) - openspace.removeSceneGraphNode(JWSTTrailCoRotOrbit) + openspace.removeSceneGraphNode(JWSTTrailCoRevOrbit) openspace.removeSceneGraphNode(JWSTTrailOrbit) openspace.removeSceneGraphNode(JWSTTrailCruise) openspace.removeSceneGraphNode(JWSTTrailLaunch) @@ -195,7 +195,7 @@ end) asset.export(JWSTTrailLaunch) asset.export(JWSTTrailCruise) asset.export(JWSTTrailOrbit) -asset.export(JWSTTrailCoRotOrbit) +asset.export(JWSTTrailCoRevOrbit) asset.export(JWSTSunTrail) diff --git a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset index 05c4724d5e..972e66717f 100644 --- a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset +++ b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset @@ -34,25 +34,25 @@ local L2Position = { } } --- This ref. frame co-rotates with L2 and is needed for a more intuitive trail of JWST in +-- This ref. frame co-revolves with L2 and is needed for a more intuitive trail of JWST in -- relation to L2 -local L2CoRotFrame = { - Identifier = "L2CoRotFrame", +local L2CoRevFrame = { + Identifier = "L2CoRevFrame", Parent = L2Position.Identifier, Transform = { Rotation = { Type = "SpiceRotation", - SourceFrame = "L2_COROT", + SourceFrame = "L2_COREV", DestinationFrame = 'GALACTIC', Kernels = { kernels .. "L2_de431.bsp", - kernels .. "L2_corot.tf" + kernels .. "L2_corev.tf" } } }, Tag = { "lagrange_points_earth", "lagrange_points_earth_l2" }, GUI = { - Name = "L2 Co-rotating Reference Frame", + Name = "L2 Co-revolving Reference Frame", Path = "/Solar System/Planets/Earth/Lagrange points", Hidden = true } @@ -155,7 +155,7 @@ local L2SunLine = { local nodes = { L2Position, - L2CoRotFrame, + L2CoRevFrame, L2Small, L2, L2SunLine, diff --git a/data/profiles/jwst.profile b/data/profiles/jwst.profile index 9ccf2cf029..ecf38ad0f5 100644 --- a/data/profiles/jwst.profile +++ b/data/profiles/jwst.profile @@ -78,7 +78,7 @@ "identifier": "profile.toggle.jwst_trails", "is_local": false, "name": "Toggle JWST trail", - "script": "local list = {'Scene.JWSTTrailLaunch.Renderable.Enabled', 'Scene.JWSTTrailCruise.Renderable.Enabled', 'Scene.JWSTTrailCoRotOrbit.Renderable.Enabled'}; for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)); end" + "script": "local list = {'Scene.JWSTTrailLaunch.Renderable.Enabled', 'Scene.JWSTTrailCruise.Renderable.Enabled', 'Scene.JWSTTrailCoRevOrbit.Renderable.Enabled'}; for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)); end" } ], "additional_scripts": [ From b3d87b63cc486241cb7c375bc38fbd4ae496b1c9 Mon Sep 17 00:00:00 2001 From: Malin E Date: Wed, 17 Aug 2022 10:50:50 +0200 Subject: [PATCH 08/21] Slow down shoot off part of timelapse of JWST deployment --- .../scene/solarsystem/missions/jwst/timelapse.asset | 12 +++++++++--- .../scene/solarsystem/missions/jwst/trail.asset | 12 ++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/timelapse.asset b/data/assets/scene/solarsystem/missions/jwst/timelapse.asset index 9efb08325c..8ebc3c0956 100644 --- a/data/assets/scene/solarsystem/missions/jwst/timelapse.asset +++ b/data/assets/scene/solarsystem/missions/jwst/timelapse.asset @@ -50,13 +50,15 @@ local function createForwardTimelapse() -- array complete openspace.scriptScheduler.loadScheduledScript("]] .. advance(launchTime, 0, 0, 30, 42) .. [[", - "openspace.time.interpolateDeltaTime(7200)" .. - "openspace.setPropertyValueSingle(\"Dashboard.JWSTStateText.Text\", \"Time speed: 2 hours/second\")" + "openspace.time.interpolateDeltaTime(2400)" .. + "openspace.setPropertyValueSingle(\"Dashboard.JWSTStateText.Text\", \"Time speed: 40 minutes/second\")" ) -- Make night layer more visible, at around 14:00 openspace.scriptScheduler.loadScheduledScript("]] .. advance(detachTime, 0, 1, 10, 0) .. [[", + "openspace.time.interpolateDeltaTime(7200)" .. + "openspace.setPropertyValueSingle(\"Dashboard.JWSTStateText.Text\", \"Time speed: 2 hours/second\")" .. "openspace.setPropertyValueSingle(\"Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma\", 0.7)" .. "openspace.setPropertyValueSingle(\"Scene.EarthAtmosphere.Renderable.Enabled\", false)" ) @@ -280,8 +282,10 @@ local function createBackwardTimelapse() -- Reset night layer, at around 14:00 openspace.scriptScheduler.loadScheduledScript("]] .. - advance(detachTime, 0, 1, 10, 0) .. [[", + advance(detachTime, 0, 1 + 1, 10, 0) .. [[", -- 1h pre delay so time to interpolate "", + "openspace.time.interpolateDeltaTime(-2400)" .. + "openspace.setPropertyValueSingle(\"Dashboard.JWSTStateText.Text\", \"Time speed: -40 minutes/second\")" .. "openspace.setPropertyValueSingle(\"Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma\", 1.0)" .. "openspace.setPropertyValueSingle(\"Scene.EarthAtmosphere.Renderable.Enabled\", true)" ) @@ -520,6 +524,8 @@ local function createActions() openspace.scriptScheduler.clear(0) openspace.time.setDeltaTime(1) openspace.setPropertyValueSingle("Dashboard.JWSTStateText.Text", "") + openspace.setPropertyValueSingle("Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma", 1.0) + openspace.setPropertyValueSingle("Scene.EarthAtmosphere.Renderable.Enabled", true) openspace.time.setTime("]] .. detachTime .. [[") ]] .. createForwardTimelapse() .. [[ openspace.time.setDeltaTime(1) diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index 0f91d4caca..b5cebc8991 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -127,12 +127,12 @@ local JWSTTrailCoRevOrbit = { Renderable = { Type = "RenderableTrailOrbit", Translation = { - Type = 'SpiceTranslation', - Target = 170, -- JWST - Observer = 392, -- L2 - Frame = 'L2_COREV', - Kernels = { kernels .. "webb.bsp" } - }, + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 392, -- L2 + Frame = 'L2_COREV', + Kernels = { kernels .. "webb.bsp" } + }, Color = { 1.0, 0.663, 0.157 }, Period = 365.242198, -- About a year, 2 orbits. 1 orbit would be 182.621099 (6 months) Resolution = 365 -- About a sample rate of once per day From 5565fb662cca4216757e6c8757cfaea765682fbc Mon Sep 17 00:00:00 2001 From: Malin E Date: Thu, 25 Aug 2022 15:48:47 +0200 Subject: [PATCH 09/21] Convert RenderableDUMeshes grids to use RenderableGrid class --- data/assets/scene/digitaluniverse/grids.asset | 226 +++++++++++++----- 1 file changed, 170 insertions(+), 56 deletions(-) diff --git a/data/assets/scene/digitaluniverse/grids.asset b/data/assets/scene/digitaluniverse/grids.asset index 91a8619ba7..14134a1ed1 100644 --- a/data/assets/scene/digitaluniverse/grids.asset +++ b/data/assets/scene/digitaluniverse/grids.asset @@ -20,6 +20,10 @@ local speck = asset.syncedResource({ Version = 2 }) +local lightDay = 2.59020684E13 +local lightMonth = 7.771E14 +local lightYear = 9.4605284E15 + local radio = { Identifier = "RadioSphere", Parent = earth_transforms.EarthBarycenter.Identifier, @@ -233,16 +237,13 @@ local plane1ld = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, Opacity = 0.4, - File = speck .. "1ld.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1ld.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 10.3, - TextMinMaxSize = { 0, 30 }, - Unit = "Km" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightDay, 2*lightDay }, }, GUI = { Name = "1ld Grid", @@ -260,16 +261,13 @@ local plane1lm = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, Opacity = 0.4, - File = speck .. "1lm.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1lm.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 11.8, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightMonth, 2*lightMonth }, }, GUI = { Name = "1lm Grid", @@ -287,16 +285,13 @@ local plane1ly = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, Opacity = 0.4, - File = speck .. "1ly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1ly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 13.0, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, }, GUI = { Name = "1ly Grid", @@ -311,19 +306,20 @@ local plane10ly = { Rotation = { Type = "StaticRotation", Rotation = eclipticRotationMatrix + }, + Scale = { + Type = "StaticScale", + Scale = 10 } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, Opacity = 0.4, - File = speck .. "10ly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "10ly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 14.17, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, }, GUI = { Name = "10ly Grid", @@ -338,19 +334,20 @@ local plane100ly = { Rotation = { Type = "StaticRotation", Rotation = eclipticRotationMatrix + }, + Scale = { + Type = "StaticScale", + Scale = 100 } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, Opacity = 0.4, - File = speck .. "100ly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "100ly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 15.0, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, }, GUI = { Name = "100ly Grid", @@ -365,19 +362,20 @@ local plane1kly = { Rotation = { Type = "StaticRotation", Rotation = eclipticRotationMatrix + }, + Scale = { + Type = "StaticScale", + Scale = 1000 } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, Opacity = 0.4, - File = speck .. "1kly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1kly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 16.0, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, }, GUI = { Name = "1kly Grid", @@ -392,19 +390,20 @@ local plane10kly = { Rotation = { Type = "StaticRotation", Rotation = eclipticRotationMatrix + }, + Scale = { + Type = "StaticScale", + Scale = 10000 } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, Opacity = 0.4, - File = speck .. "10kly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "10kly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 17.25, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, }, GUI = { Name = "10kly Grid", @@ -431,6 +430,29 @@ local plane100kly = { Path = "/Other/Grids" } } +--[[ +local plane100klynew = { + Identifier = "100klyGridnew", + Transform = { + Scale = { + Type = "StaticScale", + Scale = 100000 + } + }, + Renderable = { + Type = "RenderableGrid", + Enabled = false, + Opacity = 0.4, + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, + }, + GUI = { + Name = "100kly Grid new", + Path = "/Other/Grids" + } +}]] local plane1Mly = { Identifier = "1MlyGrid", @@ -451,6 +473,29 @@ local plane1Mly = { Path = "/Other/Grids" } } +--[[ +local plane1Mlynew = { + Identifier = "1MlyGridnew", + Transform = { + Scale = { + Type = "StaticScale", + Scale = 1000000 + } + }, + Renderable = { + Type = "RenderableGrid", + Enabled = false, + Opacity = 0.4, + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, + }, + GUI = { + Name = "1Mly Grid new", + Path = "/Other/Grids" + } +}]] local plane10Mly = { Identifier = "10MlyGrid", @@ -471,6 +516,29 @@ local plane10Mly = { Path = "/Other/Grids" } } +--[[ +local plane10Mlynew = { + Identifier = "10MlyGridnew", + Transform = { + Scale = { + Type = "StaticScale", + Scale = 10000000 + } + }, + Renderable = { + Type = "RenderableGrid", + Enabled = false, + Opacity = 0.4, + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, + }, + GUI = { + Name = "10Mly Grid new", + Path = "/Other/Grids" + } +}]] local plane100Mly = { Identifier = "100MlyGrid", @@ -491,6 +559,29 @@ local plane100Mly = { Path = "/Other/Grids" } } +--[[ +local plane100Mlynew = { + Identifier = "100MlyGridnew", + Transform = { + Scale = { + Type = "StaticScale", + Scale = 100000000 + } + }, + Renderable = { + Type = "RenderableGrid", + Enabled = false, + Opacity = 0.4, + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, + }, + GUI = { + Name = "100Mly Grid new", + Path = "/Other/Grids" + } +}]] local plane20Gly = { Identifier = "20GlyGrid", @@ -511,6 +602,29 @@ local plane20Gly = { Path = "/Other/Grids" } } +--[[ +local plane20Glynew = { + Identifier = "20GlyGridnew", + Transform = { + Scale = { + Type = "StaticScale", + Scale = 20000000000 + } + }, + Renderable = { + Type = "RenderableGrid", + Enabled = false, + Opacity = 0.4, + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear }, + }, + GUI = { + Name = "20Gly Grid new", + Path = "/Other/Grids" + } +}]] local nodes = { radio, oort, ecliptic, eclipticLabels, equatorial, equatorialLabels, From 742754424301e4a3ebf6fde42372ac49ef704409 Mon Sep 17 00:00:00 2001 From: Malin E Date: Fri, 26 Aug 2022 11:22:47 +0200 Subject: [PATCH 10/21] Add initial version of highlight feature * Note that it currently does not work well if the number of segments are odd --- .../base/rendering/grids/renderablegrid.cpp | 158 ++++++++++++++++-- modules/base/rendering/grids/renderablegrid.h | 6 + 2 files changed, 152 insertions(+), 12 deletions(-) diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index eb472e597f..a0bd21f103 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -42,6 +42,12 @@ namespace { "This value determines the color of the grid lines that are rendered" }; + constexpr openspace::properties::Property::PropertyInfo HighlightColorInfo = { + "HighlightColor", + "Highlight Color", + "This value determines the color of the highlighted lines in the grid" + }; + constexpr openspace::properties::Property::PropertyInfo SegmentsInfo = { "Segments", "Number of Segments", @@ -49,12 +55,24 @@ namespace { "grid in each direction" }; + constexpr openspace::properties::Property::PropertyInfo HighlightRateInfo = { + "HighlightRate", + "Highlight Rate", + "The rate the columns and rows are highlighted" + }; + constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { "LineWidth", "Line Width", "This value specifies the line width of the grid" }; + constexpr openspace::properties::Property::PropertyInfo HighlightLineWidthInfo = { + "HighlightLineWidth", + "HighlightLine Width", + "This value specifies the line width of the highlighted lines in the grid" + }; + constexpr openspace::properties::Property::PropertyInfo SizeInfo = { "Size", "Grid Size", @@ -65,12 +83,21 @@ namespace { // [[codegen::verbatim(ColorInfo.description)]] std::optional color [[codegen::color()]]; + // [[codegen::verbatim(HighlightColorInfo.description)]] + std::optional highlightColor [[codegen::color()]]; + // [[codegen::verbatim(SegmentsInfo.description)]] std::optional segments; + // [[codegen::verbatim(HighlightRateInfo.description)]] + std::optional highlightRate; + // [[codegen::verbatim(LineWidthInfo.description)]] std::optional lineWidth; + // [[codegen::verbatim(HighlightLineWidthInfo.description)]] + std::optional highlightLineWidth; + // [[codegen::verbatim(SizeInfo.description)]] std::optional size; }; @@ -86,8 +113,11 @@ documentation::Documentation RenderableGrid::Documentation() { RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f)) + , _highlightColor(HighlightColorInfo, glm::vec3(0.8f), glm::vec3(0.f), glm::vec3(1.f)) , _segments(SegmentsInfo, glm::uvec2(10), glm::uvec2(1), glm::uvec2(200)) + , _highlightRate(HighlightRateInfo, glm::uvec2(5), glm::uvec2(0), glm::uvec2(200)) , _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f) + , _highlightLineWidth(HighlightLineWidthInfo, 0.5f, 1.f, 20.f) , _size(SizeInfo, glm::vec2(1.f), glm::vec2(1.f), glm::vec2(1e11f)) { const Parameters p = codegen::bake(dictionary); @@ -99,13 +129,24 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary) _color.setViewOption(properties::Property::ViewOptions::Color); addProperty(_color); + _highlightColor = p.highlightColor.value_or(_highlightColor); + _highlightColor.setViewOption(properties::Property::ViewOptions::Color); + addProperty(_highlightColor); + _segments = p.segments.value_or(_segments); _segments.onChange([&]() { _gridIsDirty = true; }); addProperty(_segments); + _highlightRate = p.highlightRate.value_or(_highlightRate); + _highlightRate.onChange([&]() { _gridIsDirty = true; }); + addProperty(_highlightRate); + _lineWidth = p.lineWidth.value_or(_lineWidth); addProperty(_lineWidth); + _highlightLineWidth = p.highlightLineWidth.value_or(_highlightLineWidth); + addProperty(_highlightLineWidth); + _size.setExponent(10.f); _size = p.size.value_or(_size); _size.onChange([&]() { _gridIsDirty = true; }); @@ -130,9 +171,14 @@ void RenderableGrid::initializeGL() { glGenVertexArrays(1, &_vaoID); glGenBuffers(1, &_vBufferID); + glGenVertexArrays(1, &_highlightVaoID); + glGenBuffers(1, &_highlightVBufferID); glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); + glBindVertexArray(_highlightVaoID); + glBindBuffer(GL_ARRAY_BUFFER, _highlightVBufferID); + glEnableVertexAttribArray(0); glBindVertexArray(0); } @@ -140,9 +186,13 @@ void RenderableGrid::initializeGL() { void RenderableGrid::deinitializeGL() { glDeleteVertexArrays(1, &_vaoID); _vaoID = 0; + glDeleteVertexArrays(1, &_highlightVaoID); + _highlightVaoID = 0; glDeleteBuffers(1, &_vBufferID); _vBufferID = 0; + glDeleteBuffers(1, &_highlightVBufferID); + _highlightVBufferID = 0; BaseModule::ProgramObjectManager.release( "GridProgram", @@ -182,13 +232,24 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){ glEnable(GL_LINE_SMOOTH); glDepthMask(false); + // Render minor grid glBindVertexArray(_vaoID); glDrawArrays(_mode, 0, static_cast(_varray.size())); - glBindVertexArray(0); - _gridProgram->deactivate(); + // Render major grid +#ifndef __APPLE__ + glLineWidth(_highlightLineWidth); +#else + glLineWidth(1.f); +#endif + _gridProgram->setUniform("gridColor", _highlightColor); + + glBindVertexArray(_highlightVaoID); + glDrawArrays(_mode, 0, static_cast(_highlightArray.size())); // Restore GL State + glBindVertexArray(0); + _gridProgram->deactivate(); global::renderEngine->openglStateCache().resetBlendState(); global::renderEngine->openglStateCache().resetLineState(); global::renderEngine->openglStateCache().resetDepthState(); @@ -205,10 +266,14 @@ void RenderableGrid::update(const UpdateData&) { const int nLines = (2 * nSegments.x * nSegments.y) + nSegments.x + nSegments.y; const int nVertices = 2 * nLines; - _varray.resize(nVertices); + _varray.clear(); + _varray.reserve(nVertices); + _highlightArray.clear(); + _highlightArray.reserve(nVertices); // OBS! Could be optimized further by removing duplicate vertices - int nr = 0; + const glm::uvec2 center = glm::uvec2(nSegments.x / 2.f, nSegments.y / 2.f); + for (unsigned int i = 0; i < nSegments.x; ++i) { for (unsigned int j = 0; j < nSegments.y; ++j) { const float y0 = -halfSize.y + j * step.y; @@ -217,11 +282,39 @@ void RenderableGrid::update(const UpdateData&) { const float x0 = -halfSize.x + i * step.x; const float x1 = x0 + step.x; - _varray[nr++] = { x0, y0, 0.f }; - _varray[nr++] = { x0, y1, 0.f }; + // Line in y direction + if (_highlightRate.value().y != 0) { + int rest = static_cast(i - center.y) % _highlightRate.value().y; + if (abs(rest) == 0) { + _highlightArray.push_back({ x0, y0, 0.f }); + _highlightArray.push_back({ x0, y1, 0.f }); + } + else { + _varray.push_back({ x0, y0, 0.f }); + _varray.push_back({ x0, y1, 0.f }); + } + } + else { + _varray.push_back({ x0, y0, 0.f }); + _varray.push_back({ x0, y1, 0.f }); + } - _varray[nr++] = { x0, y0, 0.f }; - _varray[nr++] = { x1, y0, 0.f }; + // Line in x direction + if (_highlightRate.value().x != 0) { + int rest = static_cast(j - center.x) % _highlightRate.value().x; + if (abs(rest) == 0) { + _highlightArray.push_back({ x0, y0, 0.f }); + _highlightArray.push_back({ x1, y0, 0.f }); + } + else { + _varray.push_back({ x0, y0, 0.f }); + _varray.push_back({ x1, y0, 0.f }); + } + } + else { + _varray.push_back({ x0, y0, 0.f }); + _varray.push_back({ x1, y0, 0.f }); + } } } @@ -229,20 +322,49 @@ void RenderableGrid::update(const UpdateData&) { for (unsigned int i = 0; i < nSegments.x; ++i) { const float x0 = -halfSize.x + i * step.x; const float x1 = x0 + step.x; - _varray[nr++] = { x0, halfSize.y, 0.f }; - _varray[nr++] = { x1, halfSize.y, 0.f }; + + if (_highlightRate.value().x != 0) { + int rest = static_cast(nSegments.y - center.x) % _highlightRate.value().x; + if (abs(rest) == 0) { + _highlightArray.push_back({ x0, halfSize.y, 0.f }); + _highlightArray.push_back({ x1, halfSize.y, 0.f }); + } + else { + _varray.push_back({ x0, halfSize.y, 0.f }); + _varray.push_back({ x1, halfSize.y, 0.f }); + } + } + else { + _varray.push_back({ x0, halfSize.y, 0.f }); + _varray.push_back({ x1, halfSize.y, 0.f }); + } } // last y col for (unsigned int i = 0; i < nSegments.y; ++i) { const float y0 = -halfSize.y + i * step.y; const float y1 = y0 + step.y; - _varray[nr++] = { halfSize.x, y0, 0.f }; - _varray[nr++] = { halfSize.x, y1, 0.f }; + + if (_highlightRate.value().y != 0) { + int rest = static_cast(nSegments.x - center.y) % _highlightRate.value().y; + if (abs(rest) == 0) { + _highlightArray.push_back({ halfSize.x, y0, 0.f }); + _highlightArray.push_back({ halfSize.x, y1, 0.f }); + } + else { + _varray.push_back({ halfSize.x, y0, 0.f }); + _varray.push_back({ halfSize.x, y1, 0.f }); + } + } + else { + _varray.push_back({ halfSize.x, y0, 0.f }); + _varray.push_back({ halfSize.x, y1, 0.f }); + } } setBoundingSphere(glm::length(glm::dvec2(halfSize))); + // Minor grid glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); glBufferData( @@ -251,7 +373,19 @@ void RenderableGrid::update(const UpdateData&) { _varray.data(), GL_STATIC_DRAW ); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr); + // Major grid + glBindVertexArray(_highlightVaoID); + glBindBuffer(GL_ARRAY_BUFFER, _highlightVBufferID); + glBufferData( + GL_ARRAY_BUFFER, + _highlightArray.size() * sizeof(Vertex), + _highlightArray.data(), + GL_STATIC_DRAW + ); + glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr); glBindVertexArray(0); diff --git a/modules/base/rendering/grids/renderablegrid.h b/modules/base/rendering/grids/renderablegrid.h index 4b9c71701e..3ebfa0f589 100644 --- a/modules/base/rendering/grids/renderablegrid.h +++ b/modules/base/rendering/grids/renderablegrid.h @@ -61,19 +61,25 @@ protected: ghoul::opengl::ProgramObject* _gridProgram = nullptr; properties::Vec3Property _color; + properties::Vec3Property _highlightColor; // @TODO (abock, 2021-01-28) This was a UVec2Property before, but it wasn't supported // be the codegen. As soon as it does, this should be changed back properties::IVec2Property _segments; + properties::IVec2Property _highlightRate; properties::FloatProperty _lineWidth; + properties::FloatProperty _highlightLineWidth; properties::Vec2Property _size; bool _gridIsDirty = true; GLuint _vaoID = 0; GLuint _vBufferID = 0; + GLuint _highlightVaoID = 0; + GLuint _highlightVBufferID = 0; GLenum _mode = GL_LINES; std::vector _varray; + std::vector _highlightArray; }; }// namespace openspace From 767f6aa547acd65ddd14949d4a65420ade9616b0 Mon Sep 17 00:00:00 2001 From: Malin E Date: Fri, 26 Aug 2022 13:46:33 +0200 Subject: [PATCH 11/21] Use highlight feature on large grids --- data/assets/scene/digitaluniverse/grids.asset | 148 ++++-------------- .../base/rendering/grids/renderablegrid.cpp | 6 +- src/rendering/renderable.cpp | 6 +- 3 files changed, 36 insertions(+), 124 deletions(-) diff --git a/data/assets/scene/digitaluniverse/grids.asset b/data/assets/scene/digitaluniverse/grids.asset index 14134a1ed1..44e81c0ff1 100644 --- a/data/assets/scene/digitaluniverse/grids.asset +++ b/data/assets/scene/digitaluniverse/grids.asset @@ -413,26 +413,6 @@ local plane10kly = { local plane100kly = { Identifier = "100klyGrid", - Renderable = { - Type = "RenderableDUMeshes", - Enabled = false, - Opacity = 0.4, - File = speck .. "100kly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "100kly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 18.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" - }, - GUI = { - Name = "100kly Grid", - Path = "/Other/Grids" - } -} ---[[ -local plane100klynew = { - Identifier = "100klyGridnew", Transform = { Scale = { Type = "StaticScale", @@ -444,38 +424,20 @@ local plane100klynew = { Enabled = false, Opacity = 0.4, Color = { 0.1, 0.5, 0.6 }, + HighlightColor = { 0.3, 0.7, 0.8 }, LineWidth = 2.0, Segments = { 20, 20 }, + HighlightRate = { 5, 5}, Size = { 2*lightYear, 2*lightYear }, }, GUI = { - Name = "100kly Grid new", - Path = "/Other/Grids" - } -}]] - -local plane1Mly = { - Identifier = "1MlyGrid", - Renderable = { - Type = "RenderableDUMeshes", - Enabled = false, - Opacity = 0.4, - File = speck .. "1Mly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1Mly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 19.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" - }, - GUI = { - Name = "1Mly Grid", + Name = "100kly Grid", Path = "/Other/Grids" } } ---[[ -local plane1Mlynew = { - Identifier = "1MlyGridnew", + +local plane1Mly = { + Identifier = "1MlyGrid", Transform = { Scale = { Type = "StaticScale", @@ -487,38 +449,20 @@ local plane1Mlynew = { Enabled = false, Opacity = 0.4, Color = { 0.1, 0.5, 0.6 }, + HighlightColor = {0.3, 0.7, 0.8 }, LineWidth = 2.0, Segments = { 20, 20 }, + HighlightRate = { 5, 5}, Size = { 2*lightYear, 2*lightYear }, }, GUI = { - Name = "1Mly Grid new", - Path = "/Other/Grids" - } -}]] - -local plane10Mly = { - Identifier = "10MlyGrid", - Renderable = { - Type = "RenderableDUMeshes", - Enabled = false, - Opacity = 0.4, - File = speck .. "10Mly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "10Mly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 20.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" - }, - GUI = { - Name = "10Mly Grid", + Name = "1Mly Grid", Path = "/Other/Grids" } } ---[[ -local plane10Mlynew = { - Identifier = "10MlyGridnew", + +local plane10Mly = { + Identifier = "10MlyGrid", Transform = { Scale = { Type = "StaticScale", @@ -530,38 +474,20 @@ local plane10Mlynew = { Enabled = false, Opacity = 0.4, Color = { 0.1, 0.5, 0.6 }, + HighlightColor = { 0.3, 0.7, 0.8 }, LineWidth = 2.0, Segments = { 20, 20 }, + HighlightRate = { 5, 5}, Size = { 2*lightYear, 2*lightYear }, }, GUI = { - Name = "10Mly Grid new", - Path = "/Other/Grids" - } -}]] - -local plane100Mly = { - Identifier = "100MlyGrid", - Renderable = { - Type = "RenderableDUMeshes", - Enabled = false, - Opacity = 0.4, - File = speck .. "100Mly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "100Mly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 21.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" - }, - GUI = { - Name = "100Mly Grid", + Name = "10Mly Grid", Path = "/Other/Grids" } } ---[[ -local plane100Mlynew = { - Identifier = "100MlyGridnew", + +local plane100Mly = { + Identifier = "100MlyGrid", Transform = { Scale = { Type = "StaticScale", @@ -573,38 +499,20 @@ local plane100Mlynew = { Enabled = false, Opacity = 0.4, Color = { 0.1, 0.5, 0.6 }, + HighlightColor = { 0.3, 0.7, 0.8 }, LineWidth = 2.0, Segments = { 20, 20 }, + HighlightRate = { 5, 5}, Size = { 2*lightYear, 2*lightYear }, }, GUI = { - Name = "100Mly Grid new", - Path = "/Other/Grids" - } -}]] - -local plane20Gly = { - Identifier = "20GlyGrid", - Renderable = { - Type = "RenderableDUMeshes", - Enabled = false, - Opacity = 0.4, - File = speck .. "20Gly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "20Gly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 23.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" - }, - GUI = { - Name = "20Gly Grid", + Name = "100Mly Grid", Path = "/Other/Grids" } } ---[[ -local plane20Glynew = { - Identifier = "20GlyGridnew", + +local plane20Gly = { + Identifier = "20GlyGrid", Transform = { Scale = { Type = "StaticScale", @@ -616,15 +524,17 @@ local plane20Glynew = { Enabled = false, Opacity = 0.4, Color = { 0.1, 0.5, 0.6 }, + HighlightColor = { 0.3, 0.7, 0.8 }, LineWidth = 2.0, - Segments = { 20, 20 }, + Segments = { 40, 40 }, + HighlightRate = { 5, 5}, Size = { 2*lightYear, 2*lightYear }, }, GUI = { - Name = "20Gly Grid new", + Name = "20Gly Grid", Path = "/Other/Grids" } -}]] +} local nodes = { radio, oort, ecliptic, eclipticLabels, equatorial, equatorialLabels, diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index a0bd21f103..51a115d3b0 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -129,7 +129,8 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary) _color.setViewOption(properties::Property::ViewOptions::Color); addProperty(_color); - _highlightColor = p.highlightColor.value_or(_highlightColor); + // If no highlight color is specified then use the base color + _highlightColor = p.highlightColor.value_or(_color); _highlightColor.setViewOption(properties::Property::ViewOptions::Color); addProperty(_highlightColor); @@ -144,7 +145,8 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary) _lineWidth = p.lineWidth.value_or(_lineWidth); addProperty(_lineWidth); - _highlightLineWidth = p.highlightLineWidth.value_or(_highlightLineWidth); + // If no highlight line width is specified then use the base line width + _highlightLineWidth = p.highlightLineWidth.value_or(_lineWidth); addProperty(_highlightLineWidth); _size.setExponent(10.f); diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 90db17c018..3b54240258 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -207,7 +207,7 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary) if (p.renderBinMode.has_value()) { setRenderBin(codegen::map(*p.renderBinMode)); } - + _dimInAtmosphere = p.dimInAtmosphere.value_or(_dimInAtmosphere); addProperty(_dimInAtmosphere); } @@ -313,7 +313,7 @@ void Renderable::registerUpdateRenderBinFromOpacity() { } float Renderable::opacity() const { - // Rendering should depend on if camera is in the atmosphere and if camera is at the + // Rendering should depend on if camera is in the atmosphere and if camera is at the // dark part of the globe return _dimInAtmosphere ? _opacity * _fade * global::navigationHandler->camera()->atmosphereDimmingFactor() : From d1259c83a22677d0db18d87b8f4adc3208868956 Mon Sep 17 00:00:00 2001 From: Malin E Date: Fri, 26 Aug 2022 14:10:02 +0200 Subject: [PATCH 12/21] Small clean up --- modules/base/rendering/grids/renderablegrid.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index 51a115d3b0..01f5243771 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -274,8 +274,8 @@ void RenderableGrid::update(const UpdateData&) { _highlightArray.reserve(nVertices); // OBS! Could be optimized further by removing duplicate vertices + // If the number of segments are uneven the center won't be completly centered const glm::uvec2 center = glm::uvec2(nSegments.x / 2.f, nSegments.y / 2.f); - for (unsigned int i = 0; i < nSegments.x; ++i) { for (unsigned int j = 0; j < nSegments.y; ++j) { const float y0 = -halfSize.y + j * step.y; @@ -375,7 +375,6 @@ void RenderableGrid::update(const UpdateData&) { _varray.data(), GL_STATIC_DRAW ); - glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr); // Major grid @@ -387,7 +386,6 @@ void RenderableGrid::update(const UpdateData&) { _highlightArray.data(), GL_STATIC_DRAW ); - glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr); glBindVertexArray(0); From 3e142e5f2ff4c984dfe80021bac0b5a4ab2ec4b7 Mon Sep 17 00:00:00 2001 From: Malin E Date: Mon, 29 Aug 2022 13:57:40 +0200 Subject: [PATCH 13/21] Change default to not use highlight in grids --- modules/base/rendering/grids/renderablegrid.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index 01f5243771..bc4a260a34 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -115,7 +115,7 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary) , _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f)) , _highlightColor(HighlightColorInfo, glm::vec3(0.8f), glm::vec3(0.f), glm::vec3(1.f)) , _segments(SegmentsInfo, glm::uvec2(10), glm::uvec2(1), glm::uvec2(200)) - , _highlightRate(HighlightRateInfo, glm::uvec2(5), glm::uvec2(0), glm::uvec2(200)) + , _highlightRate(HighlightRateInfo, glm::uvec2(0), glm::uvec2(0), glm::uvec2(200)) , _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f) , _highlightLineWidth(HighlightLineWidthInfo, 0.5f, 1.f, 20.f) , _size(SizeInfo, glm::vec2(1.f), glm::vec2(1.f), glm::vec2(1e11f)) @@ -375,6 +375,7 @@ void RenderableGrid::update(const UpdateData&) { _varray.data(), GL_STATIC_DRAW ); + glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr); // Major grid From 933c97167379c31d57cd96e29e8958bd7856a817 Mon Sep 17 00:00:00 2001 From: Malin E Date: Mon, 29 Aug 2022 16:27:33 +0200 Subject: [PATCH 14/21] Start addressing PR comments --- data/assets/scene/digitaluniverse/grids.asset | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data/assets/scene/digitaluniverse/grids.asset b/data/assets/scene/digitaluniverse/grids.asset index 44e81c0ff1..ac28d20348 100644 --- a/data/assets/scene/digitaluniverse/grids.asset +++ b/data/assets/scene/digitaluniverse/grids.asset @@ -427,7 +427,7 @@ local plane100kly = { HighlightColor = { 0.3, 0.7, 0.8 }, LineWidth = 2.0, Segments = { 20, 20 }, - HighlightRate = { 5, 5}, + HighlightRate = { 5, 5 }, Size = { 2*lightYear, 2*lightYear }, }, GUI = { @@ -449,10 +449,10 @@ local plane1Mly = { Enabled = false, Opacity = 0.4, Color = { 0.1, 0.5, 0.6 }, - HighlightColor = {0.3, 0.7, 0.8 }, + HighlightColor = { 0.3, 0.7, 0.8 }, LineWidth = 2.0, Segments = { 20, 20 }, - HighlightRate = { 5, 5}, + HighlightRate = { 5, 5 }, Size = { 2*lightYear, 2*lightYear }, }, GUI = { @@ -477,7 +477,7 @@ local plane10Mly = { HighlightColor = { 0.3, 0.7, 0.8 }, LineWidth = 2.0, Segments = { 20, 20 }, - HighlightRate = { 5, 5}, + HighlightRate = { 5, 5 }, Size = { 2*lightYear, 2*lightYear }, }, GUI = { @@ -502,7 +502,7 @@ local plane100Mly = { HighlightColor = { 0.3, 0.7, 0.8 }, LineWidth = 2.0, Segments = { 20, 20 }, - HighlightRate = { 5, 5}, + HighlightRate = { 5, 5 }, Size = { 2*lightYear, 2*lightYear }, }, GUI = { @@ -527,7 +527,7 @@ local plane20Gly = { HighlightColor = { 0.3, 0.7, 0.8 }, LineWidth = 2.0, Segments = { 40, 40 }, - HighlightRate = { 5, 5}, + HighlightRate = { 5, 5 }, Size = { 2*lightYear, 2*lightYear }, }, GUI = { From f247b500c08f40f476da2afef1e4eaca08f12ea1 Mon Sep 17 00:00:00 2001 From: Malin E Date: Tue, 30 Aug 2022 18:03:47 +0200 Subject: [PATCH 15/21] Address some more PR comments --- data/assets/scene/digitaluniverse/grids.asset | 14 ++++---- .../base/rendering/grids/renderablegrid.cpp | 34 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/data/assets/scene/digitaluniverse/grids.asset b/data/assets/scene/digitaluniverse/grids.asset index ac28d20348..7cbbbe7102 100644 --- a/data/assets/scene/digitaluniverse/grids.asset +++ b/data/assets/scene/digitaluniverse/grids.asset @@ -365,7 +365,7 @@ local plane1kly = { }, Scale = { Type = "StaticScale", - Scale = 1000 + Scale = 1E3 } }, Renderable = { @@ -393,7 +393,7 @@ local plane10kly = { }, Scale = { Type = "StaticScale", - Scale = 10000 + Scale = 10E3 } }, Renderable = { @@ -416,7 +416,7 @@ local plane100kly = { Transform = { Scale = { Type = "StaticScale", - Scale = 100000 + Scale = 100E3 } }, Renderable = { @@ -441,7 +441,7 @@ local plane1Mly = { Transform = { Scale = { Type = "StaticScale", - Scale = 1000000 + Scale = 1E6 } }, Renderable = { @@ -466,7 +466,7 @@ local plane10Mly = { Transform = { Scale = { Type = "StaticScale", - Scale = 10000000 + Scale = 10E6 } }, Renderable = { @@ -491,7 +491,7 @@ local plane100Mly = { Transform = { Scale = { Type = "StaticScale", - Scale = 100000000 + Scale = 100E6 } }, Renderable = { @@ -516,7 +516,7 @@ local plane20Gly = { Transform = { Scale = { Type = "StaticScale", - Scale = 20000000000 + Scale = 20E9 } }, Renderable = { diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index bc4a260a34..fc4d6605b2 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -58,7 +58,9 @@ namespace { constexpr openspace::properties::Property::PropertyInfo HighlightRateInfo = { "HighlightRate", "Highlight Rate", - "The rate the columns and rows are highlighted" + "The rate that the columns and rows are highlighted, counted with respect to the " + "center of the grid. If the number of segments in the grid is odd, the " + "highlighting might be offsett from the center." }; constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { @@ -285,16 +287,15 @@ void RenderableGrid::update(const UpdateData&) { const float x1 = x0 + step.x; // Line in y direction + bool shouldHighlight = false; if (_highlightRate.value().y != 0) { int rest = static_cast(i - center.y) % _highlightRate.value().y; - if (abs(rest) == 0) { - _highlightArray.push_back({ x0, y0, 0.f }); - _highlightArray.push_back({ x0, y1, 0.f }); - } - else { - _varray.push_back({ x0, y0, 0.f }); - _varray.push_back({ x0, y1, 0.f }); - } + shouldHighlight = abs(rest) == 0; + } + + if (shouldHighlight) { + _highlightArray.push_back({ x0, y0, 0.f }); + _highlightArray.push_back({ x0, y1, 0.f }); } else { _varray.push_back({ x0, y0, 0.f }); @@ -302,16 +303,15 @@ void RenderableGrid::update(const UpdateData&) { } // Line in x direction + shouldHighlight = false; if (_highlightRate.value().x != 0) { int rest = static_cast(j - center.x) % _highlightRate.value().x; - if (abs(rest) == 0) { - _highlightArray.push_back({ x0, y0, 0.f }); - _highlightArray.push_back({ x1, y0, 0.f }); - } - else { - _varray.push_back({ x0, y0, 0.f }); - _varray.push_back({ x1, y0, 0.f }); - } + shouldHighlight = abs(rest) == 0; + } + + if (shouldHighlight) { + _highlightArray.push_back({ x0, y0, 0.f }); + _highlightArray.push_back({ x1, y0, 0.f }); } else { _varray.push_back({ x0, y0, 0.f }); From 0ce7874b90114ccd57b6f621c907b88a25d30a59 Mon Sep 17 00:00:00 2001 From: Malin E Date: Wed, 31 Aug 2022 09:10:18 +0200 Subject: [PATCH 16/21] Address more PR comments --- .../base/rendering/grids/renderablegrid.cpp | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index fc4d6605b2..094278edec 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -325,16 +325,16 @@ void RenderableGrid::update(const UpdateData&) { const float x0 = -halfSize.x + i * step.x; const float x1 = x0 + step.x; + bool shouldHighlight = false; if (_highlightRate.value().x != 0) { - int rest = static_cast(nSegments.y - center.x) % _highlightRate.value().x; - if (abs(rest) == 0) { - _highlightArray.push_back({ x0, halfSize.y, 0.f }); - _highlightArray.push_back({ x1, halfSize.y, 0.f }); - } - else { - _varray.push_back({ x0, halfSize.y, 0.f }); - _varray.push_back({ x1, halfSize.y, 0.f }); - } + int rest = + static_cast(nSegments.y - center.x) % _highlightRate.value().x; + shouldHighlight = abs(rest) == 0; + } + + if (shouldHighlight) { + _highlightArray.push_back({ x0, halfSize.y, 0.f }); + _highlightArray.push_back({ x1, halfSize.y, 0.f }); } else { _varray.push_back({ x0, halfSize.y, 0.f }); @@ -347,16 +347,15 @@ void RenderableGrid::update(const UpdateData&) { const float y0 = -halfSize.y + i * step.y; const float y1 = y0 + step.y; + bool shouldHighlight = false; if (_highlightRate.value().y != 0) { - int rest = static_cast(nSegments.x - center.y) % _highlightRate.value().y; - if (abs(rest) == 0) { - _highlightArray.push_back({ halfSize.x, y0, 0.f }); - _highlightArray.push_back({ halfSize.x, y1, 0.f }); - } - else { - _varray.push_back({ halfSize.x, y0, 0.f }); - _varray.push_back({ halfSize.x, y1, 0.f }); - } + int rest = + static_cast(nSegments.x - center.y) % _highlightRate.value().y; + shouldHighlight = abs(rest) == 0; + } + if (shouldHighlight) { + _highlightArray.push_back({ halfSize.x, y0, 0.f }); + _highlightArray.push_back({ halfSize.x, y1, 0.f }); } else { _varray.push_back({ halfSize.x, y0, 0.f }); From bb638faf1095f75a2fab1a5fd1df5da24cc99454 Mon Sep 17 00:00:00 2001 From: Malin E Date: Wed, 31 Aug 2022 13:58:08 +0200 Subject: [PATCH 17/21] Move the scaling into the size parameter of the grids --- data/assets/scene/digitaluniverse/grids.asset | 64 +++---------------- .../base/rendering/grids/renderablegrid.cpp | 2 +- 2 files changed, 10 insertions(+), 56 deletions(-) diff --git a/data/assets/scene/digitaluniverse/grids.asset b/data/assets/scene/digitaluniverse/grids.asset index 7cbbbe7102..3d4db8ccde 100644 --- a/data/assets/scene/digitaluniverse/grids.asset +++ b/data/assets/scene/digitaluniverse/grids.asset @@ -307,10 +307,6 @@ local plane10ly = { Type = "StaticRotation", Rotation = eclipticRotationMatrix }, - Scale = { - Type = "StaticScale", - Scale = 10 - } }, Renderable = { Type = "RenderableGrid", @@ -319,7 +315,7 @@ local plane10ly = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 10*2*lightYear, 10*2*lightYear }, }, GUI = { Name = "10ly Grid", @@ -335,10 +331,6 @@ local plane100ly = { Type = "StaticRotation", Rotation = eclipticRotationMatrix }, - Scale = { - Type = "StaticScale", - Scale = 100 - } }, Renderable = { Type = "RenderableGrid", @@ -347,7 +339,7 @@ local plane100ly = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 100*2*lightYear, 100*2*lightYear }, }, GUI = { Name = "100ly Grid", @@ -363,10 +355,6 @@ local plane1kly = { Type = "StaticRotation", Rotation = eclipticRotationMatrix }, - Scale = { - Type = "StaticScale", - Scale = 1E3 - } }, Renderable = { Type = "RenderableGrid", @@ -375,7 +363,7 @@ local plane1kly = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 1E3*2*lightYear, 1E3*2*lightYear }, }, GUI = { Name = "1kly Grid", @@ -391,10 +379,6 @@ local plane10kly = { Type = "StaticRotation", Rotation = eclipticRotationMatrix }, - Scale = { - Type = "StaticScale", - Scale = 10E3 - } }, Renderable = { Type = "RenderableGrid", @@ -403,7 +387,7 @@ local plane10kly = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 10E3*2*lightYear, 10E3*2*lightYear }, }, GUI = { Name = "10kly Grid", @@ -413,12 +397,6 @@ local plane10kly = { local plane100kly = { Identifier = "100klyGrid", - Transform = { - Scale = { - Type = "StaticScale", - Scale = 100E3 - } - }, Renderable = { Type = "RenderableGrid", Enabled = false, @@ -428,7 +406,7 @@ local plane100kly = { LineWidth = 2.0, Segments = { 20, 20 }, HighlightRate = { 5, 5 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 100E3*2*lightYear, 100E3*2*lightYear }, }, GUI = { Name = "100kly Grid", @@ -438,12 +416,6 @@ local plane100kly = { local plane1Mly = { Identifier = "1MlyGrid", - Transform = { - Scale = { - Type = "StaticScale", - Scale = 1E6 - } - }, Renderable = { Type = "RenderableGrid", Enabled = false, @@ -453,7 +425,7 @@ local plane1Mly = { LineWidth = 2.0, Segments = { 20, 20 }, HighlightRate = { 5, 5 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 1E6*2*lightYear, 1E6*2*lightYear }, }, GUI = { Name = "1Mly Grid", @@ -463,12 +435,6 @@ local plane1Mly = { local plane10Mly = { Identifier = "10MlyGrid", - Transform = { - Scale = { - Type = "StaticScale", - Scale = 10E6 - } - }, Renderable = { Type = "RenderableGrid", Enabled = false, @@ -478,7 +444,7 @@ local plane10Mly = { LineWidth = 2.0, Segments = { 20, 20 }, HighlightRate = { 5, 5 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 10E6*2*lightYear, 10E6*2*lightYear }, }, GUI = { Name = "10Mly Grid", @@ -488,12 +454,6 @@ local plane10Mly = { local plane100Mly = { Identifier = "100MlyGrid", - Transform = { - Scale = { - Type = "StaticScale", - Scale = 100E6 - } - }, Renderable = { Type = "RenderableGrid", Enabled = false, @@ -503,7 +463,7 @@ local plane100Mly = { LineWidth = 2.0, Segments = { 20, 20 }, HighlightRate = { 5, 5 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 100E6*2*lightYear, 100E6*2*lightYear }, }, GUI = { Name = "100Mly Grid", @@ -513,12 +473,6 @@ local plane100Mly = { local plane20Gly = { Identifier = "20GlyGrid", - Transform = { - Scale = { - Type = "StaticScale", - Scale = 20E9 - } - }, Renderable = { Type = "RenderableGrid", Enabled = false, @@ -528,7 +482,7 @@ local plane20Gly = { LineWidth = 2.0, Segments = { 40, 40 }, HighlightRate = { 5, 5 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 20E9*2*lightYear, 20E9*2*lightYear }, }, GUI = { Name = "20Gly Grid", diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index 094278edec..bf03877e12 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -60,7 +60,7 @@ namespace { "Highlight Rate", "The rate that the columns and rows are highlighted, counted with respect to the " "center of the grid. If the number of segments in the grid is odd, the " - "highlighting might be offsett from the center." + "highlighting might be offset from the center." }; constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { From fe3e1865365cd9efcd100bd74ceb7a5ed2c75589 Mon Sep 17 00:00:00 2001 From: Malin E Date: Wed, 31 Aug 2022 16:01:15 +0200 Subject: [PATCH 18/21] Remove incorrect indentation in asset file --- .../solarsystem/missions/jwst/trail.asset | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index b5cebc8991..ab74967e98 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -28,12 +28,12 @@ local JWSTTrailLaunch = { Renderable = { Type = "RenderableTrailTrajectory", Translation = { - Type = 'SpiceTranslation', - Target = 170, -- JWST - Observer = 'EARTH', - Frame = 'IAU_EARTH', - Kernels = { kernels .. "webb.bsp" } - }, + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 'EARTH', + Frame = 'IAU_EARTH', + Kernels = { kernels .. "webb.bsp" } + }, Color = { 0.9, 0.9, 0.0 }, StartTime = launchTime, EndTime = detachTime, @@ -61,12 +61,12 @@ local JWSTTrailCruise = { Renderable = { Type = "RenderableTrailTrajectory", Translation = { - Type = 'SpiceTranslation', - Target = 170, -- JWST - Observer = 'EARTH', - Frame = 'GALACTIC', - Kernels = { kernels .. "webb.bsp" } - }, + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 'EARTH', + Frame = 'GALACTIC', + Kernels = { kernels .. "webb.bsp" } + }, Color = { 0.9, 0.9, 0.0 }, StartTime = detachTime, EndTime = L2orbitInsertionTime, @@ -95,12 +95,12 @@ local JWSTTrailOrbit = { Renderable = { Type = "RenderableTrailOrbit", Translation = { - Type = 'SpiceTranslation', - Target = 170, -- JWST - Observer = 392, -- L2 - Frame = 'GALACTIC', - Kernels = { kernels .. "webb.bsp" } - }, + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 392, -- L2 + Frame = 'GALACTIC', + Kernels = { kernels .. "webb.bsp" } + }, Color = { 0.863, 0.0, 0.902 }, Period = 182.621099, -- About 6 months Resolution = 183 -- About a sample rate of once per day @@ -157,12 +157,12 @@ local JWSTSunTrail = { Renderable = { Type = "RenderableTrailOrbit", Translation = { - Type = 'SpiceTranslation', - Target = 170, -- JWST - Observer = 'SSB', - Frame = 'GALACTIC', - Kernels = { kernels .. "webb.bsp" } - }, + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 'SSB', + Frame = 'GALACTIC', + Kernels = { kernels .. "webb.bsp" } + }, Color = { 0.0, 0.9, 0.9 }, Period = 365.242, Resolution = 365 -- About a sample rate of once per day From 63bbd0d35d15d05d40198e4a6ae2d8d14815ea39 Mon Sep 17 00:00:00 2001 From: Malin E Date: Fri, 2 Sep 2022 10:48:35 +0200 Subject: [PATCH 19/21] Remove extra commas in grid asset file --- data/assets/scene/digitaluniverse/grids.asset | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/data/assets/scene/digitaluniverse/grids.asset b/data/assets/scene/digitaluniverse/grids.asset index 3d4db8ccde..813553eb1d 100644 --- a/data/assets/scene/digitaluniverse/grids.asset +++ b/data/assets/scene/digitaluniverse/grids.asset @@ -243,7 +243,7 @@ local plane1ld = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 2*lightDay, 2*lightDay }, + Size = { 2*lightDay, 2*lightDay } }, GUI = { Name = "1ld Grid", @@ -267,7 +267,7 @@ local plane1lm = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 2*lightMonth, 2*lightMonth }, + Size = { 2*lightMonth, 2*lightMonth } }, GUI = { Name = "1lm Grid", @@ -291,7 +291,7 @@ local plane1ly = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 2*lightYear, 2*lightYear }, + Size = { 2*lightYear, 2*lightYear } }, GUI = { Name = "1ly Grid", @@ -306,7 +306,7 @@ local plane10ly = { Rotation = { Type = "StaticRotation", Rotation = eclipticRotationMatrix - }, + } }, Renderable = { Type = "RenderableGrid", @@ -315,7 +315,7 @@ local plane10ly = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 10*2*lightYear, 10*2*lightYear }, + Size = { 10*2*lightYear, 10*2*lightYear } }, GUI = { Name = "10ly Grid", @@ -330,7 +330,7 @@ local plane100ly = { Rotation = { Type = "StaticRotation", Rotation = eclipticRotationMatrix - }, + } }, Renderable = { Type = "RenderableGrid", @@ -339,7 +339,7 @@ local plane100ly = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 100*2*lightYear, 100*2*lightYear }, + Size = { 100*2*lightYear, 100*2*lightYear } }, GUI = { Name = "100ly Grid", @@ -354,7 +354,7 @@ local plane1kly = { Rotation = { Type = "StaticRotation", Rotation = eclipticRotationMatrix - }, + } }, Renderable = { Type = "RenderableGrid", @@ -363,7 +363,7 @@ local plane1kly = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 1E3*2*lightYear, 1E3*2*lightYear }, + Size = { 1E3*2*lightYear, 1E3*2*lightYear } }, GUI = { Name = "1kly Grid", @@ -378,7 +378,7 @@ local plane10kly = { Rotation = { Type = "StaticRotation", Rotation = eclipticRotationMatrix - }, + } }, Renderable = { Type = "RenderableGrid", @@ -387,7 +387,7 @@ local plane10kly = { Color = { 0.1, 0.5, 0.6 }, LineWidth = 2.0, Segments = { 20, 20 }, - Size = { 10E3*2*lightYear, 10E3*2*lightYear }, + Size = { 10E3*2*lightYear, 10E3*2*lightYear } }, GUI = { Name = "10kly Grid", @@ -406,7 +406,7 @@ local plane100kly = { LineWidth = 2.0, Segments = { 20, 20 }, HighlightRate = { 5, 5 }, - Size = { 100E3*2*lightYear, 100E3*2*lightYear }, + Size = { 100E3*2*lightYear, 100E3*2*lightYear } }, GUI = { Name = "100kly Grid", @@ -425,7 +425,7 @@ local plane1Mly = { LineWidth = 2.0, Segments = { 20, 20 }, HighlightRate = { 5, 5 }, - Size = { 1E6*2*lightYear, 1E6*2*lightYear }, + Size = { 1E6*2*lightYear, 1E6*2*lightYear } }, GUI = { Name = "1Mly Grid", @@ -444,7 +444,7 @@ local plane10Mly = { LineWidth = 2.0, Segments = { 20, 20 }, HighlightRate = { 5, 5 }, - Size = { 10E6*2*lightYear, 10E6*2*lightYear }, + Size = { 10E6*2*lightYear, 10E6*2*lightYear } }, GUI = { Name = "10Mly Grid", @@ -463,7 +463,7 @@ local plane100Mly = { LineWidth = 2.0, Segments = { 20, 20 }, HighlightRate = { 5, 5 }, - Size = { 100E6*2*lightYear, 100E6*2*lightYear }, + Size = { 100E6*2*lightYear, 100E6*2*lightYear } }, GUI = { Name = "100Mly Grid", @@ -482,7 +482,7 @@ local plane20Gly = { LineWidth = 2.0, Segments = { 40, 40 }, HighlightRate = { 5, 5 }, - Size = { 20E9*2*lightYear, 20E9*2*lightYear }, + Size = { 20E9*2*lightYear, 20E9*2*lightYear } }, GUI = { Name = "20Gly Grid", @@ -502,7 +502,7 @@ asset.onInitialize(function() openspace.addSceneGraphNode(node) end end) - + asset.onDeinitialize(function() for i = #nodes, 1, -1 do local node = nodes[i] From 0a2f39dbf081d89f32a1e932912a341f9dd8d5c2 Mon Sep 17 00:00:00 2001 From: Malin E Date: Wed, 7 Sep 2022 11:27:17 +0200 Subject: [PATCH 20/21] Make the argument in asset.localResource optional * If nothing is provided, then the path to the current directory that the asset is located in is returned --- src/scene/assetmanager.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index b0c6409174..ddac86157b 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -489,10 +489,14 @@ void AssetManager::setUpAssetLuaTable(Asset* asset) { ZoneScoped Asset* thisAsset = ghoul::lua::userData(L, 1); - ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::localResourceLua"); + ghoul::lua::checkArgumentsAndThrow(L, { 0, 1 }, "lua::localResourceLua"); + + auto [name] = ghoul::lua::values>(L); + std::filesystem::path path = + name.has_value() ? + thisAsset->path().parent_path() / *name : + thisAsset->path().parent_path(); - std::string name = ghoul::lua::value(L); - std::filesystem::path path = thisAsset->path().parent_path() / name; ghoul::lua::push(L, path); return 1; }, @@ -514,7 +518,7 @@ void AssetManager::setUpAssetLuaTable(Asset* asset) { ghoul::Dictionary d = ghoul::lua::value(L); std::unique_ptr s = ResourceSynchronization::createFromDictionary(d); - + std::string uid = d.value("Type") + "/" + s->generateUid(); SyncItem* syncItem = nullptr; auto it = manager->_synchronizations.find(uid); From 75fd08246ca5cc22a35112c0d9a7971d8d65b574 Mon Sep 17 00:00:00 2001 From: Malin E Date: Thu, 8 Sep 2022 09:41:00 +0200 Subject: [PATCH 21/21] Switch from floats to doubles for the grids * Avoids jittering problems when close to SSB --- .../base/rendering/grids/renderablegrid.cpp | 59 ++++++++++--------- modules/base/rendering/grids/renderablegrid.h | 2 +- modules/base/shaders/grid_vs.glsl | 6 +- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index bf03877e12..1c4e9b712b 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -213,7 +213,7 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){ glm::dmat4 modelTransform = glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation glm::dmat4(data.modelTransform.rotation) * // Spice rotation - glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); + glm::scale(glm::dmat4(1.0), data.modelTransform.scale); glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; @@ -264,9 +264,10 @@ void RenderableGrid::update(const UpdateData&) { return; } - const glm::vec2 halfSize = _size.value() / 2.f; + const glm::dvec2 halfSize = static_cast(_size.value()) / 2.0; const glm::uvec2 nSegments = _segments.value(); - const glm::vec2 step = _size.value() / static_cast(nSegments); + const glm::dvec2 step = + static_cast(_size.value()) / static_cast(nSegments); const int nLines = (2 * nSegments.x * nSegments.y) + nSegments.x + nSegments.y; const int nVertices = 2 * nLines; @@ -280,11 +281,11 @@ void RenderableGrid::update(const UpdateData&) { const glm::uvec2 center = glm::uvec2(nSegments.x / 2.f, nSegments.y / 2.f); for (unsigned int i = 0; i < nSegments.x; ++i) { for (unsigned int j = 0; j < nSegments.y; ++j) { - const float y0 = -halfSize.y + j * step.y; - const float y1 = y0 + step.y; + const double y0 = -halfSize.y + j * step.y; + const double y1 = y0 + step.y; - const float x0 = -halfSize.x + i * step.x; - const float x1 = x0 + step.x; + const double x0 = -halfSize.x + i * step.x; + const double x1 = x0 + step.x; // Line in y direction bool shouldHighlight = false; @@ -294,12 +295,12 @@ void RenderableGrid::update(const UpdateData&) { } if (shouldHighlight) { - _highlightArray.push_back({ x0, y0, 0.f }); - _highlightArray.push_back({ x0, y1, 0.f }); + _highlightArray.push_back({ x0, y0, 0.0 }); + _highlightArray.push_back({ x0, y1, 0.0 }); } else { - _varray.push_back({ x0, y0, 0.f }); - _varray.push_back({ x0, y1, 0.f }); + _varray.push_back({ x0, y0, 0.0 }); + _varray.push_back({ x0, y1, 0.0 }); } // Line in x direction @@ -310,20 +311,20 @@ void RenderableGrid::update(const UpdateData&) { } if (shouldHighlight) { - _highlightArray.push_back({ x0, y0, 0.f }); - _highlightArray.push_back({ x1, y0, 0.f }); + _highlightArray.push_back({ x0, y0, 0.0 }); + _highlightArray.push_back({ x1, y0, 0.0 }); } else { - _varray.push_back({ x0, y0, 0.f }); - _varray.push_back({ x1, y0, 0.f }); + _varray.push_back({ x0, y0, 0.0 }); + _varray.push_back({ x1, y0, 0.0 }); } } } // last x row for (unsigned int i = 0; i < nSegments.x; ++i) { - const float x0 = -halfSize.x + i * step.x; - const float x1 = x0 + step.x; + const double x0 = -halfSize.x + i * step.x; + const double x1 = x0 + step.x; bool shouldHighlight = false; if (_highlightRate.value().x != 0) { @@ -333,19 +334,19 @@ void RenderableGrid::update(const UpdateData&) { } if (shouldHighlight) { - _highlightArray.push_back({ x0, halfSize.y, 0.f }); - _highlightArray.push_back({ x1, halfSize.y, 0.f }); + _highlightArray.push_back({ x0, halfSize.y, 0.0 }); + _highlightArray.push_back({ x1, halfSize.y, 0.0 }); } else { - _varray.push_back({ x0, halfSize.y, 0.f }); - _varray.push_back({ x1, halfSize.y, 0.f }); + _varray.push_back({ x0, halfSize.y, 0.0 }); + _varray.push_back({ x1, halfSize.y, 0.0 }); } } // last y col for (unsigned int i = 0; i < nSegments.y; ++i) { - const float y0 = -halfSize.y + i * step.y; - const float y1 = y0 + step.y; + const double y0 = -halfSize.y + i * step.y; + const double y1 = y0 + step.y; bool shouldHighlight = false; if (_highlightRate.value().y != 0) { @@ -354,12 +355,12 @@ void RenderableGrid::update(const UpdateData&) { shouldHighlight = abs(rest) == 0; } if (shouldHighlight) { - _highlightArray.push_back({ halfSize.x, y0, 0.f }); - _highlightArray.push_back({ halfSize.x, y1, 0.f }); + _highlightArray.push_back({ halfSize.x, y0, 0.0 }); + _highlightArray.push_back({ halfSize.x, y1, 0.0 }); } else { - _varray.push_back({ halfSize.x, y0, 0.f }); - _varray.push_back({ halfSize.x, y1, 0.f }); + _varray.push_back({ halfSize.x, y0, 0.0 }); + _varray.push_back({ halfSize.x, y1, 0.0 }); } } @@ -375,7 +376,7 @@ void RenderableGrid::update(const UpdateData&) { GL_STATIC_DRAW ); glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr); + glVertexAttribPointer(0, 3, GL_DOUBLE, GL_FALSE, sizeof(Vertex), nullptr); // Major grid glBindVertexArray(_highlightVaoID); @@ -386,7 +387,7 @@ void RenderableGrid::update(const UpdateData&) { _highlightArray.data(), GL_STATIC_DRAW ); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr); + glVertexAttribPointer(0, 3, GL_DOUBLE, GL_FALSE, sizeof(Vertex), nullptr); glBindVertexArray(0); diff --git a/modules/base/rendering/grids/renderablegrid.h b/modules/base/rendering/grids/renderablegrid.h index 3ebfa0f589..afba0953d0 100644 --- a/modules/base/rendering/grids/renderablegrid.h +++ b/modules/base/rendering/grids/renderablegrid.h @@ -55,7 +55,7 @@ public: protected: struct Vertex { - float location[3]; + double location[3]; }; ghoul::opengl::ProgramObject* _gridProgram = nullptr; diff --git a/modules/base/shaders/grid_vs.glsl b/modules/base/shaders/grid_vs.glsl index e2528c3de4..027bc20032 100644 --- a/modules/base/shaders/grid_vs.glsl +++ b/modules/base/shaders/grid_vs.glsl @@ -37,11 +37,11 @@ void main() { dvec4 objPosDouble = dvec4(in_position, 1.0); dvec4 positionViewSpace = modelViewTransform * objPosDouble; dvec4 positionClipSpace = MVPTransform * objPosDouble; - + positionClipSpace.z = 0.0; - + vs_depthClipSpace = float(positionClipSpace.w); vs_positionViewSpace = vec4(positionViewSpace); - + gl_Position = vec4(positionClipSpace); }