mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-26 05:58:48 -05:00
2323a8ce50
* Allow changing color map during runtime * Stary building asset with colormaps (currently using local files) * Add option to invert the color maps * Remove final use of local viridis file in example and fix broken cmap update * Use synced resource for colormap files * Update advanced colormapping example * Apply suggestions from code review Co-authored-by: Alexander Bock <alexander.bock@liu.se> * Update data/assets/util/default_colormaps.asset * Capitalize first letter of exported keys, to be more consistent with rest of code base --------- Co-authored-by: Alexander Bock <alexander.bock@liu.se>
238 lines
7.4 KiB
Lua
238 lines
7.4 KiB
Lua
local earthAsset = asset.require("scene/solarsystem/planets/earth/earth")
|
|
local colormaps = asset.require("util/default_colormaps")
|
|
|
|
|
|
|
|
-- Color mapped points close to Earth, with some different settings for color and
|
|
-- sizing, and a StaticRotation that makes them not overlap
|
|
|
|
-- Point cloud with fixed color and default size (fixed)
|
|
local FixedColor_FixedSize = {
|
|
Identifier = "ExamplePoints_FixedSize",
|
|
Parent = earthAsset.Earth.Identifier,
|
|
Renderable = {
|
|
Type = "RenderablePointCloud",
|
|
File = asset.resource("data/dummydata.csv"),
|
|
Coloring = {
|
|
FixedColor = { 0.0, 0.5, 0.0 }
|
|
}
|
|
},
|
|
GUI = {
|
|
Name = "Fixed Color / Fixed Size",
|
|
Path = "/Example/Point Clouds",
|
|
Description = "Point cloud with a fixed color and fixed sizing"
|
|
}
|
|
}
|
|
|
|
-- Point cloud with fixed color and size scaling that is limited by a certain size
|
|
local FixedColor_MaxSize = {
|
|
Identifier = "ExamplePoints_MaxSize",
|
|
Parent = earthAsset.Earth.Identifier,
|
|
Transform = {
|
|
Rotation = {
|
|
Type = "StaticRotation",
|
|
Rotation = { 0, 0, 0.5 * math.pi }
|
|
}
|
|
},
|
|
Renderable = {
|
|
Type = "RenderablePointCloud",
|
|
File = asset.resource("data/dummydata.csv"),
|
|
Coloring = {
|
|
FixedColor = { 0.0, 1.0, 1.0 }
|
|
},
|
|
SizeSettings = {
|
|
MaxSize = 0.7,
|
|
EnableMaxSizeControl = true
|
|
}
|
|
},
|
|
GUI = {
|
|
Name = "Fixed Color / Max Size",
|
|
Path = "/Example/Point Clouds",
|
|
Description = "Point cloud with a fixed color and sizing with a given max size"
|
|
}
|
|
}
|
|
|
|
-- Point cloud with color mapping and fixed point sizing
|
|
local ColorMapped_FixedSize = {
|
|
Identifier = "ExamplePoints_ColorMapped",
|
|
Parent = earthAsset.Earth.Identifier,
|
|
Transform = {
|
|
Rotation = {
|
|
Type = "StaticRotation",
|
|
Rotation = { 0, 0, -0.5 * math.pi }
|
|
}
|
|
},
|
|
Renderable = {
|
|
Type = "RenderablePointCloud",
|
|
File = asset.resource("data/dummydata.csv"),
|
|
Coloring = {
|
|
ColorMapping = {
|
|
File = colormaps.Uniform.Viridis
|
|
}
|
|
},
|
|
SizeSettings = {
|
|
-- Here we set the exponent for the scale explicitly, to a value that
|
|
-- gives the points a suitable size based on their world-space coordinates
|
|
ScaleExponent = 6.5
|
|
}
|
|
},
|
|
GUI = {
|
|
Name = "Color Mapped",
|
|
Path = "/Example/Point Clouds",
|
|
Description = "Color mapped point cloud with fixed sizing"
|
|
}
|
|
}
|
|
|
|
-- Point cloud with fixed color and size scaling from a selected data column
|
|
local FixedColor_ScaleBasedOnData = {
|
|
Identifier = "ExamplePoints_ScaleFromData",
|
|
Parent = earthAsset.Earth.Identifier,
|
|
Transform = {
|
|
Rotation = {
|
|
Type = "StaticRotation",
|
|
Rotation = { 0, 0.5 * math.pi, 0 }
|
|
}
|
|
},
|
|
Renderable = {
|
|
Type = "RenderablePointCloud",
|
|
File = asset.resource("data/dummydata.csv"),
|
|
Coloring = {
|
|
FixedColor = { 0.5, 0.5, 0.0 }
|
|
},
|
|
SizeSettings = {
|
|
-- The options for the columns that the points can be scaled by. The first
|
|
-- alternative is chosen per default
|
|
SizeMapping = { "number_withNan", "a" },
|
|
-- Use a slightly smaller scale than above for the base size of the points
|
|
-- (will decide the size of the smallest point). That way, the points don't
|
|
-- become too big when scaled by the data parameter
|
|
ScaleExponent = 5
|
|
}
|
|
},
|
|
GUI = {
|
|
Name = "Fixed Color / Size From Data",
|
|
Path = "/Example/Point Clouds",
|
|
Description = [[Point cloud with a fixed color and sizing that can be set based on a
|
|
column in the dataset]]
|
|
}
|
|
}
|
|
|
|
-- Point cloud with textures. Textured points can also be color mapped, but here it
|
|
-- is disabled per default
|
|
local Textured = {
|
|
Identifier = "ExamplePoints_Textured",
|
|
Parent = earthAsset.Earth.Identifier,
|
|
Transform = {
|
|
Rotation = {
|
|
Type = "StaticRotation",
|
|
Rotation = { 0, math.pi, 0 }
|
|
}
|
|
},
|
|
Renderable = {
|
|
Type = "RenderablePointCloud",
|
|
File = asset.resource("data/dummydata.csv"),
|
|
-- The path to the texture file. Here we use openspace.absPath so that we can use
|
|
-- the ${DATA} token to get the path to a texture in the "OpenSpace/data" folder,
|
|
-- but for a file at a relative location it would also work to use asset.resource,
|
|
-- like for the data file above
|
|
Texture = openspace.absPath("${DATA}/test3.jpg"),
|
|
-- Disable additive blending, so that points will be rendered with their actual color
|
|
-- and overlapping points will be sorted by depth. This works best when the points
|
|
-- have an opacity of 1
|
|
UseAdditiveBlending = false,
|
|
Coloring = {
|
|
ColorMapping = {
|
|
-- Disable color map per default. When enabled, the texture color will be
|
|
-- multiplied with the color from the color map
|
|
Enabled = false,
|
|
File = colormaps.Uniform.Viridis
|
|
}
|
|
}
|
|
},
|
|
GUI = {
|
|
Name = "Textured",
|
|
Path = "/Example/Point Clouds",
|
|
Description = "Point cloud with a texture per point"
|
|
}
|
|
}
|
|
|
|
-- Point cloud with more advanced color mapping and fixed point sizing.
|
|
-- Here we have predefined a couple of parameters to use for the color mapping.
|
|
-- Also, missing/NaN values are mapped to a specific color.
|
|
-- Finally, no additive blending is used for the color, meaning that the color of
|
|
-- overlapping points will not be mixed/added
|
|
local ColorMappedAdvanced_NoBlend = {
|
|
Identifier = "ExamplePoints_ColorMappedNoBlend",
|
|
Parent = earthAsset.Earth.Identifier,
|
|
Transform = {
|
|
Rotation = {
|
|
Type = "StaticRotation",
|
|
Rotation = { 0, 0, math.pi }
|
|
}
|
|
},
|
|
Renderable = {
|
|
Type = "RenderablePointCloud",
|
|
File = asset.resource("data/dummydata.csv"),
|
|
UseAdditiveBlending = false, -- Disable additive blending
|
|
Coloring = {
|
|
ColorMapping = {
|
|
File = colormaps.Uniform.Viridis,
|
|
ParameterOptions = {
|
|
{ Key = "number_withNan" }, -- no range => compute min and max
|
|
{ Key = "normaldist_withMissing", Range = { -0.5, 0.5 } }
|
|
},
|
|
ShowMissingData = true,
|
|
NoDataColor = { 0.5, 0.5, 0.5, 1.0 }
|
|
}
|
|
},
|
|
SizeSettings = {
|
|
ScaleExponent = 6.5
|
|
}
|
|
},
|
|
GUI = {
|
|
Name = "Color Mapped (Advanced) - No blending",
|
|
Path = "/Example/Point Clouds",
|
|
Description = [[Color mapped point cloud without additive blending, with missing
|
|
values shown in grey, and a limited choice of parameter options to use for
|
|
the color mapping.]]
|
|
}
|
|
}
|
|
|
|
|
|
asset.onInitialize(function()
|
|
openspace.addSceneGraphNode(FixedColor_FixedSize)
|
|
openspace.addSceneGraphNode(FixedColor_MaxSize)
|
|
openspace.addSceneGraphNode(FixedColor_ScaleBasedOnData)
|
|
openspace.addSceneGraphNode(Textured)
|
|
openspace.addSceneGraphNode(ColorMapped_FixedSize)
|
|
openspace.addSceneGraphNode(ColorMappedAdvanced_NoBlend)
|
|
end)
|
|
|
|
asset.onDeinitialize(function()
|
|
openspace.removeSceneGraphNode(ColorMappedAdvanced_NoBlend)
|
|
openspace.removeSceneGraphNode(ColorMapped_FixedSize)
|
|
openspace.removeSceneGraphNode(Textured)
|
|
openspace.removeSceneGraphNode(FixedColor_ScaleBasedOnData)
|
|
openspace.removeSceneGraphNode(FixedColor_MaxSize)
|
|
openspace.removeSceneGraphNode(FixedColor_FixedSize)
|
|
end)
|
|
|
|
asset.export(FixedColor_FixedSize)
|
|
asset.export(FixedColor_MaxSize)
|
|
asset.export(FixedColor_ScaleBasedOnData)
|
|
asset.export(Textured)
|
|
asset.export(ColorMapped_FixedSize)
|
|
asset.export(ColorMappedAdvanced_NoBlend)
|
|
|
|
|
|
|
|
asset.meta = {
|
|
Name = "Example - Point Clouds",
|
|
Version = "1.0",
|
|
Description = [[Examples of point clouds with a few different settings for sizing and
|
|
coloring]],
|
|
Author = "OpenSpace Team",
|
|
URL = "http://openspaceproject.com",
|
|
License = "MIT license"
|
|
}
|