Uniview Mod File Conversion
As an example on the Tesla in space module
Starting with tesla.mod file
Creating tesla.asset
Specifying local files we later need. By specifying with
resource, we put them in the same folder as the asset file and don’t need to put them on a server anywherelocal kernel = asset.resource("tesla.bsp") local model = asset.resource("tesla.obj") local texture = asset.resource("white.jpg")
Converting
coord { name tesla parent SolarSystem unit 1000000.0 unitname 1000 Km entrydist 10 positionfile modules/tesla/teslapos.conf orbitfile modules/tesla/teslaorbit.conf positionhook tesla }
teslapos.confmentions the spice information which is converted intoteslaOrbit.confcontains information about the orbitFirst we create a coordinate system for the Tesla (this can be merged with the model as well)
Then a *Trail object. In this case, because we have a start and end time, we use a
RenderableTrailTrajectoryrather thanRenderableTrailOrbitlocal TeslaPosition = { -- Name is arbitrary Name = "Tesla Position", -- Parent uses the asset.require to retrieve the name from another asset file Parent = transforms.SolarSystemBarycenter.Name, -- Values for this come from the original file Transform = { Translation = { Type = "SpiceTranslation", Target = "-143205", Observer = "SUN", Kernels = kernel } }, -- GuiPath is an arbitrary string that is only used in the user interface to build a tree GuiPath = "/Solar System/Tesla" } local TeslaTrail = { Name = "Tesla Trail", Parent = transforms.SolarSystemBarycenter.Name, Renderable = { Type = "RenderableTrailTrajectory", Translation = { Type = "SpiceTranslation", Target = "-143205", Observer = "SUN", Kernels = kernel }, Color = { 1.0, 0.6, 0.2 }, StartTime = "2018 02 07 02:46:00", EndTime = "2030 01 01 23:59:59", SampleInterval = 60 * 60 * 24 -- One sample every day }, GuiPath = "/Solar System/Tesla" }
Ignoring (not sure why it is needed for Uniview
coord { name teslasmC parent tesla unit 1.0 unitname 1 m entrydist 500 }
Converting
object tesla sgOrbitalObject { coord teslasmC geometry SG_USES teslaMesh.conf cameraradius 0.40 targetradius 140 scale 0.33 lsize 1000000 align earth 1 0 0 off guiName /Solar System/Satellites/Tesla }
into
local TeslaModel = { Name = "Tesla", Parent = TeslaPosition.Name, Renderable = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", GeometryFile = model }, ColorTexture = texture }, GuiPath = "/Solar System/Tesla" }
Unfortunately, we don’t support multiple textures or MTL files yet (or at least I don’t know how to use the latter), so we have to use a pure white texture.
Exporting assets to the outside world:
local objects = { TeslaPosition, TeslaTrail, TeslaModel } assetHelper.registerSceneGraphNodesAndExport(asset, objects)