Enable or disable an object at a specified distance

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: 540
Joined: 31.08.2017
Age: 27
With us: 1 year 10 months
Location: Volgodonsk, Rostov Oblast, Russia

Enable or disable an object at a specified distance

Post #1by Art Blos » 20.02.2019, 11:21

It is necessary that the object was visible only from a distance of several kilometers. And vice versa, so that it is invisible at close, but only at long distance. Scripts are capable of this?
Founder and head of the project "Celestia Origin"

Avatar
selden
Developer
Posts: 10053
Joined: 04.09.2002
With us: 16 years 10 months
Location: NY, USA

Post #2by selden » 20.02.2019, 14:30

Yes.

You could write a ScriptedOrbit for the object. It could calculate the distance from the observer to the object and call setvisible(true) or setvisible (false).
Selden

Avatar
Topic author
Art Blos M
Moderator
Posts: 540
Joined: 31.08.2017
Age: 27
With us: 1 year 10 months
Location: Volgodonsk, Rostov Oblast, Russia

Post #3by Art Blos » 20.02.2019, 15:33

selden wrote:You could write a ScriptedOrbit for the object. It could calculate the distance from the observer to the object and call setvisible(true) or setvisible (false).
You, as always, give me hope for the realization of my ideas. :smile:

Can you make a script in which object №1 disappears when approaching 10 kilometers, and then object №2 appears?
Founder and head of the project "Celestia Origin"

Avatar
selden
Developer
Posts: 10053
Joined: 04.09.2002
With us: 16 years 10 months
Location: NY, USA

Post #4by selden » 21.02.2019, 18:57

http://www.classe.cornell.edu/~seb/celestia/files/replace_obj.zip (10 KB expands to 27 KB)
is an addon which demonstrates how to use a ScriptedOrbit to replace one object by a second. It uses setvisible() to control which of the two object can be seen, depending on the distance from the observer's viewpoint to the first object.

The attachments below show what is seen depending on if the observer is more or less than 10km from an object
Attachments
obj1-c.png
Less than 10 KM from Obj1
obj1-s.png
More than 10 KM from Obj1
Selden

Avatar
Topic author
Art Blos M
Moderator
Posts: 540
Joined: 31.08.2017
Age: 27
With us: 1 year 10 months
Location: Volgodonsk, Rostov Oblast, Russia

Post #5by Art Blos » 21.02.2019, 21:12

Thank you! I will sort this out. :smile:
Founder and head of the project "Celestia Origin"

Avatar
Topic author
Art Blos M
Moderator
Posts: 540
Joined: 31.08.2017
Age: 27
With us: 1 year 10 months
Location: Volgodonsk, Rostov Oblast, Russia

Post #6by Art Blos » 26.02.2019, 10:02

selden, A big request to respond to my personal message regarding this topic. :biggrin:
Founder and head of the project "Celestia Origin"

Avatar
selden
Developer
Posts: 10053
Joined: 04.09.2002
With us: 16 years 10 months
Location: NY, USA

Post #7by selden » 26.02.2019, 15:53

replace_obj_v2 is now available:
https://www.classe.cornell.edu/~seb/celestia/files/replace_obj_v2.zip (11 KB expands to 27 KB).

You should delete replace_obj before installing v2.

v2 adds an example of replacing Mars by a cube. No modifications to Celestia's own definition of Mars are required.

Below are screengrabs to show what Mars looks like at different distances.
Attachments
mars-cube.png
Mars at 41 K Km.
mars-sphere.png
Mars at 56 K Km
Selden

Avatar
Topic author
Art Blos M
Moderator
Posts: 540
Joined: 31.08.2017
Age: 27
With us: 1 year 10 months
Location: Volgodonsk, Rostov Oblast, Russia

Post #8by Art Blos » 26.02.2019, 16:54

Fine! Thanks again!
Founder and head of the project "Celestia Origin"

Avatar
selden
Developer
Posts: 10053
Joined: 04.09.2002
With us: 16 years 10 months
Location: NY, USA

Post #9by selden » 27.02.2019, 14:37

You're very welcome.
Selden

Avatar
Lafuente_Astronomy
Moderator
Posts: 295
Joined: 04.08.2018
Age: 21
With us: 11 months 12 days
Location: Cebu, Philippines
Contact:

Post #10by Lafuente_Astronomy » 02.03.2019, 23:42

Well, is it possible to apply the same code to stars?

I'm asking that because in another post: viewtopic.php?f=23&t=17931 , I asked if it's possible to make a code in which stars only appear within 10 million light years from the user's location, meaning that as the user moves around Celestia's simulated universe, stars would get enabled and disabled on the way.
Official Administrator of the Celestia Discord Server.
Invite: https://discordapp.com/invite/WEWDcJh
If you don't have a Discord account, register here: https://discordapp.com/register
Have a blessed day.

Avatar
selden
Developer
Posts: 10053
Joined: 04.09.2002
With us: 16 years 10 months
Location: NY, USA

Post #11by selden » 03.03.2019, 04:52

Unfortunately, the various tricks one can think of to expand the distance at which Stars can be drawn need to be implemented within the C++ source code of Celestia. That distance is limited by the size of the numbers being used in Celestia's internal databases. For example, writing the C++ code to support changing the center of the coordinate system to another location in space would require some substantial research, code writing and testing.

All my code does is change the visibility of an existing Object. It doesn't affect the distance limitations.

Also, the features that I used (ScriptedOrbit and Visibility) are available only for SSC (Stellar System Catalog) objects: non-radiating objects which orbit around a star. Celestia does not currently support the use of either ScriptedOrbit or Visibility in STC (STar Catalog) or DSC (Deep Space Catalog) files. I believe it should be possible to extend STC catalog functionality to support ScriptedOrbit, but not DSC.

In principle, once Visibility is implemented for STC and DSC objects, one should be able to do something similar to what I did (turn an object off or on) by using a CELX script, but that still would be working within the distance limitations imposed by the calculations that Celestia uses to position objects in space. Objects which are within Celestia's maximum distance could be made to disappear or appear, but doing that doesn't change the maximum possible drawing distance.
Selden

Avatar
Lafuente_Astronomy
Moderator
Posts: 295
Joined: 04.08.2018
Age: 21
With us: 11 months 12 days
Location: Cebu, Philippines
Contact:

Post #12by Lafuente_Astronomy » 03.03.2019, 12:13

selden wrote:nfortunately, the various tricks one can think of to expand the distance at which Stars can be drawn need to be implemented within the C++ source code of Celestia. That distance is limited by the size of the numbers being used in Celestia's internal databases. For example, writing the C++ code to support changing the center of the coordinate system to another location in space would require some substantial research, code writing and testing.

All my code does is change the visibility of an existing Object. It doesn't affect the distance limitations.

Also, the features that I used (ScriptedOrbit and Visibility) are available only for SSC (Stellar System Catalog) objects: non-radiating objects which orbit around a star. Celestia does not currently support the use of either ScriptedOrbit or Visibility in STC (STar Catalog) or DSC (Deep Space Catalog) files. I believe it should be possible to extend STC catalog functionality to support ScriptedOrbit, but not DSC.

In principle, once Visibility is implemented for STC and DSC objects, one should be able to do something similar to what I did (turn an object off or on) by using a CELX script, but that still would be working within the distance limitations imposed by the calculations that Celestia uses to position objects in space. Objects which are within Celestia's maximum distance could be made to disappear or appear, but doing that doesn't change the maximum possible drawing distance.

Sorry if it's a late reply

Ahhhh. It may take some time, or a long time but I know that eventually you and anyone working on Celestia will get there. Keep up the good work.
Official Administrator of the Celestia Discord Server.
Invite: https://discordapp.com/invite/WEWDcJh
If you don't have a Discord account, register here: https://discordapp.com/register
Have a blessed day.


Return to “Help Central”

Who is online

Users browsing this forum: 1 guest
Bots: Google [Bot]