Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit/AppGameKit Studio Showcase / 3D Solar System Simulator Using Keplerian Formulas

Author
Message
WJF
4
Years of Service
User Offline
Joined: 15th Jan 2021
Location:
Posted: 1st Feb 2025 20:42
Using AppGameKit Studio, I have been working on an accurate 3D model of the solar system that shows planetary positions based on any given date. Year, Month and Day can be changed in realtime as you watch the planets orbit the sun. There are a lot of programs out there on the internet that do the same thing. But this code was mainly a "learning" experience for me. It includes free flight code so you can fly around the solar system using WASD. Also includes a spherical skymap with stars and constellations, orbital paths, high-resolution textures, music, sound effects, virtual buttons, compass, various visual grids, acceleration inputs, etc.

I learned more by browsing through peoples code than by reading the documentation. And I greatly appreciated people sharing their code so we could all learn from it. Just thought it was time for me to also share.
-----------------------------------------------------------------------------
For example, here is an extract of the equations for Mercury based on orbital elements and the Keplerian equations.

`MERCURY
Mercury.name= "Mercury"
Mercury.sname= "Mer"
Mercury.incli= 007.004986
Mercury.l_of_anode= 048.330893
Mercury.l_of_peri= 077.456119
Mercury.dist= 000.3870978
Mercury.daily_motion= 004.092353
Mercury.ecc= 000.2056324
Mercury.mean_long= 252.250906
Mercury.mean_anom= Mercury.daily_motion * d# + Mercury.mean_long - Mercury.l_of_peri
Mercury.mass= 003.30200E23
Mercury.radius= 002.44E6
Mercury.spin= CommonMultiplier*-.017050 `24/(58.65*24)
Mercury.tilt= 007.0

`MERCURY Movement Calculation Using Keplerian Equations..............................................................................................
MMer# = WrapAngle(Mercury.daily_motion * d# + Mercury.mean_long - Mercury.l_of_peri)
vMer# = MMer#+Rads#*(((2*Mercury.ecc-Mercury.ecc^.75)*sin(MMer#)) + (1.25*Mercury.ecc^2*sin(2*MMer#)) + (1.0833*Mercury.ecc^3*sin(3*MMer#)))
rMer# = Mercury.dist*(1-Mercury.ecc^2)/(1+Mercury.ecc*cos(vMer#))
Mervop#=WrapAngle(vMer#+Mercury.l_of_peri-Mercury.l_of_anode)

XMer#=rMer#*(cos(Mercury.l_of_anode)*cos(Mervop#)-sin(Mercury.l_of_anode)*sin(Mervop#)*cos(Mercury.incli))
YMer#=rMer#*(sin(Mercury.L_of_anode)*cos(Mervop#)+cos(Mercury.l_of_anode)*sin(Mervop#)*cos(Mercury.incli))
ZMer#=rMer#*(sin(Mervop#)*sin(Mercury.incli))

SetObjectPosition(Mer,XMer#*DisS#,ZMer#*DisS#,YMer#*DisS#)
-----------------------------------------------------------------------------






Happy to share the code, if anyone is interested. This is my first post, so I am not sure I posted the images correctly.

Jf

Attachments

Login to view attachments
Virtual Nomad
Moderator
19
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 2nd Feb 2025 17:20
looks great, WJF. and, congrats!

reminds me of PSY's expedition and that's a good thing

is it posted somewhere so we can explore?
WJF
4
Years of Service
User Offline
Joined: 15th Jan 2021
Location:
Posted: 3rd Feb 2025 20:33 Edited at: 5th Feb 2025 13:11
Code has been uploaded to github.

https://github.com/WJFLoyd/Solar-Simulator-AGK.git

I uploaded everything except the emitter code from "AppGameKit - Particle Editor Runtime Plugin".
The applicable code for the plugin is commented out. If you add the inc_gpup.asc include file, you can remove the comments and use the emitter. I used it for the sun flames and the asteroid field, so it isn't really needed except for visual appeal.

WJF
WJF
4
Years of Service
User Offline
Joined: 15th Jan 2021
Location:
Posted: 5th Feb 2025 13:13
https://github.com/WJFLoyd/Solar-Simulator-AGK.git
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 10th Feb 2025 14:53
Wow that looks really great.
Looks like you put a lot of work into that.
Can't wait to test it out tomorrow.
Very well done!


PSY LABS Games
Coders don't die, they just gosub without return

Login to post a reply

Server time is: 2025-05-10 19:27:17
Your offset time is: 2025-05-10 19:27:17