I hate scripts (help is welcome)

All about writing scripts for Celestia in Lua and the .cel system
Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 2 months
Location: Paris France

I hate scripts (help is welcome)

Post #1by jogad » 13.12.2008, 06:19

Hello

Yes! I hate scripts, but I love cel;//URLs

Recently I made a “script” for the topic about Cruithne and Cham asked:

Cham wrote:EDIT : Is there a way to simplify the first part of the script, to use CELX only ?
Tu parles !
The only reason why I wrote the script was because markers are not recorded within urls!

And now I have a similar problem with this little script:

Code: Select all

function CEL(source)
   local script = celestia:createcelscript(source)
   while script:tick() do
      wait(0)
   end
end

CEL([[
{
  seturl { url "cel://SyncOrbit/Sol:Earth/2008-06-21T13:21:05.18439?x=fbeWQgCMEQ&y=fg7E0iILKA&z=PMj5mKdiBg&ow=-0.573595&ox=-5.80523e-006&oy=-0.819139&oz=-3.23302e-006&select=Sol:Earth&fov=60&ts=0&ltd=0&p=0&rf=18470279&lm=2017986560&tsrc=0&ver=3
" }
}
]])

wait(2)
temps = celestia:gettime()
while (true) do
   wait(0.02)
   temps = temps +1
   celestia:settime(temps)
end

This script works ONLY with Celestia 1.6.0 because I wanted the horizontal grid to be active.
Its aim is to see the graceful Anna Lemma in the sky of the Earth.
So, the URL lets me initialize my position, time, timescale, observer’s mode and the render options with no effort. (Ctrl-C in Celestia and Ctrl-V in my script).

But I realize that it’s not a universal solution and particularly there is no way to do here some special effects. :roll:

No difficulty to set the flags and the position (here in Iceland).
The real problem for me is: how do I orient myself?
In this case facing the south and looking up with an angle = 25°. Moreover I want the ground not doing a funny angle with the horizontal. (At this place it may be ice…)

Thank you for your help. :mrgreen:

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Re: I hate scripts (help is welcome)

Post #2by Vincent » 13.12.2008, 11:19

Jo?l,

The following commented script should help you to convert your CelURL into a nice piece of celx code. :)
You can use the Celx Scripting section on the Celestia Wikibook to complete it with the right time/date and renderflags definitions (grids, ...).

Code: Select all

obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")

-- Define Geocentric frame of reference
e_frame = celestia:newframe("planetographic", earth)

-- Define position and orientation using cel-style URL.
u_pos = celestia:newposition("fbeWQgCMEQ", "fg7E0iILKA", "PMj5mKdiBg")
u_rot = celestia:newrotation(-0.573595, -5.80523e-006, -0.819139, -3.23302e-006)

-- Convert position and orientation from Universal to Geocentric coordinates.
e_pos = e_frame:from(u_pos)
e_rot = e_frame:from(u_rot)

obs:setposition(e_pos)
obs:setorientation(e_rot)

obs:synchronous(earth)
obs:setfov(math.rad(60))


Now, do you still hate celx ? :wink:
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 2 months
Location: Paris France

Re: I hate scripts (help is welcome)

Post #3by jogad » 13.12.2008, 15:35

Hi Vincent,

Ha ha ha! 8) In my sense it is cheating because you start with values from the Url instead of the really known values that are azimuth, elevation (pitch) and roll.

I must study on it more ahead.

In fact the Wikibook is my quasi only source of knowledge for celx. But it is not so easy because if there is a comprehensible list of function, there is practically no example nor explanation on how to use difficult (for me) notions like frames of reference or rotations. Particularly I find that the description of newrotation (axis-angle) is somewhat cryptic.

But nevertheless your example is helpful and it gives me a track to follow. :)
I just must beware rotations because they give me vertigo!

Many thanks! :mrgreen:  

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Re: I hate scripts (help is welcome)

Post #4by Vincent » 14.12.2008, 14:40

Jo?l,

Actually, I really thought that you wanted to convert celURLs into celx code...
If you want to give observer a specific orientation using azimuth and elevation,
you may want to have a look at the celutil.lua file that's included in the Lua Edu
Tools package.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3


Return to “Scripting”