diff --git a/CMakeLists.txt b/CMakeLists.txt index dfe4464edc..bd4adeff10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ set(OPENSPACE_VERSION_MINOR 15) set(OPENSPACE_VERSION_PATCH 2) set(OPENSPACE_VERSION_STRING "Beta-7") - set(OPENSPACE_BASE_DIR "${PROJECT_SOURCE_DIR}") set(OPENSPACE_CMAKE_EXT_DIR "${OPENSPACE_BASE_DIR}/support/cmake") set(GHOUL_BASE_DIR "${OPENSPACE_BASE_DIR}/ext/ghoul") @@ -134,6 +133,11 @@ if (MSVC) set(GHOUL_OPTIMIZATION_ENABLE_OTHER_OPTIMIZATIONS ${OPENSPACE_OPTIMIZATION_ENABLE_OTHER_OPTIMIZATIONS} CACHE BOOL "" FORCE) endif () +if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -stdlib=libc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++ -lc++abi") +endif () + include(src/CMakeLists.txt) ########################################################################################## diff --git a/Jenkinsfile b/Jenkinsfile index 20f10f29c0..9b09fc4eb4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -100,8 +100,10 @@ linux: { gitHelper.checkoutGit(url, branch); } stage('linux/build') { + def cmakeBuildingOptionLinux = moduleMakeFlags() + cmakeBuildingOptionLinux += '-DMAKE_BUILD_TYPE=Release' // Not sure why the linking of OpenSpaceTest takes so long - compileHelper.build(compileHelper.Make(), compileHelper.Gcc(), moduleCMakeFlags(), 'OpenSpace', 'build-all'); + compileHelper.build(compileHelper.Make(), compileHelper.Gcc(), cmakeBuildingOptionLinux, 'OpenSpace', 'build-all'); } stage('linux/warnings') { // compileHelper.recordCompileIssues(compileHelper.Gcc()); diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 3d3835c38c..ae6837af80 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 3d3835c38c8b87972f406ed44af1b5b2d48b1600 +Subproject commit ae6837af80f9ab0d3849c96808c609cc1692ddb8 diff --git a/data/assets/base.asset b/data/assets/base.asset index 19c73d5fd5..e83c6a9cf8 100644 --- a/data/assets/base.asset +++ b/data/assets/base.asset @@ -23,6 +23,8 @@ asset.require('scene/milkyway/milkyway/volume') asset.require('scene/milkyway/constellations/constellation_art') asset.require('scene/milkyway/constellations/constellation_keybinds') +assetHelper.requireAll(asset, 'scene/milkyway/exoplanets') + assetHelper.requireAll(asset, 'scene/digitaluniverse') -- Load default key bindings applicable to most scenes diff --git a/data/assets/scene/milkyway/constellations/constellation_art.asset b/data/assets/scene/milkyway/constellations/constellation_art.asset index a8a3871ffd..c77fa2e29f 100644 --- a/data/assets/scene/milkyway/constellations/constellation_art.asset +++ b/data/assets/scene/milkyway/constellations/constellation_art.asset @@ -5,11 +5,11 @@ local images = asset.syncedResource({ Name = "Constellation Images", Type = "HttpSynchronization", Identifier = "constellation_images", - Version = 1 + Version = 2 }) --function that reads the file -local createConstellations = function (guiPath, constellationfile) +local createConstellations = function (baseIdentifier, guiPath, constellationfile) local genConstellations = {}; --skip the first line local notFirstLine = false; @@ -33,7 +33,8 @@ local createConstellations = function (guiPath, constellationfile) group = (group == '' and globe or group) local aconstellation = { - Identifier = guiPath .. '-' .. name, + -- Identifier = guiPath .. '-' .. name, + Identifier = baseIdentifier .. '-' .. abbreviation, Parent = transforms.SolarSystemBarycenter.Identifier, Transform = { Translation = { @@ -83,7 +84,7 @@ local nodes = {} asset.onInitialize(function () local constellationsCSV = images .. "/constellation_data.csv" - nodes = createConstellations('Constellation Art', constellationsCSV) + nodes = createConstellations('ConstellationArt', 'Constellation Art', constellationsCSV) for _, n in ipairs(nodes) do openspace.addSceneGraphNode(n); end diff --git a/data/assets/scene/milkyway/constellations/constellation_data.csv b/data/assets/scene/milkyway/constellations/constellation_data.csv deleted file mode 100644 index 7c02f310de..0000000000 --- a/data/assets/scene/milkyway/constellations/constellation_data.csv +++ /dev/null @@ -1,85 +0,0 @@ -Data about Constellations columns are: group, name, x, y, z, scale, imageName, rotX, rotY, rotZ, centerStar -normal,Ori,Orion,-550.8742,-259.3621,-188.9620,1.5,Ori.png,1.128407,1.058407,1.668407,HD37128 -zodiac,Tau,Taurus,-18.7277,-0.3175,-6.9092,1.2,Tau.png,1.198407,0.908407,1.378407,Aldebran -zodiac,Ari,Aries,-13.2892,9.4519,-11.9378,0.8,Ari.png,0.668407,0.538407,0.518407,Hamal -zodiac,Gem,Gemini,-362.5493,-102.2245,79.4030,0.85,Gem.png,-0.731593,2.268407,-0.451593,Mekbuda -zodiac,Cnc,Cancer,-30.9209,-16.4584,22.6601,0.8,Cnc.png,-1.151593,1.888407,-1.041593,HD74442 -zodiac,Leo,Leo,-17.9030,-13.2719,31.4196,1.33,Leo.png,-0.131593,2.448407,0.418407,HD89484 -zodiac,Vir,Virgo,36.5809,-35.1877,62.3341,1.5,Vir.png,-0.371593,3.138407,0.518407,HD116658 -zodiac,Lib,Libra,17.5393,-6.2768,14.5916,1.0,Lib.png,-1.011593,3.138407,1.318407,HD130819 -zodiac,Sco,Scorpius,137.4378,-19.4456,37.3606,1.2,Sco.png,1.698407,-1.001593,-1.751593,HD148478 -zodiac,Sgr,Sagittarius,66.2304,11.1498,-14.8095,1.2,Sgr.png,1.728407,-1.321593,-1.751593,HD175191 -zodiac,Cap,Capricornus,32.9799,20.0621,-29.3945,1.3,Cap.png,1.158407,-0.881593,-0.561593,HD200761 -zodiac,Aqr,Aquarius,86.5090,149.4078,-155.8102,1.2,Aqr.png,-2.921593,-2.391593,-2.551593,-2.511593 -zodiac,Psc,Pisces,-28.0235,45.3150,-76.8893,1.6,Psc.png,0.458407,-0.001593,0.618407,HD4656 -northern,Uma,Ursa Major,-12.0503,7.1931,19.8974,1.6,UMa.png,0.748407,2.398407,0.658407,HD95418 -northern,Dra,Draco,-1.4340,20.6566,23.5098,1.9,Dra.png,0.658407,-2.541593,1.058407,HD137759 -southern,Ant,Antila,-0.2233,-103.8908,42.7940,1.3,Ant.png,1.848407,0.198407,-3.141593,HD90610 -southern,Crv,Corvus,8.0442,-16.8858,19.3984,1.1,Crv.png,2.198407,-0.041593,-2.221593,HD108767 -southern,Cet,Cetus,-28.7960,7.2425,-73.6693,1.5,Cet.png,0.238407,0.368407,0.688407,HD11353 -southern,Cha,Chameleon,53.5121,-108.3624,-38.1807,1.1,Cha.png,-1.801593,2.738407,0.448407,HD92305 -northern,Cam,Camelopardalis,-304.8155,179.0620,71.1454,1.7,Cam.png,2.128407,1.228407,1.478407,HD31910 -equatorial,Aql,Aquila,11.7741,9.7467,-1.6418,1.0,Aql.png,-2.601593,-2.511593,-3.141593,HD182640 -southern,Aps,Apus,31.6370,-32.5620,-16.5786,1.1,Aps.png,-1.691593,-2.281593,0.838407,HD149324 -northern,Lyn,Lynx,-98.3174,4.4830,67.2289,1.2,Lyn.png,1.688407,1.768407,1.668407,HD70272 -southern,Phe,Phoenix,5.0172,-4.2096,-22.8088,1.5,Phe.png,-3.141593,3.138407,-3.141593,HD6595 -northern,Cyg,Cygnus,78.7445,375.2440,12.4995,1.4,Cyg.png,1.668407,-0.931593,-0.261593,HD194093 -southern,Cen,Centaurus,20.1398,-33.1830,9.5915,2.7,Cen.png,-1.291593,3.088407,0.458407,HD110304 -northern,Aur,Auriga,-12.3062,3.8595,1.0302,1.5,Aur.png,1.378407,1.108407,1.178407,HD34029 -northern,Peg,Pegasus,0.9791,32.5947,-27.7339,2.42,Peg.png,0.918407,-0.221593,-0.191593,HD218045 -southern,Hya,Hydra,-2.9043,-33.5496,25.8962,3,Hya.png,-0.531593,2.838407,0.368407,HD93813 -southern,Oct,Octans,22.0434,-27.8601,-24.3108,1.0,Oct.png,-0.911593,0.398407,1.198407,HD214846 -southern,Nor,Norma,34.9251,-17.5643,0.0068,1.0,Nor.png,-1.631593,-2.421593,1.298407,HD146686 -southern,Mus,Musca,48.8888,-79.2952,-10.2828,1.25,Mus.png,-1.871593,3.138407,0.358407,HD109668 -southern,Hyi,Hydrus,3.2767,-4.7183,-4.7829,1.1,Hyi.png,2.438407,-3.141593,-2.381593,HD2151 -northern,Lac,Lacerta,-6.0878,30.5794,-3.6064,1.0,Lac.png,-1.521593,-2.391593,3.138407,HD213558 -equatorial,Lep,Lepus,-212.6297,-184.4909,-132.1156,1.0,Lep.png,-1.801593,-2.351593,-0.861593,HD36673 -southern,Lup,Lupus,129.1166,-102.2983,33.3251,1.2,Lup.png,-1.191593,-2.391593,0.798407,HD129056 -southern,Men,Mensa,2.4149,-8.5586,-4.8892,1.0,Men.png,-2.101593,-2.781593,0.828407,HD43834 -southern,Mic,Microscopium,51.0335,11.1671,-44.3692,1.0,Mic.png,0.728407,-0.831593,-0.561593,HD199951 -equatorial,Mon,Monoceros,-93.0725,-66.8909,8.6548,1.2,Mon.png,-1.331593,1.988407,-0.891593,HD55185 -southern,Pav,Pavo,4.4549,-2.5959,-3.2739,1.3,Pav.png,-2.391593,-2.171593,1.648407,HD190248 -southern,Ind,Indus,133.6149,-53.5569,-115.9552,1.5,Ind.png,-2.031593,-1.491593,1.758407,HD198700 -northern,LMi,Leo Minor,-23.3948,-2.5770,38.0756,1.1,LMi.png,-3.141593,0.478407,-2.201593,HD90537 -northern,Lyr,Lyra,2.8086,6.7630,2.5555,1.0,Lyr.png,-1.831593,-2.091593,3.141500,HD172167 -northern,Her,Hercules,14.0526,14.9773,12.5478,1.3,Her.png,-1.511593,-1.811593,2.288407,HD156164 -southern,Gru,Grus,18.6528,-3.2893,-24.6602,1.3,Gru.png,-3.141593,-2.511593,-2.901593,HD209952 -southern,Crt,Crater,1.5886,-43.9831,40.3390,1.3,Crt.png,-0.521593,3.140000,0.588407,HD98430 -northern,Del,Delphinus,14.8599,24.6150,-8.0550,1.2,Del.png,1.308407,-0.951593,-0.241593,HD196524 -southern,Dor,Dorado,-0.6460,-9.3172,-6.9654,1.2,Dor.png,2.118407,1.768407,-2.901593,HD33262 -northern,Equ,Equuleus,27.7363,41.7071,-27.4371,1.2,Equ.png,-1.801593,-2.511593,2.558407,HD202447 -southern,Eri,Eridanus,-37.5153,-23.5231,-65.6368,2.1,Eri.png,0.128407,0.698407,0.998407,HD20720 -southern,For,Fornax,-14.0351,-17.8282,-46.5514,1.4,For.png,3.138407,2.678407,-2.351593,HD17652 -southern,Hor,Horologium,2.1021,-27.1310,-40.5136,1.2,Hor.png,-3.141593,2.468407,-2.191593,HD16920 -southern,Pyx,Pyxis,-66.7424,-248.9639,26.0445,1.2,Pyx.png,1.838407,-1.651593,2.708407,HD74575 -southern,Ret,Reticulum,2.8130,-37.2904,-33.2644,1.5,Ret.png,1.998407,2.188407,-2.591593,HD27256 -northern,Sge,Sagitta,44.3886,70.9446,-7.6264,1.2,Sge.png,-0.741593,-2.231593,2.108407,HD189319 -southern,Scl,Sculptor,21.6545,-6.8861,-166.5240,1.3,Scl.png,-0.071593,-0.221593,0.638407,HD2429 -southern,Sct,Scutum,48.8939,21.5158,-0.1629,1.2,Sct.png,1.188407,-1.271593,-0.971593,HD171443 -southern,Tuc,Tucana,35.3950,-20.2535,-45.2324,1.1,Tuc.png,-0.351593,-0.161593,0.308407,HD211416 -northern,Tri,Triangulum,-26.6263,21.9119,-16.2254,1.2,Tri.png,1.168407,0.218407,0.558407,HD13161 -southern,TrA,Triangulum Australe,96.2283,-76.4459,-33.5257,1.2,TrA.png,-1.991593,-2.491593,1.128407,HD150798 -southern,Tel,Telescopium,72.3444,-14.5016,-20.0248,1.2,Tel.png,-0.461593,-1.731593,0.298407,HD169467 -southern,Ara,Ara,164.9273,-75.6246,-35.3100,1.1,Ara.png,-1.381593,-2.131593,1.048407,HD157244 -southern,Cae,Caelum,-6.0961,-13.7926,-13.3392,1.0,Cae.png,-0.661593,0.948407,0.418407,HD29875 -southern,CMa,Canis Major,-1.7693,-1.9125,-0.4074,1.3,CMa.png,1.128407,1.048407,1.878407,HD48915 -northern,CMi,Canis Minor,-2.8348,-1.8906,0.7881,1.2,CMi.png,2.538407,1.138407,-3.141593,HD61421 -southern,Vol,Volans,37.6000,-182.7856,-62.6559,1.2,Vol.png,-2.441593,1.988407,-0.351593,HD68520 -northern,UMi,Ursa Minor,-11.3527,27.2100,25.1835,1.3,UMi.png,-2.491593,-0.581593,-2.381593,HD131873 -northern,And,Andromdeda,-32.8276,43.3946,-27.8475,1.6,And.png,-2.021593,-3.141593,-2.521593,HD6860 -northern,Boo,Bootes,11.2468,14.9864,30.4945,2.0,Boo.png,-3.141593,-0.601593,-2.361593,HD135722 -northern,Vul,Vulpecula,46.7540,77.7780,5.3953,1.1,Vul.png,-2.301593,-2.061593,-3.141593,HD131873 -northern,CVn,Canes Venatici,-3.1198,5.7935,33.1368,1.3,CVn.png,0.148407,3.138407,0.428407,HD112413 -southern,Cir,Circinus,11.4255,-11.6937,-1.3129,1.0,Cir.png,1.448407,-0.391593,-2.211593,HD128898 -northern,Com,Coma Berenices,1.9257,-1.2062,12.2465,1.4,Com.png,3.138407,-0.051593,-2.711593,HD114378 -southern,CrA,Corona Australis,146.1322,-4.7492,-53.7124,1.0,CrA.png,-3.141593,-2.021593,-3.141593,HD178345 -northern,CrB,Corona Borealis,33.5737,32.0314,52.9729,1.3,CrB.png,-3.141593,-0.601593,-2.271593,HD143107 -northern,Cas,Cassiopeia,-36.3073,59.4424,-7.6926,1.4,Cas.png,-1.431593,3.128407,-2.331593,HD3712 -northern,Cep,Cepheus,-2.8178,14.4985,2.3848,1.7,Cep.png,-1.331593,-2.291593,-2.931593,HD203280 -southern,Car,Carina Vela Puppis,14.1325,-188.6018,-42.2785,2.0,Car.png,2.078407,1.048407,-3.111593,HD71129 -northern,Col,Columba,-11.2568,-20.5973,-11.9895,1.0,Col.png,2.518407,1.358407,-2.981593,HD39425 -northern,Per,Perseus,-139.8202,79.8063,-16.2631,1.3,Per.png,-1.751593,2.428407,-2.411593,HD22928 -northern,Oph,Ophiuchus,127.9419,14.0822,56.2015,3.2,Oph.png,2.178407,-0.781593,-1.681593,HD149757 -southern,PsA,Piscis Austrinus,99.9977,47.6679,-199.6345,1.0,PsA.png,3.138407,-2.541593,-2.881593,HD214748 -southern,Cru,Crux,49.3509,-85.0446,-0.6223,1.1,Cru.png,1.718407,0.048407,-2.741593,HD108248 -southern,Pic,Pictor,-4.5417,-45.5649,-27.1768,1.0,Pic.png,2.568407,2.138407,-2.081593,HD39523 diff --git a/data/assets/scene/milkyway/constellations/constellation_keybinds.asset b/data/assets/scene/milkyway/constellations/constellation_keybinds.asset index 1799903c53..bfc038703c 100644 --- a/data/assets/scene/milkyway/constellations/constellation_keybinds.asset +++ b/data/assets/scene/milkyway/constellations/constellation_keybinds.asset @@ -4,9 +4,9 @@ local Keybindings = { { Key = "c", Name = "Show Constellation Art", - Command = "openspace.setPropertyValue('Scene.Constellation Art*.Renderable.Opacity', 0);" .. - "openspace.setPropertyValue('Scene.Constellation Art*.Renderable.Enabled', true);" .. - "openspace.setPropertyValue('Scene.Constellation Art*.Renderable.Opacity', 0.1, 2);", + Command = "openspace.setPropertyValue('Scene.ConstellationArt*.Renderable.Opacity', 0);" .. + "openspace.setPropertyValue('Scene.ConstellationArt*.Renderable.Enabled', true);" .. + "openspace.setPropertyValue('Scene.ConstellationArt*.Renderable.Opacity', 0.1, 2);", Documentation = "Enables and fades up constellation art work", GuiPath = "/Rendering", Local = false @@ -14,7 +14,7 @@ local Keybindings = { { Key = "SHIFT+c", Name = "Hide Constellation Art", - Command = "openspace.setPropertyValue('Scene.Constellation Art*.Renderable.Opacity', 0, 2);", + Command = "openspace.setPropertyValue('Scene.ConstellationArt*.Renderable.Opacity', 0, 2);", Documentation = "Fades out constellation artwork", GuiPath = "/Rendering", Local = false @@ -22,7 +22,7 @@ local Keybindings = { { Key = "CTRL+c", Name = "Disable Constellation Art", - Command = "openspace.setPropertyValue('Scene.Constellation Art*.Renderable.Enabled', false);", + Command = "openspace.setPropertyValue('Scene.ConstellationArt*.Renderable.Enabled', false);", Documentation = "Disable constellation artwork", GuiPath = "/Rendering", Local = false diff --git a/data/assets/scene/milkyway/exoplanets/exoplanets_data.asset b/data/assets/scene/milkyway/exoplanets/exoplanets_data.asset new file mode 100644 index 0000000000..b49f091844 --- /dev/null +++ b/data/assets/scene/milkyway/exoplanets/exoplanets_data.asset @@ -0,0 +1,7 @@ +local DataPath = asset.syncedResource({ + Name = "Exoplanet Data Files", + Type = "HttpSynchronization", + Identifier = "exoplanets_data", + Version = 1 +}) +asset.export("DataPath", DataPath) diff --git a/data/assets/scene/milkyway/exoplanets/exoplanets_textures.asset b/data/assets/scene/milkyway/exoplanets/exoplanets_textures.asset new file mode 100644 index 0000000000..287b29d61e --- /dev/null +++ b/data/assets/scene/milkyway/exoplanets/exoplanets_textures.asset @@ -0,0 +1,7 @@ +local TexturesPath = asset.syncedResource({ + Name = "Exoplanet Textures", + Type = "HttpSynchronization", + Identifier = "exoplanets_textures", + Version = 1 +}) +asset.export("TexturesPath", TexturesPath) diff --git a/data/profiles/default.profile b/data/profiles/default.profile index cedf4ad6d7..d9cd9a8631 100644 --- a/data/profiles/default.profile +++ b/data/profiles/default.profile @@ -1,22 +1,30 @@ -#Version -1.0 - -#Asset -base -scene/solarsystem/planets/earth/earth earthAsset -scene/solarsystem/planets/earth/satellites/satellites - -#Property -setPropertyValue {earth_satellites}.Renderable.Enabled false - -#Time -relative -1d - -#Camera -goToGeo earthAsset.Earth.Identifier 58.5877 16.1924 20000000 - -#MarkNodes -Earth -Mars -Moon -Sun +{ + "version": { + "major": 1, + "minor": 0 + }, + "assets": [ + "base", + "scene/solarsystem/planets/earth/earth", + "scene/solarsystem/planets/earth/satellites/satellites" + ], + "properties": [ + { + "type": "setPropertyValue", + "name": "{earth_satellites}.Renderable.Enabled", + "value": "false" + } + ], + "time": { + "type": "relative", + "value": "-1d" + }, + "camera": { + "type": "goToGeo", + "anchor": "Earth", + "latitude": 58.5877, + "longitude": 16.1924, + "altitude": 20000000 + }, + "mark_nodes": [ "Earth", "Mars", "Moon", "Sun" ] +} diff --git a/data/tasks/exoplanets/csvtobin.task b/data/tasks/exoplanets/csvtobin.task new file mode 100644 index 0000000000..1ae7a44c6b --- /dev/null +++ b/data/tasks/exoplanets/csvtobin.task @@ -0,0 +1,12 @@ +local dataFolder = "${BASE}/modules/exoplanets" +return { + { + Type = "ExoplanetsCsvToBinTask", + + InputCSV = dataFolder .. "/exoplanets.csv", + InputSPECK = "${SYNC}/http/digitaluniverse_exoplanets_speck/1/expl.speck", + TeffToBvFile = "${SYNC}/http/exoplanets_data/1/teff_bv.txt", + OutputBIN = dataFolder .. "/exoplanets_data.bin", + OutputLUT = dataFolder .. "/lookup.txt" + } +} diff --git a/data/tasks/sessionRecordConvertExample1.task b/data/tasks/sessionRecordConvertExample1.task new file mode 100644 index 0000000000..2237c462e8 --- /dev/null +++ b/data/tasks/sessionRecordConvertExample1.task @@ -0,0 +1,7 @@ +return { + { + Type = "ConvertRecFormatTask", + InputFilePath = "../../recordings/input", + OutputFilePath = "../../recordings/output" + } +} diff --git a/ext/ghoul b/ext/ghoul index f568acc5fe..bca91804e8 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit f568acc5fee29a5b0c654f183baddcb7a061e7a6 +Subproject commit bca91804e8ef6a78045aee20f09acf7e6925120a diff --git a/include/openspace/interaction/keyframenavigator.h b/include/openspace/interaction/keyframenavigator.h index c78db27cd7..5d98fe412e 100644 --- a/include/openspace/interaction/keyframenavigator.h +++ b/include/openspace/interaction/keyframenavigator.h @@ -50,10 +50,13 @@ public: struct CameraPose { glm::dvec3 position = glm::dvec3(0.0); - glm::quat rotation = glm::quat(1.f, 0.f, 0.f, 0.f); + glm::quat rotation = glm::quat(0.f, 0.f, 0.f, 0.f); std::string focusNode; - float scale; - bool followFocusNodeRotation; + float scale = 1.f; + bool followFocusNodeRotation = false; + + CameraPose() = default; + CameraPose(datamessagestructures::CameraKeyframe&& kf); }; /** diff --git a/include/openspace/interaction/sessionrecording.h b/include/openspace/interaction/sessionrecording.h index 98ceb9b5ff..21b518568f 100644 --- a/include/openspace/interaction/sessionrecording.h +++ b/include/openspace/interaction/sessionrecording.h @@ -33,11 +33,24 @@ namespace openspace::interaction { + class SessionRecording : public properties::PropertyOwner { public: - enum class RecordedDataMode { + inline static const std::string FileHeaderTitle = "OpenSpace_record/playback"; + inline static const std::string HeaderCameraAscii = "camera"; + inline static const std::string HeaderTimeAscii = "time"; + inline static const std::string HeaderScriptAscii = "script"; + inline static const std::string HeaderCommentAscii = "#"; + inline static const char HeaderCameraBinary = 'c'; + inline static const char HeaderTimeBinary = 't'; + inline static const char HeaderScriptBinary = 's'; + inline static const std::string FileExtensionBinary = ".osrec"; + inline static const std::string FileExtensionAscii = ".osrectxt"; + + enum class DataMode { Ascii = 0, - Binary + Binary, + Unknown }; enum class SessionState { @@ -46,6 +59,24 @@ public: Playback }; + struct Timestamps { + double timeOs; + double timeRec; + double timeSim; + }; + + static const size_t FileHeaderVersionLength = 5; + static constexpr char FileHeaderVersion[FileHeaderVersionLength] = { + '0', '0', '.', '8', '5' + }; + static const char DataFormatAsciiTag = 'A'; + static const char DataFormatBinaryTag = 'B'; + static const size_t keyframeHeaderSize_bytes = 33; + static const size_t saveBufferCameraSize_min = 82; + static const size_t saveBufferStringSize_max = 500; + static const size_t _saveBufferMaxSize_bytes = keyframeHeaderSize_bytes + + + saveBufferCameraSize_min + saveBufferStringSize_max; + using CallbackHandle = int; using StateChangeCallback = std::function; @@ -101,7 +132,7 @@ public: * * \return \c true if recording to file starts without errors */ - void setRecordDataFormat(RecordedDataMode dataMode); + void setRecordDataFormat(DataMode dataMode); /** * Used to stop a recording in progress. If open, the recording file will be closed, @@ -215,6 +246,195 @@ public: */ std::vector playbackList() const; + /** + * Reads a camera keyframe from a binary format playback file, and populates input + * references with the parameters of the keyframe. + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a camera keyframe which contains camera details + * \param file an ifstream reference to the playback file being read + * \param lineN keyframe number in playback file where this keyframe resides + */ + static void readCameraKeyframeBinary(Timestamps& times, + datamessagestructures::CameraKeyframe& kf, std::ifstream& file, int lineN); + + /** + * Reads a camera keyframe from an ascii format playback file, and populates input + * references with the parameters of the keyframe. + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a camera keyframe which contains camera details + * \param currentParsingLine string containing the most current line that was read + * \param lineN line number in playback file where this keyframe resides + */ + static void readCameraKeyframeAscii(Timestamps& times, + datamessagestructures::CameraKeyframe& kf, std::string currentParsingLine, + int lineN); + + /** + * Reads a time keyframe from a binary format playback file, and populates input + * references with the parameters of the keyframe. + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a time keyframe which contains time details + * \param file an ifstream reference to the playback file being read + * \param lineN keyframe number in playback file where this keyframe resides + */ + static void readTimeKeyframeBinary(Timestamps& times, + datamessagestructures::TimeKeyframe& kf, std::ifstream& file, int lineN); + + /** + * Reads a time keyframe from an ascii format playback file, and populates input + * references with the parameters of the keyframe. + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a time keyframe which contains time details + * \param currentParsingLine string containing the most current line that was read + * \param lineN line number in playback file where this keyframe resides + */ + static void readTimeKeyframeAscii(Timestamps& times, + datamessagestructures::TimeKeyframe& kf, std::string currentParsingLine, + int lineN); + + /** + * Reads a script keyframe from a binary format playback file, and populates input + * references with the parameters of the keyframe. + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a script keyframe which contains the size of the script + * (in chars) and the text itself + * \param file an ifstream reference to the playback file being read + * \param lineN keyframe number in playback file where this keyframe resides + */ + static void readScriptKeyframeBinary(Timestamps& times, + datamessagestructures::ScriptMessage& kf, std::ifstream& file, int lineN); + + /** + * Reads a script keyframe from an ascii format playback file, and populates input + * references with the parameters of the keyframe. + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a script keyframe which contains the size of the script + * (in chars) and the text itself + * \param currentParsingLine string containing the most current line that was read + * \param lineN line number in playback file where this keyframe resides + */ + static void readScriptKeyframeAscii(Timestamps& times, + datamessagestructures::ScriptMessage& kf, std::string currentParsingLine, + int lineN); + + /** + * Writes a camera keyframe to a binary format recording file using a CameraKeyframe + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a camera keyframe which contains the camera details + * \param kfBuffer a buffer temporarily used for preparing data to be written + * \param file an ofstream reference to the recording file being written-to + */ + static void saveCameraKeyframeBinary(Timestamps times, + datamessagestructures::CameraKeyframe& kf, unsigned char* kfBuffer, + std::ofstream& file); + + /** + * Writes a camera keyframe to an ascii format recording file using a CameraKeyframe + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a camera keyframe which contains the camera details + * \param file an ofstream reference to the recording file being written-to + */ + static void saveCameraKeyframeAscii(Timestamps times, + datamessagestructures::CameraKeyframe& kf, std::ofstream& file); + + /** + * Writes a time keyframe to a binary format recording file using a TimeKeyframe + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a time keyframe which contains the time details + * \param kfBuffer a buffer temporarily used for preparing data to be written + * \param file an ofstream reference to the recording file being written-to + */ + static void saveTimeKeyframeBinary(Timestamps times, + datamessagestructures::TimeKeyframe& kf, unsigned char* kfBuffer, + std::ofstream& file); + + /** + * Writes a time keyframe to an ascii format recording file using a TimeKeyframe + * + * \param times reference to a timestamps structure which contains recorded times + * \param kf reference to a time keyframe which contains the time details + * \param file an ofstream reference to the recording file being written-to + */ + static void saveTimeKeyframeAscii(Timestamps times, + datamessagestructures::TimeKeyframe& kf, std::ofstream& file); + + /** + * Writes a script keyframe to a binary format recording file using a ScriptMessage + * + * \param times reference to a timestamps structure which contains recorded times + * \param sm reference to a ScriptMessage object which contains the script details + * \param smBuffer a buffer temporarily used for preparing data to be written + * \param file an ofstream reference to the recording file being written-to + */ + static void saveScriptKeyframeBinary(Timestamps times, + datamessagestructures::ScriptMessage& sm, unsigned char* smBuffer, + std::ofstream& file); + + /** + * Writes a script keyframe to an ascii format recording file using a ScriptMessage + * + * \param times reference to a timestamps structure which contains recorded times + * \param sm reference to a ScriptMessage which contains the script details + * \param file an ofstream reference to the recording file being written-to + */ + static void saveScriptKeyframeAscii(Timestamps times, + datamessagestructures::ScriptMessage& sm, std::ofstream& file); + + /** + * Reads header information from a session recording file + * + * \param stream reference to ifstream that contains the session recording file data + * \param readLen_chars number of characters to be read, which may be the expected + * length of the header line, or an arbitrary number of characters within it + */ + static std::string readHeaderElement(std::ifstream& stream, size_t readLen_chars); + + /** + * Writes a header to a binary recording file buffer + * + * \param times reference to a timestamps structure which contains recorded times + * \param type single character signifying the keyframe type + * \param kfBuffer the char buffer holding the recording info to be written + * \param idx index into write buffer (this is updated with the num of chars written) + */ + static void saveHeaderBinary(Timestamps times, char type, unsigned char* kfBuffer, + size_t& idx); + + /** + * Writes a header to an ascii recording file buffer + * + * \param times reference to a timestamps structure which contains recorded times + * \param type string signifying the keyframe type + * \param line the stringstream buffer being written to + */ + static void saveHeaderAscii(Timestamps times, const std::string& type, + std::stringstream& line); + + /** + * Saves a keyframe to an ascii recording file + * + * \param entry the ascii string version of the keyframe (any type) + * \param file ofstream object to write to + */ + static void saveKeyframeToFile(std::string entry, std::ofstream& file); + + /** + * Checks if a specified recording file ends with a particular file extension + * + * \param filename the name of the file to record to + * \param extension the file extension to check for + */ + static bool hasFileExtension(std::string filename, std::string extension); + private: properties::BoolProperty _renderPlaybackInformation; @@ -238,25 +458,25 @@ private: double appropriateTimestamp(double timeOs, double timeRec, double timeSim); double equivalentSimulationTime(double timeOs, double timeRec, double timeSim); double equivalentApplicationTime(double timeOs, double timeRec, double timeSim); - - void playbackCamera(); - void playbackTimeChange(); - void playbackScript(); + bool handleRecordingFile(std::string filenameIn); + bool playbackCamera(); + bool playbackTimeChange(); + bool playbackScript(); bool playbackAddEntriesToTimeline(); void signalPlaybackFinishedForComponent(RecordedType type); - void writeToFileBuffer(double src); - void writeToFileBuffer(std::vector& cvec); - void writeToFileBuffer(unsigned char c); - void writeToFileBuffer(bool b); - void saveStringToFile(const std::string& s); - void saveKeyframeToFileBinary(unsigned char* bufferSource, size_t size); void findFirstCameraKeyframeInTimeline(); - void saveKeyframeToFile(std::string entry); + static void saveStringToFile(const std::string& s, unsigned char* kfBuffer, + size_t& idx, std::ofstream& file); + static void saveKeyframeToFileBinary(unsigned char* bufferSource, size_t size, + std::ofstream& file); - void addKeyframe(double timestamp, - interaction::KeyframeNavigator::CameraPose keyframe); - void addKeyframe(double timestamp, datamessagestructures::TimeKeyframe keyframe); - void addKeyframe(double timestamp, std::string scriptToQueue); + bool addKeyframe(double timestamp, + interaction::KeyframeNavigator::CameraPose keyframe, int lineNum); + bool addKeyframe(double timestamp, datamessagestructures::TimeKeyframe keyframe, + int lineNum); + bool addKeyframe(double timestamp, std::string scriptToQueue, int lineNum); + bool addKeyframeToTimeline(RecordedType type, size_t indexIntoTypeKeyframes, + double timestamp, int lineNum); void moveAheadInTime(); void lookForNonCameraKeyframesThatHaveComeDue(double currTime); void updateCameraWithOrWithoutNewKeyframes(double currTime); @@ -276,7 +496,12 @@ private: double getPrevTimestamp(); void cleanUpPlayback(); - RecordedDataMode _recordingDataMode = RecordedDataMode::Binary; + static void writeToFileBuffer(unsigned char* buf, size_t& idx, double src); + static void writeToFileBuffer(unsigned char* buf, size_t& idx, std::vector& cv); + static void writeToFileBuffer(unsigned char* buf, size_t& idx, unsigned char c); + static void writeToFileBuffer(unsigned char* buf, size_t& idx, bool b); + + DataMode _recordingDataMode = DataMode::Binary; SessionState _state = SessionState::Idle; SessionState _lastState = SessionState::Idle; std::string _playbackFilename; @@ -296,14 +521,7 @@ private: double _saveRenderingDeltaTime = 1.0 / 30.0; double _saveRenderingCurrentRecordedTime; - static const size_t keyframeHeaderSize_bytes = 33; - static const size_t saveBufferCameraSize_min = 82; - static const size_t saveBufferStringSize_max = 500; - static const size_t _saveBufferMaxSize_bytes = keyframeHeaderSize_bytes + - + saveBufferCameraSize_min - + saveBufferStringSize_max; unsigned char _keyframeBuffer[_saveBufferMaxSize_bytes]; - size_t _bufferIndex = 0; bool _cleanupNeeded = false; diff --git a/include/openspace/interaction/sessionrecording.inl b/include/openspace/interaction/sessionrecording.inl index 386357c9c5..1d8ca3bcad 100644 --- a/include/openspace/interaction/sessionrecording.inl +++ b/include/openspace/interaction/sessionrecording.inl @@ -55,4 +55,11 @@ T prevKeyframeObj(unsigned int index, const std::vector& keyframeContainer) { } } +template +T readFromPlayback(std::ifstream& stream) { + T res; + stream.read(reinterpret_cast(&res), sizeof(T)); + return res; +} + } // namespace openspace::interaction diff --git a/include/openspace/interaction/tasks/convertrecformattask.h b/include/openspace/interaction/tasks/convertrecformattask.h new file mode 100644 index 0000000000..ba9f4f5ada --- /dev/null +++ b/include/openspace/interaction/tasks/convertrecformattask.h @@ -0,0 +1,68 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_CORE___CONVERTRECFORMATTASK___H__ +#define __OPENSPACE_CORE___CONVERTRECFORMATTASK___H__ + +#include +#include + +#include + +#include + + + +namespace openspace::interaction { + +class ConvertRecFormatTask : public Task { +public: + enum class ConversionDirection { + ToAscii = 0, + ToBinary + }; + ConvertRecFormatTask(const ghoul::Dictionary& dictionary); + ~ConvertRecFormatTask(); + std::string description() override; + void perform(const Task::ProgressCallback& progressCallback) override; + static documentation::Documentation documentation(); + void convert(); + +private: + void convertToAscii(); + void convertToBinary(); + void determineFormatType(); + std::string addFileSuffix(const std::string& filePath, const std::string& suffix); + std::string _inFilePath; + std::string _outFilePath; + std::ifstream _iFile; + std::ofstream _oFile; + SessionRecording::DataMode _fileFormatType; + + std::string _valueFunctionLua; +}; + +} // namespace openspace::interaction + +#endif //__OPENSPACE_CORE___CONVERTRECFORMATTASK___H__ diff --git a/include/openspace/network/messagestructures.h b/include/openspace/network/messagestructures.h index e344a95255..ec27c27dd1 100644 --- a/include/openspace/network/messagestructures.h +++ b/include/openspace/network/messagestructures.h @@ -26,10 +26,13 @@ #define __OPENSPACE_CORE___MESSAGESTRUCTURES___H__ #include +#include #include +#include +#include +#include #include #include -#include namespace openspace::datamessagestructures { @@ -167,6 +170,26 @@ struct CameraKeyframe { out.write(reinterpret_cast(&_timestamp), sizeof(_timestamp)); }; + void write(std::stringstream& out) const { + // Add camera position + out << std::fixed << std::setprecision(7) << _position.x << ' ' + << std::fixed << std::setprecision(7) << _position.y << ' ' + << std::fixed << std::setprecision(7) << _position.z << ' '; + // Add camera rotation + out << std::fixed << std::setprecision(7) << _rotation.x << ' ' + << std::fixed << std::setprecision(7) << _rotation.y << ' ' + << std::fixed << std::setprecision(7) << _rotation.z << ' ' + << std::fixed << std::setprecision(7) << _rotation.w << ' '; + out << std::scientific << _scale << ' '; + if (_followNodeRotation) { + out << "F "; + } + else { + out << "- "; + } + out << _focusNode; + }; + void read(std::istream* in) { // Read position in->read(reinterpret_cast(&_position), sizeof(_position)); @@ -194,6 +217,22 @@ struct CameraKeyframe { // Read timestamp in->read(reinterpret_cast(&_timestamp), sizeof(_timestamp)); }; + + void read(std::istringstream& iss) { + std::string rotationFollowing; + + iss >> _position.x + >> _position.y + >> _position.z + >> _rotation.x + >> _rotation.y + >> _rotation.z + >> _rotation.w + >> _scale + >> rotationFollowing + >> _focusNode; + _followNodeRotation = (rotationFollowing == "F"); + }; }; struct TimeKeyframe { @@ -226,9 +265,35 @@ struct TimeKeyframe { out->write(reinterpret_cast(this), sizeof(TimeKeyframe)); }; + void write(std::stringstream& out) const { + out << ' ' << _dt; + if (_paused) { + out << " P"; + } + else { + out << " R"; + } + if (_requiresTimeJump) { + out << " J"; + } + else { + out << " -"; + } + }; + void read(std::istream* in) { in->read(reinterpret_cast(this), sizeof(TimeKeyframe)); }; + + void read(std::istringstream& iss) { + std::string paused, jump; + + iss >> _dt + >> paused + >> jump; + _paused = (paused == "P"); + _requiresTimeJump = (jump == "J"); + }; }; struct TimeTimeline { @@ -308,6 +373,12 @@ struct ScriptMessage { double _timestamp = 0.0; void serialize(std::vector& buffer) const { + size_t strLen = _script.size(); + size_t writeSize_bytes = sizeof(size_t); + + unsigned char const *p = reinterpret_cast(&strLen); + buffer.insert(buffer.end(), p, p + writeSize_bytes); + buffer.insert(buffer.end(), _script.begin(), _script.end()); }; @@ -319,6 +390,29 @@ struct ScriptMessage { out->write(_script.c_str(), _script.size()); }; + void write(unsigned char* buf, size_t& idx, std::ofstream& file) const { + size_t strLen = _script.size(); + size_t writeSize_bytes = sizeof(size_t); + + unsigned char const *p = reinterpret_cast(&strLen); + memcpy((buf + idx), p, writeSize_bytes); + idx += static_cast(writeSize_bytes); + + memcpy((buf + idx), _script.c_str(), _script.size()); + idx += static_cast(strLen); + file.write(reinterpret_cast(buf), idx); + //Write directly to file because some scripts can be very long + file.write(_script.c_str(), _script.size()); + }; + + void write(std::stringstream& ss) const { + unsigned int numLinesInScript = static_cast( + std::count(_script.begin(), _script.end(), '\n') + ); + ss << ' ' << (numLinesInScript + 1) << ' '; + ss << _script; + } + void read(std::istream* in) { size_t strLen; //Read string length from file @@ -331,6 +425,25 @@ struct ScriptMessage { _script.erase(); _script = temp.data(); }; + + void read(std::istringstream& iss) { + int numScriptLines; + iss >> numScriptLines; + if (numScriptLines < 0) { + numScriptLines = 0; + } + std::string tmpReadbackScript; + _script.erase(); + for (int i = 0; i < numScriptLines; ++i) { + std::getline(iss, tmpReadbackScript); + size_t start = tmpReadbackScript.find_first_not_of(" "); + tmpReadbackScript = tmpReadbackScript.substr(start); + _script.append(tmpReadbackScript); + if (i < (numScriptLines - 1)) { + _script.append("\n"); + } + } + }; }; } // namespace openspace::messagestructures diff --git a/include/openspace/scene/profile.h b/include/openspace/scene/profile.h index c70df31be3..eccf6a0dd7 100644 --- a/include/openspace/scene/profile.h +++ b/include/openspace/scene/profile.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,14 @@ namespace scripting { struct LuaLibrary; } class Profile { public: + struct ParsingError : public ghoul::RuntimeError { + enum class Severity { Info, Warning, Error }; + + explicit ParsingError(Severity severity, std::string msg); + + Severity severity; + }; + // Version struct Version { int major = 0; @@ -47,20 +56,16 @@ public: }; struct Module { std::string name; - std::string loadedInstruction; - std::string notLoadedInstruction; + std::optional loadedInstruction; + std::optional notLoadedInstruction; }; struct Meta { - std::string name; - std::string version; - std::string description; - std::string author; - std::string url; - std::string license; - }; - struct Asset { - std::string path; - std::string name; + std::optional name; + std::optional version; + std::optional description; + std::optional author; + std::optional url; + std::optional license; }; struct Property { enum class SetType { @@ -87,13 +92,13 @@ public: }; Type type; - std::string time; + std::string value; }; struct CameraNavState { static constexpr const char* Type = "setNavigationState"; std::string anchor; - std::string aim; + std::optional aim; std::string referenceFrame; glm::dvec3 position; std::optional up; @@ -109,9 +114,9 @@ public: std::optional altitude; }; using CameraType = std::variant; - + Profile() = default; - Profile(const std::vector& content); + explicit Profile(const std::string& content); std::string serialize() const; std::string convertToScene() const; @@ -147,7 +152,7 @@ private: Version version = CurrentVersion; std::vector modules; std::optional meta; - std::vector assets; + std::vector assets; std::vector properties; std::vector keybindings; std::optional