From 18b8aab89820d67cbf088a63caf38b91bb5f22b5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 27 Oct 2016 21:45:49 +0200 Subject: [PATCH] Changes in ProjectionComponent initialization - Remove parsing function - Make ProjectionComponent accept sub-dictionary Remove "Rotation" key-value from RenderableModelProjection - Information moved into RenderableFOV to do conversion between object and frame Changes in mod files to reflect ProjectionComponent and RenderableModelProjection changes Added Documentation to - RenderablePlanetProjection - RenderableModelProjection - ProjectionComponent - PlanetGeometry - ModelGeometry --- .../newhorizons/jupiter/callisto/callisto.mod | 32 +- .../newhorizons/jupiter/europa/europa.mod | 28 +- .../newhorizons/jupiter/ganymede/ganymede.mod | 28 +- data/scene/newhorizons/jupiter/io/io.mod | 28 +- .../newhorizons/jupiter/jupiter/jupiter.mod | 91 ++--- .../newhorizons/newhorizons/newhorizons.mod | 10 +- .../scene/newhorizons/pluto/charon/charon.mod | 35 +- data/scene/newhorizons/pluto/pluto/pluto.mod | 196 +++++----- data/scene/osirisrex/bennu/bennu.mod | 68 ++-- data/scene/osirisrex/osirisrex/osirisrex.mod | 3 + data/scene/rosetta/67P/67P.mod | 76 ++-- data/scene/rosetta/rosetta/rosetta.mod | 3 + modules/base/basemodule.cpp | 4 +- modules/base/rendering/modelgeometry.cpp | 72 ++-- modules/base/rendering/modelgeometry.h | 4 +- modules/base/rendering/planetgeometry.cpp | 44 ++- modules/base/rendering/planetgeometry.h | 7 +- modules/newhorizons/newhorizonsmodule.cpp | 8 + modules/newhorizons/newhorizonsmodule.h | 2 + .../newhorizons/rendering/renderablefov.cpp | 12 + .../rendering/renderablemodelprojection.cpp | 120 +++--- .../rendering/renderablemodelprojection.h | 8 +- .../rendering/renderableplanetprojection.cpp | 79 +++- .../rendering/renderableplanetprojection.h | 6 +- .../newhorizons/util/projectioncomponent.cpp | 351 +++++++++++------- .../newhorizons/util/projectioncomponent.h | 10 +- 26 files changed, 770 insertions(+), 555 deletions(-) diff --git a/data/scene/newhorizons/jupiter/callisto/callisto.mod b/data/scene/newhorizons/jupiter/callisto/callisto.mod index 83e4e58c14..5454e41ed6 100644 --- a/data/scene/newhorizons/jupiter/callisto/callisto.mod +++ b/data/scene/newhorizons/jupiter/callisto/callisto.mod @@ -22,20 +22,22 @@ return { Observer = "NEW HORIZONS", Target = "CALLISTO", Aberration = "NONE", - AspectRatio = 2 + AspectRatio = 2, + + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, + + PotentialTargets = { + "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" + } }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, - PotentialTargets = { - "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" - } }, Transform = { Translation = { @@ -74,7 +76,7 @@ return { Position = {0, -10000000, 0} }, }, - }, + }, -- CallistoTrail module { Name = "CallistoTrail", @@ -93,7 +95,7 @@ return { Type = "simple", Color = "${COMMON_MODULE}/textures/glare_blue.png", -- need to add different texture - }, + }, }, } } diff --git a/data/scene/newhorizons/jupiter/europa/europa.mod b/data/scene/newhorizons/jupiter/europa/europa.mod index f09899f0f3..31933603e7 100644 --- a/data/scene/newhorizons/jupiter/europa/europa.mod +++ b/data/scene/newhorizons/jupiter/europa/europa.mod @@ -22,20 +22,22 @@ return { Observer = "NEW HORIZONS", Target = "EUROPA", Aberration = "NONE", - AspectRatio = 2 + AspectRatio = 2, + + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, + + PotentialTargets = { + "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" + } }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, - PotentialTargets = { - "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" - } }, Transform = { Translation = { diff --git a/data/scene/newhorizons/jupiter/ganymede/ganymede.mod b/data/scene/newhorizons/jupiter/ganymede/ganymede.mod index eb6d0aa01b..0e7952fa87 100644 --- a/data/scene/newhorizons/jupiter/ganymede/ganymede.mod +++ b/data/scene/newhorizons/jupiter/ganymede/ganymede.mod @@ -22,20 +22,22 @@ return { Observer = "NEW HORIZONS", Target = "GANYMEDE", Aberration = "NONE", - AspectRatio = 2 + AspectRatio = 2, + + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, + + PotentialTargets = { + "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" + } }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, - PotentialTargets = { - "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" - } }, Transform = { Translation = { diff --git a/data/scene/newhorizons/jupiter/io/io.mod b/data/scene/newhorizons/jupiter/io/io.mod index a5fe7540b3..e6b481c40c 100644 --- a/data/scene/newhorizons/jupiter/io/io.mod +++ b/data/scene/newhorizons/jupiter/io/io.mod @@ -22,20 +22,22 @@ return { Observer = "NEW HORIZONS", Target = "IO", Aberration = "NONE", - AspectRatio = 2 + AspectRatio = 2, + + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, + + PotentialTargets = { + "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" + } }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, - PotentialTargets = { - "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" - } }, Transform = { Translation = { diff --git a/data/scene/newhorizons/jupiter/jupiter/jupiter.mod b/data/scene/newhorizons/jupiter/jupiter/jupiter.mod index 04d07a3a1e..317ac79798 100644 --- a/data/scene/newhorizons/jupiter/jupiter/jupiter.mod +++ b/data/scene/newhorizons/jupiter/jupiter/jupiter.mod @@ -38,53 +38,54 @@ return { Observer = "NEW HORIZONS", Target = "JUPITER", Aberration = "NONE", - AspectRatio = 2 - }, - DataInputTranslation = { - Instrument = { - LORRI = { - DetectorType = "Camera", - Spice = {"NH_LORRI"}, - }, - }, - Target ={ - Read = { - "TARGET_NAME", - "INSTRUMENT_HOST_NAME", - "INSTRUMENT_ID", - "START_TIME", - "STOP_TIME", - "DETECTOR_TYPE", - --"SEQUENCE_ID", - }, - Convert = { - JRINGS = {"IMAGE-PLANE" }, - J1IO = {"IO" }, - J2EUROPA = {"EUROPA" }, - J6HIMALIA = {"IMAGE-PLANE" }, - J7ELARA = {"IMAGE-PLANE" }, - CALIBRATION = {"CALIBRATION" }, - JUPITER = {"JUPITER" }, - CALLISTO = {"CALLISTO" }, - GANYMEDE = {"GANYMEDE" }, - EARTH = {"EARTH" }, - NEWHORIZONS = {"NEW HORIZONS"}, - CCD = {"CAMERA" }, - FRAMECCD = {"SCANNER" }, + AspectRatio = 2, + + DataInputTranslation = { + Instrument = { + LORRI = { + DetectorType = "Camera", + Spice = {"NH_LORRI"}, + }, + }, + Target ={ + Read = { + "TARGET_NAME", + "INSTRUMENT_HOST_NAME", + "INSTRUMENT_ID", + "START_TIME", + "STOP_TIME", + "DETECTOR_TYPE", + --"SEQUENCE_ID", + }, + Convert = { + JRINGS = {"IMAGE-PLANE" }, + J1IO = {"IO" }, + J2EUROPA = {"EUROPA" }, + J6HIMALIA = {"IMAGE-PLANE" }, + J7ELARA = {"IMAGE-PLANE" }, + CALIBRATION = {"CALIBRATION" }, + JUPITER = {"JUPITER" }, + CALLISTO = {"CALLISTO" }, + GANYMEDE = {"GANYMEDE" }, + EARTH = {"EARTH" }, + NEWHORIZONS = {"NEW HORIZONS"}, + CCD = {"CAMERA" }, + FRAMECCD = {"SCANNER" }, + }, }, }, - }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, - PotentialTargets = { - "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, + PotentialTargets = { + "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" + } } }, Transform = { diff --git a/data/scene/newhorizons/newhorizons/newhorizons.mod b/data/scene/newhorizons/newhorizons/newhorizons.mod index af08d5f56b..e9935d5906 100644 --- a/data/scene/newhorizons/newhorizons/newhorizons.mod +++ b/data/scene/newhorizons/newhorizons/newhorizons.mod @@ -90,7 +90,7 @@ return { Geometry = { Type = "MultiModelGeometry", GeometryFile = "models/NewHorizonsCleanModel.obj", - Magnification = 4, + -- Magnification = 4, }, Textures = { Type = "simple", @@ -114,6 +114,10 @@ return { SourceFrame = "NH_SPACECRAFT", DestinationFrame = "GALACTIC", }, + Scale = { + Type = "StaticScale", + Scale = 1000 + } }, }, --NewHorizonsTrail module @@ -150,7 +154,7 @@ return { Geometry = { Type = "MultiModelGeometry", GeometryFile = "models/Labels.obj", - Magnification = 4, + -- Magnification = 4, }, Textures = { Type = "simple", @@ -166,7 +170,7 @@ return { Fadeable = false, Ghosting = false, }, - }, + } }, { diff --git a/data/scene/newhorizons/pluto/charon/charon.mod b/data/scene/newhorizons/pluto/charon/charon.mod index d800cce9c9..01c370acc6 100644 --- a/data/scene/newhorizons/pluto/charon/charon.mod +++ b/data/scene/newhorizons/pluto/charon/charon.mod @@ -22,38 +22,35 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanetProjection", - Frame = "IAU_CHARON", - Body = "CHARON", Geometry = { Type = "SimpleSphere", Radius = { 6.035 , 5 }, Segments = 100 }, Textures = { - Type = "simple", Color = ColorTexture, Height = "textures/cpdem-Mcolor2-MLorriCA-lr-5_ZMfs-cyl.jpg", - Project = "textures/defaultProj.png", - Sequencing = "true", }, Projection = { Observer = "NEW HORIZONS", Target = "CHARON", Aberration = "NONE", - AspectRatio = 2 - }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, - PotentialTargets = { - "PLUTO", - "CHARON" + AspectRatio = 2, + + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, + + PotentialTargets = { + "PLUTO", + "CHARON" + } } }, Transform = { diff --git a/data/scene/newhorizons/pluto/pluto/pluto.mod b/data/scene/newhorizons/pluto/pluto/pluto.mod index e6c4537046..08eb750c1b 100644 --- a/data/scene/newhorizons/pluto/pluto/pluto.mod +++ b/data/scene/newhorizons/pluto/pluto/pluto.mod @@ -36,19 +36,14 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanetProjection", - Frame = "IAU_PLUTO", - Body = "PLUTO", Geometry = { Type = "SimpleSphere", Radius = { 1.173 , 6 }, Segments = 100 }, Textures = { - Type = "simple", Color = ColorTexture, Height = "textures/pluto_shenk_heightmap.jpg", - Project = "textures/3.jpg", - Sequencing = "true" }, Projection = { Sequence = "${OPENSPACE_DATA}/scene/newhorizons/pluto/pluto/images", @@ -57,103 +52,106 @@ return { Observer = "NEW HORIZONS", Target = "PLUTO", Aberration = "NONE", - AspectRatio = 2 - }, - DataInputTranslation = { - Instrument = { - LORRI = { - DetectorType = "Camera", - Spice = {"NH_LORRI"}, - }, - RALPH_MVIC_PAN_FRAME = { - DetectorType = "Scanner", - StopCommand = "RALPH_ABORT", - Spice = {"NH_RALPH_MVIC_FT"}, - }, - RALPH_MVIC_COLOR = { - DetectorType = "Scanner", - StopCommand = "END_NOM", - Spice = { "NH_RALPH_MVIC_NIR", - "NH_RALPH_MVIC_METHANE", - "NH_RALPH_MVIC_RED", - "NH_RALPH_MVIC_BLUE" }, - }, - RALPH_LEISA = { - DetectorType = "Scanner", - StopCommand = "END_NOM", - Spice = {"NH_RALPH_LEISA"}, - }, - RALPH_MVIC_PAN1 = { - DetectorType = "Scanner", - StopCommand = "END_NOM", - Spice = {"NH_RALPH_MVIC_PAN1"}, - }, - RALPH_MVIC_PAN2 = { - DetectorType = "Scanner", - StopCommand = "END_NOM", - Spice = {"NH_RALPH_MVIC_PAN2"}, - }, - ALICE_Use_AIRGLOW = { - DetectorType = "Scanner", - StopCommand = "ALICE_END_PIXELLIST", - Spice = {"NH_ALICE_AIRGLOW"}, - }, - ALICE_Use_AIRGLOW = { - DetectorType = "Scanner", - StopCommand = "ALICE_END_HISTOGRAM", - Spice = {"NH_ALICE_AIRGLOW"}, - }, - ALICE_Use_SOCC = { - DetectorType = "Scanner", - StopCommand = "ALICE_END_PIXELLIST", - Spice = {"NH_ALICE_SOC"}, - }, - ALICE_Use_SOCC = { - DetectorType = "Scanner", - StopCommand = "ALICE_END_HISTOGRAM", - Spice = {"NH_ALICE_SOC"}, - }, - REX_START = { - DetectorType = "Scanner", - StopCommand = "REX_MODE_OFF", - Spice = { "NH_REX" }, - } - }, - Target ={ - Read = { - "TARGET_NAME", - "INSTRUMENT_HOST_NAME", - "INSTRUMENT_ID", - "START_TIME", - "STOP_TIME", - "DETECTOR_TYPE", - --"SEQUENCE_ID", - }, - Convert = { - PLUTO = {"PLUTO" }, - NEWHORIZONS = {"NEW HORIZONS"}, - CCD = {"CAMERA" }, - FRAMECCD = {"SCANNER" }, + AspectRatio = 2, + + DataInputTranslation = { + Instrument = { + LORRI = { + DetectorType = "Camera", + Spice = {"NH_LORRI"}, + }, + RALPH_MVIC_PAN_FRAME = { + DetectorType = "Scanner", + StopCommand = "RALPH_ABORT", + Spice = {"NH_RALPH_MVIC_FT"}, + }, + RALPH_MVIC_COLOR = { + DetectorType = "Scanner", + StopCommand = "END_NOM", + Spice = { "NH_RALPH_MVIC_NIR", + "NH_RALPH_MVIC_METHANE", + "NH_RALPH_MVIC_RED", + "NH_RALPH_MVIC_BLUE" }, + }, + RALPH_LEISA = { + DetectorType = "Scanner", + StopCommand = "END_NOM", + Spice = {"NH_RALPH_LEISA"}, + }, + RALPH_MVIC_PAN1 = { + DetectorType = "Scanner", + StopCommand = "END_NOM", + Spice = {"NH_RALPH_MVIC_PAN1"}, + }, + RALPH_MVIC_PAN2 = { + DetectorType = "Scanner", + StopCommand = "END_NOM", + Spice = {"NH_RALPH_MVIC_PAN2"}, + }, + ALICE_Use_AIRGLOW = { + DetectorType = "Scanner", + StopCommand = "ALICE_END_PIXELLIST", + Spice = {"NH_ALICE_AIRGLOW"}, + }, + ALICE_Use_AIRGLOW = { + DetectorType = "Scanner", + StopCommand = "ALICE_END_HISTOGRAM", + Spice = {"NH_ALICE_AIRGLOW"}, + }, + ALICE_Use_SOCC = { + DetectorType = "Scanner", + StopCommand = "ALICE_END_PIXELLIST", + Spice = {"NH_ALICE_SOC"}, + }, + ALICE_Use_SOCC = { + DetectorType = "Scanner", + StopCommand = "ALICE_END_HISTOGRAM", + Spice = {"NH_ALICE_SOC"}, + }, + REX_START = { + DetectorType = "Scanner", + StopCommand = "REX_MODE_OFF", + Spice = { "NH_REX" }, + } + }, + Target ={ + Read = { + "TARGET_NAME", + "INSTRUMENT_HOST_NAME", + "INSTRUMENT_ID", + "START_TIME", + "STOP_TIME", + "DETECTOR_TYPE", + --"SEQUENCE_ID", + }, + Convert = { + PLUTO = {"PLUTO" }, + NEWHORIZONS = {"NEW HORIZONS"}, + CCD = {"CAMERA" }, + FRAMECCD = {"SCANNER" }, + }, }, }, + + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, + + PotentialTargets = { + "PLUTO", + "CHARON", + "NIX", + "HYDRA", + "P5", + "P4", + } }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, - PotentialTargets = { - "PLUTO", - "CHARON", - "NIX", - "HYDRA", - "P5", - "P4", - } }, Transform = { Translation = { diff --git a/data/scene/osirisrex/bennu/bennu.mod b/data/scene/osirisrex/bennu/bennu.mod index eeabed0e09..cbbfc05ad3 100644 --- a/data/scene/osirisrex/bennu/bennu.mod +++ b/data/scene/osirisrex/bennu/bennu.mod @@ -38,53 +38,51 @@ return { Project = "textures/defaultProj.png", Default = "textures/defaultProj.png" }, - Rotation = { - Source = "IAU_BENNU", - Destination = "GALACTIC" - }, Projection = { Sequence = "InstrumentTimes", SequenceType = "instrument-times", Observer = "OSIRIS-REX", Target = BENNU_BODY, Aberration = "NONE", - AspectRatio = 2 - }, - DataInputTranslation = { - Instruments = { - ORX_OCAMS_POLYCAM = { - DetectorType = "Camera", - Spice = {"ORX_OCAMS_POLYCAM"}, - Files = { - "BaseballDiamond_PolyCam.txt", - --"OrbitalB_Site08_PolyCamImages.txt", - "Recon_225m_Equatorial_PolyCam.txt", + AspectRatio = 2, + + DataInputTranslation = { + Instruments = { + ORX_OCAMS_POLYCAM = { + DetectorType = "Camera", + Spice = {"ORX_OCAMS_POLYCAM"}, + Files = { + "BaseballDiamond_PolyCam.txt", + --"OrbitalB_Site08_PolyCamImages.txt", + "Recon_225m_Equatorial_PolyCam.txt", + }, }, - }, - ORX_REXIS = { - DetectorType = "Camera", - Spice = {"ORX_REXIS"}, - Files = { - "DetailedSurvey_EquatorialStations_Spectrometers.txt", - "Recon_225m_Equatorial_spectrometers.txt", - "Recon_525m_Equatorial_spectrometers.txt", + ORX_REXIS = { + DetectorType = "Camera", + Spice = {"ORX_REXIS"}, + Files = { + "DetailedSurvey_EquatorialStations_Spectrometers.txt", + "Recon_225m_Equatorial_spectrometers.txt", + "Recon_525m_Equatorial_spectrometers.txt", + }, }, + }, + Target = { + Body = BENNU_BODY, -- Do we need this? }, - }, - Target = { - Body = BENNU_BODY, -- Do we need this? + }, + + Instrument = { -- INVALID DATA - JUST FOR TESTING + Name = "ORX_OCAMS_POLYCAM", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.792, + Aspect = 1, + Near = 0.01, + Far = 1000000, }, }, - Instrument = { -- INVALID DATA - JUST FOR TESTING - Name = "ORX_OCAMS_POLYCAM", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.792, - Aspect = 1, - Near = 0.01, - Far = 1000000, - }, }, Transform = { diff --git a/data/scene/osirisrex/osirisrex/osirisrex.mod b/data/scene/osirisrex/osirisrex/osirisrex.mod index 51272879be..d8dded5250 100644 --- a/data/scene/osirisrex/osirisrex/osirisrex.mod +++ b/data/scene/osirisrex/osirisrex/osirisrex.mod @@ -137,6 +137,9 @@ return { }, PotentialTargets = { BENNU_BODY -- Bennu + }, + FrameConversions = { + [BENNU_BODY] = "IAU_BENNU" } }, }, diff --git a/data/scene/rosetta/67P/67P.mod b/data/scene/rosetta/67P/67P.mod index 1b8d3a5aa7..5358b6b9ce 100644 --- a/data/scene/rosetta/67P/67P.mod +++ b/data/scene/rosetta/67P/67P.mod @@ -17,22 +17,14 @@ return { Renderable = { Type = "RenderableModelProjection", - Body = "CHURYUMOV-GERASIMENKO", Geometry = { Type = "MultiModelGeometry", GeometryFile = "obj/67P_rotated_5_130.obj", Magnification = 0, }, Textures = { - Type = "simple", Color = "textures/gray.jpg", -- Color = "textures/may9_map.jpg", - Project = "textures/defaultProj.png", - Default = "textures/defaultProj.png" - }, - Rotation = { - Source = "67P/C-G_CK", - Destination = "GALACTIC" }, Projection = { Sequence = "rosettaimages", @@ -41,43 +33,45 @@ return { Target = "CHURYUMOV-GERASIMENKO", Aberration = "NONE", TextureMap = true, - ShadowMap = true - }, - DataInputTranslation = { + ShadowMap = true, + + DataInputTranslation = { + Instrument = { + NAVCAM = { + DetectorType = "Camera", + Spice = {"ROS_NAVCAM-A"}, + }, + }, + Target = { + Read = { + "TARGET_NAME", + "INSTRUMENT_HOST_NAME", + "INSTRUMENT_ID", + "START_TIME", + "STOP_TIME", + }, + Convert = { + CHURYUMOV = {"CHURYUMOV-GERASIMENKO"}, + ROSETTA = {"ROSETTA" }, + --NAVCAM = {"NAVCAM"}, + ["ROSETTA-ORBITER"] = {"ROSETTA" }, + CHURYUMOVGERASIMENKO11969R1 = {"CHURYUMOV-GERASIMENKO"}, + CHURYUMOVGERASIMENKO = {"CHURYUMOV-GERASIMENKO"}, + ["CHURYUMOV-GERASIMENKO1(1969R1)"] = {"CHURYUMOV-GERASIMENKO"}, + --NAVIGATIONCAMERA = {"NAVCAM" }, + }, + }, + }, + Instrument = { - NAVCAM = { - DetectorType = "Camera", - Spice = {"ROS_NAVCAM-A"}, - }, - }, - Target = { - Read = { - "TARGET_NAME", - "INSTRUMENT_HOST_NAME", - "INSTRUMENT_ID", - "START_TIME", - "STOP_TIME", - }, - Convert = { - CHURYUMOV = {"CHURYUMOV-GERASIMENKO"}, - ROSETTA = {"ROSETTA" }, - --NAVCAM = {"NAVCAM"}, - ["ROSETTA-ORBITER"] = {"ROSETTA" }, - CHURYUMOVGERASIMENKO11969R1 = {"CHURYUMOV-GERASIMENKO"}, - CHURYUMOVGERASIMENKO = {"CHURYUMOV-GERASIMENKO"}, - ["CHURYUMOV-GERASIMENKO1(1969R1)"] = {"CHURYUMOV-GERASIMENKO"}, - --NAVIGATIONCAMERA = {"NAVCAM" }, - }, + Name = "ROS_NAVCAM-A", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 5.00, + Aspect = 1 }, }, - Instrument = { - Name = "ROS_NAVCAM-A", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 5.00, - Aspect = 1 - }, BoundingSphereRadius = 5000.0 }, Transform = { diff --git a/data/scene/rosetta/rosetta/rosetta.mod b/data/scene/rosetta/rosetta/rosetta.mod index 1bb96fe198..dffee7acb6 100644 --- a/data/scene/rosetta/rosetta/rosetta.mod +++ b/data/scene/rosetta/rosetta/rosetta.mod @@ -437,6 +437,9 @@ return { }, PotentialTargets = { "CHURYUMOV-GERASIMENKO" + }, + FrameConversions = { + ["CHURYUMOV-GERASIMENKO"] = "67P/C-G_CK" } }, }, diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index f52e3acd0f..bc9ddc22e9 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -139,7 +139,9 @@ std::vector BaseModule::documentations() const { SpiceRotation::Documentation(), StaticScale::Documentation(), StaticTranslation::Documentation(), - SpiceTranslation::Documentation() + SpiceTranslation::Documentation(), + modelgeometry::ModelGeometry::Documentation(), + planetgeometry::PlanetGeometry::Documentation() }; } diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index 655c883a2e..38288d425e 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -23,6 +23,8 @@ ****************************************************************************************/ #include + +#include #include #include #include @@ -35,59 +37,70 @@ namespace { const int8_t CurrentCacheVersion = 3; const std::string keyType = "Type"; const std::string keyName = "Name"; - const std::string keySize = "Magnification"; } namespace openspace { namespace modelgeometry { +Documentation ModelGeometry::Documentation() { + using namespace documentation; + return { + "Model Geometry", + "base_geometry_model", + { + { + keyType, + new StringVerifier, + "The type of the Model Geometry that should be generated", + Optional::No + }, + { + keyGeomModelFile, + new StringVerifier, + "The file that should be loaded in this ModelGeometry. The file can " + "contain filesystem tokens or can be specified relatively to the " + "location of the .mod file.", + Optional::No + } + } + }; +} + + ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) { - std::string geometryType; - const bool success = dictionary.getValue( - keyType, geometryType); - if (!success) { - LERROR("ModelGeometry did not contain a correct value of the key '" - << keyType << "'"); - return nullptr; + if (!dictionary.hasKeyAndValue(keyType)) { + throw ghoul::RuntimeError("Dictionary did not contain a key 'Type'"); } - ghoul::TemplateFactory* factory - = FactoryManager::ref().factory(); + + std::string geometryType = dictionary.value(keyType); + auto factory = FactoryManager::ref().factory(); ModelGeometry* result = factory->create(geometryType, dictionary); if (result == nullptr) { - LERROR("Failed to create a ModelGeometry object of type '" << geometryType - << "'"); - return nullptr; + throw ghoul::RuntimeError( + "Failed to create a ModelGeometry object of type '" + geometryType + "'" + ); } return result; } ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) : _parent(nullptr) - , _magnification("magnification", "Magnification", 1.f, 0.f, 10.f) , _mode(GL_TRIANGLES) { + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "ModelGeometry" + ); + setName("ModelGeometry"); std::string name; bool success = dictionary.getValue(keyName, name); ghoul_assert(success, "Name tag was not present"); - if (dictionary.hasKeyAndValue(keySize)) - _magnification = static_cast(dictionary.value(keySize)); - - success = dictionary.getValue(keyGeomModelFile, _file); - if (!success) { - LERROR("Geometric Model file of '" << name << "' did not provide a key '" - << keyGeomModelFile << "'"); - } - _file = FileSys.absolutePath(_file); - - if (!FileSys.fileExists(_file, ghoul::filesystem::FileSystem::RawPath::Yes)) - LERROR("Could not load the geometric model file '" << _file << "': File not found"); - - - addProperty(_magnification); + _file = absPath(dictionary.value(keyGeomModelFile)); } double ModelGeometry::boundingRadius() const { @@ -273,7 +286,6 @@ bool ModelGeometry::getIndices(std::vector* indexList) { } void ModelGeometry::setUniforms(ghoul::opengl::ProgramObject& program) { - program.setUniform("_magnification", _magnification); } } // namespace modelgeometry diff --git a/modules/base/rendering/modelgeometry.h b/modules/base/rendering/modelgeometry.h index b85062b897..edfbada197 100644 --- a/modules/base/rendering/modelgeometry.h +++ b/modules/base/rendering/modelgeometry.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -59,13 +60,14 @@ public: virtual void setUniforms(ghoul::opengl::ProgramObject& program); + static openspace::Documentation Documentation(); + protected: Renderable* _parent; bool loadObj(const std::string& filename); bool loadCachedFile(const std::string& filename); bool saveCachedFile(const std::string& filename); - properties::FloatProperty _magnification; GLuint _vaoID; GLuint _vbo; diff --git a/modules/base/rendering/planetgeometry.cpp b/modules/base/rendering/planetgeometry.cpp index 32e366b0fd..a876bbf041 100644 --- a/modules/base/rendering/planetgeometry.cpp +++ b/modules/base/rendering/planetgeometry.cpp @@ -25,6 +25,8 @@ #include #include +#include + namespace { const std::string _loggerCat = "PlanetGeometry"; const std::string KeyType = "Type"; @@ -33,22 +35,38 @@ namespace { namespace openspace { namespace planetgeometry { -PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) { - std::string geometryType; - const bool success = dictionary.getValue(KeyType, geometryType); - if (!success) { - LERROR("PlanetGeometry did not contain a correct value of the key '" - << KeyType << "'"); - return nullptr; - } - ghoul::TemplateFactory* factory - = FactoryManager::ref().factory(); +Documentation PlanetGeometry::Documentation() { + using namespace documentation; + return { + "Planet Geometry", + "base_geometry_planet", + { + { + KeyType, + new StringVerifier, + "The type of the PlanetGeometry that will can be constructed.", + Optional::No + } + } + }; +} + +PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "PlanetGeometry" + ); + + std::string geometryType = dictionary.value(KeyType); + auto factory = FactoryManager::ref().factory(); PlanetGeometry* result = factory->create(geometryType, dictionary); if (result == nullptr) { - LERROR("Failed to create a PlanetGeometry object of type '" << geometryType - << "'"); - return nullptr; + throw ghoul::RuntimeError( + "Failed to create a PlanetGeometry object of type '" + geometryType + "'" + ); } return result; } diff --git a/modules/base/rendering/planetgeometry.h b/modules/base/rendering/planetgeometry.h index 3a38f3be81..2442fa11d5 100644 --- a/modules/base/rendering/planetgeometry.h +++ b/modules/base/rendering/planetgeometry.h @@ -26,10 +26,11 @@ #define __PLANETGEOMETRY_H__ #include -#include -#include + +#include namespace openspace { +class Renderable; namespace planetgeometry { @@ -43,6 +44,8 @@ public: virtual void deinitialize(); virtual void render() = 0; + static openspace::Documentation Documentation(); + protected: Renderable* _parent; }; diff --git a/modules/newhorizons/newhorizonsmodule.cpp b/modules/newhorizons/newhorizonsmodule.cpp index 72caa9b844..49e3beb07e 100644 --- a/modules/newhorizons/newhorizonsmodule.cpp +++ b/modules/newhorizons/newhorizonsmodule.cpp @@ -71,4 +71,12 @@ void NewHorizonsModule::internalInitialize() { fDecoder->registerClass("Target"); } +std::vector NewHorizonsModule::documentations() const { + return { + RenderableModelProjection::Documentation(), + RenderablePlanetProjection::Documentation(), + ProjectionComponent::Documentation() + }; +} + } // namespace openspace diff --git a/modules/newhorizons/newhorizonsmodule.h b/modules/newhorizons/newhorizonsmodule.h index e4b57eaa7a..8bd39cbce4 100644 --- a/modules/newhorizons/newhorizonsmodule.h +++ b/modules/newhorizons/newhorizonsmodule.h @@ -33,6 +33,8 @@ class NewHorizonsModule : public OpenSpaceModule { public: NewHorizonsModule(); + std::vector documentations() const override; + protected: void internalInitialize() override; }; diff --git a/modules/newhorizons/rendering/renderablefov.cpp b/modules/newhorizons/rendering/renderablefov.cpp index 878d833186..aa29f631cb 100644 --- a/modules/newhorizons/rendering/renderablefov.cpp +++ b/modules/newhorizons/rendering/renderablefov.cpp @@ -46,6 +46,7 @@ namespace { const std::string keyInstrumentMethod = "Instrument.Method"; const std::string keyInstrumentAberration = "Instrument.Aberration"; const std::string keyPotentialTargets = "PotentialTargets"; + const std::string keyFrameConversions = "FrameConversions"; const int InterpolationSteps = 10; const int Stride = 8; @@ -94,6 +95,17 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary) _potentialTargets[i] = target; } + ghoul::Dictionary frameConversions; + success = dictionary.getValue(keyFrameConversions, frameConversions); + if (success) { + for (const std::string& key : frameConversions.keys()) { + openspace::SpiceManager::ref().addFrame( + key, + frameConversions.value(key) + ); + } + } + addProperty(_lineWidth); addProperty(_drawSolid); } diff --git a/modules/newhorizons/rendering/renderablemodelprojection.cpp b/modules/newhorizons/rendering/renderablemodelprojection.cpp index 3daadde566..76dc7dd40a 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.cpp +++ b/modules/newhorizons/rendering/renderablemodelprojection.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -38,17 +39,62 @@ namespace { const std::string _loggerCat = "RenderableModelProjection"; const std::string keySource = "Rotation.Source"; const std::string keyDestination = "Rotation.Destination"; - const std::string keyBody = "Body"; const std::string keyGeometry = "Geometry"; + const std::string keyProjection = "Projection"; const std::string keyBoundingSphereRadius = "BoundingSphereRadius"; const std::string keyTextureColor = "Textures.Color"; - const std::string keyTextureProject = "Textures.Project"; - const std::string keyTextureDefault = "Textures.Default"; + + const std::string _destination = "GALACTIC"; } namespace openspace { +Documentation RenderableModelProjection::Documentation() { + using namespace documentation; + + return { + "Renderable Model Projection", + "newhorizons_renderable_modelprojection", + { + { + "Type", + new StringEqualVerifier("RenderableModelProjection"), + "", + Optional::No + }, + { + keyGeometry, + new ReferencingVerifier("base_geometry_model"), + "The geometry that is used for rendering this model.", + Optional::No + }, + { + keyProjection, + new ReferencingVerifier("newhorizons_projectioncomponent"), + "Contains information about projecting onto this planet.", + Optional::No + }, + { + keyTextureColor, + new StringVerifier, + "The base texture for the model that is shown before any projection " + "occurred.", + Optional::No + }, + { + keyBoundingSphereRadius, + new DoubleVerifier, + "The radius of the bounding sphere of this object. This has to be a " + "radius that is larger than anything that is rendered by it. It has to " + "be at least as big as the convex hull of the object. The default value " + "is 10e9 meters.", + Optional::Yes + } + } + }; +} + RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _colorTexturePath("colorTexture", "Color Texture") @@ -59,44 +105,35 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di , _geometry(nullptr) , _performShading("performShading", "Perform Shading", true) { + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "RenderableModelProjection" + ); + std::string name; bool success = dictionary.getValue(SceneGraphNode::KeyName, name); ghoul_assert(success, "Name was not passed to RenderableModelProjection"); - ghoul::Dictionary geometryDictionary; - success = dictionary.getValue(keyGeometry, geometryDictionary); - if (success) { - using modelgeometry::ModelGeometry; - geometryDictionary.setValue(SceneGraphNode::KeyName, name); - _geometry = std::unique_ptr( - ModelGeometry::createFromDictionary(geometryDictionary) - ); - } + using ghoul::Dictionary; + Dictionary geometryDictionary = dictionary.value(keyGeometry); + using modelgeometry::ModelGeometry; + geometryDictionary.setValue(SceneGraphNode::KeyName, name); + _geometry = std::unique_ptr( + ModelGeometry::createFromDictionary(geometryDictionary) + ); - std::string texturePath = ""; - success = dictionary.getValue(keyTextureColor, texturePath); - if (success) - _colorTexturePath = absPath(texturePath); + _colorTexturePath = absPath(dictionary.value(keyTextureColor)); - success = dictionary.getValue(keyTextureDefault, texturePath); - if (success) - _defaultProjImage = absPath(texturePath); - addPropertySubOwner(_geometry.get()); addPropertySubOwner(_projectionComponent); addProperty(_colorTexturePath); _colorTexturePath.onChange(std::bind(&RenderableModelProjection::loadTextures, this)); - dictionary.getValue(keySource, _source); - dictionary.getValue(keyDestination, _destination); - dictionary.getValue(keyBody, _target); - - - bool completeSuccess = true; - completeSuccess &= _projectionComponent.initializeProjectionSettings(dictionary); - - openspace::SpiceManager::ref().addFrame(_target, _source); + _projectionComponent.initialize( + dictionary.value(keyProjection) + ); float boundingSphereRadius = 1.0e9; dictionary.getValue(keyBoundingSphereRadius, boundingSphereRadius); @@ -104,9 +141,6 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di Renderable::addProperty(_performShading); Renderable::addProperty(_rotation); - - success = _projectionComponent.initializeParser(dictionary); - ghoul_assert(success, ""); } bool RenderableModelProjection::isReady() const { @@ -139,15 +173,12 @@ bool RenderableModelProjection::initialize() { completeSuccess &= loadTextures(); - completeSuccess &= _projectionComponent.initialize(); + completeSuccess &= _projectionComponent.initializeGL(); auto bs = getBoundingSphere(); completeSuccess &= _geometry->initialize(this); setBoundingSphere(bs); // ignore bounding sphere set by geometry. - completeSuccess &= !_source.empty(); - completeSuccess &= !_destination.empty(); - return completeSuccess; } @@ -246,18 +277,12 @@ void RenderableModelProjection::update(const UpdateData& data) { } } - // set spice-orientation in accordance to timestamp - if (!_source.empty()) { - _stateMatrix = SpiceManager::ref().positionTransformMatrix( - _source, _destination, _time - ); - } - - double lt; + _stateMatrix = data.modelTransform.rotation; + glm::dvec3 p = - openspace::SpiceManager::ref().targetPosition( - "SUN", _target, "GALACTIC", {}, _time, lt - ); + OsEng.renderEngine().scene()->sceneGraphNode("Sun")->worldPosition() - + data.modelTransform.translation; + _sunPosition = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z); } @@ -308,7 +333,6 @@ void RenderableModelProjection::imageProjectGPU( void RenderableModelProjection::attitudeParameters(double time) { try { - _stateMatrix = SpiceManager::ref().positionTransformMatrix(_source, _destination, time); _instrumentMatrix = SpiceManager::ref().positionTransformMatrix(_projectionComponent.instrumentId(), _destination, time); } catch (const SpiceManager::SpiceException& e) { diff --git a/modules/newhorizons/rendering/renderablemodelprojection.h b/modules/newhorizons/rendering/renderablemodelprojection.h index 1a0ef2c259..60349f5033 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.h +++ b/modules/newhorizons/rendering/renderablemodelprojection.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -59,6 +60,8 @@ public: ghoul::opengl::Texture& baseTexture() const; + static openspace::Documentation Documentation(); + private: bool loadTextures(); void attitudeParameters(double time); @@ -83,11 +86,6 @@ private: glm::dmat3 _stateMatrix; glm::dmat3 _instrumentMatrix; - std::string _defaultProjImage; - std::string _source; - std::string _destination; - std::string _target; - // uniforms glm::vec2 _camScaling; glm::vec3 _up; diff --git a/modules/newhorizons/rendering/renderableplanetprojection.cpp b/modules/newhorizons/rendering/renderableplanetprojection.cpp index 3f892aecb0..80338f7e79 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.cpp +++ b/modules/newhorizons/rendering/renderableplanetprojection.cpp @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -45,16 +46,64 @@ namespace { const std::string _loggerCat = "RenderablePlanetProjection"; - const std::string keyFrame = "Frame"; const std::string keyGeometry = "Geometry"; + const std::string keyProjection = "Projection"; + const std::string keyColorTexture = "Textures.Color"; + const std::string keyHeightTexture = "Textures.Height"; + + const std::string keyRadius = "Geometry.Radius"; const std::string keyShading = "PerformShading"; - const std::string keyBody = "Body"; const std::string _mainFrame = "GALACTIC"; } namespace openspace { +Documentation RenderablePlanetProjection::Documentation() { + using namespace openspace::documentation; + return { + "Renderable Planet Projection", + "newhorizons_renderable_planetprojection", + { + { + "Type", + new StringEqualVerifier("RenderablePlanetProjection"), + "", + Optional::No + }, + { + keyGeometry, + new ReferencingVerifier("base_geometry_planet"), + "The geometry that is used for rendering this planet.", + Optional::No + }, + { + keyProjection, + new ReferencingVerifier("newhorizons_projectioncomponent"), + "Contains information about projecting onto this planet.", + Optional::No + }, + { + keyColorTexture, + new StringVerifier, + "The path to the base color texture that is used on the planet prior to " + "any image projection. The path can use tokens of the form '${...}' or " + "be specified relative to the directory of the mod file.", + Optional::No + }, + { + keyHeightTexture, + new StringVerifier, + "The path to the height map texture that is used on the planet. The path " + "can use tokens of the form '${...}' or be specified relative to the " + "directory of the mod file. If no height map is specified the planet " + "does not use a height field.", + Optional::Yes + } + } + }; +} + RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _colorTexturePath("planetTexture", "RGB Texture") @@ -68,6 +117,12 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& , _heightMapTexture(nullptr) , _capture(false) { + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "RenderablePlanetProject" + ); + std::string name; bool success = dictionary.getValue(SceneGraphNode::KeyName, name); ghoul_assert(success, ""); @@ -83,11 +138,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& ); } - dictionary.getValue(keyFrame, _frame); - dictionary.getValue(keyBody, _body); - - success = _projectionComponent.initializeProjectionSettings(dictionary); - ghoul_assert(success, ""); + _projectionComponent.initialize(dictionary.value(keyProjection)); // TODO: textures need to be replaced by a good system similar to the geometry as soon // as the requirements are fixed (ab) @@ -117,9 +168,6 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& addProperty(_heightExaggeration); addProperty(_debugProjectionTextureRotation); - - success = _projectionComponent.initializeParser(dictionary); - ghoul_assert(success, ""); } RenderablePlanetProjection::~RenderablePlanetProjection() {} @@ -138,7 +186,7 @@ bool RenderablePlanetProjection::initialize() { ); completeSuccess &= loadTextures(); - completeSuccess &= _projectionComponent.initialize(); + completeSuccess &= _projectionComponent.initializeGL(); completeSuccess &= _geometry->initialize(this); if (completeSuccess) { @@ -233,7 +281,6 @@ void RenderablePlanetProjection::imageProjectGPU( void RenderablePlanetProjection::attitudeParameters(double time) { // precomputations for shader - _stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, _mainFrame, time); _instrumentMatrix = SpiceManager::ref().positionTransformMatrix( _projectionComponent.instrumentId(), _mainFrame, time ); @@ -256,12 +303,7 @@ void RenderablePlanetProjection::attitudeParameters(double time) { glm::vec3(0, 1, 0) ); - for (int i = 0; i < 3; i++){ - for (int j = 0; j < 3; j++){ - _transform[i][j] = static_cast(_stateMatrix[i][j]); - } - } - _transform = _transform * rot * roty * rotProp; + _transform = glm::mat4(_stateMatrix) * rot * roty * rotProp; glm::dvec3 bs; try { @@ -411,6 +453,7 @@ void RenderablePlanetProjection::update(const UpdateData& data) { } } + _stateMatrix = data.modelTransform.rotation; } bool RenderablePlanetProjection::loadTextures() { diff --git a/modules/newhorizons/rendering/renderableplanetprojection.h b/modules/newhorizons/rendering/renderableplanetprojection.h index c5f2553183..6e7cac4630 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.h +++ b/modules/newhorizons/rendering/renderableplanetprojection.h @@ -26,10 +26,11 @@ #define __RENDERABLEPLANETPROJECTION_H__ #include -#include #include +#include +#include #include #include #include @@ -56,6 +57,8 @@ public: void update(const UpdateData& data) override; ghoul::opengl::Texture& baseTexture() const; + static openspace::Documentation Documentation(); + protected: bool loadTextures(); void attitudeParameters(double time); @@ -95,7 +98,6 @@ private: std::vector _imageTimes; - std::string _body; std::string _frame; bool _capture; diff --git a/modules/newhorizons/util/projectioncomponent.cpp b/modules/newhorizons/util/projectioncomponent.cpp index 21a36cbd61..9ff4439010 100644 --- a/modules/newhorizons/util/projectioncomponent.cpp +++ b/modules/newhorizons/util/projectioncomponent.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -44,17 +45,18 @@ namespace { const std::string keyInstrumentFovy = "Instrument.Fovy"; const std::string keyInstrumentAspect = "Instrument.Aspect"; - const std::string keyProjObserver = "Projection.Observer"; - const std::string keyProjTarget = "Projection.Target"; - const std::string keyProjAberration = "Projection.Aberration"; - - const std::string keySequenceDir = "Projection.Sequence"; - const std::string keySequenceType = "Projection.SequenceType"; const std::string keyTranslation = "DataInputTranslation"; - const std::string keyNeedsTextureMapDilation = "Projection.TextureMap"; - const std::string keyNeedsShadowing = "Projection.ShadowMap"; - const std::string keyTextureMapAspectRatio = "Projection.AspectRatio"; + const std::string keyProjObserver = "Observer"; + const std::string keyProjTarget = "Target"; + const std::string keyProjAberration = "Aberration"; + + const std::string keySequenceDir = "Sequence"; + const std::string keySequenceType = "SequenceType"; + + const std::string keyNeedsTextureMapDilation = "TextureMap"; + const std::string keyNeedsShadowing = "ShadowMap"; + const std::string keyTextureMapAspectRatio = "AspectRatio"; const std::string sequenceTypeImage = "image-sequence"; const std::string sequenceTypePlaybook = "playbook"; @@ -72,6 +74,94 @@ namespace openspace { using ghoul::Dictionary; using glm::ivec2; +Documentation ProjectionComponent::Documentation() { + using namespace documentation; + return { + "Projection Component", + "newhorizons_projectioncomponent", + { + { + keyInstrument, + new StringAnnotationVerifier("A SPICE name of an instrument"), + "The instrument that is used to perform the projections", + Optional::No + }, + { + keyInstrumentFovy, + new DoubleVerifier, + "The field of view in degrees along the y axis", + Optional::No + }, + { + keyInstrumentAspect, + new DoubleVerifier, + "The aspect ratio of the instrument in relation between x and y axis", + Optional::No + }, + { + keyProjObserver, + new StringAnnotationVerifier("A SPICE name of the observing object"), + "The observer that is doing the projection. This has to be a valid SPICE " + "name or SPICE integer.", + Optional::No + }, + { + keyProjTarget, + new StringAnnotationVerifier("A SPICE name of the observed object"), + "The observed object that is projected on. This has to be a valid SPICE " + "name or SPICE integer.", + Optional::No + }, + { + keyProjAberration, + new StringInListVerifier({ + // from SpiceManager::AberrationCorrection::AberrationCorrection + "NONE", "LT", "LT+S", "CN", "CN+S", "XLT", "XLT+S", "XCN", "XCN+S" + }), + "The aberration correction that is supposed to be used for the " + "projection. The values for the correction correspond to the SPICE " + "definition as described in " + "ftp://naif.jpl.nasa.gov/pub/naif/toolkit_docs/IDL/cspice/spkezr_c.html", + Optional::No + }, + { + keyPotentialTargets, + new StringListVerifier, + "The list of potential targets that are involved with the image " + "projection", + Optional::Yes + }, + { + keyNeedsTextureMapDilation, + new BoolVerifier, + "Determines whether a dilation step of the texture map has to be " + "performed after each projection. This is necessary if the texture of " + "the projected object is a texture map where the borders are not " + "touching. The default value is 'false'.", + Optional::Yes + }, + { + keyNeedsShadowing, + new BoolVerifier, + "Determines whether the object requires a self-shadowing algorithm. This " + "is necessary if the object is concave and might cast a shadow on itself " + "during presentation. The default value is 'false'.", + Optional::Yes + }, + { + keyTextureMapAspectRatio, + new DoubleVerifier, + "Sets the desired aspect ratio of the projected texture. This might be " + "necessary as planets usually have 2x1 aspect ratios, whereas this does " + "not hold for non-planet objects (comets, asteroids, etc). The default " + "value is '1.0'.", + Optional::Yes + } + + } + }; +} + ProjectionComponent::ProjectionComponent() : properties::PropertyOwner() , _performProjection("performProjection", "Perform Projections", true) @@ -96,7 +186,123 @@ ProjectionComponent::ProjectionComponent() _applyTextureSize.onChange([this]() { _textureSizeDirty = true; }); } -bool ProjectionComponent::initialize() { +void ProjectionComponent::initialize(const ghoul::Dictionary& dictionary) { + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "ProjectionComponent" + ); + _instrumentID = dictionary.value(keyInstrument); + _projectorID = dictionary.value(keyProjObserver); + _projecteeID = dictionary.value(keyProjTarget); + _fovy = dictionary.value(keyInstrumentFovy); + _aspectRatio = dictionary.value(keyInstrumentAspect); + + _aberration = SpiceManager::AberrationCorrection( + dictionary.value(keyProjAberration) + ); + + if (dictionary.hasKeyAndValue(keyPotentialTargets)) { + ghoul::Dictionary potentialTargets = dictionary.value( + keyPotentialTargets + ); + + _potentialTargets.reserve(potentialTargets.size()); + for (int i = 1; i <= potentialTargets.size(); ++i) { + _potentialTargets.emplace_back( + potentialTargets.value(std::to_string(i)) + ); + } + } + + if (dictionary.hasKeyAndValue(keyNeedsTextureMapDilation)) { + _dilation.isEnabled = dictionary.value(keyNeedsTextureMapDilation); + } + + if (dictionary.hasKeyAndValue(keyNeedsShadowing)) { + _shadowing.isEnabled = dictionary.value(keyNeedsShadowing); + } + + _projectionTextureAspectRatio = 1.f; + if (dictionary.hasKeyAndValue(keyTextureMapAspectRatio)) { + _projectionTextureAspectRatio = + static_cast(dictionary.value(keyTextureMapAspectRatio)); + } + + std::string name; + dictionary.getValue(SceneGraphNode::KeyName, name); + + std::vector parsers; + + std::string sequenceSource; + std::string sequenceType; + bool foundSequence = dictionary.getValue(keySequenceDir, sequenceSource); + if (foundSequence) { + sequenceSource = absPath(sequenceSource); + + foundSequence = dictionary.getValue(keySequenceType, sequenceType); + //Important: client must define translation-list in mod file IFF playbook + if (dictionary.hasKey(keyTranslation)) { + ghoul::Dictionary translationDictionary; + //get translation dictionary + dictionary.getValue(keyTranslation, translationDictionary); + + if (sequenceType == sequenceTypePlaybook) { + parsers.push_back(new HongKangParser( + name, + sequenceSource, + _projectorID, + translationDictionary, + _potentialTargets)); + } + else if (sequenceType == sequenceTypeImage) { + parsers.push_back(new LabelParser( + name, + sequenceSource, + translationDictionary)); + } + else if (sequenceType == sequenceTypeHybrid) { + //first read labels + parsers.push_back(new LabelParser( + name, + sequenceSource, + translationDictionary)); + + std::string _eventFile; + bool foundEventFile = dictionary.getValue("Projection.EventFile", _eventFile); + if (foundEventFile) { + //then read playbook + _eventFile = absPath(_eventFile); + parsers.push_back(new HongKangParser( + name, + _eventFile, + _projectorID, + translationDictionary, + _potentialTargets)); + } + else { + LWARNING("No eventfile has been provided, please check modfiles"); + } + } + else if (sequenceType == sequenceTypeInstrumentTimes) { + parsers.push_back(new InstrumentTimesParser( + name, + sequenceSource, + translationDictionary)); + } + + for (SequenceParser* parser : parsers) { + openspace::ImageSequencer::ref().runSequenceParser(parser); + delete parser; + } + } + else { + LWARNING("No playbook translation provided, please make sure all spice calls match playbook!"); + } + } +} + +bool ProjectionComponent::initializeGL() { int maxSize = OpenGLCap.max2DTextureSize(); glm::ivec2 size; @@ -193,131 +399,6 @@ bool ProjectionComponent::isReady() const { return (_projectionTexture != nullptr); } -bool ProjectionComponent::initializeProjectionSettings(const Dictionary& dictionary) { - bool completeSuccess = true; - completeSuccess &= dictionary.getValue(keyInstrument, _instrumentID); - completeSuccess &= dictionary.getValue(keyProjObserver, _projectorID); - completeSuccess &= dictionary.getValue(keyProjTarget, _projecteeID); - completeSuccess &= dictionary.getValue(keyInstrumentFovy, _fovy); - completeSuccess &= dictionary.getValue(keyInstrumentAspect, _aspectRatio); - - ghoul_assert(completeSuccess, "All neccessary attributes not found in modfile"); - - std::string a = "NONE"; - bool s = dictionary.getValue(keyProjAberration, a); - _aberration = SpiceManager::AberrationCorrection(a); - completeSuccess &= s; - ghoul_assert(completeSuccess, "All neccessary attributes not found in modfile"); - - - if (dictionary.hasKeyAndValue(keyPotentialTargets)) { - ghoul::Dictionary potentialTargets = dictionary.value( - keyPotentialTargets - ); - - _potentialTargets.resize(potentialTargets.size()); - for (int i = 0; i < potentialTargets.size(); ++i) { - std::string target; - potentialTargets.getValue(std::to_string(i + 1), target); - _potentialTargets[i] = target; - } - } - - if (dictionary.hasKeyAndValue(keyNeedsTextureMapDilation)) { - _dilation.isEnabled = dictionary.value(keyNeedsTextureMapDilation); - } - - if (dictionary.hasKeyAndValue(keyNeedsShadowing)) { - _shadowing.isEnabled = dictionary.value(keyNeedsShadowing); - } - - _projectionTextureAspectRatio = 1.f; - if (dictionary.hasKeyAndValue(keyTextureMapAspectRatio)) { - _projectionTextureAspectRatio = - static_cast(dictionary.value(keyTextureMapAspectRatio)); - } - - return completeSuccess; -} - -bool ProjectionComponent::initializeParser(const ghoul::Dictionary& dictionary) { - bool completeSuccess = true; - - std::string name; - dictionary.getValue(SceneGraphNode::KeyName, name); - - std::vector parsers; - - std::string sequenceSource; - std::string sequenceType; - bool foundSequence = dictionary.getValue(keySequenceDir, sequenceSource); - if (foundSequence) { - sequenceSource = absPath(sequenceSource); - - foundSequence = dictionary.getValue(keySequenceType, sequenceType); - //Important: client must define translation-list in mod file IFF playbook - if (dictionary.hasKey(keyTranslation)) { - ghoul::Dictionary translationDictionary; - //get translation dictionary - dictionary.getValue(keyTranslation, translationDictionary); - - if (sequenceType == sequenceTypePlaybook) { - parsers.push_back(new HongKangParser( - name, - sequenceSource, - _projectorID, - translationDictionary, - _potentialTargets)); - } - else if (sequenceType == sequenceTypeImage) { - parsers.push_back(new LabelParser( - name, - sequenceSource, - translationDictionary)); - } - else if (sequenceType == sequenceTypeHybrid) { - //first read labels - parsers.push_back(new LabelParser( - name, - sequenceSource, - translationDictionary)); - - std::string _eventFile; - bool foundEventFile = dictionary.getValue("Projection.EventFile", _eventFile); - if (foundEventFile) { - //then read playbook - _eventFile = absPath(_eventFile); - parsers.push_back(new HongKangParser( - name, - _eventFile, - _projectorID, - translationDictionary, - _potentialTargets)); - } - else { - LWARNING("No eventfile has been provided, please check modfiles"); - } - } - else if (sequenceType == sequenceTypeInstrumentTimes) { - parsers.push_back(new InstrumentTimesParser( - name, - sequenceSource, - translationDictionary)); - } - - for(SequenceParser* parser : parsers){ - openspace::ImageSequencer::ref().runSequenceParser(parser); - delete parser; - } - } - else { - LWARNING("No playbook translation provided, please make sure all spice calls match playbook!"); - } - } - - return completeSuccess; -} - void ProjectionComponent::imageProjectBegin() { // keep handle to the current bound FBO glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); diff --git a/modules/newhorizons/util/projectioncomponent.h b/modules/newhorizons/util/projectioncomponent.h index 6bae9afa6f..ef6b57cd4e 100644 --- a/modules/newhorizons/util/projectioncomponent.h +++ b/modules/newhorizons/util/projectioncomponent.h @@ -26,6 +26,8 @@ #define __PROJECTIONCOMPONENT_H__ #include + +#include #include #include #include @@ -48,14 +50,12 @@ class ProjectionComponent : public properties::PropertyOwner { public: ProjectionComponent(); - bool initialize(); + void initialize(const ghoul::Dictionary& dictionary); + bool initializeGL(); bool deinitialize(); bool isReady() const; - bool initializeProjectionSettings(const ghoul::Dictionary& dictionary); - bool initializeParser(const ghoul::Dictionary& dictionary); - ghoul::opengl::Texture& depthTexture(); void imageProjectBegin(); void imageProjectEnd(); @@ -101,6 +101,8 @@ public: float fieldOfViewY() const; float aspectRatio() const; + static openspace::Documentation Documentation(); + private: bool generateProjectionLayerTexture(const glm::ivec2& size); bool generateDepthTexture(const glm::ivec2& size);