Files
OpenSpace/data/assets/util/procedural_globe.asset
T
Alexander Bock db7ae7e384 Issue/453 (#556)
* Introduced guiName to PropertyOwner
  * Added requirement that PropertyOwner::identifier may not contain whitespaces
  * Changed Name to Identifier in asset and scene files
  * Added new PropertyOwner to RenderEngine that owns the ScreenSpaceRenderables
  * Moved Name and GuiPath into GUI group
  * Added user-facing names to layer groups
2018-03-16 09:21:29 -04:00

107 lines
3.0 KiB
Plaintext

asset.require('spice/base')
local createGlobeWithoutName = function(identifier, parent, parentSpiceName, spiceName, radii, tags, guiPath, trailColor, orbitPeriod, kernels)
return {
Identifier = identifier,
Parent = parent,
Transform = {
Translation = {
Type = "SpiceTranslation",
Target = spiceName,
Observer = parentSpiceName,
Kernels = kernels
}
},
Renderable = {
Type = "RenderableGlobe",
Radii = radii,
SegmentsPerPatch = 64,
Layers = {},
Tag = tags
},
GUI = {
Path = guiPath
}
},
{
Identifier = identifier .. "Trail",
Parent = parent,
Renderable = {
Type = "RenderableTrailOrbit",
Translation = {
Type = "SpiceTranslation",
Target = spiceName,
Observer = parentSpiceName
},
Color = trailColor,
Period = orbitPeriod,
Resolution = 1000
},
GUI = {
Path = guiPath
}
}
end
local createGlobeWithName = function(identifier, name, parent, parentSpiceName, spiceName, radii, tags, guiPath, trailColor, orbitPeriod, kernels)
g, t = createGlobeWithoutName(identifier, parent, parentSpiceName, spiceName, radii, tags, guiPath, trailColor, orbitPeriod, kernels)
g.GUI.Name = name
t.GUI.Name = name .. " Trail"
return g, t
end
asset.export("createGlobeWithoutName", createGlobeWithoutName)
asset.export("createGlobeWithName", createGlobeWithName)
local createGlobes = function(t)
for _,v in pairs(t) do
if type(v) ~= "table" then
openspace.printWarning("The table passed to 'createGlobes' was not a table of tables")
-- We return an empty table of tables to silence a potential future warning
return {{}}
end
end
result = {}
for i, v in ipairs(t) do
local globe = nil
local trail = nil
if v.Name then
globe, trail = createGlobeWithName(
v.Identifier,
v.GUI.Name,
v.Parent.Identifier,
v.Parent.Spice,
v.Spice,
v.Radii,
v.Tags,
v.GUI.Path,
v.TrailColor,
v.OrbitPeriod,
v.Kernels
)
else
globe, trail = createGlobeWithoutName(
v.Identifier,
v.Parent.Identifier,
v.Parent.Spice,
v.Spice,
v.Radii,
v.Tags,
v.GUI.Path,
v.TrailColor,
v.OrbitPeriod,
v.Kernels
)
end
table.insert(result, globe)
table.insert(result, trail)
end
return result
end
asset.export("createGlobes", createGlobes)