We Create Games

Orrery – 3D Planet simulator

Posted July 20th by Jay Crossler in Code, FOGE, Games, MoonBaseOne, Web

Happy 40th anniversary of the Moon landing!

In honor of this auspicious occasion, I’m releasing a new “Orrery” resource for the Torque programming language. This isn’t yet a full-fledged game, rather just a library of celestial mechanics.

I wrote the instructionsfor integrating within Torque 3D (which is currently in a closed Beta) — this is a new version of the video Game engine that I’ve used on many projects. If you want to integrate this into an older version of Torque (such as TGE/TGEA), it should be pretty easy to do so.

I’ve intentionally kept all of the calculations in TorqueScript, rather than using the engine C++ code. This will allow you to make quick changes without having to recompile the game. Torque uses two layers, a “crunchy shell” of TorqueScript (a C++ derivative scripting language) and a “molten core” of C++ (which is much faster yet more complex). If you want to get more accurate calculations of the planets, you should move the code into the C++ engine. For example, the calculations now are only 32-bit Floating Point, so please don’t use these to launch interplanetary voyages… the planetary positions will only be accurate within 1 or 2% for the next 1000 years, and break down to chaos after that.

The way it works is by specifying a Julian Date – a time specified in centuries down to the second. You can pass in convertDateTimeToEpoch(2000,1,1,12,0,0) and it returns a JD that is the number of centuries since January 1st, 2000 at noon.

The Instructions code describes how to use this:
Orrery_Create("orrery1", "Mini System", "-233.581 -60.61 196.786", "5 5 5", 5, 4, "", 0.00004, 0.1, "Sol", 1);

  • This will create an orrery at the world points at “-233.581 -60.61 196.786″.
  • It will stretch the orrery to fit within 5 cubic game units (mostly likely 5 cubic meters if you use the standard game settings).
  • It will only show the first 5 planets
  • It will render the planets in a realistic configuration
  • It will use the default planets file (so you can pass in your own settings)
  • It will animate at 0.00004 (about 2 days every 10th of a second)
  • It will scale all planets to 10% (0.10) of their scaled size
  • It will only show children of the object named “Sol” (so you can have hundreds of planets and moons in the same file and only use the ones you want
  • It will only show 1 level of child objects (2 would show planets and moons)

You can have multiple Orreries in the same game. The more you have, the more choppy it gets. You might want to change the animation to move faster that every 10th of a second.

Let me know if it works for you, or you use it in a game! I’m working on another version, where moons and satellites will render. Let me know if there are any features I can add.


(required) (Won't be displayed)

Your Comment: