Interactive positioning of SSC objects.

All about writing scripts for Celestia in Lua and the .cel system
Avatar
Topic author
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Interactive positioning of SSC objects.

Post #1by selden » 02.07.2007, 18:10

Celestia v1.5 provides support for ScriptedOrbit and ScriptedRotation functions. Since these functions run in a separate context, they do not (yet?) have access to the keyboard or joystick. However, these functions can determine what object is currently selected.

If one defines appropriate DSC objects, one can use them to communicate with ScriptedOrbits and thus cause the object controlled by that script to move arbitrarily.

A very simple and crude example of such control is available in
http://www.lepp.cornell.edu/~seb/celest ... ontrol.zip

It's about 1MB since I left in the files used to develop the rather simple spacecraft model that it uses.

Here's an example of a split-screen control:

Image

The upper pane is the object being controlled, positioned above the reference object located where it started.
The lower half shows the three DSC objects one selects to move it: Fwd, Stop & Rev. One can also watch the object in a full-screen window and select the objects by typing their names.

Expanding on this to provide full 3D control of an object is left as an exercise for the student. ;)
Last edited by selden on 02.07.2007, 22:03, edited 1 time in total.
Selden

hank
Developer
Posts: 645
Joined: 03.02.2002
With us: 22 years 9 months
Location: Seattle, WA USA

Re: manual positioning of SSC objects.

Post #2by hank » 02.07.2007, 18:41

selden wrote:Celestia v1.5 provides support for ScriptedOrbit and ScriptedRotation functions. Since these functions run in a separate context, they do not (yet?) have access to the keyboard or joystick. However, these functions can determine what object is currently selected.
...
One can also watch the object in a full-screen window and select the objects by typing their names.

I suppose one could also write a user script with keyboard input that responds to a particular key press by selecting one of the DSC control objects.

- Hank

Avatar
Topic author
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #3by selden » 02.07.2007, 18:57

Hank,

Yup, you're right!

Related comment:

For some reason, my attempts to directly compare selected objects with "found" objects always returned a false. I wound up having to test the distance between the selected object and the control objects. Maybe I was just doing something wrong. In particular, I couldn't seem to get something like this to work:

Code: Select all

Vel = function ()
local c1 = celestia:find("Fwd")
local c2 = celestia:find("Stop")
local c3 = celestia:find("Rev")
local s1 = celestia:getselection()


  if (s1 == c2) then return 0
    elseif (s1 == c1) then return 1e4
    elseif (s1 == c3) then return -1e4
    else   return vP
  end

end


It always seemed to take the "else" branch. :(
Selden

hank
Developer
Posts: 645
Joined: 03.02.2002
With us: 22 years 9 months
Location: Seattle, WA USA

Post #4by hank » 02.07.2007, 19:23

selden wrote:For some reason, my attempts to directly compare selected objects with "found" objects always returned a false. I wound up having to test the distance between the selected object and the control objects.

My guess would be that the celx functions are returning copies, so the identity test fails. But why not just check the name of the current selection?

- Hank

Avatar
Topic author
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #5by selden » 02.07.2007, 19:36

uhhh.. because I didn't think of it.

I was expecting to be able to compare the object ID and when that failed, tried other things that used it... *sigh*
Selden

ElecMoHwk
Posts: 33
Joined: 02.12.2006
With us: 17 years 11 months
Location: JPL

Post #6by ElecMoHwk » 28.07.2007, 05:23

So... once this is fully into Celestia, I could in theory (and with some time for development for models, and the innards of Celestia orbits and rotations and such) ...

... Load up ElChristou's Atlantis... open the bay doors, close them, perform RCS burns, and even rotate to dock with ISS? All from typed in keyboard commands?

I will NEVER leave the house again. :P

Avatar
Topic author
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #7by selden » 28.07.2007, 11:37

ElecMoHwk,


Almost ;-)

This technique depends on having separate SSC objects for each of the movable pieces.
Selden


Return to “Scripting”