Enable or disable an object at a specified distance
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.
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.
-
Topic authorArt Blos
- Moderator
- Posts: 1152
- Joined: 31.08.2017
- Age: 32
- With us: 7 years 3 months
- Location: Volgodonsk, Rostov Oblast, Russia
Enable or disable an object at a specified distance
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"
-
Topic authorArt Blos
- Moderator
- Posts: 1152
- Joined: 31.08.2017
- Age: 32
- With us: 7 years 3 months
- Location: Volgodonsk, Rostov Oblast, Russia
You, as always, give me hope for the realization of my ideas.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).
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"
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
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
Selden
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.
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.
Selden
- Lafuente_Astronomy
- Moderator
- Posts: 726
- Joined: 04.08.2018
- Age: 26
- With us: 6 years 3 months
- Location: Cebu City, Cebu Province, Philippines
- Contact:
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.
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.
Invite: https://discordapp.com/invite/WEWDcJh
If you don't have a Discord account, register here: https://discordapp.com/register
Have a blessed day.
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.
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
- Lafuente_Astronomy
- Moderator
- Posts: 726
- Joined: 04.08.2018
- Age: 26
- With us: 6 years 3 months
- Location: Cebu City, Cebu Province, Philippines
- Contact:
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.
Invite: https://discordapp.com/invite/WEWDcJh
If you don't have a Discord account, register here: https://discordapp.com/register
Have a blessed day.