Files
OpenSpace/data/assets/util/generate_bookmarks.asset
T
Alexander Bock 8b74493d96 Removing the asset_helper file (#1868)
- Remove the asset_helper file and call the onInitialize and onDeinitialize functions directly
 - Small compile fix on Windows
 - Removes the need for the registerIdentifierWithMeta function by automatically doing that for all asset.export statements
 - Allow the passing of either identifiers (as before) or entire tables to the removeSceneGraphNode, removeScreenSpaceRenderable, deleteLayer, removeAction, and export methods. In that case, the Identifier key from the table is extracted and used instead
2022-02-01 23:44:36 +01:00

83 lines
2.3 KiB
Lua

local getBookmarks = function (guiPath, bookmarkfile)
local genBookmarks = {};
local notFirstLine = false;
local PARSEC_CONSTANT = 3.0856776E16;
for line in io.lines(openspace.absPath(bookmarkfile)) do
if (notFirstLine) then
local matchstring = "(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-)$"
local group, name, globe, lat, lon, altitude, x, y, z, scale, linewidth = line:match(matchstring)
scale = (scale == "" and 75000 or scale)
linewidth = (linewidth == "" and 2.0 or tonumber(linewidth))
group = (group == "" and globe or group)
local parent = (globe == "" and "Root" or globe)
local sgn = {
Identifier = guiPath .. "-" .. name,
Parent = parent,
Transform = {
Scale = {
Type = "StaticScale",
Scale = tonumber(scale);
},
Rotation = {
Type = "StaticRotation",
Rotation = {
-0.05487554, 0.4941095, -0.8676661,
-0.9938214 , -0.1109906, -0.0003515167,
-0.09647644, 0.8622859, 0.4971472
}
}
},
Renderable = {
Type = "RenderableSphericalGrid",
Enabled = false,
Opacity = 0.3,
Color = { 0.3, 0.84, 1.0},
LineWidth = linewidth
},
GUI = {
Name = name,
Path = "/" .. guiPath
}
}
if (group ~= "") then
sgn.GUI.Path = sgn.GUI.Path .. "/" .. group
end
if (globe == "") then
sgn.Transform.Translation = {
Type = "StaticTranslation",
Position = {
tonumber(x) * PARSEC_CONSTANT,
tonumber(y) * PARSEC_CONSTANT,
tonumber(z) * PARSEC_CONSTANT
}
}
else
sgn.Transform.Translation = {
Type = "GlobeTranslation",
Globe = globe,
Latitude = tonumber(lat),
Longitude = tonumber(lon)
}
if (altitude == nil) then
sgn.Transform.Translation.UseHeightMap = true;
else
sgn.Transform.Translation.UseHeightMap = false;
sgn.Transform.Translation.Altitude = tonumber(altitude);
end
end
table.insert(genBookmarks, sgn);
else
notFirstLine = true
end
end
return genBookmarks
end
asset.export("getBookmarks", getBookmarks)