Celestia/Scripting Positions

From Wikibooks, open books for an open world
Jump to: navigation, search

Fly Your Spacecraft, Buddy?[edit]

One of the not-so-obvious implications of the Scripted methods available in the SSC files of Celestia v1.5.0 (and later) is that objects can now be repositioned at arbitrary coordinates and orientations while Celestia is running.

In other words, you can fly an interplanetary spacecraft anywhere in a solar system.

Placement[edit]

The return values of the ScriptedOrbit function are x,y,z in the object's coordinate system.

Any x, y, z.

Similarly, ScriptedRotation can return the components of any quaternion.

You can minimize the complexity of the algorithm to be used in the ScriptedOrbit or ScriptedRotation if you specify appropriate Orbit and Body ReferenceFrames for the object in its SSC file.

Unfortunately, ScriptedOrbit and ScriptedRotation aren't available in STC files yet. As a result, you're limited to defining movable objects within 1 LY of a Star or Barycenter, since Celestia only draws SSC objects when the viewpoint is within 1LY of the parent Star.

Communicating with the User[edit]

You still need a way for the user to communicate with ScriptedOrbit to tell it to generate a new x,y,z.

The ScriptedOrbit and ScriptedRotation modules can't interact directly with the keyboard, mouse or joystick, or with a CELX script, but they can detect the name of the currently selected object by calling celestia:getselection()

A solution is to define objects with unique names which can be selected by the user or by a script. One possibility is to define DSC OpenCluster objects for this.

Temporal Anomalies[edit]

In the positioning algorithms you use, you should take into account that the user can set the current time to be an arbitrary value. "Should" is the operative word. It really is no big deal if your algorithms don't work correctly if time runs backward: just be sure to document that limitation.