I’ve posted an updated version of the Orrery Torquescript library. Thanks for all of the great feedback. This new version has a few features:
- Fully Object Oriented, so you can add multiple orreries or systems
- Renders correct positions of the moon
- Has a datetime object to show the current universal epoch (date/time)
- Allows for different animation speeds and interactions
The code is at: http://wecreategames.com/apps/planets/Orrery.v2.zip. Feel free to download and play with it (it currently works only with Torque3D).
I’ve also built a version for Torque Gaming Engine. It’s a fully compiled project, so should work on any Mac. Leave a comment if you’d like me to build a version to work with PC. It’s a 100Mb download, but has all the files within. There are a few extra math functions in this one that weren’t included in TGE (but were in T3D), so I added them to the Functions_Math.cs.
Getting Torquescript (which is a scripting layer on top of Torque’s C++ engine to support OO behavior was a bit painful, so I used a few of the concepts from JavaScript to make pseudo-classes.
I’ve released all the code under Creative Commons BY 3.0 license – you can use and make money from this, just give me credit, please!
Here are the steps to implement:
//=====================================
1) Create a new mission, named Orrery
//=====================================
2) Add Orrery.mis to Orrery/game/levels/
3) Delete the other missions (simple.mis NewMission.mis) in this directory
4) In Orrery/game/scripts/client/init.cs:
Within this function, change:
function loadDefaultMission()
{
Canvas.setCursor(“DefaultCursor”);
createServer( “SinglePlayer”, “levels/simple.mis” );
to:
createServer( “SinglePlayer”, “levels/Orrery.mis” );
//=====================================
5) Add PlanetsInit.cs and the Functions*.cs to Orrery/game/scripts/server/
6) Update Orrery/game/scripts/server/scriptExec.cs
add to end of file:
//Supporting functions
exec(“./Functions_Math.cs”);
exec(“./Functions_Time.cs”);
exec(“./Functions_Objects.cs”);
//Initialize planets
exec(“./PlanetsInit.cs”);
//=====================================
7) Copy planets.cs to Orrery/game/art/datablocks/
exec(“./planets.cs”);
8 ) Update Orrery/game/art/datablocks/datablockExec.cs
add to end of file:
exec(“./planets.cs”);
9) Add materials.cs to Orrery/game/art/materials.cs
10) Copy the planets directory to Orrery/game/art/shapes/ (so it’s Orrery/games/shapes/planets)
//=====================================
11) Copy the sky_night directory to Orrery/game/art/skies
12) Copy the three rocks jpgs (rocks_65.jpg, rocks_dark.jpg, rocks_meddark.jpg) to the Orrery/game/art/terrains/WarriorCamp directory
NOTE: If you open the world and there are big orange patches, go into World Editor, Terrain Painter, then select the “Warning Material” and choose Edit. Navigate to the rocks_65 and rocks_dark textures)
Walking forward, you can step on each of the three rocks to change the animation speed of the Orrery.
If you want to make your own orreries through script:
You need to (1) Create an Orrery, (2) Initialize planets in the correct location, (3) Animate them:
//Orrery_Create(%orreryHandler, %name, %center, %radius, %numplanets,
%spacingmode, %planetarchivefile, %timestep, %planetsizing,
%show_children_of, %levels_of_children, %animationstep)
Examples:
Orrery_Create("orrery1");
orrery1.build_planets();
orrery1.begin_animation();
Orrery_Create("orrery2", "Mini System", "-233.581 -60.61 196.786", "5 5 5", 5, 4, "", "hour:2", 0.2, "Sol", 1,500);
orrery2.build_planets();
orrery2.begin_animation();
If you are editing code, a shortcut is to type “r” in the console, which reloads the PlanetsInit.cs. This way, you don’t need to quit Torque to make sure code compiles/updates correctly
The Orrery/game/art/shapes/solar_system.cs has all of the planet/moon information in it
- You can copy this and make your own solar system (or update to new information).
- Important fields:
//For a planet
new ScriptObject() {
planetName = "Pluto"; //Name of the planet that's shown, also used for lookups
planetOrder = 9; // The order of the planet out from the star (used as an estimate, as sometimes planet orbits are elongated and some move within others)
satelliteOf = "Sol"; // What does this orbit around?
shapeName = "art/shapes/planets/pluto.dts"; // Which DTS file is used? Materials.cs has to describe the texture as well
scale_mult = "1 1 1"; // Some planets are squished (especially gas giants, which have a smaller Z axis. Jupiter's is "1 1 .92" for example)
orbit_calc_method = "major_planet"; // How should the orbits be calculated?
dist_from_parent = 5900000000; // Average distance from parent. Not yet used
days_sidereal_rot = 90767.11; // How many earth days in a rotation? Not yet used
diameter_km = 2302; // Diameter, Not yet used
obliquity = 119.61; //How much tilt? Not yet used
//As of 1 Jan 2000, Julian Date = 2451545
a_semimajor_axis = 39.48168677; //6 variables are used to calculate planetary axis
e_eccentricity = 0.24880766;
i_inclination = 17.14175;
O_ecliptic_long = 110.30347;
w_perihelion = 224.06676;
L_mean_longitude = 238.92881;
a_per_cy = -0.00076912; //This is how much does they vary per century
e_per_cy = 0.00006465;
i_per_cy = 11.07;
O_per_cy = -37.33;
w_per_cy = -132.25;
L_per_cy = 522747.90;
//Only the Earth's moon is currently implemented - others will be in release #3


Jeff Yaskus
February 29th, 2012
Hello Jay,
I’ve merged your code into T3D v1.2 and removed all of the terrain and other objects … in an attempt to use this to re-create a visualization of our actual solar system.
To do this, I tried expanding it out the radius to 40x what was the default… and used spacing type #4, as the others seemed even more “off”.
Here is the code used to generate the orrery;
[code]
%radiusV = "2320 2320 920"; // 40x radius
Orrery_Create("orrery2", "Solar System", "", %radiusV, 10, %spacing, "", "hour:1", 1.0 , "Sol", 1, 500);
orrery2.build_planets();
orrery2.begin_animation();
[/code]
Problem is, its still all clumped up around the Sun … and scale between planets and sun is way off. and no moon.
can you offer any suggestions on how to ;
a) add the moon into this ?
b) improve the accuracy of the orbits ?
c) properly create the radius/scale ??
thanks!
Jeff Y.