CELX command to display an arrow?

All about writing scripts for Celestia in Lua and the .cel system
Topic author
dams2008
Posts: 16
Joined: 26.08.2008
With us: 16 years 3 months

CELX command to display an arrow?

Post #1by dams2008 » 26.08.2008, 17:06

Hello,

I would like to add in my CELX script a command allowing to display an arrow from an object pointing the sun or the magnetic field direction or even to display a frame.

Do you know the command? Is it possible to call directly the functions defined in the celestia source? RenderSunDirectionArrow? or RenderAxisArrows?
I would prefer not to use the mouse command in order to add an automatic sequence of displays...
I have searched in all available tutorials and I don't find anything.

Hope you could help me.
Thanks.

Dams.

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

Re: CELX command to display an arrow?

Post #2by Vincent » 26.08.2008, 19:48

You can add your reference mark using, e.g.:

Code: Select all

sel = celestia:getselection()
sel:addreferencemark{type = "sun direction", size = 5000, color = "yellow", tag = "sun_dir"}

Then use this line to remove it:

Code: Select all

sel:removereferencemark("sun_dir")


Here you'll find more about how to use reference marks in celx:
http://en.wikibooks.org/wiki/Celestia/C ... erencemark
@+
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

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 10 months
Location: Seattle, Washington, USA

Re: CELX command to display an arrow?

Post #3by chris » 26.08.2008, 21:40

Note that the reference mark functions are not present in version 1.5.1 and earlier. You'll need to have a SVN build of version of 1.6.0 (search the forum for the link) in order to enable reference marks via script.

--Chris

Topic author
dams2008
Posts: 16
Joined: 26.08.2008
With us: 16 years 3 months

Re: CELX command to display an arrow?

Post #4by dams2008 » 27.08.2008, 07:28

Thanks Chris and Vincent.
I have just a last question for you Chris... I am not sure to understand what you mean.
If I am using a version 1.5.0 (for example), I cannot use the reference marks functions. Right?
So, you explain that I need a SVN build of version 1.6.0... what is a SVN build of version 1.6.0 ?

Thanks.

Dams.

Topic author
dams2008
Posts: 16
Joined: 26.08.2008
With us: 16 years 3 months

Re: CELX command to display an arrow?

Post #5by dams2008 » 27.08.2008, 07:54

Ok ! sorry for this last question...
It's obvious. I have found two executables WIN32 on the website of Cartrite and Phoenix.
I have just to replace the celestia.exe file and it should work.
Do you know if a lot of things are changing with this version?
- deprecated functions?
- CELX commands difference?
- ...

Dams.

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 10 months
Location: Seattle, Washington, USA

Re: CELX command to display an arrow?

Post #6by chris » 27.08.2008, 08:15

dams2008 wrote:Ok ! sorry for this last question...
It's obvious. I have found two executables WIN32 on the website of Cartrite and Phoenix.
I have just to replace the celestia.exe file and it should work.
Do you know if a lot of things are changing with this version?
- deprecated functions?
- CELX commands difference?
- ...

Many things are changing. There are no newly deprecated functions, however. The changes are mostly feature additions and bug fixes. There's no list of celx differences yet, but new celx functions are flagged with a green '1.6.0' in the reference on the WikiBook:
http://en.wikibooks.org/wiki/Celestia/C ... ua_Methods

If you're creating add-ons, you might also be interested in new features for add-on creators:
http://en.wikibooks.org/wiki/Celestia/160Files

--Chris

Topic author
dams2008
Posts: 16
Joined: 26.08.2008
With us: 16 years 3 months

Re: CELX command to display an arrow?

Post #7by dams2008 » 27.08.2008, 09:27

OK !
So, I think I have a problem with the install of the SVN build of version 1.6.0.
I have downloaded the r4407 (from Cartrite's website) and I do the followings steps:
- copy the r4407_celestia.exe in the Celestia directory.
- run the r4407_celestia.exe
- run my script (draw a satellite in orbit around earth)
=> but nothing is drawn excepted the earth!! The satellite object is not recognized if I try to go to the object manually.
- with the original executable, it works perfectly.

Do you have an idea? If there something else to modify to install in order to use the version 1.6.0?

Dams.

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 10 months
Location: Seattle, Washington, USA

Re: CELX command to display an arrow?

Post #8by chris » 27.08.2008, 09:45

dams2008 wrote:OK !
So, I think I have a problem with the install of the SVN build of version 1.6.0.
I have downloaded the r4407 (from Cartrite's website) and I do the followings steps:
- copy the r4407_celestia.exe in the Celestia directory.
- run the r4407_celestia.exe
- run my script (draw a satellite in orbit around earth)
=> but nothing is drawn excepted the earth!! The satellite object is not recognized if I try to go to the object manually.
- with the original executable, it works perfectly.

Do you have an idea? If there something else to modify to install in order to use the version 1.6.0?

Is there an error message in the console? (You can enable it by pressing the tilde (~) key; use the up and down arrows to scroll.) Can you post the part of the script that draws the satellite? Is there a custom .ssc file involved as well?

--Chris

Topic author
dams2008
Posts: 16
Joined: 26.08.2008
With us: 16 years 3 months

Re: CELX command to display an arrow?

Post #9by dams2008 » 27.08.2008, 10:13

I have enabled the error message and I notice the following errors before running my celx script:
Loaded 10937 deep space objects
Error in the file .ssc (line 92): object 'TYC 3466-0819-1' .. not found
Error in the file .ssc (line 92): bad alternative surface
...
Body frame for GB2 is needed too deep (probably circular)
...
After running my script, nothing else is appearing.
The view is modified and correspond to the right view but without the satellite...
I have added alternative surface (new .ssc) for earth. Maybe it causes an issue...

Code: Select all

Here is the *.ssc script and *.celx script
------------------------  SSC -----------------
"GB2" "Sol/Earth"
 {
 Class "moon"
 Mesh "gb2.3ds"
 Radius 800
 Beginning 2454993.782004444
 OrbitFrame { EquatorJ2000 { Center "Sol/Earth" }}
 BodyFrame { BodyFixed { Center "Sol/Earth/GB2" }}
 SampledOrbit "gb2.xyz"
 SampledOrientation "gb2.q"
 Albedo 0.10
  Orientation [90 1 0 0]
 Ending 2454993.823671111
 }

---------------------- CELX --------------------
while celestia:gettime()< 2454993.782004444 do celestia:flash(" Debut Script GB2 ",1) wait(0) end
-- Do not label the following objects
celestia:hidelabel("planets","moons","spacecraft","asteroids","constellations")
celestia:hidelabel("stars","galaxies","moon")
-- Label the following objects
-- celestia:showlabel("moon")
-- Do not render the following objects
celestia:setrenderflags{asteroids = flase,grid=flase,constellations=false}
-- Render the following objects
celestia:setrenderflags{atmosphere=true,stars=true}
-- Do not render the following objects
celestia:setlabelflags{planets = flase,spacecraft=false}
-- Set Time Rate
celestia:settimescale(2.0)

tt=celestia:find("Sol/Earth")
gb2=celestia:find("Sol/Earth/GB2")
celestia:unmark(tt)
celestia:unmark(gb2)
celestia:select(gb2)
obs = celestia:getobserver()
obs:lock(tt)
obs:center(gb2)
obs:track(gb2)
obs:chase(gb2)
obs:gotodistance(gb2,6000,5)
obs:lock(tt)
while celestia:gettime()< 2454993.823671111 do celestia:flash(" Fin Script GB2 ",1) wait(0) end

---------------- SSC for alternative surface ---------------
AltSurface "earth_real_color" "Sol/Earth"
  {
   Texture "earth_real_color.*" 
  }

AltSurface "earth_high_res" "Sol/Earth"
  {
   Texture "earth_high_res.*" 
  }
------------------------------------------------------------------


chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 10 months
Location: Seattle, Washington, USA

Re: CELX command to display an arrow?

Post #10by chris » 27.08.2008, 10:59

dams2008 wrote:I have enabled the error message and I notice the following errors before running my celx script:
Loaded 10937 deep space objects
Error in the file .ssc (line 92): object 'TYC 3466-0819-1' .. not found
Error in the file .ssc (line 92): bad alternative surface
...
Body frame for GB2 is needed too deep (probably circular)

It sounds like the problem is with your definition for GB2 in the ssc file. Could you cut and paste that into a forum post?

--Chris

Topic author
dams2008
Posts: 16
Joined: 26.08.2008
With us: 16 years 3 months

Re: CELX command to display an arrow?

Post #11by dams2008 » 27.08.2008, 11:10

[/quote]

It sounds like the problem is with your definition for GB2 in the ssc file. Could you cut and paste that into a forum post?

--Chris[/quote]

Do you mean in a new post or in this one?
Otherwise, the gb2.ssc file is already pasted in the previous message. I paste it again hereafter.


------------------------ SSC -----------------
"GB2" "Sol/Earth"
{
Class "moon"
Mesh "gb2.3ds"
Radius 800
Beginning 2454993.782004444
OrbitFrame { EquatorJ2000 { Center "Sol/Earth" }}
BodyFrame { BodyFixed { Center "Sol/Earth/GB2" }}
SampledOrbit "gb2.xyz"
SampledOrientation "gb2.q"
Albedo 0.10
Orientation [90 1 0 0]
Ending 2454993.823671111
}

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

Re: CELX command to display an arrow?

Post #12by selden » 27.08.2008, 12:31

Unfortunately, an object's BodyFrame cannot be defined relative to itself. Orbits and Rotations always are relative to other objects.

GB2 needs to be deleted from its BodyFrame declaration.
BodyFrame { BodyFixed { Center "Sol/Earth/GB2" }}
could be
BodyFrame { BodyFixed { Center "Sol/Earth" }}
or it could specify some other previously defined body.
Selden

Topic author
dams2008
Posts: 16
Joined: 26.08.2008
With us: 16 years 3 months

Re: CELX command to display an arrow?

Post #13by dams2008 » 27.08.2008, 12:50

Thanks for your answer. It works perfectly now.
I have another question.
I know (thanks to previous messages) how to display the sun direction, the body frame,... but I do not know how to display an arrow representing for instance the earth magnetic field direction or total angular momentum... it's not the same thing than drawing an arrow representing the direction from an object to another object.
Do I have to create a new frame and display one axis of this new frame?

Dams.

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

Re: CELX command to display an arrow?

Post #14by selden » 27.08.2008, 14:38

Dams,

Magnetic fields are not designed into Celestia.
Defining an appropriate body and displaying that body's axis does sound like a reasonable approach.
Selden

Topic author
dams2008
Posts: 16
Joined: 26.08.2008
With us: 16 years 3 months

Re: CELX command to display an arrow?

Post #15by dams2008 » 29.08.2008, 13:36

Ok I understand but I do not know how to proceed...
Would it be possible to have a simple explanation?

Thanks.

Dams.

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

Re: CELX command to display an arrow?

Post #16by selden » 29.08.2008, 14:24

I think Cham's "Magnetic Earth" Addon might be a good place to start. It's available on the MotherLode at
http://www.celestiamotherlode.net/catal ... on_id=1016
Selden


Return to “Scripting”