Control individual elements

Have a question about using Celestia? Check here first for FAQs and helpful advice.
Forum rules
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
Avatar
Topic author
Art Blos M
Moderator
Posts: 1151
Joined: 31.08.2017
Age: 32
With us: 7 years 2 months
Location: Volgodonsk, Rostov Oblast, Russia

Control individual elements

Post #1by Art Blos » 21.05.2018, 19:43

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:
Founder and head of the project "Celestia Origin"

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #2by selden » 21.05.2018, 20:32

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.
Selden

Avatar
Topic author
Art Blos M
Moderator
Posts: 1151
Joined: 31.08.2017
Age: 32
With us: 7 years 2 months
Location: Volgodonsk, Rostov Oblast, Russia

Post #3by Art Blos » 21.05.2018, 20:53

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?
Founder and head of the project "Celestia Origin"

Janus
Posts: 537
Joined: 13.08.2016
With us: 8 years 3 months

Post #4by Janus » 21.05.2018, 20:54

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.

Avatar
Topic author
Art Blos M
Moderator
Posts: 1151
Joined: 31.08.2017
Age: 32
With us: 7 years 2 months
Location: Volgodonsk, Rostov Oblast, Russia

Post #5by Art Blos » 21.05.2018, 20:59

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.
Founder and head of the project "Celestia Origin"

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #6by selden » 21.05.2018, 21:23

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
Selden

Avatar
Topic author
Art Blos M
Moderator
Posts: 1151
Joined: 31.08.2017
Age: 32
With us: 7 years 2 months
Location: Volgodonsk, Rostov Oblast, Russia

Post #7by Art Blos » 22.05.2018, 05:17

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?
Founder and head of the project "Celestia Origin"


Return to “Help Central”