[Feature Request] Save objects position at a given time
Hi
I wondered if it would be possible to have a function which saves the positions of all objects at a given time?
Ideally, a binary array of [id, x, y, z] with the asteroid id could be the AstDyS id so I can find out later its name, size and type, and just the name for planets and moons. The coordinates could be a long which should be enough to store the position at meter precision.
Btw I only need one set of data (i.e. 1 Jan 2020).
Thanks for an excellent project.
I wondered if it would be possible to have a function which saves the positions of all objects at a given time?
Ideally, a binary array of [id, x, y, z] with the asteroid id could be the AstDyS id so I can find out later its name, size and type, and just the name for planets and moons. The coordinates could be a long which should be enough to store the position at meter precision.
Btw I only need one set of data (i.e. 1 Jan 2020).
Thanks for an excellent project.
Comments
Note that above gives you each Body's position relative to its parent. The Sun is 0,0,0 so this only matters for moons. If you want moon positions to be absolute, do it recursively from top down:
There is a function in Timekeeper that is supposed to convert strings like "2020-01-01 12:00" to time (days from J2000 epoch), but it appears to be broken now. (I've opened an issue.) [This is working now.]
OK, asteroids...
Unfortunately, they are not objects and the CPU doesn't know where they are. Fixed orbital parameters for the 647,000 asteroids* are held in compact "pool" arrays (in AsteroidGroup objects) that are passed to the GPU as mesh arrays. The CPU passes "time" to the GPU each frame that asteroids are visible (this happens in HUDPoints). From here on, everything is done by "shaders" in the GPU. So only the GPU knows the asteroid positions. And it is not easy to get data from the GPU back to the CPU.
(* Actually, only 64,738 are currently imported based on mag_cutoff=15 in data/solar_system/asteroid_group_data.csv. If you have a good graphics card, set mag_cutoff=100 for all groups to see all 647,000! Or set mag_cutoff=100 for "Near Earth" if you want to see all NEOs no matter how small; that's not a huge number.)
This is why you can't currently "visit" an asteroid in I, Voyager. However, we absolutely want to be able to visit asteroids! In outline, here is what we need:
- Some way to select one or a few asteroids. Perhaps from a list.
- Asteroid models. For the core I, Voyager system, I'll probably limit this to the list of explored asteroids. However, it would be great to have a procedural model generator for non-explored asteroids as an add-on (if anyone knows of open-source code that already does this, please let me know!).
- When user selects an individual asteroid, that asteroid is instanced as a Body with an Orbit (and Model, HUDOrbit, HUDLabel, etc.) from data in AsteroidGroup.
So, back to your question. What you really need is code for step #3 above. Then you would get position from the Orbit object exactly as above. It's code that I need to write at some point, but I can't promise when. I'll post again here if I do get to it...My original idea was to use least significant bits of color, but there are not enough "non-noticeable" bits to encode >millions of IDs (without using adjacent pixels, but that gets hellishly complicated to program). The next idea was to do it all in a single frame and hope the user doesn't see that.
I have not messed around with viewports at all so I'm currently pondering your "hidden viewport" idea. Would this mean that all of the asteroids (which are a ShaderMaterial instance for each "group" of asteroids) would have to be instantiated again under this hidden viewport? That would be a problem -- the asteroids are already expensive and cause a small hang with the user first makes them visible.
But the hang might be caused by Godot compiling the shader. That's a common problem when working with particle effects. People often get around it by instantiating every particle effect once when starting the program.
tree_nodes/hud_points.gd is the MeshInstance, and this uses either shaders/orbit_points.shader or shaders/orbit_points_lagrangian.shader.