diff --git a/.gitignore b/.gitignore index c544d58b66..ad419e3265 100644 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,4 @@ data/spice/MAR063.BSP data/spice/de430_1850-2150.bsp data/spice/jup260.bsp data/scene/newhorizons/pluto/plutoprojection/images +data/spice/nh_kernels/ diff --git a/CREDITS b/CREDITS index d29402c4fb..1190a23a66 100644 --- a/CREDITS +++ b/CREDITS @@ -1,6 +1,15 @@ Alexander Bock Joakim Kilby +Emil Axelsson +Jonathas Costa +Niclas Hultberg +Michael Nilsson +Sebastian Piwell +Kalle Bladin +Erik Broberg + Jonas Strandstedt Hans-Christian Helltegen Michal Marcinkowski -Anton Arbring \ No newline at end of file +Anton Arbring +Tomas Forsyth Rosin diff --git a/LICENSE b/LICENSE index adad14bc81..0e48e547cb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014 +Copyright (c) 2014-2016 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 diff --git a/config/flareConfig.txt b/config/flareConfig.txt deleted file mode 100644 index b456a06554..0000000000 --- a/config/flareConfig.txt +++ /dev/null @@ -1,82 +0,0 @@ -# Filenames -# Don't change during runtime -# (Transfer function values can be changed during runtime though) -tsp_filename ${OPENSPACE_DATA}/enlil_64_32_8.tsp -transferfunction_filename ${CONFIG}/transferfunctions/fire.txt - -# Window dimensions -# Don't change during runtime -# NOT USED -win_width 512 -win_height 512 - -# Save screenshots every frame (saved in flare/ folder) 0/1 -take_screenshot 0 - - -# 0 to not clear cache every frame, 1 to clear it -# Used for benchmarking purposes -clear_cache 0 - -# Local kernel work size -# Can't be changed during runtime -local_worksize_x 16 -local_worksize_y 16 - -# Scaling division to make textures smaller -# Saves OpenCL threads -# (A factor of 2 results in half the number of threads per dimension etc) -texture_division_factor 1 - -# Error tolerances -# Use -1 for no tolerance -spatial_error_tolerance -1 -temporal_error_tolerance -1 - -# Calculate error or not (0 no, 1 yes) -calculate_error 0 - -# Step size for TSP probing -# Decrease this if holes appear in the rendering -tsp_traversal_stepsize 0.02 - -# Ray caster constants -raycaster_stepsize 0.005 -raycaster_intensity 1.0 - -# Animation speed -animator_refresh_interval 0.5 - -# Various paths -raycaster_kernel_filename ${KERNELS}/RaycasterTSP.cl -tsp_traversal_kernel_filename ${KERNELS}/TSPTraversal.cl -cube_shader_vert_filename ${SHADERS}/cubeVert.glsl -cube_shader_frag_filename ${SHADERS}/cubeFrag.glsl -quad_shader_vert_filename ${SHADERS}/quadVertFlare.glsl -quad_shader_frag_filename ${SHADERS}/quadFrag.glsl - -# Model -start_pitch -20.0 -start_roll 30.0 -start_yaw 0.0 - -# Automatic pitch/roll/yaw -pitch_speed 0.0 -roll_speed 0.0 -yaw_speed 0.0 - -# View - -# Works well for standalone.xml -translate_x -0.5 -translate_y -0.5 -translate_z -1.0 - -# Navigation -# If mouse motion seems backwards, flip the sign of the roll and/or pitch factors -mouse_pitch_factor -0.05 -mouse_roll_factor 0.05 -zoom_factor 0.35 - - - diff --git a/config/sgct/single.xml b/config/sgct/single.xml index c01c1487d2..c8a26c0f79 100644 --- a/config/sgct/single.xml +++ b/config/sgct/single.xml @@ -4,7 +4,7 @@ - + diff --git a/config/sgct/single_fisheye.xml b/config/sgct/single_fisheye.xml index bb7b8e6d90..893a18a853 100644 --- a/config/sgct/single_fisheye.xml +++ b/config/sgct/single_fisheye.xml @@ -1,7 +1,7 @@ - + diff --git a/data/scene/callisto/callisto.mod b/data/scene/callisto/callisto.mod index 97dfb0362e..3d95a18559 100644 --- a/data/scene/callisto/callisto.mod +++ b/data/scene/callisto/callisto.mod @@ -5,8 +5,8 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_CALLISTO", -- should exist. - Body = "CALLISTO", + Frame = "IAU_CALLISTO", -- should exist. + Body = "CALLISTO", Geometry = { Type = "SimpleSphere", Radius = { 2.631, 6}, diff --git a/data/scene/ceres/ceres.mod b/data/scene/ceres/ceres.mod index c09f0d5cce..2c2406d4a6 100644 --- a/data/scene/ceres/ceres.mod +++ b/data/scene/ceres/ceres.mod @@ -4,10 +4,10 @@ return { Name = "Ceres", Parent = "SolarSystemBarycenter", - Renderable = { + Renderable = { Type = "RenderablePlanet", - Frame = "IAU_CERES", - Body = "CERES", + Frame = "IAU_CERES", + Body = "CERES", Geometry = { Type = "SimpleSphere", Radius = { 6.390, 5 }, @@ -17,18 +17,18 @@ return { Type = "simple", Color = "textures/gray.png", }, - StartTime = "2010 JAN 01 00:00:00", - EndTime = "2018 JAN 22 12:00:00" + StartTime = "2010 JAN 01 00:00:00", + EndTime = "2018 JAN 22 12:00:00" }, - Ephemeris = { + Ephemeris = { Type = "Spice", Body = "CERES", Reference = "GALACTIC", Observer = "SUN", Kernels = { "${OPENSPACE_DATA}/spice/DawnKernels/pck/dawn_ceres_v01.tpc", - "${OPENSPACE_DATA}/spice/DawnKernels/spk/sb_ceres_140724.bsp", - "${OPENSPACE_DATA}/spice/DawnKernels/spk/sb_ceres_110211.bsp", + "${OPENSPACE_DATA}/spice/DawnKernels/spk/sb_ceres_140724.bsp", + "${OPENSPACE_DATA}/spice/DawnKernels/spk/sb_ceres_110211.bsp", } }, Rotation = { @@ -36,34 +36,34 @@ return { Frame = "IAU_CERES", Reference = "GALACTIC" }, - + GuiName = "/Solar/Ceres" }, - --[[ Ceres Trail Module + --[[ Ceres Trail Module { Name = "CeresTrail", Parent = "SolarSystemBarycenter", - Renderable = { + Renderable = { Type = "RenderableTrail", Body = "CERES", - Frame = "GALACTIC", - Observer = "SUN", - - -- 3 Dummy values for compilation: - TropicalOrbitPeriod = 500.0, + Frame = "GALACTIC", + Observer = "SUN", + + -- 3 Dummy values for compilation: + TropicalOrbitPeriod = 500.0, EarthOrbitRatio = 0.2, DayLength = 2, - -- End of Dummy values - - RGB = { 0.7, 0.5, 0.5 }, - Textures = { + -- End of Dummy values + + RGB = { 0.7, 0.5, 0.5 }, + Textures = { Type = "simple", - Color = "textures/glare.png" - }, - StartTime = "2010 JAN 01T00:00:00", - EndTime = "2018 JAN 22 12:00:00" - }, + Color = "textures/glare.png" + }, + StartTime = "2010 JAN 01T00:00:00", + EndTime = "2018 JAN 22 12:00:00" + }, GuiName = "/Solar/CeresTrail" } - --]] + --]] } \ No newline at end of file diff --git a/data/scene/charon/charon.mod b/data/scene/charon/charon.mod index 4f8df43763..4f87e20531 100644 --- a/data/scene/charon/charon.mod +++ b/data/scene/charon/charon.mod @@ -5,8 +5,8 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_CHARON", - Body = "CHARON", + Frame = "IAU_CHARON", + Body = "CHARON", Geometry = { Type = "SimpleSphere", Radius = { 6.035 , 5 }, diff --git a/data/scene/common/common.mod b/data/scene/common/common.mod index 3022f22b87..aa9e0d050c 100644 --- a/data/scene/common/common.mod +++ b/data/scene/common/common.mod @@ -1,11 +1,11 @@ return { - -- Solar System module - { - Name = "SolarSystem", - Parent = "Root", - Ephemeris = { - Type = "Static", - Position = { 0, 0, 0, 0} - } - }, + -- Solar System module + { + Name = "SolarSystem", + Parent = "Root", + Ephemeris = { + Type = "Static", + Position = { 0, 0, 0, 0} + } + }, } \ No newline at end of file diff --git a/data/scene/dawn.scene b/data/scene/dawn.scene index 145d6b9154..b4298f5eb9 100644 --- a/data/scene/dawn.scene +++ b/data/scene/dawn.scene @@ -1,3 +1,35 @@ +function preInitialization() + --[[ + The scripts in this function are executed after the scene is loaded but before the + scene elements have been initialized, thus they should be used to set the time at + which the scene should start and other settings that might determine initialization + critical objects. + ]]-- + + openspace.time.setTime("2011 AUG 06 00:00:00") + dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) +end + +function postInitialization() + --[[ + The scripts in this function are executed after all objects in the scene have been + created and initialized, but before the first render call. This is the place to set + graphical settings for the renderables. + ]]-- + openspace.printInfo("Setting default values") + openspace.setPropertyValue("Sun.renderable.enabled", false) + openspace.setPropertyValue("SunMarker.renderable.enabled", true) + openspace.setPropertyValue("EarthMarker.renderable.enabled", true) + --openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false) + openspace.setPropertyValue("PlutoTrail.renderable.enabled", false) + openspace.setPropertyValue("PlutoTexture.renderable.enabled", false) + + openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55) + openspace.setPropertyValue("MilkyWay.renderable.segments", 50) + + openspace.printInfo("Done setting default values") +end + return { ScenePath = ".", CommonFolder = "common", diff --git a/data/scene/default.scene b/data/scene/default.scene index da737c5c01..65c7e3b609 100644 --- a/data/scene/default.scene +++ b/data/scene/default.scene @@ -1,3 +1,36 @@ +function preInitialization() + --[[ + The scripts in this function are executed after the scene is loaded but before the + scene elements have been initialized, thus they should be used to set the time at + which the scene should start and other settings that might determine initialization + critical objects. + ]]-- + + openspace.time.setTime(openspace.time.currentWallTime()) + dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) +end + +function postInitialization() + --[[ + The scripts in this function are executed after all objects in the scene have been + created and initialized, but before the first render call. This is the place to set + graphical settings for the renderables. + ]]-- + openspace.printInfo("Setting default values") + openspace.setPropertyValue("Sun.renderable.enabled", false) + openspace.setPropertyValue("SunMarker.renderable.enabled", true) + openspace.setPropertyValue("EarthMarker.renderable.enabled", true) + --openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false) + openspace.setPropertyValue("PlutoTrail.renderable.enabled", false) + openspace.setPropertyValue("PlutoTexture.renderable.enabled", false) + + openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55) + openspace.setPropertyValue("MilkyWay.renderable.segments", 50) + + openspace.printInfo("Done setting default values") +end + + return { ScenePath = ".", CommonFolder = "common", @@ -30,4 +63,3 @@ return { --"gridEquatorial", } } - diff --git a/data/scene/default_nh.scene b/data/scene/default_nh.scene index dacd320a0c..c4fa4bbd9e 100644 --- a/data/scene/default_nh.scene +++ b/data/scene/default_nh.scene @@ -1,5 +1,38 @@ UseAccurateNewHorizonsKernels = false +function preInitialization() + --[[ + The scripts in this function are executed after the scene is loaded but before the + scene elements have been initialized, thus they should be used to set the time at + which the scene should start and other settings that might determine initialization + critical objects. + ]]-- + + openspace.time.setTime("2015-07-14T10:00:00.00") + openspace.time.setDeltaTime(0) + dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) +end + +function postInitialization() + --[[ + The scripts in this function are executed after all objects in the scene have been + created and initialized, but before the first render call. This is the place to set + graphical settings for the renderables. + ]]-- + openspace.printInfo("Setting default values") + openspace.setPropertyValue("Sun.renderable.enabled", false) + openspace.setPropertyValue("SunMarker.renderable.enabled", true) + openspace.setPropertyValue("EarthMarker.renderable.enabled", true) + --openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false) + openspace.setPropertyValue("PlutoTrail.renderable.enabled", false) + openspace.setPropertyValue("PlutoTexture.renderable.enabled", false) + + openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55) + openspace.setPropertyValue("MilkyWay.renderable.segments", 50) + + openspace.printInfo("Done setting default values") +end + return { ScenePath = ".", CommonFolder = "common", diff --git a/data/scene/earth/earth.mod b/data/scene/earth/earth.mod index 987ed1f0be..a853ebe9c9 100644 --- a/data/scene/earth/earth.mod +++ b/data/scene/earth/earth.mod @@ -27,7 +27,7 @@ return { Renderable = { Type = "RenderablePlanet", Frame = "IAU_EARTH", - Body = "EARTH", + Body = "EARTH", Geometry = { Type = "SimpleSphere", Radius = { 6.371, 6 }, @@ -36,7 +36,7 @@ return { Textures = { Type = "simple", Color = "textures/earth_bluemarble.jpg", - Night = "textures/earth_night.jpg", + Night = "textures/earth_night.jpg", -- Depth = "textures/earth_depth.png" }, Atmosphere = { @@ -82,7 +82,7 @@ return { Billboard = true, Texture = "textures/marker.png" }, - Ephemeris = { + Ephemeris = { Type = "Static", Position = {0, 0, 0, 5} } diff --git a/data/scene/enlilnh/enlilnh.mod b/data/scene/enlilnh/enlilnh.mod index cfd8de50de..497a9d4439 100644 --- a/data/scene/enlilnh/enlilnh.mod +++ b/data/scene/enlilnh/enlilnh.mod @@ -13,9 +13,9 @@ return { Rotation = {2.1, 0, 0}, Scaling = {1.1, 1.1, 1.1}, ScalingExponent = 12, - Source = "tsp/enlil_nh_128_128_16.tsp", + Source = "tsp/enlil_nh_128_128_16.tsp", TransferFunction = "transferfunctions/fire.txt", - BrickSelector = "tf", + BrickSelector = "tf", }, GuiName = "/Volumes/ENLIL New Horizons" } diff --git a/data/scene/ephemeris/ephemeris.mod b/data/scene/ephemeris/ephemeris.mod index 88652db53f..17fae9e0d1 100644 --- a/data/scene/ephemeris/ephemeris.mod +++ b/data/scene/ephemeris/ephemeris.mod @@ -5,12 +5,12 @@ return { Parent = "Root", Renderable = { Type = "RenderableEphemeris", - Textures = { + Textures = { Type = "simple", - Color = "textures/glare_blue.png", - -- need to add different texture - }, - }, + Color = "textures/glare_blue.png", + -- need to add different texture + }, + }, GuiName = "/Solar/Ephemeris" } } \ No newline at end of file diff --git a/data/scene/europa/europa.mod b/data/scene/europa/europa.mod index 48cc2d45bb..4ddba87974 100644 --- a/data/scene/europa/europa.mod +++ b/data/scene/europa/europa.mod @@ -5,8 +5,8 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_EUROPA", -- should exist. - Body = "EUROPA", + Frame = "IAU_EUROPA", -- should exist. + Body = "EUROPA", Geometry = { Type = "SimpleSphere", Radius = { 1.561, 6}, diff --git a/data/scene/ganymede/ganymede.mod b/data/scene/ganymede/ganymede.mod index 3690f595ca..9daaf1e584 100644 --- a/data/scene/ganymede/ganymede.mod +++ b/data/scene/ganymede/ganymede.mod @@ -5,7 +5,7 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_GANYMEDE", -- should exist. + Frame = "IAU_GANYMEDE", -- should exist. Geometry = { Type = "SimpleSphere", Radius = { 2.631, 6}, diff --git a/data/scene/gridEcliptic/gridEcliptic.mod b/data/scene/gridEcliptic/gridEcliptic.mod index c5a96dc112..3aea1790ae 100644 --- a/data/scene/gridEcliptic/gridEcliptic.mod +++ b/data/scene/gridEcliptic/gridEcliptic.mod @@ -3,23 +3,23 @@ return { { Name = "SphericalGrid", Parent = "Root", - Static = true, + Static = true, Renderable = { Type = "RenderableSphericalGrid", - GridType = "ECLIPJ2000", - GridColor = { 0.4, 0.0, 0.0, 1}, - GridMatrix = { -0.05487554, 0.4941095, -0.8676661 , 0.0, - -0.9938214 , -0.1109906, -0.0003515167, 0.0, - -0.09647644, 0.8622859, 0.4971472 , 0.0, - 0.0 , 0.0 , 0.0 , 1.0 }, - GridSegments = 36, - }, - Ephemeris = { + GridType = "ECLIPJ2000", + GridColor = { 0.4, 0.0, 0.0, 1}, + GridMatrix = { -0.05487554, 0.4941095, -0.8676661 , 0.0, + -0.9938214 , -0.1109906, -0.0003515167, 0.0, + -0.09647644, 0.8622859, 0.4971472 , 0.0, + 0.0 , 0.0 , 0.0 , 1.0 }, + GridSegments = 36, + }, + Ephemeris = { Type = "Static" -- for now, might change. }, - - --[[ - Ephemeris = { + + --[[ + Ephemeris = { Type = "Spice", Body = "EARTH", Reference = "ECLIPJ2000", @@ -27,8 +27,8 @@ return { Kernels = { "kernels/earth.bsp" } - }, - --]] + }, + --]] GuiName = "/Grid/Ecliptic" } } \ No newline at end of file diff --git a/data/scene/gridEquatorial/gridEquatorial.mod b/data/scene/gridEquatorial/gridEquatorial.mod index efcb7d9ca0..e35fdf7ee6 100644 --- a/data/scene/gridEquatorial/gridEquatorial.mod +++ b/data/scene/gridEquatorial/gridEquatorial.mod @@ -3,18 +3,18 @@ return { { Name = "SphericalGrid", Parent = "Root", - Static = true, + Static = true, Renderable = { Type = "RenderableSphericalGrid", - GridType = "ICRF", - GridColor = { 0.0, 0.0, 0.4, 1}, - GridMatrix = { -0.05487554, 0.4941095, -0.8676661, 0.0, - -0.8734371 , -0.4448296, -0.1980764, 0.0, - -0.483835 , 0.7469823, 0.4559838, 0.0, - 0.0 , 0.0 , 0.0 , 1.0 }, - GridSegments = 36, - }, - Ephemeris = { + GridType = "ICRF", + GridColor = { 0.0, 0.0, 0.4, 1}, + GridMatrix = { -0.05487554, 0.4941095, -0.8676661, 0.0, + -0.8734371 , -0.4448296, -0.1980764, 0.0, + -0.483835 , 0.7469823, 0.4559838, 0.0, + 0.0 , 0.0 , 0.0 , 1.0 }, + GridSegments = 36, + }, + Ephemeris = { Type = "Static" -- for now, might change. }, diff --git a/data/scene/gridGalactic/gridGalactic.mod b/data/scene/gridGalactic/gridGalactic.mod index 23558e92d0..95f25afe4f 100644 --- a/data/scene/gridGalactic/gridGalactic.mod +++ b/data/scene/gridGalactic/gridGalactic.mod @@ -3,23 +3,23 @@ return { { Name = "gridGalactic", Parent = "SolarSystem", - Static = true, + Static = true, Renderable = { Type = "RenderableSphericalGrid", - GridType = "GALACTIC", - GridColor = { 0.0, 0.4, 0.4, 1}, - GridMatrix = { 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 }, - GridSegments = 36, - }, - Ephemeris = { + GridType = "GALACTIC", + GridColor = { 0.0, 0.4, 0.4, 1}, + GridMatrix = { 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 }, + GridSegments = 36, + }, + Ephemeris = { Type = "Static" -- for now, might change. }, - - --[[ - Ephemeris = { + + --[[ + Ephemeris = { Type = "Spice", Body = "EARTH", Reference = "ECLIPJ2000", @@ -27,8 +27,8 @@ return { Kernels = { "kernels/earth.bsp" } - }, - --]] + }, + --]] GuiName = "/Grid/Galactic" } } \ No newline at end of file diff --git a/data/scene/imageplane/imageplane.mod b/data/scene/imageplane/imageplane.mod index 028fa58b6a..419e651374 100644 --- a/data/scene/imageplane/imageplane.mod +++ b/data/scene/imageplane/imageplane.mod @@ -1,15 +1,15 @@ return { -- Latest image taken by LORRI - { + { Name = "ImagePlane", Parent = "NewHorizons", Renderable = { Type = "RenderablePlaneProjection", - Frame = "IAU_JUPITER", - DefaultTarget = "JUPITER", - Spacecraft = "NEW HORIZONS", - Instrument = "NH_LORRI", - Moving = false, + Frame = "IAU_JUPITER", + DefaultTarget = "JUPITER", + Spacecraft = "NEW HORIZONS", + Instrument = "NH_LORRI", + Moving = false, Texture = "textures/test.jpg", }, Ephemeris = { @@ -17,17 +17,17 @@ return { Position = {0, 0, 0, 1} }, }, - -- LORRI FoV square - { + -- LORRI FoV square + { Name = "ImagePlane2", Parent = "NewHorizons", Renderable = { Type = "RenderablePlaneProjection", - Frame = "IAU_JUPITER", - DefaultTarget = "JUPITER", - Spacecraft = "NEW HORIZONS", - Instrument = "NH_LORRI", - Moving = true, + Frame = "IAU_JUPITER", + DefaultTarget = "JUPITER", + Spacecraft = "NEW HORIZONS", + Instrument = "NH_LORRI", + Moving = true, Texture = "textures/squarefov.png", }, Ephemeris = { diff --git a/data/scene/io/io.mod b/data/scene/io/io.mod index 717f3e11c9..293e5d2ac4 100644 --- a/data/scene/io/io.mod +++ b/data/scene/io/io.mod @@ -5,8 +5,8 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_IO", -- should exist. - Body = "IO", + Frame = "IAU_IO", -- should exist. + Body = "IO", Geometry = { Type = "SimpleSphere", Radius = { 1.8213, 6 }, @@ -29,7 +29,7 @@ return { Observer = "JUPITER BARYCENTER", Kernels = { --"${OPENSPACE_DATA}/spice/de430_1850-2150.bsp" - "${SPICE}/jup260.bsp", + "${SPICE}/jup260.bsp", } }, Rotation = { diff --git a/data/scene/jupiter/jupiter.mod b/data/scene/jupiter/jupiter.mod index cfbcda68b1..9c7ef970ac 100644 --- a/data/scene/jupiter/jupiter.mod +++ b/data/scene/jupiter/jupiter.mod @@ -3,7 +3,7 @@ return { { Name = "JupiterBarycenter", Parent = "SolarSystemBarycenter", - Ephemeris = { + Ephemeris = { Type = "Spice", Body = "JUPITER BARYCENTER", Reference = "ECLIPJ2000", @@ -11,7 +11,7 @@ return { Kernels = { "${OPENSPACE_DATA}/spice/de430_1850-2150.bsp" } - }, + }, }, -- Jupiter module { @@ -19,8 +19,8 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_JUPITER", - Body = "JUPITER BARYCENTER", + Frame = "IAU_JUPITER", + Body = "JUPITER BARYCENTER", Geometry = { Type = "SimpleSphere", Radius = { 0.71492, 8 }, @@ -36,7 +36,7 @@ return { MieColor = {1.0, 1.0, 1.0} } }, - Ephemeris = { + Ephemeris = { Type = "Static" -- jupiter is at its barycenter }, Rotation = { diff --git a/data/scene/mars/mars.mod b/data/scene/mars/mars.mod index bd6b5f6cb3..003c604e57 100644 --- a/data/scene/mars/mars.mod +++ b/data/scene/mars/mars.mod @@ -14,8 +14,8 @@ return { Parent = "MarsBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_MARS", - Body = "MARS BARYCENTER", + Frame = "IAU_MARS", + Body = "MARS BARYCENTER", Geometry = { Type = "SimpleSphere", Radius = { 6.390, 6 }, diff --git a/data/scene/mercury/mercury.mod b/data/scene/mercury/mercury.mod index 72a9ab46f5..5f2ec68a6c 100644 --- a/data/scene/mercury/mercury.mod +++ b/data/scene/mercury/mercury.mod @@ -14,8 +14,8 @@ return { Parent = "MercuryBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_MERCURY", - Body = "MERCURY", + Frame = "IAU_MERCURY", + Body = "MERCURY", Geometry = { Type = "SimpleSphere", Radius = { 2.440, 6 }, diff --git a/data/scene/neptune/neptune.mod b/data/scene/neptune/neptune.mod index 471583b1a7..a0a55c47f3 100644 --- a/data/scene/neptune/neptune.mod +++ b/data/scene/neptune/neptune.mod @@ -14,8 +14,8 @@ return { Parent = "NeptuneBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_NEPTUNE", - Body = "NEPTUNE BARYCENTER", + Frame = "IAU_NEPTUNE", + Body = "NEPTUNE BARYCENTER", Geometry = { Type = "SimpleSphere", Radius = { 2.4622 , 7 }, diff --git a/data/scene/newhorizons/jupiter/callistoprojection/callistoprojection.mod b/data/scene/newhorizons/jupiter/callistoprojection/callistoprojection.mod index fae2d6575a..3f380d86fb 100644 --- a/data/scene/newhorizons/jupiter/callistoprojection/callistoprojection.mod +++ b/data/scene/newhorizons/jupiter/callistoprojection/callistoprojection.mod @@ -5,8 +5,8 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanetProjection", - Frame = "IAU_CALLISTO", - Body = "CALLISTO", + Frame = "IAU_CALLISTO", + Body = "CALLISTO", Geometry = { Type = "SimpleSphere", Radius = { 1.8213, 6 }, @@ -15,28 +15,28 @@ return { Textures = { Type = "simple", Color = "textures/callisto.jpg", - Project = "textures/defaultProj.png", - Sequencing = "true", + Project = "textures/defaultProj.png", + Sequencing = "true", }, Atmosphere = { Type = "Nishita", -- for example, values missing etc etc MieFactor = 1.0, MieColor = {1.0, 1.0, 1.0} }, - Projection = { - Observer = "NEW HORIZONS", - Target = "CALLISTO", - Aberration = "NONE", - }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, + Projection = { + Observer = "NEW HORIZONS", + Target = "CALLISTO", + Aberration = "NONE", + }, + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, PotentialTargets = { "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" } @@ -67,7 +67,7 @@ return { Billboard = true, Texture = "textures/Callisto-Text.png" }, - Ephemeris = { + Ephemeris = { Type = "Static", Position = {0, -1, 0, 7} } @@ -85,7 +85,7 @@ return { TropicalOrbitPeriod = 80 , EarthOrbitRatio = 0.04, DayLength = 9.9259, - LineFade = 2.0, + LineFade = 2.0, Textures = { Type = "simple", Color = "${COMMON_MODULE}/textures/glare_blue.png", diff --git a/data/scene/newhorizons/jupiter/europaprojection/europaprojection.mod b/data/scene/newhorizons/jupiter/europaprojection/europaprojection.mod index dc6141286c..1d3715f6c7 100644 --- a/data/scene/newhorizons/jupiter/europaprojection/europaprojection.mod +++ b/data/scene/newhorizons/jupiter/europaprojection/europaprojection.mod @@ -5,8 +5,8 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanetProjection", - Frame = "IAU_EUROPA", - Body = "EUROPA", + Frame = "IAU_EUROPA", + Body = "EUROPA", Geometry = { Type = "SimpleSphere", Radius = { 1.8213, 6 }, @@ -15,28 +15,28 @@ return { Textures = { Type = "simple", Color = "textures/europa.jpg", - Project = "textures/defaultProj.png", - Sequencing = "true", + Project = "textures/defaultProj.png", + Sequencing = "true", }, Atmosphere = { Type = "Nishita", -- for example, values missing etc etc MieFactor = 1.0, MieColor = {1.0, 1.0, 1.0} }, - Projection = { - Observer = "NEW HORIZONS", - Target = "EUROPA", - Aberration = "NONE", - }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, + Projection = { + Observer = "NEW HORIZONS", + Target = "EUROPA", + Aberration = "NONE", + }, + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, PotentialTargets = { "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" } @@ -85,7 +85,7 @@ return { TropicalOrbitPeriod = 80 , EarthOrbitRatio = 0.009, DayLength = 9.9259, - LineFade = 2.0, + LineFade = 2.0, Textures = { Type = "simple", Color = "${COMMON_MODULE}/textures/glare_blue.png", diff --git a/data/scene/newhorizons/jupiter/ganymedeprojection/ganymedeprojection.mod b/data/scene/newhorizons/jupiter/ganymedeprojection/ganymedeprojection.mod index 97d1683311..abc0c2ecdc 100644 --- a/data/scene/newhorizons/jupiter/ganymedeprojection/ganymedeprojection.mod +++ b/data/scene/newhorizons/jupiter/ganymedeprojection/ganymedeprojection.mod @@ -5,8 +5,8 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanetProjection", - Frame = "IAU_GANYMEDE", - Body = "GANYMEDE", + Frame = "IAU_GANYMEDE", + Body = "GANYMEDE", Geometry = { Type = "SimpleSphere", Radius = { 1.8213, 6 }, @@ -15,28 +15,28 @@ return { Textures = { Type = "simple", Color = "textures/ganymede.jpg", - Project = "textures/defaultProj.png", - Sequencing = "true", + Project = "textures/defaultProj.png", + Sequencing = "true", }, Atmosphere = { Type = "Nishita", -- for example, values missing etc etc MieFactor = 1.0, MieColor = {1.0, 1.0, 1.0} }, - Projection = { - Observer = "NEW HORIZONS", - Target = "GANYMEDE", - Aberration = "NONE", - }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, + Projection = { + Observer = "NEW HORIZONS", + Target = "GANYMEDE", + Aberration = "NONE", + }, + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, PotentialTargets = { "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" } @@ -85,7 +85,7 @@ return { TropicalOrbitPeriod = 80 , EarthOrbitRatio = 0.018, DayLength = 9.9259, - LineFade = 2.0, + LineFade = 2.0, Textures = { Type = "simple", Color = "${COMMON_MODULE}/textures/glare_blue.png", diff --git a/data/scene/newhorizons/jupiter/ioprojection/ioprojection.mod b/data/scene/newhorizons/jupiter/ioprojection/ioprojection.mod index efab4ba1ea..e956081077 100644 --- a/data/scene/newhorizons/jupiter/ioprojection/ioprojection.mod +++ b/data/scene/newhorizons/jupiter/ioprojection/ioprojection.mod @@ -5,8 +5,8 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanetProjection", - Frame = "IAU_IO", - Body = "IO", + Frame = "IAU_IO", + Body = "IO", Geometry = { Type = "SimpleSphere", Radius = { 1.8213, 6 }, @@ -15,28 +15,28 @@ return { Textures = { Type = "simple", Color = "textures/io.jpg", - Project = "textures/defaultProj.png", - Sequencing = "true", + Project = "textures/defaultProj.png", + Sequencing = "true", }, Atmosphere = { Type = "Nishita", -- for example, values missing etc etc MieFactor = 1.0, MieColor = {1.0, 1.0, 1.0} }, - Projection = { - Observer = "NEW HORIZONS", - Target = "IO", - Aberration = "NONE", - }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, + Projection = { + Observer = "NEW HORIZONS", + Target = "IO", + Aberration = "NONE", + }, + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, PotentialTargets = { "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" } @@ -85,7 +85,7 @@ return { TropicalOrbitPeriod = 100 , EarthOrbitRatio = 0.0045, DayLength = 9.9259, - LineFade = 2.0, + LineFade = 2.0, Textures = { Type = "simple", Color = "${COMMON_MODULE}/textures/glare_blue.png", diff --git a/data/scene/newhorizons/jupiter/jupiterprojection/jupiterprojection.mod b/data/scene/newhorizons/jupiter/jupiterprojection/jupiterprojection.mod index 3da31853b4..5853649995 100644 --- a/data/scene/newhorizons/jupiter/jupiterprojection/jupiterprojection.mod +++ b/data/scene/newhorizons/jupiter/jupiterprojection/jupiterprojection.mod @@ -3,7 +3,7 @@ return { { Name = "JupiterBarycenter", Parent = "SolarSystemBarycenter", - Ephemeris = { + Ephemeris = { Type = "Spice", Body = "JUPITER BARYCENTER", Reference = "ECLIPJ2000", @@ -11,7 +11,7 @@ return { Kernels = { "${OPENSPACE_DATA}/spice/de430_1850-2150.bsp", } - }, + }, }, -- JupiterProjection module { @@ -19,8 +19,8 @@ return { Parent = "JupiterBarycenter", Renderable = { Type = "RenderablePlanetProjection", - Frame = "IAU_JUPITER", - Body = "JUPITER", + Frame = "IAU_JUPITER", + Body = "JUPITER", Geometry = { Type = "SimpleSphere", Radius = { 0.71492, 8 }, @@ -29,71 +29,71 @@ return { Textures = { Type = "simple", Color = "textures/jupiterFlipped_low.jpg", - Project = "textures/lorriTest1.jpg", - Sequencing = "true", + Project = "textures/lorriTest1.jpg", + Sequencing = "true", }, Atmosphere = { Type = "Nishita", -- for example, values missing etc etc MieFactor = 1.0, MieColor = {1.0, 1.0, 1.0} }, - Projection = { - --Sequence = "F:/JupiterFullSequence", - Sequence = "${OPENSPACE_DATA}/scene/newhorizons/jupiter/jupiterprojection/ProjectionsOfInterest", + Projection = { + --Sequence = "F:/JupiterFullSequence", + Sequence = "${OPENSPACE_DATA}/scene/newhorizons/jupiter/jupiterprojection/ProjectionsOfInterest", SequenceType = "image-sequence", - Observer = "NEW HORIZONS", - Target = "JUPITER", - Aberration = "NONE", - }, - 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, - }, + Observer = "NEW HORIZONS", + Target = "JUPITER", + Aberration = "NONE", + }, + 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" } }, - Ephemeris = { - Type = "Static" + Ephemeris = { + Type = "Static" }, Rotation = { @@ -139,5 +139,5 @@ return { }, GuiName = "/Solar/JupiterTrail" } - + } diff --git a/data/scene/newhorizons/newhorizonsfov/newhorizonsfov.mod b/data/scene/newhorizons/newhorizonsfov/newhorizonsfov.mod index 87b3fda155..d6c12a2f94 100644 --- a/data/scene/newhorizons/newhorizonsfov/newhorizonsfov.mod +++ b/data/scene/newhorizons/newhorizonsfov/newhorizonsfov.mod @@ -218,7 +218,7 @@ return { }, GuiName = "/Solar/NH_RALPH_MVIC_METHANE" }, - -- NewHorizonsFov module NH_RALPH_MVIC_NIR + -- NewHorizonsFov module NH_RALPH_MVIC_NIR { Name = "NH_RALPH_MVIC_NIR", Parent = "NewHorizons", @@ -245,7 +245,7 @@ return { }, GuiName = "/Solar/NH_RALPH_MVIC_METHANE" }, - -- NewHorizonsFov module NH_ALICE_AIRGLOW + -- NewHorizonsFov module NH_ALICE_AIRGLOW { Name = "NH_ALICE_AIRGLOW", Parent = "NewHorizons", @@ -272,7 +272,7 @@ return { }, GuiName = "/Solar/NH_ALICE_AIRGLOW" }, - -- NewHorizonsFov module NH_ALICE_SOC + -- NewHorizonsFov module NH_ALICE_SOC { Name = "NH_ALICE_SOC", Parent = "NewHorizons", diff --git a/data/scene/newhorizons/newhorizonspath/newhorizonspath.mod b/data/scene/newhorizons/newhorizonspath/newhorizonspath.mod index d03c0bbcb2..6ebf488e5f 100644 --- a/data/scene/newhorizons/newhorizonspath/newhorizonspath.mod +++ b/data/scene/newhorizons/newhorizonspath/newhorizonspath.mod @@ -8,13 +8,13 @@ return { Body = "NEW HORIZONS", Frame = "GALACTIC", Observer = "SUN", - RGB = { 0.8, 0.7, 0.7 }, - Textures = { + RGB = { 0.8, 0.7, 0.7 }, + Textures = { Type = "simple", - Color = "textures/glare_blue.png", - -- need to add different texture - }, - }, + Color = "textures/glare_blue.png", + -- need to add different texture + }, + }, GuiName = "/Solar/NewHorizonsPath" } } \ No newline at end of file diff --git a/data/scene/newhorizons/newhorizonstrail/newhorizonstrail.mod b/data/scene/newhorizons/newhorizonstrail/newhorizonstrail.mod index a7135a78a4..ac6d22401b 100644 --- a/data/scene/newhorizons/newhorizonstrail/newhorizonstrail.mod +++ b/data/scene/newhorizons/newhorizonstrail/newhorizonstrail.mod @@ -8,16 +8,16 @@ return { Body = "NEW HORIZONS", Frame = "GALACTIC", Observer = "SUN", - RGB = { 0.1,0.01,0.30 }, - TropicalOrbitPeriod = 6330.595 , - EarthOrbitRatio = 0.857, - DayLength = 9.9259, - Textures = { + RGB = { 0.1,0.01,0.30 }, + TropicalOrbitPeriod = 6330.595 , + EarthOrbitRatio = 0.857, + DayLength = 9.9259, + Textures = { Type = "simple", - Color = "textures/glare_blue.png", - -- need to add different texture - }, - }, + Color = "textures/glare_blue.png", + -- need to add different texture + }, + }, GuiName = "/Solar/NewHorizonsTrail" } } \ No newline at end of file diff --git a/data/scene/newhorizons/pluto/charonprojection/charonprojection.mod b/data/scene/newhorizons/pluto/charonprojection/charonprojection.mod index 0f87f05ae9..70ba1533aa 100644 --- a/data/scene/newhorizons/pluto/charonprojection/charonprojection.mod +++ b/data/scene/newhorizons/pluto/charonprojection/charonprojection.mod @@ -16,8 +16,8 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanetProjection", - Frame = "IAU_CHARON", - Body = "CHARON", + Frame = "IAU_CHARON", + Body = "CHARON", Geometry = { Type = "SimpleSphere", Radius = { 6.035 , 5 }, @@ -26,28 +26,28 @@ return { Textures = { Type = "simple", Color = "textures/charon_highres.jpg", - Project = "textures/defaultProj.png", - Sequencing = "true", + Project = "textures/defaultProj.png", + Sequencing = "true", }, Atmosphere = { Type = "Nishita", -- for example, values missing etc etc MieFactor = 1.0, MieColor = {1.0, 1.0, 1.0} }, - Projection = { - Observer = "NEW HORIZONS", - Target = "CHARON", - Aberration = "NONE", - }, - Instrument = { - Name = "NH_LORRI", - Method = "ELLIPSOID", - Aberration = "NONE", - Fovy = 0.2907, - Aspect = 1, - Near = 0.2, - Far = 10000, - }, + Projection = { + Observer = "NEW HORIZONS", + Target = "CHARON", + Aberration = "NONE", + }, + Instrument = { + Name = "NH_LORRI", + Method = "ELLIPSOID", + Aberration = "NONE", + Fovy = 0.2907, + Aspect = 1, + Near = 0.2, + Far = 10000, + }, PotentialTargets = { "PLUTO", "CHARON" @@ -82,18 +82,18 @@ return { Position = {0, -10, 0, 5} } }, - { + { Name = "CharonShadow", Parent = "Charon", Renderable = { Type = "RenderableShadowCylinder", - TerminatorType = "PENUMBRAL", - LightSource = "SUN", - Observer = "NEW HORIZONS", - Body = "CHARON", - BodyFrame = "IAU_CHARON", - MainFrame = "GALACTIC", - Aberration = "NONE", + TerminatorType = "PENUMBRAL", + LightSource = "SUN", + Observer = "NEW HORIZONS", + Body = "CHARON", + BodyFrame = "IAU_CHARON", + MainFrame = "GALACTIC", + Aberration = "NONE", }, Ephemeris = { Type = "Static", diff --git a/data/scene/newhorizons/pluto/hydra/hydra.mod b/data/scene/newhorizons/pluto/hydra/hydra.mod index e6f27bbff5..46b4d774da 100644 --- a/data/scene/newhorizons/pluto/hydra/hydra.mod +++ b/data/scene/newhorizons/pluto/hydra/hydra.mod @@ -15,8 +15,8 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_PLUTO", - Body = "HYDRA", + Frame = "IAU_PLUTO", + Body = "HYDRA", Geometry = { Type = "SimpleSphere", Radius = { 0.53 , 5 }, @@ -83,5 +83,5 @@ return { }, GuiName = "/Solar/HydraTrail" } - + } diff --git a/data/scene/newhorizons/pluto/kerberos/kerberos.mod b/data/scene/newhorizons/pluto/kerberos/kerberos.mod index 75720abde4..382f67bcfd 100644 --- a/data/scene/newhorizons/pluto/kerberos/kerberos.mod +++ b/data/scene/newhorizons/pluto/kerberos/kerberos.mod @@ -15,8 +15,8 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_PLUTO", - Body = "KERBEROS", + Frame = "IAU_PLUTO", + Body = "KERBEROS", Geometry = { Type = "SimpleSphere", Radius = { 0.1 , 5 }, @@ -83,5 +83,5 @@ return { }, GuiName = "/Solar/KerberosTrail" } - + } diff --git a/data/scene/newhorizons/pluto/nix/nix.mod b/data/scene/newhorizons/pluto/nix/nix.mod index 8e56474f56..38f3186226 100644 --- a/data/scene/newhorizons/pluto/nix/nix.mod +++ b/data/scene/newhorizons/pluto/nix/nix.mod @@ -15,8 +15,8 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_PLUTO", - Body = "NIX", + Frame = "IAU_PLUTO", + Body = "NIX", Geometry = { Type = "SimpleSphere", Radius = { 0.45 , 5 }, @@ -83,5 +83,5 @@ return { }, GuiName = "/Solar/NixTrail" } - + } diff --git a/data/scene/newhorizons/pluto/plutoprojection/plutoprojection.mod b/data/scene/newhorizons/pluto/plutoprojection/plutoprojection.mod index 1e2f8a3d17..c61baa4836 100644 --- a/data/scene/newhorizons/pluto/plutoprojection/plutoprojection.mod +++ b/data/scene/newhorizons/pluto/plutoprojection/plutoprojection.mod @@ -28,8 +28,8 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanetProjection", - Frame = "IAU_PLUTO", - Body = "PLUTO", + Frame = "IAU_PLUTO", + Body = "PLUTO", Geometry = { Type = "SimpleSphere", Radius = { 1.173 , 6 }, @@ -41,116 +41,116 @@ return { Color = "textures/Shenk_180.jpg", -- Color = "textures/pluto_large.jpg", -- Color = "textures/white.png", - Project = "textures/3.jpg", - Sequencing = "true", + Project = "textures/3.jpg", + Sequencing = "true", }, Atmosphere = { Type = "Nishita", -- for example, values missing etc etc MieFactor = 1.0, MieColor = {1.0, 1.0, 1.0} }, - Projection = { - Sequence = "${OPENSPACE_DATA}/scene/newhorizons/pluto/plutoprojection/images", - EventFile = "${OPENSPACE_DATA}/scene/newhorizons/pluto/plutoprojection/assets/core_v9h_obs_getmets_v8_time_fix_nofrcd_mld.txt", + Projection = { + Sequence = "${OPENSPACE_DATA}/scene/newhorizons/pluto/plutoprojection/images", + EventFile = "${OPENSPACE_DATA}/scene/newhorizons/pluto/plutoprojection/assets/core_v9h_obs_getmets_v8_time_fix_nofrcd_mld.txt", SequenceType = "hybrid", - Observer = "NEW HORIZONS", - Target = "PLUTO", - Aberration = "NONE", - }, - 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"}, - }, + Observer = "NEW HORIZONS", + Target = "PLUTO", + Aberration = "NONE", + }, + 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, - }, + }, + 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", + "PLUTO", + "CHARON", + "NIX", + "HYDRA", + "P5", + "P4", } }, Ephemeris = { @@ -167,7 +167,7 @@ return { }, GuiName = "/Solar/Planets/Pluto" }, - { + { Name = "PlutoBarycenterLabel", Parent = "PlutoBarycenter", Renderable = { @@ -201,7 +201,7 @@ return { Position = {0, -20, 0, 5} } }, - { + { Name = "PlutoTexture", Parent = "PlutoProjection", Renderable = { @@ -209,7 +209,7 @@ return { Size = {1.0, 6.4}, Origin = "Center", Billboard = true, - ProjectionListener = true, + ProjectionListener = true, Texture = "textures/Pluto-Text.png" }, Ephemeris = { @@ -217,25 +217,25 @@ return { Position = {0, 0, 40, 5} } }, - { + { Name = "PlutoShadow", Parent = "PlutoProjection", Renderable = { Type = "RenderableShadowCylinder", - TerminatorType = "PENUMBRAL", - LightSource = "SUN", - Observer = "NEW HORIZONS", - Body = "PLUTO", - BodyFrame = "IAU_PLUTO", - MainFrame = "GALACTIC", - Aberration = "NONE", + TerminatorType = "PENUMBRAL", + LightSource = "SUN", + Observer = "NEW HORIZONS", + Body = "PLUTO", + BodyFrame = "IAU_PLUTO", + MainFrame = "GALACTIC", + Aberration = "NONE", }, Ephemeris = { Type = "Static", Position = {0, 0, 0, 5} } }, - -- PlutoBarycentricTrail module + -- PlutoBarycentricTrail module { Name = "PlutoBarycentricTrail", Parent = "PlutoBarycenter", @@ -276,5 +276,5 @@ return { }, }, GuiName = "/Solar/PlutoTrail" - } + } } diff --git a/data/scene/newhorizons/pluto/styx/styx.mod b/data/scene/newhorizons/pluto/styx/styx.mod index 56523e95da..5b49230388 100644 --- a/data/scene/newhorizons/pluto/styx/styx.mod +++ b/data/scene/newhorizons/pluto/styx/styx.mod @@ -15,8 +15,8 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_PLUTO", - Body = "STYX", + Frame = "IAU_PLUTO", + Body = "STYX", Geometry = { Type = "SimpleSphere", Radius = { 0.75 , 4 }, @@ -83,5 +83,5 @@ return { }, GuiName = "/Solar/CharonTrail" } - + } diff --git a/data/scene/planetCoordinates/planetCoordinates.mod b/data/scene/planetCoordinates/planetCoordinates.mod index f3408cacb6..81924709d2 100644 --- a/data/scene/planetCoordinates/planetCoordinates.mod +++ b/data/scene/planetCoordinates/planetCoordinates.mod @@ -3,21 +3,21 @@ return { { Name = "PlanetCoordinates", Parent = "JupiterBarycenter", - Static = true, + Static = true, Renderable = { Type = "RenderableSphericalGrid", - GridType = "GALACTIC", - GridColor = { 0.2, 0.2, 0.2, 1}, - ParentsRotation = "IAU_JUPITER", - GridSegments = 36, - GridRadius = { 0.72, 8 }, - }, - Ephemeris = { + GridType = "GALACTIC", + GridColor = { 0.2, 0.2, 0.2, 1}, + ParentsRotation = "IAU_JUPITER", + GridSegments = 36, + GridRadius = { 0.72, 8 }, + }, + Ephemeris = { Type = "Static" -- for now, might change. }, - - --[[ - Ephemeris = { + + --[[ + Ephemeris = { Type = "Spice", Body = "EARTH", Reference = "ECLIPJ2000", @@ -25,8 +25,8 @@ return { Kernels = { "kernels/earth.bsp" } - }, - --]] + }, + --]] GuiName = "/Grid/Galactic" } } \ No newline at end of file diff --git a/data/scene/pluto/pluto.mod b/data/scene/pluto/pluto.mod index 493bb5601f..830e130226 100644 --- a/data/scene/pluto/pluto.mod +++ b/data/scene/pluto/pluto.mod @@ -21,8 +21,8 @@ return { Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_PLUTO", - Body = "PLUTO", + Frame = "IAU_PLUTO", + Body = "PLUTO", Geometry = { Type = "SimpleSphere", Radius = { 1.173 , 6 }, @@ -46,7 +46,7 @@ return { Kernels = { "${OPENSPACE_DATA}/spice/de430_1850-2150.bsp", -- "${OPENSPACE_DATA}/spice/Pluto/EPHEMERIDES/nh_plu017.bsp" - -- "C:/Users/michal/NewHorizons/SPICE/nh_plu017.bsp" + -- "C:/Users/michal/NewHorizons/SPICE/nh_plu017.bsp" } }, Rotation = { @@ -56,7 +56,7 @@ return { }, GuiName = "/Solar/Planets/Pluto" }, - --[[ + --[[ -- PlutoTrail module { Name = "PlutoTrail", diff --git a/data/scene/rosetta.scene b/data/scene/rosetta.scene index d7236b4cfd..abf65265f4 100644 --- a/data/scene/rosetta.scene +++ b/data/scene/rosetta.scene @@ -1,3 +1,35 @@ +function preInitialization() + --[[ + The scripts in this function are executed after the scene is loaded but before the + scene elements have been initialized, thus they should be used to set the time at + which the scene should start and other settings that might determine initialization + critical objects. + ]]-- + + openspace.time.setTime("2011 JUL 28 12:00:00") + dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) +end + +function postInitialization() + --[[ + The scripts in this function are executed after all objects in the scene have been + created and initialized, but before the first render call. This is the place to set + graphical settings for the renderables. + ]]-- + openspace.printInfo("Setting default values") + openspace.setPropertyValue("Sun.renderable.enabled", false) + openspace.setPropertyValue("SunMarker.renderable.enabled", true) + openspace.setPropertyValue("EarthMarker.renderable.enabled", true) + --openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false) + openspace.setPropertyValue("PlutoTrail.renderable.enabled", false) + openspace.setPropertyValue("PlutoTexture.renderable.enabled", false) + + openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55) + openspace.setPropertyValue("MilkyWay.renderable.segments", 50) + + openspace.printInfo("Done setting default values") +end + return { ScenePath = ".", CommonFolder = "common", diff --git a/data/scene/saturn/saturn.mod b/data/scene/saturn/saturn.mod index 7fc7f83d1e..be6e518e22 100644 --- a/data/scene/saturn/saturn.mod +++ b/data/scene/saturn/saturn.mod @@ -14,8 +14,8 @@ return { Parent = "SaturnBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_SATURN", - Body = "SATURN BARYCENTER", + Frame = "IAU_SATURN", + Body = "SATURN BARYCENTER", Geometry = { Type = "SimpleSphere", Radius = { 5.8232, 7 }, diff --git a/data/scene/sun/sun.mod b/data/scene/sun/sun.mod index dbab164127..288335bb39 100644 --- a/data/scene/sun/sun.mod +++ b/data/scene/sun/sun.mod @@ -4,8 +4,8 @@ return { Name = "SolarSystemBarycenter", Parent = "SolarSystem", Ephemeris = { - Type = "Static", - }, + Type = "Static", + }, }, -- Sun module @@ -14,8 +14,8 @@ return { Parent = "SolarSystemBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_SUN", - Body = "SUN", + Frame = "IAU_SUN", + Body = "SUN", Geometry = { Type = "SimpleSphere", Radius = { 2.783200, 9 }, @@ -72,7 +72,7 @@ return { Billboard = true, Texture = "textures/marker.png" }, - Ephemeris = { + Ephemeris = { Type = "Static", Position = {0, 0, 0, 5} } diff --git a/data/scene/uranus/uranus.mod b/data/scene/uranus/uranus.mod index b1cade2a15..473fe725b7 100644 --- a/data/scene/uranus/uranus.mod +++ b/data/scene/uranus/uranus.mod @@ -14,8 +14,8 @@ return { Parent = "UranusBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_URANUS", - Body = "URANUS BARYCENTER", + Frame = "IAU_URANUS", + Body = "URANUS BARYCENTER", Geometry = { Type = "SimpleSphere", Radius = { 2.5362 , 7 }, diff --git a/data/scene/venus/venus.mod b/data/scene/venus/venus.mod index faca7a5467..753e164b55 100644 --- a/data/scene/venus/venus.mod +++ b/data/scene/venus/venus.mod @@ -14,8 +14,8 @@ return { Parent = "VenusBarycenter", Renderable = { Type = "RenderablePlanet", - Frame = "IAU_VENUS", - Body = "VENUS", + Frame = "IAU_VENUS", + Body = "VENUS", Geometry = { Type = "SimpleSphere", Radius = { 3.760, 6 }, diff --git a/ext/ghoul b/ext/ghoul index ef1063b4af..960bf261b1 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit ef1063b4afb99826e7c254b2e7f9ed79f5bd600c +Subproject commit 960bf261b1e980ee56ba2300e7d58a1bfdb3b696 diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 891e8c795b..6aa13c20a4 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -104,7 +104,7 @@ public: void enableBarrier(); void disableBarrier(); - void runSettingsScripts(); + void runPostInitializationScripts(const std::string& sceneDescription); private: OpenSpaceEngine(std::string programName, std::unique_ptr windowWrapper); @@ -115,7 +115,7 @@ private: bool loadSpiceKernels(); void loadFonts(); void runScripts(const ghoul::Dictionary& scripts); - void runStartupScripts(); + void runPreInitializationScripts(const std::string& sceneDescription); void configureLogging(); // Components diff --git a/kernels/Raycaster.cl b/kernels/Raycaster.cl deleted file mode 100644 index 98474ced33..0000000000 --- a/kernels/Raycaster.cl +++ /dev/null @@ -1,202 +0,0 @@ -// Needs to mirror struct on host -struct KernelConstants { - float stepSize; - float intensity; - int aDim; - int bDim; - int cDim; -}; - - -// Turn normalized [0..1] coordinates into array index -int CoordsToIndex(float3 _coordinates, - int3 _dimensions) { - // Put coords in [0 .. dim-1] range - int x = (float)(_dimensions.x-1) * _coordinates.x; - int y = (float)(_dimensions.y-1) * _coordinates.y; - int z = (float)(_dimensions.z-1) * _coordinates.z; - // Return index - return x + y*_dimensions.x + z*_dimensions.x*_dimensions.y; -} - - -// Linearly interpolate between two values. Distance -// is assumed to be normalized. -float Lerp(float _v0, float _v1, float _d) { - return _v0*(1.0 - _d) + _v1*_d; -} - -// Sample a volume given spherical integer coordinates -float Sample(__global __read_only float *_data, - int3 _coords, - int3 _dims) { - - int r = (_coords.x < _dims.x) ? _coords.x : _dims.x-1; - int t = (_coords.y < _dims.y) ? _coords.y : _dims.y-1; - int p = (_coords.z < _dims.z) ? _coords.z : _dims.z-1; - int idx = r + t*_dims.x + p*_dims.x*_dims.y; - return _data[idx]; -} - -// Trilinear interpolation and sampling -float Trilerp(__global __read_only float *_data, - float3 _spherical, - int3 _dims) { - - // TODO fix wrap issue - // Get coordinates in [0..dim-1] range - float r = (float)(_dims.x-1) * _spherical.x; - float t = (float)(_dims.y-1) * _spherical.y; - float p = (float)(_dims.z-1) * _spherical.z; - - // Lower values - int r0 = (int)floor(r); - int t0 = (int)floor(t); - int p0 = (int)floor(p); - - // Upper values - int r1 = r0+1; - int t1 = t0+1; - int p1 = p0+1; - - // Interpolation values - float dr = r - floor(r); - float dt = t - floor(t); - float dp = p - floor(p); - - // Sample corners - float v000 = Sample(_data, (int3)(r0, t0, p0), _dims); - float v100 = Sample(_data, (int3)(r1, t0, p0), _dims); - float v010 = Sample(_data, (int3)(r0, t1, p0), _dims); - float v110 = Sample(_data, (int3)(r1, t1, p0), _dims); - float v001 = Sample(_data, (int3)(r0, t0, p1), _dims); - float v101 = Sample(_data, (int3)(r1, t0, p1), _dims); - float v011 = Sample(_data, (int3)(r0, t1, p1), _dims); - float v111 = Sample(_data, (int3)(r1, t1, p1), _dims); - - // Interpolate - float v00 = Lerp(v000, v100, dr); - float v10 = Lerp(v010, v110, dr); - float v01 = Lerp(v001, v101, dr); - float v11 = Lerp(v011, v111, dr); - float v0 = Lerp(v00, v10, dt); - float v1 = Lerp(v01, v11, dt); - float v = Lerp(v0, v1, dp); - - return min(v, 1.0); -} - - -// Turn normalized [0..1] cartesian coordinates -// to normalized spherical [0..1] coordinates -float3 CartesianToSpherical(float3 _cartesian) { - // Put cartesian in [-1..1] range first - _cartesian = (float3)(-1.0) + 2.0* _cartesian; - float r = length(_cartesian); - float theta, phi; - if (r == 0.0) { - theta = phi = 0.0; - } else { - theta = acos(_cartesian.z/r) / M_PI; - phi = (M_PI + atan2(_cartesian.y, _cartesian.x)) / (2.0*M_PI); - } - r = r / sqrt(3.0); - // Sampler ignores w component - return (float3)(r, theta, phi); -} - -float4 TransferFunction(__global __read_only float *_tf, float _i) { - // TODO remove 512 hard-coded value and change to 1D texture - int i0 = (int)floor(511.0*_i); - int i1 = (i0 < 511) ? i0+1 : i0; - float di = _i - floor(_i); - - float tfr0 = _tf[i0*4+0]; - float tfr1 = _tf[i1*4+0]; - float tfg0 = _tf[i0*4+1]; - float tfg1 = _tf[i1*4+1]; - float tfb0 = _tf[i0*4+2]; - float tfb1 = _tf[i1*4+2]; - float tfa0 = _tf[i0*4+3]; - float tfa1 = _tf[i1*4+3]; - - float tfr = Lerp(tfr0, tfr1, di); - float tfg = Lerp(tfg0, tfg1, di); - float tfb = Lerp(tfb0, tfb1, di); - float tfa = Lerp(tfa0, tfa1, di); - - return (float4)(tfr, tfg, tfb, tfa); -} - -__kernel void -Raycaster(__global __read_only image2d_t _cubeFront, - __global __read_only image2d_t _cubeBack, - __global __write_only image2d_t _output, - __global __read_only float * _voxelData, - __constant struct KernelConstants *_constants, - __global __read_only float *_tf) { - - - int3 dimensions = (int3)(_constants->aDim, - _constants->bDim, - _constants->cDim); - - // Kernel should be launched in 2D with one work item per pixel - int idx = get_global_id(0); - int idy = get_global_id(1); - int2 intCoords = (int2)(idx, idy); - - // Sampler for texture reading - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE; - const sampler_t volumeSampler = CLK_FILTER_LINEAR | - CLK_NORMALIZED_COORDS_TRUE | - CLK_ADDRESS_CLAMP_TO_EDGE; - - // Read from textures - float4 cubeFrontColor = read_imagef(_cubeFront, sampler, intCoords); - float4 cubeBackColor = read_imagef(_cubeBack, sampler, intCoords); - - // Figure out the direction - float3 direction = (cubeBackColor-cubeFrontColor).xyz; - float maxDistance = length(direction); - direction = normalize(direction); - - // Keep track of distance traversed - float traversed = 0.0; - - // Sum colors - float stepSize = _constants->stepSize; - float3 samplePoint = cubeFrontColor.xyz; - float3 spherical; - float4 associatedColor; - float4 color = (float4)(0.0, 0.0, 0.0, 0.0); - - while (traversed < maxDistance) { - spherical = CartesianToSpherical(samplePoint); - - //int index = timestepOffset + CoordsToIndex(spherical, dimensions); - // Get intensity from data - //float i = _voxelData[index]; - float i = Trilerp(_voxelData, spherical, dimensions); - - // Texture stores intensity in R channel - //float i = read_imagef(_voxelData, volumeSampler, spherical).x; - - // Front-to-back compositing - float4 tf = TransferFunction(_tf, i); - color += (1.0 - color.w)*tf; - - // color += (float4)(i, i, i, 1.0); - samplePoint += direction * stepSize; - traversed += stepSize; - } - - // Output - float intensity = _constants->intensity; - color *= intensity*stepSize; - - // Write to image - write_imagef(_output, intCoords, color); - -} - diff --git a/kernels/RaycasterBricks.cl b/kernels/RaycasterBricks.cl deleted file mode 100644 index 278008e32d..0000000000 --- a/kernels/RaycasterBricks.cl +++ /dev/null @@ -1,297 +0,0 @@ -// Needs to mirror struct on host -struct KernelConstants { - float stepSize; - float intensity; - int numBoxesPerAxis; -}; - -// Linearly interpolate between two values. Distance -// is assumed to be normalized. -float Lerp(float _v0, float _v1, float _d) { - return _v0*(1.0 - _d) + _v1*_d; -} - - -// Turn normalized [0..1] cartesian coordinates -// to normalized spherical [0..1] coordinates -float3 CartesianToSpherical(float3 _cartesian) { - // Put cartesian in [-1..1] range first - _cartesian = (float3)(-1.0) + 2.0* _cartesian; - float r = length(_cartesian); - float theta, phi; - if (r == 0.0) { - theta = phi = 0.0; - } else { - theta = acospi(_cartesian.z/r); - phi = (M_PI + atan2(_cartesian.y, _cartesian.x)) / (2.0*M_PI); - } - r = r / native_sqrt(3.0); - // Sampler ignores w component - return (float3)(r, theta, phi); -} - -float4 TransferFunction(__global __read_only float *_tf, float _i) { - // TODO remove hard-coded value and change to 1D texture - int i0 = (int)floor(1023.0*_i); - int i1 = (i0 < 1023) ? i0+1 : i0; - float di = _i - floor(_i); - - float tfr0 = _tf[i0*4+0]; - float tfr1 = _tf[i1*4+0]; - float tfg0 = _tf[i0*4+1]; - float tfg1 = _tf[i1*4+1]; - float tfb0 = _tf[i0*4+2]; - float tfb1 = _tf[i1*4+2]; - float tfa0 = _tf[i0*4+3]; - float tfa1 = _tf[i1*4+3]; - - float tfr = Lerp(tfr0, tfr1, di); - float tfg = Lerp(tfg0, tfg1, di); - float tfb = Lerp(tfb0, tfb1, di); - float tfa = Lerp(tfa0, tfa1, di); - - return (float4)(tfr, tfg, tfb, tfa); -} - -// Translates a global volume coordinate [0..1] to a box coordinate, -// given a number of boxes that fit along each axis -int3 BoxCoords(float3 _globalCoords, int _boxesPerAxis) { - int3 boxCoords = convert_int3(floor(_globalCoords * (float)_boxesPerAxis)); - return clamp(boxCoords, (int3)(0, 0, 0), (int3)(_boxesPerAxis-1)); -} - -// Calculate global volume coordinates for the corners of a box, given -// the box's coordinates [0..NumBoxesPerAxis] and the number of boxes -// that fit along each axis -void BoxCorners(int3 _boxCoords, float3 *_minCorner, float3 *_maxCorner, - int _boxesPerAxis) { - // TODO figure out a better way to handle offsets - *_minCorner = convert_float3(_boxCoords) / (float)_boxesPerAxis + - (float3)(0.00001); - *_maxCorner = convert_float3((_boxCoords+1)) / (float)_boxesPerAxis - - (float3)(0.00001); -} - - -// Intersect a ray specifiec by origin and direction -// with a box specified by opposing corners. -// Returns intersect/no intersect along with t values -// for intersections points. -bool IntersectBox(float3 _boundsMin, float3 _boundsMax, - float3 _rayO, float3 _rayD, - float *_tMinOut, float *_tMaxOut) { - - float _tMin, _tMax, tYMin, tYMax, tZMin, tZMax; - float divx = 1.0/_rayD.x; - if (divx >= 0.0) { - _tMin = (_boundsMin.x - _rayO.x) * divx; - _tMax = (_boundsMax.x - _rayO.x) * divx; - } else { - _tMin = (_boundsMax.x - _rayO.x) * divx; - _tMax = (_boundsMin.x - _rayO.x) * divx; - } - float divy = 1.0/_rayD.y; - if (divy >= 0.0) { - tYMin = (_boundsMin.y - _rayO.y) * divy; - tYMax = (_boundsMax.y - _rayO.y) * divy; - } else { - tYMin = (_boundsMax.y - _rayO.y) * divy; - tYMax = (_boundsMin.y - _rayO.y) * divy; - } - if ( (_tMin > tYMax || tYMin > _tMax) ) return false; - if (tYMin > _tMin) _tMin = tYMin; - if (tYMax < _tMax) _tMax = tYMax; - float divz = 1.0/_rayD.z; - if (divz >= 0.0) { - tZMin = (_boundsMin.z - _rayO.z) * divz; - tZMax = (_boundsMax.z - _rayO.z) * divz; - } else { - tZMin = (_boundsMax.z - _rayO.z) * divz; - tZMax = (_boundsMin.z - _rayO.z) * divz; - } - if ( (_tMin > tZMax || tZMin > _tMax) ) return false; - if (tZMin > _tMin) _tMin = tZMin; - if (tZMax < _tMax) _tMax = tZMax; - *_tMinOut = _tMin; - *_tMaxOut = _tMax; - return ( (_tMin < 1e20 && _tMax > -1e20 ) ); -} - - -int3 BrickAtlasCoords(int3 _boxCoords, - __global int *_boxList, - int _numBoxesPerAxis) { - int boxIndex = _boxCoords.x + - _boxCoords.y*_numBoxesPerAxis + - _boxCoords.z*_numBoxesPerAxis*_numBoxesPerAxis; - int x = _boxList[5*boxIndex+1]; - int y = _boxList[5*boxIndex+2]; - int z = _boxList[5*boxIndex+3]; - return (int3)(x, y, z); -} - - -int BrickSize(int3 _boxCoords, - __global int * _brickList, - int _numBoxesPerAxis) { - int boxIndex = _boxCoords.x + - _boxCoords.y*_numBoxesPerAxis + - _boxCoords.z*_numBoxesPerAxis*_numBoxesPerAxis; - return _brickList[5*boxIndex+4]; -} - - -// Traverse one brick, sampling individual voxels -float4 TraverseBrick(__global __read_only image3d_t _textureAtlas, - __global __read_only float *_tf, - int3 _brickAtlasCoords, int _numBoxesPerAxis, - int _brickSize, float _globalStepSize, - float3 _brickEntry, float3 _brickExit) { - - // Number of bricks of this size for each axix - int numBricksPerAxis = _numBoxesPerAxis/_brickSize; - // Find brick coordinates [0 .. NumBricksPerAxis] - // Also taking brick size into account - int3 brickCoords = BoxCoords(_brickEntry, numBricksPerAxis); - - float numBoxesPerAxisf = (float)_numBoxesPerAxis; - float numBricksPerAxisf = (float)numBricksPerAxis; - - // Calculate local brick entry and exit coordinates [0..1] - float3 localEntryCoords = numBricksPerAxisf * - (_brickEntry - convert_float3(brickCoords)/numBricksPerAxisf); - float3 localExitCoords = numBricksPerAxisf * - (_brickExit - convert_float3(brickCoords)/numBricksPerAxisf); - - // Calculate offset into texture atlas - float3 offset = convert_float3(_brickAtlasCoords)/numBoxesPerAxisf; - float3 atlasEntry = localEntryCoords/numBoxesPerAxisf + offset; - float3 atlasExit = localExitCoords/numBoxesPerAxisf + offset; - - float3 direction = atlasExit - atlasEntry; - float maxDistance = length(atlasExit - atlasEntry); - direction = normalize(direction); - - float localStepSize = _globalStepSize * (float)_brickSize; - float4 color = (float4)(0.0, 0.0, 0.0, 0.0); - float traversed = 0.0; - float3 samplePoint = atlasEntry; - float4 spherical; - const sampler_t atlasSampler = CLK_FILTER_LINEAR | - CLK_NORMALIZED_COORDS_TRUE | - CLK_ADDRESS_CLAMP_TO_EDGE; - - while (traversed < maxDistance) { - spherical.xyz = CartesianToSpherical(samplePoint); - spherical.w = 1.0; - - // Texture stores intensity in R channel - float i = read_imagef(_textureAtlas, atlasSampler, spherical).x; - - // Front-to-back compositing - float4 tf = TransferFunction(_tf, i); - color += (1.0 - color.w)*tf; - - traversed += localStepSize; - samplePoint += localStepSize * direction; - - } - - return color; -} - - -__kernel void -Raycaster(__global __read_only image2d_t _cubeFront, - __global __read_only image2d_t _cubeBack, - __global __write_only image2d_t _output, - __global __read_only image3d_t _textureAtlas, - __constant struct KernelConstants *_constants, - __global __read_only float *_tf, - __global int *_brickList) { - - // Kernel should be launched in 2D with one work item per pixel - int idx = get_global_id(0); - int idy = get_global_id(1); - int2 intCoords = (int2)(idx, idy); - - // Sampler for texture reading - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE; - - // Read from textures - float4 cubeFrontColor = read_imagef(_cubeFront, sampler, intCoords); - float4 cubeBackColor = read_imagef(_cubeBack, sampler, intCoords); - - // Figure out the direction - float3 direction = (cubeBackColor-cubeFrontColor).xyz; - float maxDistance = length(direction); - direction = normalize(direction); - float3 origin = cubeFrontColor.xyz - 0.001 * direction; - - - // Keep track of distance traversed - float traversed = 0.0; - - // Sum colors - float stepSize = _constants->stepSize; - float3 samplePoint = cubeFrontColor.xyz; - float4 color = (float4)(0.0, 0.0, 0.0, 0.0); - - // TODO temp - float a, b; - if (IntersectBox((float3)(0.0), (float3)(1.0), origin, direction, &a, &b)) { - color += (float4)(0.0, 0.0, 0.08, 1.0); - } - - while (traversed < maxDistance) { - - int numBoxesPerAxis = _constants->numBoxesPerAxis; - - // Convert the sample point to coords - int3 boxCoords = BoxCoords(samplePoint, numBoxesPerAxis); - // Lookup brick coords and size - int3 brickAtlasCoords = BrickAtlasCoords(boxCoords, - _brickList, - numBoxesPerAxis); - int brickSize = BrickSize(boxCoords, _brickList, numBoxesPerAxis); - - // Calculate the box's corners - float3 minCorner, maxCorner; - BoxCorners(boxCoords, &minCorner, &maxCorner, numBoxesPerAxis); - - // Intersect ray with box - float tMin, tMax; - IntersectBox(minCorner, maxCorner, origin, direction, &tMin, &tMax); - - float3 brickEntry = origin + tMin*direction; - // TODO calculate BRICK exit - float3 brickExit = origin + tMax*direction; - float brickDist = length(brickExit - brickEntry); - - // Traverse brick - float4 brickColor = TraverseBrick(_textureAtlas, _tf, - brickAtlasCoords, numBoxesPerAxis, - brickSize, stepSize, - brickEntry, brickExit); - - // Compositing - color += (1.0 - brickColor.w)*brickColor; - - // Advance ray - samplePoint = brickExit; - traversed += brickDist; - - // color += (float4)(i, i, i, 1.0); - samplePoint += direction * stepSize; - traversed += stepSize; - } - - // Output - float intensity = _constants->intensity; - color *= intensity*stepSize; - - // Write to image - write_imagef(_output, intCoords, color); - -} - diff --git a/kernels/RaycasterTSP.cl b/kernels/RaycasterTSP.cl deleted file mode 100644 index de239b4c07..0000000000 --- a/kernels/RaycasterTSP.cl +++ /dev/null @@ -1,579 +0,0 @@ -struct KernelConstants { - int gridType_; - float stepsize_; - float intensity_; - int numTimesteps_; - int numValuesPerNode_; - int numOTNodes_; - int numBoxesPerAxis_; - float temporalTolerance_; - float spatialTolerance_; - int rootLevel_; - int paddedBrickDim_; -}; - -float3 CartesianToSpherical(float3 _cartesian); -float Lerp(float _v0, float _v1, float _d); -int LeftBST(int _bstNodeIndex, int _numValuesPerNode, int _numOTNodes, - bool _bstRoot, __global __read_only int *_tsp); -int RightBST(int _bstNodeIndex, int _numValuesPerNode, int _numOTNodes, - bool _bstRoot, __global __read_only int *_tsp); -int ChildNodeIndex(int _bstNodeIndex, - int *_timespanStart, - int *_timespanEnd, - int _timestep, - int _numValuesPerNode, - int _numOTNodes, - bool _bstRoot, - __global __read_only int *_tsp); -int BrickIndex(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp); -bool IsBSTLeaf(int _bstNodeIndex, int _numValuesPerNode, - bool _bstRoot, __global __read_only int *_tsp); -bool IsOctreeLeaf(int _otNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp); -int OTChildIndex(int _otNodeIndex, int _numValuesPerNode, - int _child, - __global __read_only int *_tsp) ; -float TemporalError(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) ; -float SpatialError(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp); -int3 BoxCoords(float3 _globalCoords, int _boxesPerAxis) ; -int3 AtlasBoxCoords(int _brickIndex, - __global __read_only int *_brickList); -float3 AtlasCoords(float3 _globalCoords, int _brickIndex, int _boxesPerAxis, - int _paddedBrickDim, int _level, - __global __read_only int *_brickList) ; -void SampleAtlas(float4 *_color, float3 _coords, int _brickIndex, - int _boxesPerAxis, int _paddedBrickDim, int _level, - const sampler_t _atlasSampler, - __read_only image3d_t _textureAtlas, - __read_only image2d_t _transferFunction, - const sampler_t _tfSampler, - __global __read_only int *_brickList); -bool TraverseBST(int _otNodeIndex, int *_brickIndex, - __constant __read_only struct KernelConstants *_constants, - __global __read_only int *_tsp, const int _timestep); -int EnclosingChild(float3 _P, float _boxMid, float3 _offset) ; -void UpdateOffset(float3 *_offset, float _boxDim, int _child) ; -float4 TraverseOctree(float3 _rayO, float3 _rayD, float _maxDist, - __read_only image3d_t _textureAtlas, - __constant struct KernelConstants *_constants, - __read_only image2d_t _transferFunction, - __global __read_only int *_tsp, - __global __read_only int *_brickList, - const int _timestep); -__kernel void RaycasterTSP(__read_only image2d_t _cubeFront, - __read_only image2d_t _cubeBack, - __write_only image2d_t _output, - __read_only image3d_t _textureAtlas, - __constant struct KernelConstants *_constants, - __read_only image2d_t _transferFunction, - //__global __read_only float *_transferFunction, - __global __read_only int *_tsp, - __global __read_only int *_brickList, - const int _timestep); - - - -// Turn normalized [0..1] cartesian coordinates -// to normalized spherical [0..1] coordinates -float3 CartesianToSpherical(float3 _cartesian) { - // Put cartesian in [-1..1] range first - _cartesian = (float3)(-1.0) + 2.0f* _cartesian; - float r = length(_cartesian); - float theta, phi; - if (r == 0.0) { - theta = phi = 0.0; - } else { - theta = acospi(_cartesian.z/r); - phi = (M_PI + atan2(_cartesian.y, _cartesian.x)) / (2.0*M_PI); - } - r = r / native_sqrt(3.0f); - // Sampler ignores w component - return (float3)(r, theta, phi); -} - -// Linearly interpolate between two values. Distance -// is assumed to be normalized. -float Lerp(float _v0, float _v1, float _d) { - return _v0*(1.0 - _d) + _v1*_d; -} - -/* -float4 TransferFunction(__global __read_only image2d_t _tf, - const sampler_t _tfSampler, - float _i) { - // TODO remove hard-coded value and change to 1D texture - int i0 = (int)floor(1023.0*_i); - int i1 = (i0 < 1023) ? i0+1 : i0; - float di = _i - floor(_i); - - float tfr0 = _tf[i0*4+0]; - float tfr1 = _tf[i1*4+0]; - float tfg0 = _tf[i0*4+1]; - float tfg1 = _tf[i1*4+1]; - float tfb0 = _tf[i0*4+2]; - float tfb1 = _tf[i1*4+2]; - float tfa0 = _tf[i0*4+3]; - float tfa1 = _tf[i1*4+3]; - - float tfr = Lerp(tfr0, tfr1, di); - float tfg = Lerp(tfg0, tfg1, di); - float tfb = Lerp(tfb0, tfb1, di); - float tfa = Lerp(tfa0, tfa1, di); - - return clamp((float4)(tfr, tfg, tfb, tfa), (float4)(0.0), (float4)(1.0)); - //return (float4)(tfr, tfg, tfb, tfa); - float2 sampleCoords = (float2)(1.0, _i); - return read_imagef(_tf, _tfSampler, sampleCoords); -} -*/ - -/* -// Return index to the octree root (same index as BST root at that OT node) -int OctreeRootNodeIndex() { - return 0; -} -*/ - -// Return index to left BST child (low timespan) -int LeftBST(int _bstNodeIndex, int _numValuesPerNode, int _numOTNodes, - bool _bstRoot, __global __read_only int *_tsp) { - // If the BST node is a root, the child pointer is used for the OT. - // The child index is next to the root. - // If not root, look up in TSP structure. - if (_bstRoot) { - return _bstNodeIndex + _numOTNodes; - } else { - return _tsp[_bstNodeIndex*_numValuesPerNode + 1]; - } -} - -// Return index to right BST child (high timespan) -int RightBST(int _bstNodeIndex, int _numValuesPerNode, int _numOTNodes, - bool _bstRoot, __global __read_only int *_tsp) { - if (_bstRoot) { - return _bstNodeIndex + _numOTNodes*2; - } else { - return _tsp[_bstNodeIndex*_numValuesPerNode + 1] + _numOTNodes; - } -} - -// Return child node index given a BST node, a time span and a timestep -// Updates timespan -int ChildNodeIndex(int _bstNodeIndex, - int *_timespanStart, - int *_timespanEnd, - int _timestep, - int _numValuesPerNode, - int _numOTNodes, - bool _bstRoot, - __global __read_only int *_tsp) { - // Choose left or right child - int middle = *_timespanStart + (*_timespanEnd - *_timespanStart)/2; - if (_timestep <= middle) { - // Left subtree - *_timespanEnd = middle; - return LeftBST(_bstNodeIndex, _numValuesPerNode, _numOTNodes, - _bstRoot, _tsp); - } else { - // Right subtree - *_timespanStart = middle+1; - return RightBST(_bstNodeIndex, _numValuesPerNode, _numOTNodes, - _bstRoot, _tsp); - } -} - -// Return the brick index that a BST node represents -int BrickIndex(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) { - return _tsp[_bstNodeIndex*_numValuesPerNode + 0]; -} - -// Checks if a BST node is a leaf ot not -bool IsBSTLeaf(int _bstNodeIndex, int _numValuesPerNode, - bool _bstRoot, __global __read_only int *_tsp) { - if (_bstRoot) return false; - return (_tsp[_bstNodeIndex*_numValuesPerNode + 1] == -1); -} - -// Checks if an OT node is a leaf or not -bool IsOctreeLeaf(int _otNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) { - // CHILD_INDEX is at offset 1, and -1 represents leaf - return (_tsp[_otNodeIndex*_numValuesPerNode + 1] == -1); -} - -// Return OT child index given current node and child number (0-7) -int OTChildIndex(int _otNodeIndex, int _numValuesPerNode, - int _child, - __global __read_only int *_tsp) { - int firstChild = _tsp[_otNodeIndex*_numValuesPerNode + 1]; - return firstChild + _child; -} - -float TemporalError(int _bstNodeIndex, int _numValuesPerNode, - - __global __read_only int *_tsp) { - return as_float(_tsp[_bstNodeIndex*_numValuesPerNode + 3]); -} - -float SpatialError(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) { - return as_float(_tsp[_bstNodeIndex*_numValuesPerNode + 2]); -} - -// Converts a global coordinate [0..1] to a box coordinate [0..boxesPerAxis] -int3 BoxCoords(float3 _globalCoords, int _boxesPerAxis) { - int3 boxCoords = convert_int3((_globalCoords * (float)_boxesPerAxis)); - return clamp(boxCoords, (int3)(0, 0, 0), (int3)(_boxesPerAxis-1)); -} - -// Fetch atlas box coordinates from brick list -int3 AtlasBoxCoords(int _brickIndex, - __global __read_only int *_brickList) { - int x = _brickList[3*_brickIndex+0]; - int y = _brickList[3*_brickIndex+1]; - int z = _brickList[3*_brickIndex+2]; - return (int3)(x, y, z); -} - -// Convert a global coordinate to a local in-box coordinate, given -// the number of boxes (of this size) per axis and the box coordinates -float3 InBoxCoords(float3 _globalCoords, int3 _boxCoords, - int _boxesPerAxis, int _paddedBrickDim) { - // Calculate [0.0 1.0] box coordinates - float3 inbox = (_globalCoords - convert_float3(_boxCoords)/(float)_boxesPerAxis) - * (float)_boxesPerAxis; - // Map to padding range - float low = 1.0/(float)_paddedBrickDim; - float high = (float)(_paddedBrickDim-1)/(float)_paddedBrickDim; - return (float3)(low) + inbox * ((float3)(high)-(float3)(low)); -} - -float3 AtlasCoords(float3 _globalCoords, int _brickIndex, int _boxesPerAxis, - int _paddedBrickDim, int _level, - __global __read_only int *_brickList) { - - // Use current octree level to calculate dividing factor for coordinates - int divisor = (int)pow(2.0, _level); - - // Calculate box coordinates, taking current subdivision level into account - int3 boxCoords = BoxCoords(_globalCoords, _boxesPerAxis/divisor); - - // Calculate local in-box coordinates for the point - float3 inBoxCoords = InBoxCoords(_globalCoords, boxCoords, - _boxesPerAxis/divisor, - _paddedBrickDim*divisor); - - // Fetch atlas box coordinates - int3 atlasBoxCoords = AtlasBoxCoords(_brickIndex, _brickList); - - // Transform coordinates to atlas coordinates - return inBoxCoords/(float)_boxesPerAxis + - convert_float3(atlasBoxCoords)/(float)_boxesPerAxis; -} - - - -// Sample atlas -void SampleAtlas(float4 *_color, float3 _coords, int _brickIndex, - int _boxesPerAxis, int _paddedBrickDim, int _level, - const sampler_t _atlasSampler, - __read_only image3d_t _textureAtlas, - __read_only image2d_t _transferFunction, - const sampler_t _tfSampler, - __global __read_only int *_brickList) { - - // Find the texture atlas coordinates for the point - float3 atlasCoords = AtlasCoords(_coords, _brickIndex, - _boxesPerAxis, _paddedBrickDim, - _level, _brickList); - - int3 boxCoords = BoxCoords(_coords, _boxesPerAxis); - - float4 a4 = (float4)(atlasCoords.x, atlasCoords.y, atlasCoords.z, 1.0); - // Sample the atlas - float sample = read_imagef(_textureAtlas, _atlasSampler, a4).x; - // Composition - float4 tf = read_imagef(_transferFunction, _tfSampler, (float2)(sample, 0.0)); - *_color += (1.0f - _color->w)*tf; - -} - - -bool TraverseBST(int _otNodeIndex, int *_brickIndex, - __constant __read_only struct KernelConstants *_constants, - __global __read_only int *_tsp, const int _timestep) { - // Start att the root of the current BST - int bstNodeIndex = _otNodeIndex; - bool bstRoot = true; - int timespanStart = 0; - int timespanEnd = _constants->numTimesteps_; - - while (true) { - *_brickIndex = BrickIndex(bstNodeIndex, - _constants->numValuesPerNode_, - _tsp); - - // Check temporal error - if (TemporalError(bstNodeIndex, _constants->numValuesPerNode_, _tsp) <= - _constants->temporalTolerance_) { - - // If the OT node is a leaf, we cannot do any better spatially - if (IsOctreeLeaf(_otNodeIndex, _constants->numValuesPerNode_, _tsp)) { - return true; - - } else if (SpatialError(bstNodeIndex, _constants->numValuesPerNode_, - _tsp) <= _constants->spatialTolerance_) { - return true; - - } else if (IsBSTLeaf(bstNodeIndex, _constants->numValuesPerNode_, - bstRoot, _tsp)) { - return false; - - } else { - - // Keep traversing - bstNodeIndex = ChildNodeIndex(bstNodeIndex, ×panStart, - ×panEnd, - _timestep, - _constants->numValuesPerNode_, - _constants->numOTNodes_, - bstRoot, _tsp); - } - - } else if (IsBSTLeaf(bstNodeIndex, _constants->numValuesPerNode_, - bstRoot, _tsp)) { - return false; - - } else { - - // Keep traversing - bstNodeIndex = ChildNodeIndex(bstNodeIndex, ×panStart, - ×panEnd, - _timestep, - _constants->numValuesPerNode_, - _constants->numOTNodes_, - bstRoot, _tsp); - } - - bstRoot = false; - } -} - - -// Given a point, a box mid value and an offset, return enclosing child -int EnclosingChild(float3 _P, float _boxMid, float3 _offset) { - if (_P.x < _boxMid+_offset.x) { - if (_P.y < _boxMid+_offset.y) { - if (_P.z < _boxMid+_offset.z) { - return 0; - } else { - return 4; - } - } else { - if (_P.z < _boxMid+_offset.z) { - return 2; - } else { - return 6; - } - } - } else { - if (_P.y < _boxMid+_offset.y) { - if (_P.z < _boxMid+_offset.z) { - return 1; - } else { - return 5; - } - } else { - if (_P.z < _boxMid+_offset.z) { - return 3; - } else { - return 7; - } - } - } -} - -void UpdateOffset(float3 *_offset, float _boxDim, int _child) { - if (_child == 0) { - // do nothing - } else if (_child == 1) { - _offset->x += _boxDim; - } else if (_child == 2) { - _offset->y += _boxDim; - } else if (_child == 3) { - _offset->x += _boxDim; - _offset->y += _boxDim; - } else if (_child == 4) { - _offset->z += _boxDim; - } else if (_child == 5) { - _offset->x += _boxDim; - _offset->z += _boxDim; - } else if (_child == 6) { - _offset->y += _boxDim; - _offset->z += _boxDim; - } else if (_child == 7) { - *_offset += (float3)(_boxDim); - } -} - -float4 TraverseOctree(float3 _rayO, float3 _rayD, float _maxDist, - __read_only image3d_t _textureAtlas, - __constant struct KernelConstants *_constants, - __read_only image2d_t _transferFunction, - __global __read_only int *_tsp, - __global __read_only int *_brickList, - const int _timestep) { - - float stepsize = _constants->stepsize_; - // Sample point - float3 cartesianP = _rayO; - // Keep track of distance traveled along ray - float traversed = 0; - // Cumulative color for ray to return - float4 color = (float4)(0.0); - - // Sampler for texture atlas - const sampler_t atlasSampler = CLK_FILTER_LINEAR | - CLK_NORMALIZED_COORDS_TRUE | - CLK_ADDRESS_CLAMP_TO_EDGE; - - - // Sampler for transfer function texture - const sampler_t tfSampler = CLK_FILTER_LINEAR | - CLK_NORMALIZED_COORDS_TRUE | - CLK_ADDRESS_CLAMP_TO_EDGE; - - // Traverse until sample point is outside of volume - while (traversed < _maxDist) { - - // Reset octree traversal variables - float3 offset = (float3)(0.0); - float boxDim = 1.0; - bool foundBrick = false; - int child; - int level = _constants->rootLevel_; - - int otNodeIndex = 0; - - // Rely on finding a leaf for loop termination - while (true) { - - // Traverse BST to get a brick index, and see if the found brick - // is good enough - int brickIndex; - bool bstSuccess = TraverseBST(otNodeIndex, - &brickIndex, - _constants, - _tsp, - _timestep); - - // Convert to spherical if needed - float3 sampleP; - if (_constants->gridType_ == 0) { // cartesian - sampleP = cartesianP; - } else { // spherical ( == 1) - sampleP = CartesianToSpherical(cartesianP); - } - - if (bstSuccess || - IsOctreeLeaf(otNodeIndex, _constants->numValuesPerNode_, _tsp)) { - - //float s = 0.008*SpatialError(brickIndex, 4, _tsp); - //color += (float4)(s); - - - // Sample the brick - SampleAtlas(&color, sampleP, brickIndex, - _constants->numBoxesPerAxis_, - _constants->paddedBrickDim_, - level, - atlasSampler, _textureAtlas, - _transferFunction, - tfSampler, _brickList); - break; - - } else { - - // Keep traversing the octree - - // Next box dimension - boxDim /= 2.0f; - - // Current mid point - float boxMid = boxDim; - - // Check which child encloses the sample point - child = EnclosingChild(sampleP, boxMid, offset); - - // Update offset for next level - UpdateOffset(&offset, boxDim, child); - - // Update index to new node - otNodeIndex = OTChildIndex(otNodeIndex, _constants->numValuesPerNode_, - child, _tsp); - - level--; - - } - - } // while traversing - - // Update sample point - traversed += stepsize; - cartesianP += stepsize * _rayD; - - } // while (traversed < maxDist) - - return color; -} - - -__kernel void RaycasterTSP(__read_only image2d_t _cubeFront, - __read_only image2d_t _cubeBack, - __write_only image2d_t _output, - __read_only image3d_t _textureAtlas, - __constant struct KernelConstants *_constants, - __read_only image2d_t _transferFunction, - //__global __read_only float *_transferFunction, - __global __read_only int *_tsp, - __global __read_only int *_brickList, - const int _timestep) { - - // Kernel should be launched in 2D with one work item per pixel - int2 intCoords = (int2)(get_global_id(0), get_global_id(1)); - - // Sampler for color cube reading - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE; - - // Read from color cube textures - float4 cubeFrontColor = read_imagef(_cubeFront, sampler, intCoords); - float4 cubeBackColor = read_imagef(_cubeBack, sampler, intCoords); - // Figure out ray direction and distance to traverse - float3 direction = cubeBackColor.xyz - cubeFrontColor.xyz; - - float maxDist = length(direction); - - direction = normalize(direction); - - float4 color = TraverseOctree(cubeFrontColor.xyz, // ray origin - direction, // direction - maxDist, // distance to traverse - _textureAtlas, // voxel data atlas - _constants, // kernel constants - _transferFunction, // transfer function - _tsp, // TSP tree struct - _brickList, - _timestep); - - //color = 0.0001*color + cubeFrontColor; - - write_imagef(_output, intCoords, _constants->intensity_*color); - - return; -} - diff --git a/kernels/RaycasterTexture.cl b/kernels/RaycasterTexture.cl deleted file mode 100644 index a4c1e6f422..0000000000 --- a/kernels/RaycasterTexture.cl +++ /dev/null @@ -1,124 +0,0 @@ -// Needs to mirror struct on host -struct KernelConstants { - float stepSize; - float intensity; - int aDim; - int bDim; - int cDim; -}; - -// Linearly interpolate between two values. Distance -// is assumed to be normalized. -float Lerp(float _v0, float _v1, float _d) { - return _v0*(1.0 - _d) + _v1*_d; -} - - -// Turn normalized [0..1] cartesian coordinates -// to normalized spherical [0..1] coordinates -float3 CartesianToSpherical(float3 _cartesian) { - // Put cartesian in [-1..1] range first - _cartesian = (float3)(-1.0) + 2.0* _cartesian; - float r = length(_cartesian); - float theta, phi; - if (r == 0.0) { - theta = phi = 0.0; - } else { - theta = acospi(_cartesian.z/r); - phi = (M_PI + atan2(_cartesian.y, _cartesian.x)) / (2.0*M_PI); - } - r = r / native_sqrt(3.0); - // Sampler ignores w component - return (float3)(r, theta, phi); -} - -float4 TransferFunction(__global __read_only float *_tf, float _i) { - // TODO remove hard-coded value and change to 1D texture - int i0 = (int)floor(1023.0*_i); - int i1 = (i0 < 1023) ? i0+1 : i0; - float di = _i - floor(_i); - - float tfr0 = _tf[i0*4+0]; - float tfr1 = _tf[i1*4+0]; - float tfg0 = _tf[i0*4+1]; - float tfg1 = _tf[i1*4+1]; - float tfb0 = _tf[i0*4+2]; - float tfb1 = _tf[i1*4+2]; - float tfa0 = _tf[i0*4+3]; - float tfa1 = _tf[i1*4+3]; - - float tfr = Lerp(tfr0, tfr1, di); - float tfg = Lerp(tfg0, tfg1, di); - float tfb = Lerp(tfb0, tfb1, di); - float tfa = Lerp(tfa0, tfa1, di); - - return (float4)(tfr, tfg, tfb, tfa); -} - -__kernel void -Raycaster(__global __read_only image2d_t _cubeFront, - __global __read_only image2d_t _cubeBack, - __global __write_only image2d_t _output, - __global __read_only image3d_t _voxelData, - __constant struct KernelConstants *_constants, - __global __read_only float *_tf) { - - - int3 dimensions = (int3)(_constants->aDim, - _constants->bDim, - _constants->cDim); - - // Kernel should be launched in 2D with one work item per pixel - int idx = get_global_id(0); - int idy = get_global_id(1); - int2 intCoords = (int2)(idx, idy); - - // Sampler for texture reading - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE; - const sampler_t volumeSampler = CLK_FILTER_LINEAR | - CLK_NORMALIZED_COORDS_TRUE | - CLK_ADDRESS_CLAMP_TO_EDGE; - - // Read from textures - float4 cubeFrontColor = read_imagef(_cubeFront, sampler, intCoords); - float4 cubeBackColor = read_imagef(_cubeBack, sampler, intCoords); - - // Figure out the direction - float3 direction = (cubeBackColor-cubeFrontColor).xyz; - float maxDistance = length(direction); - direction = normalize(direction); - - // Keep track of distance traversed - float traversed = 0.0; - - // Sum colors - float stepSize = _constants->stepSize; - float3 samplePoint = cubeFrontColor.xyz; - float4 spherical; - float4 color = (float4)(0.0, 0.0, 0.0, 0.0); - - while (traversed < maxDistance) { - spherical.xyz = CartesianToSpherical(samplePoint); - spherical.w = 1.0; - - // Texture stores intensity in R channel - float i = read_imagef(_voxelData, volumeSampler, spherical).x; - - // Front-to-back compositing - float4 tf = TransferFunction(_tf, i); - color += (1.0 - color.w)*tf; - - // color += (float4)(i, i, i, 1.0); - samplePoint += direction * stepSize; - traversed += stepSize; - } - - // Output - float intensity = _constants->intensity; - color *= intensity*stepSize; - - // Write to image - write_imagef(_output, intCoords, color); - -} - diff --git a/kernels/TSPTraversal.cl b/kernels/TSPTraversal.cl deleted file mode 100644 index 0ea26357b4..0000000000 --- a/kernels/TSPTraversal.cl +++ /dev/null @@ -1,445 +0,0 @@ -// Mirrors struct on host side -struct TraversalConstants { - int gridType_; - float stepsize_; - int numTimesteps_; - int numValuesPerNode_; - int numOTNodes_; - float temporalTolerance_; - float spatialTolerance_; -}; - -float3 CartesianToSpherical(float3 _cartesian); -int OctreeRootNodeIndex(); -int LeftBST(int _bstNodeIndex, int _numValuesPerNode, int _numOTNodes, - bool _bstRoot, __global __read_only int *_tsp); -int RightBST(int _bstNodeIndex, int _numValuesPerNode, int _numOTNodes, - bool _bstRoot, __global __read_only int *_tsp); -int ChildNodeIndex(int _bstNodeIndex, - int *_timespanStart, - int *_timespanEnd, - int _timestep, - int _numValuesPerNode, - int _numOTNodes, - bool _bstRoot, - __global __read_only int *_tsp); -int BrickIndex(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) ; -bool IsBSTLeaf(int _bstNodeIndex, int _numValuesPerNode, - bool _bstRoot, __global __read_only int *_tsp) ; -bool IsOctreeLeaf(int _otNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) ; -int OTChildIndex(int _otNodeIndex, int _numValuesPerNode, - int _child, - __global __read_only int *_tsp); -void AddToList(int _brickIndex, - __global volatile int *_reqList); -float TemporalError(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) ; -float SpatialError(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp); -bool TraverseBST(int _otNodeIndex, - int *_brickIndex, - int _timestep, - __constant struct TraversalConstants *_constants, - __global volatile int *_reqList, - __global __read_only int *_tsp); -int EnclosingChild(float3 _P, float _boxMid, float3 _offset); -void UpdateOffset(float3 *_offset, float _boxDim, int _child) ; -void TraverseOctree(float3 _rayO, - float3 _rayD, - float _maxDist, - __constant struct TraversalConstants *_constants, - __global volatile int *_reqList, - __global __read_only int *_tsp, - const int _timestep); -__kernel void TSPTraversal(__read_only image2d_t _cubeFront, - __read_only image2d_t _cubeBack, - __constant struct TraversalConstants *_constants, - __global __read_only int *_tsp, - __global int *_reqList, - const int _timestep) ; - - - - - -// Turn normalized [0..1] cartesian coordinates -// to normalized spherical [0..1] coordinates -float3 CartesianToSpherical(float3 _cartesian) { - // Put cartesian in [-1..1] range first - _cartesian = (float3)(-1.0) + 2.0f* _cartesian; - float r = length(_cartesian); - float theta, phi; - if (r == 0.0) { - theta = phi = 0.0; - } else { - theta = acospi(_cartesian.z/r); - phi = (M_PI + atan2(_cartesian.y, _cartesian.x)) / (2.0*M_PI); - } - r = r / native_sqrt(3.0f); - // Sampler ignores w component - return (float3)(r, theta, phi); -} - -// Return index to the octree root (same index as BST root at that OT node) -int OctreeRootNodeIndex() { - return 0; -} - -// Return index to left BST child (low timespan) -int LeftBST(int _bstNodeIndex, int _numValuesPerNode, int _numOTNodes, - bool _bstRoot, __global __read_only int *_tsp) { - // If the BST node is a root, the child pointer is used for the OT. - // The child index is next to the root. - // If not root, look up in TSP structure. - if (_bstRoot) { - return _bstNodeIndex + _numOTNodes; - //return _bstNodeIndex + 1; - } else { - return _tsp[_bstNodeIndex*_numValuesPerNode + 1]; - } -} - -// Return index to right BST child (high timespan) -int RightBST(int _bstNodeIndex, int _numValuesPerNode, int _numOTNodes, - bool _bstRoot, __global __read_only int *_tsp) { - if (_bstRoot) { - return _bstNodeIndex + _numOTNodes*2; - } else { - return _tsp[_bstNodeIndex*_numValuesPerNode + 1] + _numOTNodes; - } -} - -// Return child node index given a BST node, a time span and a timestep -// Updates timespan -int ChildNodeIndex(int _bstNodeIndex, - int *_timespanStart, - int *_timespanEnd, - int _timestep, - int _numValuesPerNode, - int _numOTNodes, - bool _bstRoot, - __global __read_only int *_tsp) { - // Choose left or right child - int middle = *_timespanStart + (*_timespanEnd - *_timespanStart)/2; - if (_timestep <= middle) { - // Left subtree - *_timespanEnd = middle; - return LeftBST(_bstNodeIndex, _numValuesPerNode, _numOTNodes, - _bstRoot, _tsp); - } else { - // Right subtree - *_timespanStart = middle+1; - return RightBST(_bstNodeIndex, _numValuesPerNode, _numOTNodes, - _bstRoot, _tsp); - } -} - -// Return the brick index that a BST node represents -int BrickIndex(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) { - return _tsp[_bstNodeIndex*_numValuesPerNode + 0]; -} - -// Checks if a BST node is a leaf ot not -bool IsBSTLeaf(int _bstNodeIndex, int _numValuesPerNode, - bool _bstRoot, __global __read_only int *_tsp) { - if (_bstRoot) return false; - return (_tsp[_bstNodeIndex*_numValuesPerNode + 1] == -1); -} - -// Checks if an OT node is a leaf or not -bool IsOctreeLeaf(int _otNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) { - // CHILD_INDEX is at offset 1, and -1 represents leaf - return (_tsp[_otNodeIndex*_numValuesPerNode + 1] == -1); -} - -// Return OT child index given current node and child number (0-7) -int OTChildIndex(int _otNodeIndex, int _numValuesPerNode, - int _child, - __global __read_only int *_tsp) { - int firstChild = _tsp[_otNodeIndex*_numValuesPerNode+1]; - return firstChild + _child; -} - -// Increment the count for a brick in the request list -void AddToList(int _brickIndex, - __global volatile int *_reqList) { - atomic_inc(&_reqList[_brickIndex]); -} - -float TemporalError(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) { - return as_float(_tsp[_bstNodeIndex*_numValuesPerNode + 3]); -} - -float SpatialError(int _bstNodeIndex, int _numValuesPerNode, - __global __read_only int *_tsp) { - return as_float(_tsp[_bstNodeIndex*_numValuesPerNode + 2]); -} - - -// Given an octree node index, traverse the corresponding BST tree and look -// for a useful brick. -bool TraverseBST(int _otNodeIndex, - int *_brickIndex, - int _timestep, - __constant struct TraversalConstants *_constants, - __global volatile int *_reqList, - __global __read_only int *_tsp) { - - // Start at the root of the current BST - int bstNodeIndex = _otNodeIndex; - bool bstRoot = true; - int timespanStart = 0; - int timespanEnd = _constants->numTimesteps_; - - // Rely on structure for termination - while (true) { - - // Update brick index (regardless if we use it or not) - *_brickIndex = BrickIndex(bstNodeIndex, - _constants->numValuesPerNode_, - _tsp); - - // If temporal error is ok - // TODO float and <= errors - if (TemporalError(bstNodeIndex, _constants->numValuesPerNode_, - _tsp) <= _constants->temporalTolerance_) { - - // If the ot node is a leaf, we can't do any better spatially so we - // return the current brick - if (IsOctreeLeaf(_otNodeIndex, _constants->numValuesPerNode_, _tsp)) { - return true; - - // All is well! - } else if (SpatialError(bstNodeIndex, _constants->numValuesPerNode_, - _tsp) <= _constants->spatialTolerance_) { - return true; - - // If spatial failed and the BST node is a leaf - // The traversal will continue in the octree (we know that - // the octree node is not a leaf) - } else if (IsBSTLeaf(bstNodeIndex, _constants->numValuesPerNode_, - bstRoot, _tsp)) { - return false; - - // Keep traversing BST - } else { - bstNodeIndex = ChildNodeIndex(bstNodeIndex, - ×panStart, - ×panEnd, - _timestep, - _constants->numValuesPerNode_, - _constants->numOTNodes_, - bstRoot, - _tsp); - } - - // If temporal error is too big and the node is a leaf - // Return false to traverse OT - } else if (IsBSTLeaf(bstNodeIndex, _constants->numValuesPerNode_, - bstRoot, _tsp)) { - return false; - - // If temporal error is too big and we can continue - } else { - bstNodeIndex = ChildNodeIndex(bstNodeIndex, - ×panStart, - ×panEnd, - _timestep, - _constants->numValuesPerNode_, - _constants->numOTNodes_, - bstRoot, - _tsp); - } - - bstRoot = false; - } -} - -// Given a point, a box mid value and an offset, return enclosing child -int EnclosingChild(float3 _P, float _boxMid, float3 _offset) { - if (_P.x < _boxMid+_offset.x) { - if (_P.y < _boxMid+_offset.y) { - if (_P.z < _boxMid+_offset.z) { - return 0; - } else { - return 4; - } - } else { - if (_P.z < _boxMid+_offset.z) { - return 2; - } else { - return 6; - } - } - } else { - if (_P.y < _boxMid+_offset.y) { - if (_P.z < _boxMid+_offset.z) { - return 1; - } else { - return 5; - } - } else { - if (_P.z < _boxMid+_offset.z) { - return 3; - } else { - return 7; - } - } - } -} - -void UpdateOffset(float3 *_offset, float _boxDim, int _child) { - if (_child == 0) { - // do nothing - } else if (_child == 1) { - _offset->x += _boxDim; - } else if (_child == 2) { - _offset->y += _boxDim; - } else if (_child == 3) { - _offset->x += _boxDim; - _offset->y += _boxDim; - } else if (_child == 4) { - _offset->z += _boxDim; - } else if (_child == 5) { - _offset->x += _boxDim; - _offset->z += _boxDim; - } else if (_child == 6) { - _offset->y += _boxDim; - _offset->z += _boxDim; - } else if (_child == 7) { - *_offset += (float3)(_boxDim); - } -} - -// Traverse one ray through the volume, build brick list -void TraverseOctree(float3 _rayO, - float3 _rayD, - float _maxDist, - __constant struct TraversalConstants *_constants, - __global volatile int *_reqList, - __global __read_only int *_tsp, - const int _timestep) { - - // Choose a stepsize that guarantees that we don't miss any bricks - // TODO dynamic depending on brick dimensions - float stepsize = _constants->stepsize_; - float3 P = _rayO; - // Keep traversing until the sample point goes outside the unit cube - float traversed = 0.0f; - - int max_iterations = 50; - int iterations = 0; - bool ok = stepsize > 0.0f && stepsize < fabs(_maxDist); - //while (traversed < _maxDist && iterations < max_iterations) { - while (traversed < _maxDist) { - - // Reset traversal variables - float3 offset = (float3)(0.0f); - float boxDim = 1.0f; - int child; - - // Init the octree node index to the root - int otNodeIndex = OctreeRootNodeIndex(); - - // Start traversing octree - // Rely on finding a leaf for loop termination - - while (true) { - // See if the BST tree is good enough - int brickIndex = 0; - bool bstSuccess = TraverseBST(otNodeIndex, - &brickIndex, - _timestep, - _constants, - _reqList, - _tsp); - - - - if (bstSuccess) { - - // Add the found brick to brick list - AddToList(brickIndex, _reqList); - // We are now done with this node, so go to next - break; - - // If the BST lookup failed but the octree node is a leaf, - // add the brick anyway (it is the BST leaf) - } else if (IsOctreeLeaf(otNodeIndex, - _constants->numValuesPerNode_, _tsp)) { - AddToList(brickIndex, _reqList); - // We are now done with this node, so go to next - break; - - // If the BST lookup failed and we can traverse the octree, - // visit the child that encloses the point - } else { - - // Next box dimension - boxDim = boxDim/2.0f; - - // Current mid point - float boxMid = boxDim; - - // Check which child encloses P - - if (_constants->gridType_ == 0) { // Cartesian - child = EnclosingChild(P, boxMid, offset); - } else { // Spherical (==1) - child = EnclosingChild(CartesianToSpherical(P), boxMid, offset); - } - - // Update offset - UpdateOffset(&offset, boxDim, child); - - // Update node index to new node - //int oldIndex = otNodeIndex; - otNodeIndex = OTChildIndex(otNodeIndex, _constants->numValuesPerNode_, - child, _tsp); - } - } // while traversing - - // Update - traversed = traversed + stepsize; - P = P + stepsize * _rayD; - - } // while (traversed < maxDist) - - -} - -__kernel void TSPTraversal(__read_only image2d_t _cubeFront, - __read_only image2d_t _cubeBack, - __constant struct TraversalConstants *_constants, - __global __read_only int *_tsp, - __global int *_reqList, - const int _timestep) { - - // Kernel should be launched in 2D with one work item per pixel - int2 intCoords = (int2)(get_global_id(0), get_global_id(1)); - - // Sampler for color cube reading - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE; - - // Read from color cube textures - float4 cubeFrontColor = read_imagef(_cubeFront, sampler, intCoords); - - if (length(cubeFrontColor.xyz) == 0.0) return; - float4 cubeBackColor = read_imagef(_cubeBack, sampler, intCoords); - - // Figure out ray direction - float maxDist = length(cubeBackColor.xyz-cubeFrontColor.xyz); - float3 direction = normalize(cubeBackColor.xyz-cubeFrontColor.xyz); - - // Traverse octree and fill the brick request list - TraverseOctree(cubeFrontColor.xyz, direction, maxDist, - _constants, _reqList, _tsp, _timestep); - - return; - -} diff --git a/kernels/helpers/volume_helpers.cl b/kernels/helpers/volume_helpers.cl deleted file mode 100644 index b3ba1d07ad..0000000000 --- a/kernels/helpers/volume_helpers.cl +++ /dev/null @@ -1,28 +0,0 @@ - -float3 CartesianToSpherical(float3 _cartesian); -float intensityNormalizer(float intensity, float iMin, float iMax); - -float3 CartesianToSpherical(float3 _cartesian) { - // Put cartesian in [-1..1] range first - _cartesian = (float3)(-1.0) + 2.0f* _cartesian; - float r = length(_cartesian); - float theta, phi; - if (r == 0.0) { - theta = phi = 0.0; - } else { - theta = acospi(_cartesian.z/r); - phi = (M_PI + atan2(_cartesian.y, _cartesian.x)) / (2.0*M_PI); - } - r = r / native_sqrt(3.0f); - // Sampler ignores w component - return (float3)(r, theta, phi); -} - -float intensityNormalizer(float intensity, float iMin, float iMax) { - float i = clamp(intensity, iMin, iMax); - i = (i - iMin) / (iMax - iMin); - return clamp(i, 0.0f, 1.0f); -} - - - diff --git a/kernels/helpers/volume_raycasting.cl b/kernels/helpers/volume_raycasting.cl deleted file mode 100644 index ae8402606f..0000000000 --- a/kernels/helpers/volume_raycasting.cl +++ /dev/null @@ -1,113 +0,0 @@ - -#ifdef CL_VERSION_1_2 - #define RC_TF_TYPE image1d_t - #define RC_TF_MAP(intensity) intensity -#else - #define RC_TF_TYPE image2d_t - #define RC_TF_MAP(intensity) (float2)(intensity,0.0f) -#endif - - -#define EARLY_RAY_TERMINATION_OPACITY 0.95 - -void raySetup(float3 first, float3 last, float3 dimension, float3* rayDirection, float* tIncr, float* tEnd); -bool earlyRayTermination(float4* color, float maxOpacity); - - -#define RC_DEFINE_TEXTUE_COORDINATES(coords) \ - int2 coords = (int2)(get_global_id(0), get_global_id(1)) - -#define RC_DEFINE_VOLUME3D_DIMENSIONS(dimension, volume) \ - float3 dimension; \ - { \ - int4 idim = get_image_dim(volume); \ - dimension = (float3)(idim.x,idim.y,idim.z); \ - } - - -//#define RC_DEFINE_VARIABLES(dimension, intCoords) - -/*** - * Calculates the direction of the ray and returns the number - * of steps and the direction. - ***/ -void raySetup(float3 first, float3 last, float3 dimension, float3* rayDirection, float* tIncr, float* tEnd) { - float samplingRate_ = 1.0f; - *rayDirection = last - first; - *tEnd = length(*rayDirection); - *rayDirection = normalize(*rayDirection); - *tIncr = 1.0/(samplingRate_*length((*rayDirection)*dimension)); - -} - -/*** - * Applies early ray termination. The current opacity is compared to - * the maximum opacity. In case it is greater, the opacity is set to - * 1.0 and true is returned, otherwise false is returned. - ***/ -bool earlyRayTermination(float4* color, float maxOpacity) { - if ((*color).w >= maxOpacity) { - (*color).w = 1.0f; - return true; - } else { - return false; - } -} - -#define RC_EARLY_RAY_TERMINATION(opacity, maxOpacity, finished) \ - finished = earlyRayTermination(&opacity, maxOpacity) - -#define RC_BEGIN_LOOP_FOR \ - for (int loop=0; !finished && loop tEnd); \ - RC_END_LOOP_BRACES -#else -#define RC_END_LOOP(result) \ - RC_EARLY_RAY_TERMINATION(result, EARLY_RAY_TERMINATION_OPACITY, finished); \ - t += tIncr; \ - finished = finished || (t > tEnd); \ - RC_END_LOOP_BRACES - -#endif - -/** -* In order to keep the shaders as free as possible from dealing -* with bricking and adaptive sampling, these defines can be placed -* before and after the compositing function calls to enable adaptive -* sampling when bricking is used. For normal datasets these defines -* will have no impact at all. -*/ -#ifdef ADAPTIVE_SAMPLING -#define RC_BEGIN_COMPOSITING \ - for (int i=0; i #include -#include #include #include @@ -75,7 +74,6 @@ void BaseModule::internalInitialize() { auto fEphemeris = FactoryManager::ref().factory(); ghoul_assert(fEphemeris, "Ephemeris factory was not created"); fEphemeris->registerClass("Static"); - fEphemeris->registerClass("Dynamic"); fEphemeris->registerClass("Spice"); auto fPlanetGeometry = FactoryManager::ref().factory(); diff --git a/modules/base/ephemeris/dynamicephemeris.cpp b/modules/base/ephemeris/dynamicephemeris.cpp deleted file mode 100644 index 4efb8274fc..0000000000 --- a/modules/base/ephemeris/dynamicephemeris.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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. * - ****************************************************************************************/ - -#include - -namespace { - const std::string KeyPosition = "Position"; -} - -namespace openspace { - -DynamicEphemeris::DynamicEphemeris(const ghoul::Dictionary& dictionary) - : _position(0.f, 0.f, 0.f, 0.f) -{ - const bool hasPosition = dictionary.hasKeyAndValue(KeyPosition); - if (hasPosition) { - glm::vec4 tmp; - dictionary.getValue(KeyPosition, tmp); - _position = tmp; - } -} - -DynamicEphemeris::~DynamicEphemeris() {} - -const psc& DynamicEphemeris::position() const { - return _position; -} - -void DynamicEphemeris::setPosition(psc pos) { - _position = pos; -} - -void DynamicEphemeris::update(const UpdateData&) {} - -} // namespace openspace \ No newline at end of file diff --git a/modules/base/ephemeris/dynamicephemeris.h b/modules/base/ephemeris/dynamicephemeris.h deleted file mode 100644 index f6d679d7dd..0000000000 --- a/modules/base/ephemeris/dynamicephemeris.h +++ /dev/null @@ -1,46 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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 __DYNAMICEPHEMERIS_H__ -#define __DYNAMICEPHEMERIS_H__ - -#include - -namespace openspace { - -class DynamicEphemeris: public Ephemeris { -public: - DynamicEphemeris(const ghoul::Dictionary& dictionary - = ghoul::Dictionary()); - virtual ~DynamicEphemeris(); - virtual const psc& position() const; - virtual void update(const UpdateData& data) override; - void setPosition(psc pos); -private: - psc _position; -}; - -} // namespace openspace - -#endif // __DYNAMICEPHEMERIS_H__ diff --git a/modules/base/rendering/renderableplanet.cpp b/modules/base/rendering/renderableplanet.cpp index 6a3c333c1a..95753a70d2 100644 --- a/modules/base/rendering/renderableplanet.cpp +++ b/modules/base/rendering/renderableplanet.cpp @@ -131,16 +131,17 @@ bool RenderablePlanet::initialize() { // Night texture program _programObject = renderEngine.buildRenderProgram( "nightTextureProgram", - "${SHADERS}/nighttexture_vs.glsl", - "${SHADERS}/nighttexture_fs.glsl"); - if (!_programObject) return false; + "${MODULE_BASE}/shaders/nighttexture_vs.glsl", + "${MODULE_BASE}/shaders/nighttexture_fs.glsl"); + if (!_programObject) + return false; } else if (_programObject == nullptr) { // pscstandard _programObject = renderEngine.buildRenderProgram( "pscstandard", - "${SHADERS}/pscstandard_vs.glsl", - "${SHADERS}/pscstandard_fs.glsl"); + "${MODULE_BASE}/shaders/pscstandard_vs.glsl", + "${MODULE_BASE}/shaders/pscstandard_fs.glsl"); if (!_programObject) return false; } diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index 259afdf6c7..557831bd43 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -121,7 +121,7 @@ bool RenderableSphere::initialize() { // pscstandard RenderEngine& renderEngine = OsEng.renderEngine(); _shader = renderEngine.buildRenderProgram("Sphere", - "${MODULES}/base/shaders/sphere_vs.glsl", + "${MODULE_BASE}/shaders/sphere_vs.glsl", "${MODULES}/base/shaders/sphere_fs.glsl"); if (!_shader) return false; diff --git a/shaders/nighttexture_fs.glsl b/modules/base/shaders/nighttexture_fs.glsl similarity index 100% rename from shaders/nighttexture_fs.glsl rename to modules/base/shaders/nighttexture_fs.glsl diff --git a/shaders/nighttexture_vs.glsl b/modules/base/shaders/nighttexture_vs.glsl similarity index 100% rename from shaders/nighttexture_vs.glsl rename to modules/base/shaders/nighttexture_vs.glsl diff --git a/shaders/pscstandard_fs.glsl b/modules/base/shaders/pscstandard_fs.glsl similarity index 100% rename from shaders/pscstandard_fs.glsl rename to modules/base/shaders/pscstandard_fs.glsl diff --git a/shaders/pscstandard_vs.glsl b/modules/base/shaders/pscstandard_vs.glsl similarity index 100% rename from shaders/pscstandard_vs.glsl rename to modules/base/shaders/pscstandard_vs.glsl diff --git a/modules/base/shaders/sphere_fs.glsl b/modules/base/shaders/sphere_fs.glsl index 17b58bbb44..f059466731 100644 --- a/modules/base/shaders/sphere_fs.glsl +++ b/modules/base/shaders/sphere_fs.glsl @@ -40,6 +40,7 @@ Fragment getFragment() vec4 diffuse; vec2 texCoord = vs_st; + // Why is this here? ---abock texCoord.s = 1 - texCoord.s; texCoord.t = 1 - texCoord.y; diff --git a/modules/newhorizons/CMakeLists.txt b/modules/newhorizons/CMakeLists.txt index beff9e3a8b..8f59851507 100644 --- a/modules/newhorizons/CMakeLists.txt +++ b/modules/newhorizons/CMakeLists.txt @@ -64,6 +64,8 @@ source_group("Source Files" FILES ${SOURCE_FILES}) set(SHADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/crawlingline_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/crawlingline_vs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fboPass_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fboPass_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fov_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fov_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/projectiveTexture_fs.glsl diff --git a/modules/newhorizons/rendering/renderableplaneprojection.cpp b/modules/newhorizons/rendering/renderableplaneprojection.cpp index 5359541467..cb5d499ea9 100644 --- a/modules/newhorizons/rendering/renderableplaneprojection.cpp +++ b/modules/newhorizons/rendering/renderableplaneprojection.cpp @@ -275,13 +275,20 @@ void RenderablePlaneProjection::updatePlane(const Image img, double currentTime) const GLfloat vertex_data[] = { // square of two triangles drawn within fov in target coordinates // x y z w s t - projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 1 - projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper right 2 - projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 0, // Upper left 3 - projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 4 = 1 - projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 1, // Lower right 5 - projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper left 6 = 2 + projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 0, // Lower left 1 + projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 1, // Upper right 2 + projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 1, // Upper left 3 + projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 0, // Lower left 4 = 1 + projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 0, // Lower right 5 + projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 1, // Upper left 6 = 2 }; + //projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 1 + // projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper right 2 + // projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 0, // Upper left 3 + // projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 4 = 1 + // projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 1, // Lower right 5 + // projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper left 6 = 2 + glBindVertexArray(_quad); // bind array glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer diff --git a/modules/newhorizons/rendering/renderableplanetprojection.cpp b/modules/newhorizons/rendering/renderableplanetprojection.cpp index 798e33b544..31be13364c 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.cpp +++ b/modules/newhorizons/rendering/renderableplanetprojection.cpp @@ -619,7 +619,7 @@ void RenderablePlanetProjection::loadTexture() { if (_colorTexturePath.value() != "") { _textureOriginal = ghoul::io::TextureReader::ref().loadTexture(_colorTexturePath); if (_textureOriginal) { - ghoul::opengl::convertTextureFormat(Texture::Format::RGB, *_texture); + ghoul::opengl::convertTextureFormat(Texture::Format::RGB, *_textureOriginal); _textureOriginal->uploadTexture(); _textureOriginal->setFilter(Texture::FilterMode::Linear); diff --git a/modules/newhorizons/scripts/crawl_newhorizons_images.py b/modules/newhorizons/scripts/crawl_newhorizons_images.py index bc674ad539..5a36c70dd8 100644 --- a/modules/newhorizons/scripts/crawl_newhorizons_images.py +++ b/modules/newhorizons/scripts/crawl_newhorizons_images.py @@ -35,8 +35,7 @@ def downloadPage(pageNumber): pos = p+beginOffset imageName = source[pos:p+imageEnd] imageLength = len('imageName') - # imageName = source[pos:pos+imageLength] - pos = pos + imageLength + utcDateOffset + pos = p + imageEnd + utcDateOffset utcDate = source[pos:pos+utcDateLength] pos = pos + utcDateLength + utcTimeOffset @@ -49,6 +48,12 @@ def downloadPage(pageNumber): urlFirstPart = imageName[len('lor_'): len('lor_') + len('029912')] imageURL = 'http://pluto.jhuapl.edu/soc/Pluto-Encounter/data/pluto/level2/lor/jpeg/' + urlFirstPart + '/' + imageName + print("ImageName: " + imageName) + print("UTCDate: " + utcDate) + print("UTCTime: " + utcTime) + print("Target: " + target) + print("URL: " + imageURL) + # Download image urlretrieve(imageURL, imageName) @@ -58,7 +63,7 @@ def downloadPage(pageNumber): f.write('SEQUENCE_ID = "UNUSED"\n') f.write('TARGET_NAME = "' + target + '"\n') f.write('START_TIME = ' + utcDate + 'T' + utcTime + '.000\n') - f.write('START_TIME = ' + utcDate + 'T' + utcTime + '.005\n') + f.write('STOP_TIME = ' + utcDate + 'T' + utcTime + '.005\n') f.write('INSTRUMENT_HOST_NAME = "NEW HORIZONS"\n') f.write('INSTRUMENT_ID = "LORRI"\n') f.write('DETECTOR_ID = "LORRI"\n') diff --git a/shaders/fboPass_fs.glsl b/modules/newhorizons/shaders/fboPass_fs.glsl similarity index 100% rename from shaders/fboPass_fs.glsl rename to modules/newhorizons/shaders/fboPass_fs.glsl diff --git a/shaders/fboPass_vs.glsl b/modules/newhorizons/shaders/fboPass_vs.glsl similarity index 100% rename from shaders/fboPass_vs.glsl rename to modules/newhorizons/shaders/fboPass_vs.glsl diff --git a/openspace.cfg b/openspace.cfg index 976fb70dd9..d17e612453 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -13,7 +13,6 @@ return { SGCT = "${BASE_PATH}/config/sgct", SCRIPTS = "${BASE_PATH}/scripts", SHADERS = "${BASE_PATH}/shaders", - SHADERS_GENERATED = "${SHADERS}/generated", OPENSPACE_DATA = "${BASE_PATH}/data", SCENE = "${OPENSPACE_DATA}/scene", SPICE = "${OPENSPACE_DATA}/spice", @@ -31,12 +30,6 @@ return { Mono = "${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf", Light = "${FONTS}/Roboto/Roboto-Regular.ttf" }, - StartupScripts = { - "${SCRIPTS}/default_startup.lua" - }, - SettingsScripts = { - "${SCRIPTS}/default_settings.lua" - }, Logging = { LogLevel = "Debug", ImmediateFlush = false, diff --git a/scripts/default_settings.lua b/scripts/default_settings.lua deleted file mode 100644 index edd1057278..0000000000 --- a/scripts/default_settings.lua +++ /dev/null @@ -1,17 +0,0 @@ ---[[ OpenSpace settings script ]]-- --- This Lua script get executed once at the start of the application and is used to --- set settings in the loaded scene graph - -openspace.printInfo("Setting default values") -openspace.setPropertyValue("Sun.renderable.enabled", false) -openspace.setPropertyValue("SunMarker.renderable.enabled", true) -openspace.setPropertyValue("EarthMarker.renderable.enabled", true) ---openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false) -openspace.setPropertyValue("PlutoTrail.renderable.enabled", false) -openspace.setPropertyValue("PlutoTexture.renderable.enabled", false) - -openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.75) -openspace.setPropertyValue("MilkyWay.renderable.segments", 50) - - -openspace.printInfo("Done setting default values") diff --git a/scripts/default_startup.lua b/scripts/default_startup.lua deleted file mode 100644 index dea47a83fd..0000000000 --- a/scripts/default_startup.lua +++ /dev/null @@ -1,50 +0,0 @@ ---[[ OpenSpace startup script ]]-- --- This Lua script get executed once at the start of the application - ---openspace.setInvertRotation(true) -- Uncomment this if you want to invert the rotation -openspace.setInvertRoll(true); ---openspace.setInteractionSensitivity(10) -- This is the default value for the sensitivity (the higher, the more sensitive) - --- openspace.time.setTime("2007 FEB 27 16:30:00") -- This is the start time for a Jupiter run of New Horizons - ---openspace.time.setTime("2011 AUG 06 00:00:00") -- Dawn takes pictures of Vesta ---openspace.time.setTime("2011 JUL 28 12:00:00") -- Rosetta starts dancing around 67p ---openspace.time.setTime("2007 FEB 28 11:45:00") -- europa rise ---TESTING ALICE ---openspace.time.setTime("2015-07-13T00:00:00.00") - -openspace.time.setTime("2015-07-14T10:00:00.00") - -openspace.time.setDeltaTime(0) -- How many seconds pass per second of realtime, changeable in the GUI - -dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) -- Load the default keybindings - --- openspace.time.setDeltaTime(50); - ---openspace.time.setTime("2015-07-14T12:00:00.00") -- PLUTO --- NH takes series of images from visible to dark side (across terminator) --- Sequence lasts ~10 mins, (recommended dt = 10) - ---openspace.time.setTime("2015-07-14T11:22:00.00") -- PLUTO ---BEAUTIFUL SEQUENCE -- NH takes series of images (same as previous) --- Sequence ends at 2015 JUL 14T11:24:00:000, (recommended dt = 1) - ---openspace.time.setTime("2015-07-14T11:36:40.00") -- PLUTO --- NH takes series of images (same as previous) --- Sequence ends at 2015 JUL 14T11:39:15:000, (recommended dt = 1) - ---openspace.time.setTime("2015-07-14T11:48:43.00") -- CHARON ---NH takes imagesequence across terminator --- Sequence ends at 2015 JUL 14T11:49:30:000, (recommended dt = 1) - ---openspace.time.setTime("2015-07-14T12:04:35.00") -- PLUTO ---NH takes imagesequence across Plutos north pole --- Sequence ends at 2015 JUL 14T12:05:48:000, (recommended dt = 1) - ---openspace.time.setTime("2015-07-14T15:02:46.00") -- PLUTO DARKSIDE ---From this point on NH takes a huge amount of images of the far side of --- CHARON and PLUTO - recommend run time from here and just let it run --- until audience tires (enough to fill 10-15 mins if run at dt = 100) - - --- print(openspace.time.currentTimeUTC()) diff --git a/shaders/cubeFrag.glsl b/shaders/cubeFrag.glsl deleted file mode 100644 index 876035e2c9..0000000000 --- a/shaders/cubeFrag.glsl +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -in vec4 color; -out vec4 outputColor; - -void main() { - outputColor = color; -} \ No newline at end of file diff --git a/shaders/cubeVert.glsl b/shaders/cubeVert.glsl deleted file mode 100644 index b240159d65..0000000000 --- a/shaders/cubeVert.glsl +++ /dev/null @@ -1,37 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -uniform mat4 projectionMatrix; -uniform mat4 viewMatrix; -uniform mat4 modelMatrix; - -in vec4 position; -out vec4 color; - -void main() { - gl_Position = projectionMatrix * viewMatrix * modelMatrix * position; - color = position; -} \ No newline at end of file diff --git a/shaders/exitpoints.frag b/shaders/exitpoints.frag deleted file mode 100644 index 938df00ca5..0000000000 --- a/shaders/exitpoints.frag +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -uniform int volumeType; - -in vec3 vPosition; -in vec4 worldPosition; -in float s; - -#include "ABuffer/abufferStruct.hglsl" -#include "ABuffer/abufferAddToBuffer.hglsl" -#include "PowerScaling/powerScaling_fs.hglsl" - -void main() { - vec4 fragColor = vec4(vPosition+0.5, 1.0); - vec4 position = worldPosition; - float depth = pscDepth(position); - - gl_FragDepth = depth; - - ABufferStruct_t frag; - _col_(frag, fragColor); - _z_(frag, depth); - _type_(frag, volumeType); - _pos_(frag, position); - addToBuffer(frag); -} \ No newline at end of file diff --git a/shaders/exitpoints.vert b/shaders/exitpoints.vert deleted file mode 100644 index 1abe4bf478..0000000000 --- a/shaders/exitpoints.vert +++ /dev/null @@ -1,57 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -layout(location = 0) in vec4 vertPosition; - -uniform mat4 modelViewProjection; -uniform mat4 modelTransform; - -out vec3 vPosition; -out vec4 worldPosition; -out float s; - -#include "PowerScaling/powerScaling_vs.hglsl" - -void main() { - - //vs_st = in_st; - //vs_stp = in_position.xyz; - - vPosition = vertPosition.xyz; - worldPosition = vertPosition; - - // this is wrong for the normal. The normal transform is the transposed inverse of the model transform - //vs_normal = normalize(modelTransform * vec4(in_normal,0)); - - vec4 position = pscTransform(worldPosition, modelTransform); - - // project the position to view space - gl_Position = z_normalization(modelViewProjection * position); - - // vPosition = vertPosition.xyz; - // worldPosition = (modelTransform *vec4(vPosition, 1.0)).xyz; - // gl_Position = modelViewProjection *vec4(worldPosition, 1.0); -} \ No newline at end of file diff --git a/shaders/pointcloud_fs.glsl b/shaders/pointcloud_fs.glsl deleted file mode 100644 index 7e4028f34f..0000000000 --- a/shaders/pointcloud_fs.glsl +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - - -in vec4 vs_color; -out vec4 diffuse; - -void main() -{ - diffuse = vs_color; -} \ No newline at end of file diff --git a/shaders/pointcloud_vs.glsl b/shaders/pointcloud_vs.glsl deleted file mode 100644 index eaad8b33f9..0000000000 --- a/shaders/pointcloud_vs.glsl +++ /dev/null @@ -1,41 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -uniform mat4 ViewProjection; -uniform mat4 ModelTransform; - -layout(location = 0) in vec3 in_position; -layout(location = 1) in vec4 in_color; - -out vec4 vs_color; - -void main() -{ - // set variables - vs_color = in_color; - - gl_Position = ViewProjection*ModelTransform*vec4(in_position,1); -} \ No newline at end of file diff --git a/shaders/postFX_fs.glsl b/shaders/postFX_fs.glsl deleted file mode 100644 index 4a2dbe46ba..0000000000 --- a/shaders/postFX_fs.glsl +++ /dev/null @@ -1,36 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version 430 - -in vec2 UV; -out vec4 Color; - -uniform sampler2D Tex; -uniform float Opacity; - -void main() -{ - Color = texture(Tex, UV) * Opacity; -} \ No newline at end of file diff --git a/shaders/postFX_vs.glsl b/shaders/postFX_vs.glsl deleted file mode 100644 index 9c9cc2381f..0000000000 --- a/shaders/postFX_vs.glsl +++ /dev/null @@ -1,36 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version 430 - -layout (location = 0) in vec2 TexCoords; -layout (location = 1) in vec3 Position; - -out vec2 UV; - -void main() -{ - gl_Position = vec4(Position, 1.0); - UV = TexCoords; -} \ No newline at end of file diff --git a/shaders/quadFrag.glsl b/shaders/quadFrag.glsl deleted file mode 100644 index 235e8a3afd..0000000000 --- a/shaders/quadFrag.glsl +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -uniform sampler2D quadTex; -in vec2 texCoord; -out vec4 color; - -void main() { - color = texture(quadTex, texCoord); -} \ No newline at end of file diff --git a/shaders/quadVert.glsl b/shaders/quadVert.glsl deleted file mode 100644 index 419392bd62..0000000000 --- a/shaders/quadVert.glsl +++ /dev/null @@ -1,38 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -layout(location = 0) in vec2 texCoordinate; -layout(location = 2) in vec3 vertPosition; - -in vec4 position; -out vec2 texCoord; - -const vec2 screenScale = vec2(0.5, 0.5); - -void main() { - texCoord = vertPosition.xy*screenScale+screenScale; // scale vertex attribute to [0-1] range - gl_Position = vec4(vertPosition.xy, 0.0, 1.0); -} diff --git a/shaders/quadVertFlare.glsl b/shaders/quadVertFlare.glsl deleted file mode 100644 index 78bcc9c4a4..0000000000 --- a/shaders/quadVertFlare.glsl +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -in vec4 position; -out vec2 texCoord; - -void main() { - gl_Position = position; - texCoord = position.xy/2.0 + 0.5; -} diff --git a/shaders/singlepassraycaster.frag b/shaders/singlepassraycaster.frag deleted file mode 100644 index 92dacbb64e..0000000000 --- a/shaders/singlepassraycaster.frag +++ /dev/null @@ -1,118 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -// Based on http://prideout.net/blog/?p=64 - -uniform sampler3D texVolume; -uniform mat4 modelView; -uniform mat4 modelViewProjection; -uniform float focalLength; -uniform vec2 windowSize; -uniform vec3 rayOrigin; -uniform float stepSize; - -const int maxNumSamples = 128; - -out vec4 fragColor; - -struct Ray { - vec3 Origin; - vec3 Dir; -}; - -struct AABB { - vec3 Min; - vec3 Max; -}; - -bool IntersectBox(Ray r, AABB box, out float t0, out float t1) { - vec3 invR = 1.0 / r.Dir; - vec3 tbot = invR * (box.Min-r.Origin); - vec3 ttop = invR * (box.Max-r.Origin); - vec3 tmin = min(ttop, tbot); - vec3 tmax = max(ttop, tbot); - vec2 t = max(tmin.xx, tmin.yz); - t0 = max(t.x, t.y); - t = min(tmax.xx, tmax.yz); - t1 = min(t.x, t.y); - return t0 <= t1; -} - -void main() { - vec3 rayDirection; - rayDirection.x = 2.0 * gl_FragCoord.x / windowSize.x - 1.0; - rayDirection.y = 2.0 * gl_FragCoord.y / windowSize.y - 1.0; - rayDirection.z = -focalLength; - rayDirection = (vec4(rayDirection, 0) * modelView).xyz; - - Ray eye = Ray( rayOrigin, normalize(rayDirection) ); - AABB box = AABB(vec3(-1.0), vec3(1.0)); - - float tnear, tfar; - IntersectBox(eye, box, tnear, tfar); - tnear = max(tnear, 0.0); - - vec3 front = eye.Origin + eye.Dir* tnear; - vec3 back = eye.Origin + eye.Dir* tfar; - front = 0.5 * (front + 1.0); - back = 0.5 * (back + 1.0); - - vec3 direction = back-front; - float directionLength = length(direction); - direction = normalize(direction); - vec3 position = front; - vec4 tmp, color = vec4(0); - int i = 0; - - while (length(position-front) < directionLength && color.r != 1.0 && i < maxNumSamples) { - ++i; - tmp = texture(texVolume, position); - color = max(color, tmp); // MIP - position = position + direction * stepSize; - } - - fragColor = vec4(color.rrr,1.0); - - // // DEBUG DEBUG DEBUG - // fragColor = vec4(front, 1.0); - // if (front.x < 0.1) - // fragColor = vec4(1.0); - - // if (front.y < 0.1) - // fragColor = vec4(1.0); - - // if (front.x > 0.9) - // fragColor = vec4(1.0); - - // if (front.y > 0.9) - // fragColor = vec4(1.0); - - // if (front.x > 0.45 && front.x < 0.55) - // fragColor = vec4(0.0); - - // if (front.y > 0.45 && front.y < 0.55) - // fragColor = vec4(0.0); -} \ No newline at end of file diff --git a/shaders/singlepassraycaster.gs b/shaders/singlepassraycaster.gs deleted file mode 100644 index 8d5f274293..0000000000 --- a/shaders/singlepassraycaster.gs +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -// Based on http://prideout.net/blog/?p=64 - -layout(points) in; -layout(triangle_strip, max_vertices = 24) out; -uniform mat4 modelViewProjection; -in vec4 vPosition[1]; - -vec4 objCube[8]; // Object space coordinate of cube corner -vec4 ndcCube[8]; // Normalized device coordinate of cube corner -ivec4 faces[6]; // Vertex indices of the cube faces - -void emit_vert(int vert) { - gl_Position = ndcCube[vert]; - EmitVertex(); -} - -void emit_face(int face) { - emit_vert(faces[face][1]); emit_vert(faces[face][0]); - emit_vert(faces[face][3]); emit_vert(faces[face][2]); - EndPrimitive(); -} - -void main() { - faces[0] = ivec4(0,1,3,2); faces[1] = ivec4(5,4,6,7); - faces[2] = ivec4(4,5,0,1); faces[3] = ivec4(3,2,7,6); - faces[4] = ivec4(0,3,4,7); faces[5] = ivec4(2,1,6,5); - - float size = 0.5; - vec4 P = vPosition[0]; - vec4 I = vec4(size, 0, 0, 0); - vec4 J = vec4(0, size, 0, 0); - vec4 K = vec4(0, 0, size, 0); - - objCube[0] = P+K+I+J; objCube[1] = P+K+I-J; - objCube[2] = P+K-I-J; objCube[3] = P+K-I+J; - objCube[4] = P-K+I+J; objCube[5] = P-K+I-J; - objCube[6] = P-K-I-J; objCube[7] = P-K-I+J; - - // Transform the corners of the box: - for (int vert = 0; vert < 8; vert++) - ndcCube[vert] = modelViewProjection * objCube[vert]; - - // Emit the six faces: - for (int face = 0; face < 6; face++) - emit_face(face); -} diff --git a/shaders/singlepassraycaster.vert b/shaders/singlepassraycaster.vert deleted file mode 100644 index f62e2c2a5e..0000000000 --- a/shaders/singlepassraycaster.vert +++ /dev/null @@ -1,36 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -// Based on http://prideout.net/blog/?p=64 - -layout(location = 0) in vec4 Position; -out vec4 vPosition; -uniform mat4 modelViewProjection; - -void main() { - gl_Position = modelViewProjection * Position; - vPosition = Position; -} \ No newline at end of file diff --git a/shaders/twopassraycaster.frag b/shaders/twopassraycaster.frag deleted file mode 100644 index 2456c232b3..0000000000 --- a/shaders/twopassraycaster.frag +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -uniform sampler2D texBack, texFront; -uniform sampler3D texVolume; -uniform float stepSize; - -in vec3 vPosition; -in vec2 texCoords; -out vec4 fragColor; - -void main() { - vec3 front = texture(texFront, texCoords).xyz; - vec3 back = texture(texBack, texCoords).xyz; - vec3 direction = back-front; - float directionLength = length(direction); - direction = normalize(direction); - vec3 position = front; - vec4 tmp, color = vec4(0); - - while (length(position-front) < directionLength && color.r != 1.0) { - tmp = texture(texVolume, position); - color = max(color, tmp); // MIP - position = position + direction * stepSize; - } - - fragColor = vec4(color.rrr, 1.0); - - // // DEBUG DEBUG DEBUG - // fragColor = vec4(front, 1.0); - // if (front.x < 0.1) - // fragColor = vec4(1.0); - - // if (front.y < 0.1) - // fragColor = vec4(1.0); - - // if (front.x > 0.9) - // fragColor = vec4(1.0); - - // if (front.y > 0.9) - // fragColor = vec4(1.0); - - // if (front.x > 0.45 && front.x < 0.55) - // fragColor = vec4(0.0); - - // if (front.y > 0.45 && front.y < 0.55) - // fragColor = vec4(0.0); -} \ No newline at end of file diff --git a/shaders/twopassraycaster.vert b/shaders/twopassraycaster.vert deleted file mode 100644 index 01669e0b9c..0000000000 --- a/shaders/twopassraycaster.vert +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -layout(location = 0) in vec2 texCoordinate; -layout(location = 2) in vec3 vertPosition; - -out vec3 vPosition; -out vec2 texCoords; - -// Source: http://stackoverflow.com/questions/2588875/whats-the-best-way-to-draw-a-fullscreen-quad-in-opengl-3-2 -const vec2 screenScale = vec2(0.5, 0.5); - -void main() { - texCoords = vertPosition.xy*screenScale+screenScale; // scale vertex attribute to [0-1] range - gl_Position = vec4(vertPosition.xy, 0.0, 1.0); -} \ No newline at end of file diff --git a/src/engine/configurationmanager.cpp b/src/engine/configurationmanager.cpp index 30e21f1ea6..f868aa5316 100644 --- a/src/engine/configurationmanager.cpp +++ b/src/engine/configurationmanager.cpp @@ -50,8 +50,6 @@ const string ConfigurationManager::KeyPropertyDocumentationType = const string ConfigurationManager::KeyPropertyDocumentationFile = "PropertyDocumentationFile.File"; const string ConfigurationManager::KeyConfigScene = "Scene"; -const string ConfigurationManager::KeyStartupScript = "StartupScripts"; -const string ConfigurationManager::KeySettingsScript = "SettingsScripts"; const string ConfigurationManager::KeySpiceTimeKernel = "SpiceKernel.Time"; const string ConfigurationManager::KeySpiceLeapsecondKernel = "SpiceKernel.LeapSecond"; const string ConfigurationManager::KeyLogLevel = "Logging.LogLevel"; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 9d3a6d4df9..8fafb203e4 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include @@ -87,6 +88,9 @@ namespace { const std::string _defaultCacheLocation = "${BASE_PATH}/cache"; const std::string _sgctConfigArgumentCommand = "-config"; + + const std::string PreInitializeFunction = "preInitialization"; + const std::string PostInitializationFunction = "postInitialization"; const int CacheVersion = 1; const int DownloadVersion = 1; @@ -398,7 +402,7 @@ bool OpenSpaceEngine::initialize() { _interactionHandler->setMouseController(new interaction::OrbitalMouseController); // Run start up scripts - runStartupScripts(); + runPreInitializationScripts(sceneDescriptionPath); // Load a light and a monospaced font loadFonts(); @@ -504,18 +508,64 @@ void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) { } -void OpenSpaceEngine::runStartupScripts() { - ghoul::Dictionary scripts; - configurationManager().getValue( - ConfigurationManager::KeyStartupScript, scripts); - runScripts(scripts); +void OpenSpaceEngine::runPreInitializationScripts(const std::string& sceneDescription) { + LINFO("Running Initialization scripts"); + lua_State* state = ghoul::lua::createNewLuaState(); + OnExit( + // Delete the Lua state at the end of the scope, no matter what + [state](){ghoul::lua::destroyLuaState(state);} + ); + OsEng.scriptEngine().initializeLuaState(state); + + // First execute the script to get all global variables + ghoul::lua::runScriptFile(state, absPath(sceneDescription)); + + // Get the preinitialize function + lua_getglobal(state, PreInitializeFunction.c_str()); + bool isFunction = lua_isfunction(state, -1); + if (!isFunction) { + LERROR("Error executing startup script '" << sceneDescription << "'. Scene '" << + sceneDescription << "' does not have a function '" << + PreInitializeFunction << "'"); + return; + } + + // And execute the preinitialize function + int success = lua_pcall(state, 0, 0, 0); + if (success != 0) { + LERROR("Error executing '" << PreInitializeFunction << "': " << + lua_tostring(state, -1)); + } } -void OpenSpaceEngine::runSettingsScripts() { - ghoul::Dictionary scripts; - configurationManager().getValue( - ConfigurationManager::KeySettingsScript, scripts); - runScripts(scripts); +void OpenSpaceEngine::runPostInitializationScripts(const std::string& sceneDescription) { + LINFO("Running Setup scripts"); + lua_State* state = ghoul::lua::createNewLuaState(); + OnExit( + // Delete the Lua state at the end of the scope, no matter what + [state](){ghoul::lua::destroyLuaState(state);} + ); + OsEng.scriptEngine().initializeLuaState(state); + + // First execute the script to get all global variables + ghoul::lua::runScriptFile(state, absPath(sceneDescription)); + + // Get the preinitialize function + lua_getglobal(state, PostInitializationFunction.c_str()); + bool isFunction = lua_isfunction(state, -1); + if (!isFunction) { + LERROR("Error executing startup script '" << sceneDescription << "'. Scene '" << + sceneDescription << "' does not have a function '" << + PostInitializationFunction << "'"); + return; + } + + // And execute the preinitialize function + int success = lua_pcall(state, 0, 0, 0); + if (success != 0) { + LERROR("Error executing '" << PostInitializationFunction << "': " << + lua_tostring(state, -1)); + } } void OpenSpaceEngine::loadFonts() { diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index 31c30d3c68..79e09f3f44 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -50,7 +50,7 @@ InteractionHandler::InteractionHandler() , _deltaTime(0.0) , _validKeyLua(false) , _controllerSensitivity(1.f) - , _invertRoll(false) + , _invertRoll(true) , _invertRotation(false) , _keyboardController(nullptr) , _mouseController(nullptr) diff --git a/src/interaction/luaconsole_lua.inl b/src/interaction/luaconsole_lua.inl index 72c9b6fabc..99497bfaeb 100644 --- a/src/interaction/luaconsole_lua.inl +++ b/src/interaction/luaconsole_lua.inl @@ -32,12 +32,12 @@ namespace luascriptfunctions { * Shows the console */ int show(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 0) + return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.console().setVisible(true); - return 0; + OsEng.console().setVisible(true); + return 0; } /** @@ -46,12 +46,12 @@ int show(lua_State* L) { * Hides the console */ int hide(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 0) + return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.console().setVisible(false); - return 0; + OsEng.console().setVisible(false); + return 0; } /** @@ -60,12 +60,12 @@ int hide(lua_State* L) { * Toggles the console */ int toggle(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 0) + return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.console().toggleVisibility(); - return 0; + OsEng.console().toggleVisibility(); + return 0; } } // namespace luascriptfunctions diff --git a/src/network/parallelconnection_lua.inl b/src/network/parallelconnection_lua.inl index 6361b3038a..59ef2b3730 100644 --- a/src/network/parallelconnection_lua.inl +++ b/src/network/parallelconnection_lua.inl @@ -33,118 +33,118 @@ namespace luascriptfunctions { */ int setPort(lua_State* L) { - const bool isFunction = (lua_isfunction(L, -1) != 0); - if (isFunction) { - // If the top of the stack is a function, it is ourself - const char* msg = lua_pushfstring(L, "method called without argument"); - return luaL_error(L, "bad argument (%s)", msg); - } + const bool isFunction = (lua_isfunction(L, -1) != 0); + if (isFunction) { + // If the top of the stack is a function, it is ourself + const char* msg = lua_pushfstring(L, "method called without argument"); + return luaL_error(L, "bad argument (%s)", msg); + } - const bool isNumber = (lua_isnumber(L, -1) != 0); - if (isNumber) { - int value = lua_tonumber(L, -1); - std::string port = std::to_string(value); + const bool isNumber = (lua_isnumber(L, -1) != 0); + if (isNumber) { + int value = lua_tonumber(L, -1); + std::string port = std::to_string(value); if(OsEng.isMaster()){ OsEng.parallelConnection().setPort(port); } - return 0; - } - else { - const char* msg = lua_pushfstring(L, "%s expected, got %s", - lua_typename(L, LUA_TNUMBER), luaL_typename(L, -1)); - return luaL_error(L, "bad argument #%d (%s)", 1, msg); - } + return 0; + } + else { + const char* msg = lua_pushfstring(L, "%s expected, got %s", + lua_typename(L, LUA_TNUMBER), luaL_typename(L, -1)); + return luaL_error(L, "bad argument #%d (%s)", 1, msg); + } - return 0; + return 0; } int setAddress(lua_State* L) { - const bool isFunction = (lua_isfunction(L, -1) != 0); - if (isFunction) { - // If the top of the stack is a function, it is ourself - const char* msg = lua_pushfstring(L, "method called without argument"); - return luaL_error(L, "bad argument (%s)", msg); - } + const bool isFunction = (lua_isfunction(L, -1) != 0); + if (isFunction) { + // If the top of the stack is a function, it is ourself + const char* msg = lua_pushfstring(L, "method called without argument"); + return luaL_error(L, "bad argument (%s)", msg); + } - const int type = lua_type(L, -1); - if (type == LUA_TSTRING) { - std::string address = luaL_checkstring(L, -1); + const int type = lua_type(L, -1); + if (type == LUA_TSTRING) { + std::string address = luaL_checkstring(L, -1); if(OsEng.isMaster()){ OsEng.parallelConnection().setAddress(address); } - return 0; - } - else { - const char* msg = lua_pushfstring(L, "%s expected, got %s", - lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); - return luaL_error(L, "bad argument #%d (%s)", 1, msg); - } + return 0; + } + else { + const char* msg = lua_pushfstring(L, "%s expected, got %s", + lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); + return luaL_error(L, "bad argument #%d (%s)", 1, msg); + } - return 0; + return 0; } int setPassword(lua_State* L) { - const bool isFunction = (lua_isfunction(L, -1) != 0); - if (isFunction) { - // If the top of the stack is a function, it is ourself - const char* msg = lua_pushfstring(L, "method called without argument"); - return luaL_error(L, "bad argument (%s)", msg); - } + const bool isFunction = (lua_isfunction(L, -1) != 0); + if (isFunction) { + // If the top of the stack is a function, it is ourself + const char* msg = lua_pushfstring(L, "method called without argument"); + return luaL_error(L, "bad argument (%s)", msg); + } - const int type = lua_type(L, -1); - if (type == LUA_TSTRING) { - std::string pwd = luaL_checkstring(L, -1); + const int type = lua_type(L, -1); + if (type == LUA_TSTRING) { + std::string pwd = luaL_checkstring(L, -1); if(OsEng.isMaster()){ OsEng.parallelConnection().setPassword(pwd); } - return 0; - } - else { - const char* msg = lua_pushfstring(L, "%s expected, got %s", - lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); - return luaL_error(L, "bad argument #%d (%s)", 1, msg); - } + return 0; + } + else { + const char* msg = lua_pushfstring(L, "%s expected, got %s", + lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); + return luaL_error(L, "bad argument #%d (%s)", 1, msg); + } - return 0; + return 0; } int setDisplayName(lua_State* L) { - const bool isFunction = (lua_isfunction(L, -1) != 0); - if (isFunction) { - // If the top of the stack is a function, it is ourself - const char* msg = lua_pushfstring(L, "method called without argument"); - return luaL_error(L, "bad argument (%s)", msg); - } + const bool isFunction = (lua_isfunction(L, -1) != 0); + if (isFunction) { + // If the top of the stack is a function, it is ourself + const char* msg = lua_pushfstring(L, "method called without argument"); + return luaL_error(L, "bad argument (%s)", msg); + } - const int type = lua_type(L, -1); - if (type == LUA_TSTRING) { - std::string name = luaL_checkstring(L, -1); + const int type = lua_type(L, -1); + if (type == LUA_TSTRING) { + std::string name = luaL_checkstring(L, -1); if(OsEng.isMaster()){ OsEng.parallelConnection().setName(name); } - return 0; - } - else { - const char* msg = lua_pushfstring(L, "%s expected, got %s", - lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); - return luaL_error(L, "bad argument #%d (%s)", 1, msg); - } + return 0; + } + else { + const char* msg = lua_pushfstring(L, "%s expected, got %s", + lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); + return luaL_error(L, "bad argument #%d (%s)", 1, msg); + } - return 0; + return 0; } int connect(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 0) + return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); if(OsEng.isMaster()){ OsEng.parallelConnection().clientConnect(); } - return 0; + return 0; } int disconnect(lua_State* L) { diff --git a/src/rendering/renderengine_lua.inl b/src/rendering/renderengine_lua.inl index cd7b78885d..558182620e 100644 --- a/src/rendering/renderengine_lua.inl +++ b/src/rendering/renderengine_lua.inl @@ -39,16 +39,16 @@ int changeCoordinateSystem(lua_State* L) { */ /** - * \ingroup LuaScripts - * takeScreenshot(): - * Save the rendering to an image file - */ + * \ingroup LuaScripts + * takeScreenshot(): + * Save the rendering to an image file + */ int takeScreenshot(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.renderEngine().takeScreenshot(); - return 0; + int nArguments = lua_gettop(L); + if (nArguments != 0) + return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); + OsEng.renderEngine().takeScreenshot(); + return 0; } /** @@ -57,16 +57,16 @@ int takeScreenshot(lua_State* L) { * Set renderer */ int setRenderer(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - const int type = lua_type(L, -1); + const int type = lua_type(L, -1); if (type != LUA_TSTRING) return luaL_error(L, "Expected argument of type 'bool'"); std::string r = lua_tostring(L, -1); OsEng.renderEngine().setRendererFromString(r); - return 0; + return 0; } /** @@ -75,16 +75,16 @@ int setRenderer(lua_State* L) { * Toggle the visualization of the ABuffer */ int showRenderInformation(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - const int type = lua_type(L, -1); + const int type = lua_type(L, -1); if (type != LUA_TBOOLEAN) return luaL_error(L, "Expected argument of type 'bool'"); - bool b = lua_toboolean(L, -1) != 0; - OsEng.renderEngine().toggleInfoText(b); - return 0; + bool b = lua_toboolean(L, -1) != 0; + OsEng.renderEngine().toggleInfoText(b); + return 0; } /** @@ -93,13 +93,13 @@ int showRenderInformation(lua_State* L) { * Toggle the visualization of the ABuffer */ int setPerformanceMeasurement(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - bool b = lua_toboolean(L, -1) != 0; - OsEng.renderEngine().setPerformanceMeasurements(b); - return 0; + bool b = lua_toboolean(L, -1) != 0; + OsEng.renderEngine().setPerformanceMeasurements(b); + return 0; } /** @@ -108,14 +108,14 @@ int setPerformanceMeasurement(lua_State* L) { * start a global fadein over (float) seconds */ int fadeIn(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - double t = luaL_checknumber(L, -1); - - OsEng.renderEngine().startFading(1, static_cast(t)); - return 0; + double t = luaL_checknumber(L, -1); + + OsEng.renderEngine().startFading(1, static_cast(t)); + return 0; } /** * \ingroup LuaScripts @@ -123,14 +123,14 @@ int fadeIn(lua_State* L) { * start a global fadeout over (float) seconds */ int fadeOut(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - double t = luaL_checknumber(L, -1); + double t = luaL_checknumber(L, -1); - OsEng.renderEngine().startFading(-1, static_cast(t)); - return 0; + OsEng.renderEngine().startFading(-1, static_cast(t)); + return 0; } } // namespace luascriptfunctions diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 5fd2c0a9f1..190c8d77fb 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -77,24 +78,7 @@ Scene::~Scene() { } bool Scene::initialize() { - LDEBUG("Initializing SceneGraph"); - - using ghoul::opengl::ShaderObject; - using ghoul::opengl::ProgramObject; - - std::unique_ptr tmpProgram; - - // fboPassthrough program - tmpProgram = ProgramObject::Build( - "fboPassProgram", - "${SHADERS}/fboPass_vs.glsl", - "${SHADERS}/fboPass_fs.glsl"); - if (!tmpProgram) - return false; - - tmpProgram->setIgnoreSubroutineUniformLocationError(ProgramObject::IgnoreError::Yes); - OsEng.configurationManager().setValue("fboPassProgram", tmpProgram.get()); - + LDEBUG("Initializing SceneGraph"); return true; } @@ -159,7 +143,21 @@ void Scene::clearSceneGraph() { bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) { ghoul::Dictionary dictionary; - ghoul::lua::loadDictionaryFromFile(sceneDescriptionFilePath, dictionary); + + + lua_State* state = ghoul::lua::createNewLuaState(); + OnExit( + // Delete the Lua state at the end of the scope, no matter what + [state](){ghoul::lua::destroyLuaState(state);} + ); + + OsEng.scriptEngine().initializeLuaState(state); + + ghoul::lua::loadDictionaryFromFile( + sceneDescriptionFilePath, + dictionary, + state + ); _graph.loadFromFile(sceneDescriptionFilePath); @@ -291,6 +289,9 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) { // the camera position const SceneGraphNode* fn = OsEng.interactionHandler().focusNode(); + if (!fn) { + throw ghoul::RuntimeError("Could not find focus node"); + } // Check crash for when fn == nullptr glm::mat4 la = glm::lookAt(cameraPosition.vec3(), fn->worldPosition().vec3(), c->lookUpVector()); @@ -328,7 +329,7 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) { } - OsEng.runSettingsScripts(); + OsEng.runPostInitializationScripts(sceneDescriptionFilePath); OsEng.enableBarrier(); diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index ed07ef8408..a14bdb0b3c 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -38,34 +38,34 @@ int property_setValue(lua_State* L) { using ghoul::lua::errorLocation; using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); + int nArguments = lua_gettop(L); SCRIPT_CHECK_ARGUMENTS(L, 2, nArguments); - std::string uri = luaL_checkstring(L, -2); - const int type = lua_type(L, -1); + std::string uri = luaL_checkstring(L, -2); + const int type = lua_type(L, -1); - openspace::properties::Property* prop = property(uri); - if (!prop) { + openspace::properties::Property* prop = property(uri); + if (!prop) { LERROR(errorLocation(L) << "Property with URI '" << uri << "' was not found"); return 0; } - if (type != prop->typeLua()) { + if (type != prop->typeLua()) { LERROR(errorLocation(L) << "Property '" << uri << "' does not accept input of type '" << luaTypeToString(type) << "'. Requested type: '" << luaTypeToString(prop->typeLua()) << "'"); return 0; } else{ - prop->setLuaValue(L); + prop->setLuaValue(L); //ensure properties are synced over parallel connection std::string value; prop->getStringValue(value); OsEng.parallelConnection().scriptMessage(prop->fullyQualifiedIdentifier(), value); } - return 0; + return 0; } /** @@ -78,19 +78,19 @@ int property_getValue(lua_State* L) { static const std::string _loggerCat = "property_getValue"; using ghoul::lua::errorLocation; - int nArguments = lua_gettop(L); + int nArguments = lua_gettop(L); SCRIPT_CHECK_ARGUMENTS(L, 1, nArguments); - std::string uri = luaL_checkstring(L, -1); + std::string uri = luaL_checkstring(L, -1); - openspace::properties::Property* prop = property(uri); - if (!prop) { + openspace::properties::Property* prop = property(uri); + if (!prop) { LERROR(errorLocation(L) << "Property with URL '" << uri << "' was not found"); return 0; } - else - prop->getLuaValue(L); - return 1; + else + prop->getLuaValue(L); + return 1; } /** @@ -102,14 +102,14 @@ int property_getValue(lua_State* L) { int loadScene(lua_State* L) { static const std::string _loggerCat = "loadScene"; - int nArguments = lua_gettop(L); + int nArguments = lua_gettop(L); SCRIPT_CHECK_ARGUMENTS(L, 1, nArguments); - std::string sceneFile = luaL_checkstring(L, -1); + std::string sceneFile = luaL_checkstring(L, -1); - OsEng.renderEngine().scene()->scheduleLoadSceneFile(sceneFile); + OsEng.renderEngine().scene()->scheduleLoadSceneFile(sceneFile); - return 0; + return 0; } } // namespace luascriptfunctions diff --git a/src/scene/scenegraph.cpp b/src/scene/scenegraph.cpp index 78848535f7..da01476bf6 100644 --- a/src/scene/scenegraph.cpp +++ b/src/scene/scenegraph.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -89,10 +90,24 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) { } LINFO("Loading SceneGraph from file '" << absSceneFile << "'"); + + lua_State* state = ghoul::lua::createNewLuaState(); + OnExit( + // Delete the Lua state at the end of the scope, no matter what + [state](){ghoul::lua::destroyLuaState(state);} + ); + + OsEng.scriptEngine().initializeLuaState(state); + + // Load dictionary ghoul::Dictionary sceneDictionary; try { - ghoul::lua::loadDictionaryFromFile(absSceneFile, sceneDictionary); + ghoul::lua::loadDictionaryFromFile( + absSceneFile, + sceneDictionary, + state + ); } catch (...) { return false; @@ -127,8 +142,8 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) { // There are no modules that are loaded return true; - lua_State* state = ghoul::lua::createNewLuaState(); - OsEng.scriptEngine().initializeLuaState(state); +// lua_State* state = ghoul::lua::createNewLuaState(); +// OsEng.scriptEngine().initializeLuaState(state); // Above we generated a ghoul::Dictionary from the scene file; now we run the scene // file again to load any variables defined inside into the state that is passed to @@ -324,7 +339,7 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) { addModule(i); } } - ghoul::lua::destroyLuaState(state); +// ghoul::lua::destroyLuaState(state); FileSys.setCurrentDirectory(oldDirectory); for (SceneGraphNodeInternal* node : _nodes) { diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index 38ce5a1b16..8b08660d4b 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -26,131 +26,131 @@ namespace openspace { namespace luascriptfunctions { - int printInternal(ghoul::logging::LogManager::LogLevel level, lua_State* L) { - using ghoul::lua::luaTypeToString; - const std::string _loggerCat = "print"; + int printInternal(ghoul::logging::LogManager::LogLevel level, lua_State* L) { + using ghoul::lua::luaTypeToString; + const std::string _loggerCat = "print"; - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - const int type = lua_type(L, -1); - switch (type) { - case LUA_TNONE: - case LUA_TLIGHTUSERDATA: - case LUA_TTABLE: - case LUA_TFUNCTION: - case LUA_TUSERDATA: - case LUA_TTHREAD: - LOG(level, "Function parameter was of type '" << - luaTypeToString(type) << "'"); - case LUA_TNIL: - break; - case LUA_TBOOLEAN: - LOG(level, lua_toboolean(L, -1)); - break; - case LUA_TNUMBER: - LOG(level, lua_tonumber(L, -1)); - break; - case LUA_TSTRING: - LOG(level, lua_tostring(L, -1)); - break; - } - return 0; - } + const int type = lua_type(L, -1); + switch (type) { + case LUA_TNONE: + case LUA_TLIGHTUSERDATA: + case LUA_TTABLE: + case LUA_TFUNCTION: + case LUA_TUSERDATA: + case LUA_TTHREAD: + LOG(level, "Function parameter was of type '" << + luaTypeToString(type) << "'"); + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + LOG(level, lua_toboolean(L, -1)); + break; + case LUA_TNUMBER: + LOG(level, lua_tonumber(L, -1)); + break; + case LUA_TSTRING: + LOG(level, lua_tostring(L, -1)); + break; + } + return 0; + } - /** - * \ingroup LuaScripts - * printDebug(*): - * Logs the passed value to the installed LogManager with a LogLevel of 'Debug'. - * For Boolean, numbers, and strings, the internal values are printed, for all other - * types, the type is printed instead - */ - int printDebug(lua_State* L) { - return printInternal(ghoul::logging::LogManager::LogLevel::Debug, L); - } + /** + * \ingroup LuaScripts + * printDebug(*): + * Logs the passed value to the installed LogManager with a LogLevel of 'Debug'. + * For Boolean, numbers, and strings, the internal values are printed, for all other + * types, the type is printed instead + */ + int printDebug(lua_State* L) { + return printInternal(ghoul::logging::LogManager::LogLevel::Debug, L); + } - /** - * \ingroup LuaScripts - * printInfo(*): - * Logs the passed value to the installed LogManager with a LogLevel of 'Info'. - * For Boolean, numbers, and strings, the internal values are printed, for all other - * types, the type is printed instead - */ - int printInfo(lua_State* L) { - return printInternal(ghoul::logging::LogManager::LogLevel::Info, L); - } + /** + * \ingroup LuaScripts + * printInfo(*): + * Logs the passed value to the installed LogManager with a LogLevel of 'Info'. + * For Boolean, numbers, and strings, the internal values are printed, for all other + * types, the type is printed instead + */ + int printInfo(lua_State* L) { + return printInternal(ghoul::logging::LogManager::LogLevel::Info, L); + } - /** - * \ingroup LuaScripts - * printWarning(*): - * Logs the passed value to the installed LogManager with a LogLevel of 'Warning'. - * For Boolean, numbers, and strings, the internal values are printed, for all other - * types, the type is printed instead - */ - int printWarning(lua_State* L) { - return printInternal(ghoul::logging::LogManager::LogLevel::Warning, L); - } + /** + * \ingroup LuaScripts + * printWarning(*): + * Logs the passed value to the installed LogManager with a LogLevel of 'Warning'. + * For Boolean, numbers, and strings, the internal values are printed, for all other + * types, the type is printed instead + */ + int printWarning(lua_State* L) { + return printInternal(ghoul::logging::LogManager::LogLevel::Warning, L); + } - /** - * \ingroup LuaScripts - * printError(*): - * Logs the passed value to the installed LogManager with a LogLevel of 'Error'. - * For Boolean, numbers, and strings, the internal values are printed, for all other - * types, the type is printed instead - */ - int printError(lua_State* L) { - return printInternal(ghoul::logging::LogManager::LogLevel::Error, L); - } + /** + * \ingroup LuaScripts + * printError(*): + * Logs the passed value to the installed LogManager with a LogLevel of 'Error'. + * For Boolean, numbers, and strings, the internal values are printed, for all other + * types, the type is printed instead + */ + int printError(lua_State* L) { + return printInternal(ghoul::logging::LogManager::LogLevel::Error, L); + } - /** - * \ingroup LuaScripts - * printFatal(*): - * Logs the passed value to the installed LogManager with a LogLevel of 'Fatal'. - * For Boolean, numbers, and strings, the internal values are printed, for all other - * types, the type is printed instead - */ - int printFatal(lua_State* L) { - return printInternal(ghoul::logging::LogManager::LogLevel::Fatal, L); - } + /** + * \ingroup LuaScripts + * printFatal(*): + * Logs the passed value to the installed LogManager with a LogLevel of 'Fatal'. + * For Boolean, numbers, and strings, the internal values are printed, for all other + * types, the type is printed instead + */ + int printFatal(lua_State* L) { + return printInternal(ghoul::logging::LogManager::LogLevel::Fatal, L); + } - /** - * \ingroup LuaScripts - * absPath(string): - * Passes the argument to FileSystem::absolutePath, which resolves occuring path - * tokens and returns the absolute path. - */ - int absolutePath(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %d arguments, got %d", 1, nArguments); + /** + * \ingroup LuaScripts + * absPath(string): + * Passes the argument to FileSystem::absolutePath, which resolves occuring path + * tokens and returns the absolute path. + */ + int absolutePath(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %d arguments, got %d", 1, nArguments); - std::string path = luaL_checkstring(L, -1); - path = absPath(path); - lua_pushstring(L, path.c_str()); - return 1; - } + std::string path = luaL_checkstring(L, -1); + path = absPath(path); + lua_pushstring(L, path.c_str()); + return 1; + } - /** - * \ingroup LuaScripts - * setPathToken(string, string): - * Registers the path token provided by the first argument to the path in the second - * argument. If the path token already exists, it will be silently overridden. - */ - int setPathToken(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 2) - return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments); + /** + * \ingroup LuaScripts + * setPathToken(string, string): + * Registers the path token provided by the first argument to the path in the second + * argument. If the path token already exists, it will be silently overridden. + */ + int setPathToken(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments != 2) + return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments); - std::string pathToken = luaL_checkstring(L, -1); - std::string path = luaL_checkstring(L, -2); - FileSys.registerPathToken( + std::string pathToken = luaL_checkstring(L, -1); + std::string path = luaL_checkstring(L, -2); + FileSys.registerPathToken( pathToken, path, ghoul::filesystem::FileSystem::Override::Yes ); - return 0; - } + return 0; + } } // namespace luascriptfunctions diff --git a/src/util/time.cpp b/src/util/time.cpp index eb6b61efa8..a4aa96925f 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -24,13 +24,14 @@ #include +#include "time_lua.inl" + #include #include #include #include -#include "time_lua.inl" namespace openspace { @@ -215,6 +216,13 @@ scripting::ScriptEngine::LuaLibrary Time::luaLibrary() { "", "Returns the current time as an ISO 8601 date string " "(YYYY-MM-DDTHH:MN:SS)" + }, + { + "currentWallTime", + &luascriptfunctions::time_currentWallTime, + "", + "Returns the current wall time as an ISO 8601 date string " + "(YYYY-MM-DDTHH-MN-SS) in the UTC timezone" } } }; diff --git a/src/util/time_lua.inl b/src/util/time_lua.inl index 1b77cd851a..687780c459 100644 --- a/src/util/time_lua.inl +++ b/src/util/time_lua.inl @@ -22,6 +22,11 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include + +#include +#include + namespace openspace { namespace luascriptfunctions { @@ -32,24 +37,24 @@ namespace luascriptfunctions { * Sets the delta time by calling the Time::setDeltaTime method */ int time_setDeltaTime(lua_State* L) { - const bool isFunction = (lua_isfunction(L, -1) != 0); - if (isFunction) { - // If the top of the stack is a function, it is ourself - const char* msg = lua_pushfstring(L, "method called without argument"); - return luaL_error(L, "bad argument (%s)", msg); - } + const bool isFunction = (lua_isfunction(L, -1) != 0); + if (isFunction) { + // If the top of the stack is a function, it is ourself + const char* msg = lua_pushfstring(L, "method called without argument"); + return luaL_error(L, "bad argument (%s)", msg); + } - const bool isNumber = (lua_isnumber(L, -1) != 0); - if (isNumber) { - double value = lua_tonumber(L, -1); - openspace::Time::ref().setDeltaTime(value); - return 0; - } - else { - const char* msg = lua_pushfstring(L, "%s expected, got %s", - lua_typename(L, LUA_TNUMBER), luaL_typename(L, -1)); - return luaL_error(L, "bad argument #%d (%s)", 1, msg); - } + const bool isNumber = (lua_isnumber(L, -1) != 0); + if (isNumber) { + double value = lua_tonumber(L, -1); + openspace::Time::ref().setDeltaTime(value); + return 0; + } + else { + const char* msg = lua_pushfstring(L, "%s expected, got %s", + lua_typename(L, LUA_TNUMBER), luaL_typename(L, -1)); + return luaL_error(L, "bad argument #%d (%s)", 1, msg); + } } @@ -59,8 +64,8 @@ int time_setDeltaTime(lua_State* L) { * Returns the delta time by calling the Time::deltaTime method */ int time_deltaTime(lua_State* L) { - lua_pushnumber(L, openspace::Time::ref().deltaTime()); - return 1; + lua_pushnumber(L, openspace::Time::ref().deltaTime()); + return 1; } /** @@ -99,32 +104,32 @@ int time_setPause(lua_State* L) { * is called */ int time_setTime(lua_State* L) { - const bool isFunction = (lua_isfunction(L, -1) != 0); - if (isFunction) { - // If the top of the stack is a function, it is ourself - const char* msg = lua_pushfstring(L, "method called without argument"); - return luaL_error(L, "bad argument (%s)", 1, msg); - } + const bool isFunction = (lua_isfunction(L, -1) != 0); + if (isFunction) { + // If the top of the stack is a function, it is ourself + const char* msg = lua_pushfstring(L, "method called without argument"); + return luaL_error(L, "bad argument (%s)", 1, msg); + } - const bool isNumber = (lua_isnumber(L, -1) != 0); - const bool isString = (lua_isstring(L, -1) != 0); - if (!isNumber && !isString) { - const char* msg = lua_pushfstring(L, "%s or %s expected, got %s", - lua_typename(L, LUA_TNUMBER), - lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); - return luaL_error(L, "bad argument #%d (%s)", 1, msg); - } - if (isNumber) { - double value = lua_tonumber(L, -1); - openspace::Time::ref().setTime(value); - return 0; - } - if (isString) { - const char* time = lua_tostring(L, -1); - openspace::Time::ref().setTime(time); - return 0; - } - return 0; + const bool isNumber = (lua_isnumber(L, -1) != 0); + const bool isString = (lua_isstring(L, -1) != 0); + if (!isNumber && !isString) { + const char* msg = lua_pushfstring(L, "%s or %s expected, got %s", + lua_typename(L, LUA_TNUMBER), + lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); + return luaL_error(L, "bad argument #%d (%s)", 1, msg); + } + if (isNumber) { + double value = lua_tonumber(L, -1); + openspace::Time::ref().setTime(value); + return 0; + } + if (isString) { + const char* time = lua_tostring(L, -1); + openspace::Time::ref().setTime(time); + return 0; + } + return 0; } /** @@ -134,8 +139,8 @@ int time_setTime(lua_State* L) { * It is returned by calling the Time::currentTime method. */ int time_currentTime(lua_State* L) { - lua_pushnumber(L, openspace::Time::ref().currentTime()); - return 1; + lua_pushnumber(L, openspace::Time::ref().currentTime()); + return 1; } /** @@ -145,8 +150,31 @@ int time_currentTime(lua_State* L) { * timezone by calling the Time::currentTimeUTC method */ int time_currentTimeUTC(lua_State* L) { - lua_pushstring(L, openspace::Time::ref().currentTimeUTC().c_str()); - return 1; + lua_pushstring(L, openspace::Time::ref().currentTimeUTC().c_str()); + return 1; +} + +/** + * \ingroup LuaScripts + * currentWallTime(): + * Returns the current wallclock time as a structured ISO 8601 string in the UTC timezone. + */ +int time_currentWallTime(lua_State* L) { + std::time_t t = std::time(nullptr); + std::tm* utcTime = std::gmtime(&t); + ghoul_assert(utcTime, "Conversion to UTC failed"); + + std::string time = fmt::format( + "{:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}", + utcTime->tm_year + 1900, + utcTime->tm_mon + 1, + utcTime->tm_mday, + utcTime->tm_hour, + utcTime->tm_min, + utcTime->tm_sec + ); + lua_pushstring(L, time.c_str()); + return 1; } } // namespace luascriptfunctions diff --git a/support/cmake/support_macros.cmake b/support/cmake/support_macros.cmake index 8e3bb7e588..44bbbc0df7 100644 --- a/support/cmake/support_macros.cmake +++ b/support/cmake/support_macros.cmake @@ -149,7 +149,7 @@ function (add_external_dependencies) # Unfortunately, we have to set this value manually; sigh # In the future, if the Qt version is updated, just add to this variable ---abock if (APPLE) - set(CMAKE_PREFIX_PATH "~/Qt/5.5/clang_64/lib/cmake" PARENT_SCOPE) + set(CMAKE_PREFIX_PATH "~/Qt/5.6/clang_64/lib/cmake" PARENT_SCOPE) endif () endfunction () diff --git a/support/coding/convert_tabs.py b/support/coding/convert_tabs.py index 7ee74f1cf1..c87c4f5316 100644 --- a/support/coding/convert_tabs.py +++ b/support/coding/convert_tabs.py @@ -37,6 +37,7 @@ if len(sys.argv) > 1: positivePathList = [ 'src/**/*.cpp', + 'src/**/*.inl', 'include/**/*.h', 'include/**/*.inl', 'apps/**/*.cpp', @@ -53,7 +54,8 @@ positivePathList = [ 'shaders/**/*.hglsl', 'shaders/**/*.vert', 'shaders/**/*.gs', - 'shaders/**/*.frag' + 'shaders/**/*.frag', + 'data/**/*.mod' ] negativePathList = [