Page 1 of 1

Control individual elements

Posted: 21.05.2018, 19:43
by Art Blos
Hello. I have a serious question and me can be helped by brainstorming from all over the community.

I want to find a way to control individual elements of an object without changing the source code Celestia. For example, enable/disable rings, switch between the sphere and 3D model, change the atmosphere or clouds. Switching should occur in the program itself without the need for a restart.

With "Lua Edu Tools" it is possible to only turn on/off whole object, but do not change its properties. Working variant with two different objects (with different names) does not suit me. And the function "Modify" requires a restart.

Can I implement the idea using scripts (CEL, CELX)? Or somehow yet?

Thank you for any help. :help:

Posted: 21.05.2018, 20:32
by selden
SSC objects have several characteristics which can be changed by making an appropriate CelX function call.

For specifics, see the list of object methods at https://en.wikibooks.org/wiki/Celestia/Celx_Scripting/CELX_Lua_Methods/Celx_object

A workaround for those characteristics which are not supported is to use the "setvisible" function, using it to replace one object by another.

Posted: 21.05.2018, 20:53
by Art Blos
selden wrote:SSC objects have several characteristics which can be changed by making an appropriate CelX function call.
I have no experience with scripts yet. Can I see an example code for controlling Saturn's rings?

Posted: 21.05.2018, 20:54
by Janus
I have been working on something like this myself.
In my case, it is replicating constellations as script controllable paths to show travel.
Making them individually showable, and in stages if desired, unlike constellations that are all or nothing.

However, all you are really talking about is recognizing individual attributes of objects at run time.
Simply expanding a scripts ability to dive into the class/subclass structures is not hard, just time consuming.
SolarSystem::Body::RingSystem.GetRings can be made script accessible, as can SetRings.

Feel like learning some C/C++ ?


Janus.

Posted: 21.05.2018, 20:59
by Art Blos
Janus wrote:Feel like learning some C/C++ ?
Art Blos wrote:without changing the source code Celestia

Janus wrote:Simply expanding a scripts ability to dive into the class/subclass structures is not hard, just time consuming.
Let it be so. If only it worked. But I would like to make sure that scripts are the only solution.

Posted: 21.05.2018, 21:23
by selden
Unfortunately, by itself, ring visibility is not one of the available options. As a result, one much change the visibility of two complete Saturn definitions, one containing one ring definition (e.g. the default Saturn definition provided with Celestia) and one containing the other (e.g. Saturn_rings2).

For example, create this ssc file:
saturn2.ssc

Code: Select all

"Saturn2" "Sol"
{
Visible false
   Texture "saturn.*"
# much omitted
   Rings {
      Inner   74500
      Outer  140220
      Texture "saturn_rings2.png"  # specify image for new rings
   }
}

I have left out most of the SSC definition. You'll have to fill it in appropriately, perhaps copying the text from Celestia's file solarsys.ssc

Here's a script which replaces Saturn with Saturn2 or Saturn2 by Saturn, depending on which is currently visible:

toggle_saturn.celx

Code: Select all

obj1 = celestia:find("Sol/Saturn")
obj2 = celestia:find("Sol/Saturn2")
if obj1:visible() then
   obj1:setvisible(false)
   obj2:setvisible(true)
else
   obj1:setvisible(true)
   obj2:setvisible(false)
end

Posted: 22.05.2018, 05:17
by Art Blos
selden wrote:Unfortunately, by itself, ring visibility is not one of the available options.
Then this method is no better than control through "Lua Edu Tools". Again duplicate objects and the catalog is littered.:fie: Hence the disappointing conclusion that scripts will not help me.:cry:

No more ideas?