Firstly, I'm advocating the official change from start.cel to start.celx since it allows MUCH more freedom and customization than with a CEL script only, and I don't see any disadvantage of using a CELX script instead. In this case, we only have to edit the line in the config file (celestia.cfg) to point to the start.celx file, instead of a start.cel file.
Then, we need to make the start.celx file itself. This was already done by Vincent, on my request a long time ago. The content of that new CELX start file looks like this (I'm using parts of my own start.celx file as an example) :
Code: Select all
-- start.celx
celestia:setlabelcolor("stars", 0.500, 0.500, 1.000)
celestia:setlabelcolor("planets", 0.150, 0.740, 1.000)
celestia:setlabelcolor("moons", 0.450, 0.576, 0.612)
celestia:setlabelcolor("asteroids", 0.460, 0.440, 0.360)
celestia:setlabelcolor("comets", 0.840, 0.620, 0.280)
celestia:setlabelcolor("spacecraft", 0.750, 0.740, 0.670)
celestia:setlabelcolor("locations", 0.220, 0.940, 0.440)
celestia:setlabelcolor("galaxies", 0.190, 0.850, 0.710)
celestia:setlabelcolor("nebulae", 0.850, 0.350, 0.290)
celestia:setlabelcolor("openclusters", 0.620, 0.480, 0.540)
celestia:setlabelcolor("constellations", 0.385, 0.280, 0.567)
celestia:setlabelcolor("dwarfplanets", 0.350, 0.400, 0.600)
celestia:setlabelcolor("minormoons", 0.400, 0.612, 0.576)
celestia:setlabelcolor("planetographicgrid", 0.200, 0.900, 1.000)
celestia:setlabelcolor("equatorialgrid", 0.318, 0.439, 0.361)
celestia:setlabelcolor("galacticgrid", 0.360, 0.360, 0.150)
celestia:setlabelcolor("eclipticgrid", 0.500, 0.220, 0.300)
celestia:setlabelcolor("horizontalgrid", 0.318, 0.361, 0.439)
celestia:setlinecolor ("starorbits", 0.500, 0.500, 0.800)
celestia:setlinecolor ("planetorbits", 0.000, 0.360, 0.900)
celestia:setlinecolor ("moonorbits", 0.220, 0.330, 0.400)
celestia:setlinecolor ("asteroidorbits", 0.280, 0.240, 0.216)
celestia:setlinecolor ("cometorbits", 0.520, 0.320, 0.128)
celestia:setlinecolor ("spacecraftorbits", 0.360, 0.360, 0.360)
celestia:setlinecolor ("constellations", 0.234, 0.090, 0.576)
celestia:setlinecolor ("boundaries", 0.192, 0.079, 0.151)
celestia:setlinecolor("dwarfplanetorbits", 0.098, 0.195, 0.439)
celestia:setlinecolor("minormoonorbits", 0.130, 0.260, 0.215)
celestia:setlinecolor("planetographicgrid", 0.150, 0.525, 0.525)
celestia:setlinecolor("planetequator", 0.400, 0.900, 1.000)
celestia:setlinecolor ("equatorialgrid", 0.192, 0.248, 0.184)
celestia:setlinecolor ("galacticgrid", 0.200, 0.200, 0.000)
celestia:setlinecolor ("eclipticgrid", 0.300, 0.050, 0.100)
celestia:setlinecolor ("horizontalgrid", 0.192, 0.184, 0.248)
***** REPLACE THIS LINE WITH CUSTOM FUNCTIONS. SEE THE EXAMPLE BELOW *****
function CEL(source)
local script = celestia:createcelscript(source)
while script:tick() do
wait(0)
end
end
CEL([[
{
# ... Beginning of standard CEL script
***** REPLACE THIS LINE WITH THE CONTENT OF YOUR USUAL START.CEL FILE *****
# End of standard CEL script...
}
]])
-- end
Now, we can add some custom functions to the first line above beginning with *****. Personally, I'm using the "Fast GoTo" function defined below by Vincent (in my opinion, this should be made hard coded in Celestia's code. It's really usefull when you need to save time !). The second function defined below allows the first "layer" I want to talk about :
Code: Select all
function fastgoto()
sel = celestia:getselection()
obs = celestia:getobserver()
if sel and obs then
obs:goto(sel, 0.001)
end
end
objects_t = {
"Sol/Earth/Tectonic Plates",
"Sol/Earth/Borders"
}
for k, object in pairs(objects_t) do
obj = celestia:find(object)
obj:setvisible(false)
end
function toggleObj()
for k, object in pairs(objects_t) do
obj = celestia:find(object)
obj:setvisible(not obj:visible())
end
end
keyhandlers =
{
G = fastgoto,
T = toggleObj
}
function handlekey(k)
handler = keyhandlers[k.char]
if (handler ~= nil) then
handler()
return true
else
return false
end
end
celestia:registereventhandler("key", handlekey)
Then, after you start Celestia, using shift-g (or "G") will bring you instantaneously to the selected object. This is the "Fast GoTo" function. Using shift-t (or "T") will switch ON/OFF the layer which includes two models (in the exemple presented above) : "Tectonic Plates" and "Borders" around the Earth.
We can now define in a similar way several "layers", with any number of models declared in some SSC file. We can even edit the script to add some textual information to be displayed each time the layer is activated or desactivated. For example :
Code: Select all
if obj:visible() then
celestia:print("Tectonic Plates activated.\nEmpirical model from Peter Bird (2003)", 4)
else
celestia:print("Tectonic Plates desactivated.", 2)
end
The only constraint is the access to the keyboard, in such a way that we can use a key switch. Currently, we only have access to simple keys in a CELX script (a, A, b, B, c, C, ... etc), and we need to be carefull to not use a key which is already used by Celestia. Personally, I need to toggle ON/OFF several layers independently of each other (up to 9 layers : Political borders, tectonic plates, magnetic field, charged particle paths in the magnetic field, ... etc), so currently I'm in trouble with Celestia's keyboard ! I asked Chris to add the ability to use combos like "ctrl-1", "ctrl-2", ... "alt-1", "alt-2", ... That way, we could define 10 or even 20 layers, which should be enough for most users.
Actually, I think that "layers" are so important, that it should be HARD CODED into Celestia (to simplify the user's life), so we only have to define the lists of objects in the start.celx file. My suggestion is to declare something like this, in the start.celx :
Code: Select all
Layer1 = {
"Sol/Earth/Tectonic Plates"
}
Layer2 = {
"Sol/Earth/Borders",
"Sol/Earth/Quebec"
}
Layer3 = {
"Sol/Earth/Magnetic Field"
}
Layer4 = {
"Sol/Earth/Charged Particle Path 1",
"Sol/Earth/Charged Particle Path 2",
"Sol/Earth/Charged Particle Path 3"
}
etc ...
The key combo could be hard coded so that "ctrl-1" is automatically associated to the first list (Layer1), etc. By default, ALL layers are set to OFF when we start Celestia. The user has to use the key combo to activate a given layer, if he placed something in his/her start file (the official start version should have empty lists : {}, with some brief comments to show to the novice how to use the layers). Of course, for this simple suggestion we wont be able to add a onscreen comment when we toggle ON/OFF the layer.