Building files from Celestia's data

Post requests, images, descriptions and reports about work in progress here.
Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 2 months
Location: Paris France

Building files from Celestia's data

Post #1by jogad » 10.04.2010, 07:06

Fenerit wrote:
A proposito, what was the suggestion :?:
Now the point. Lets consider the coordinates plug-in, just in the part concerning the coordinates (long/lat) without deal with the compass' animation and the azimuth/elev. Such plug-in get the coordinates by referring it to center of the screen. Now, if we add a PNG image of a sight, a pinhole, a target centered on screen, we should know the subpoint with more precision. Now suppose that to such PNG let be assigned the clickable propriety of saving (appending) in a TXT file (like your slideshow) the coordinates points, so to have a set of coordinates in tabular form. You will say: "and then?". Well, this is an easy way to build wireframe CMODs! Such a plug-in is both informative as a 3D tool with lots of utility, because what is now possible for the Earth once downloaded a dataset, should be possible even for other planets. One could say about of its scientificity, but should be the most scientific-like than nothing, isn't? And just to mark some features, with generic, educational purposes. The coordinates' set would have the form (within the text file) like:

LONGITUDE LATITUDE (or the converse, no matter, is based on which strings one do write before)
42.675 102.568 (the float precision is matter of taste :wink: )
43.568 103.512
.
.
.
Note that your (here idle) controlbox's buttons could be "channels" for more advanced operations upon such points (conversions, means, etc).
I've already made a Perl script to process such data and got a complete ASCII CMOD model (as you can see in the case of geologic add-on). Such plugin could be useful for the SCI_FI users for its creations.
Anyhow, I love the blues and the jazz is not dead.

Hi,

For me, there is no need to make a plugin. :?
It sounds quite simple and in my opinion, a simple script is enough.

This is how I see the problem to have as less work as possible 8)

:arrow: The code to calculate coordinates is already available - done!

:arrow: I suggest a script that replace the Celesestia's demo script. So pressing de "d" key launch your script with no need to go into the menus.

:arrow: The only work of your script is to take the coordinates and write them via the io.write command.

- Of course you can add a target or whatever you want :wink: but a celestia marker is a very simple and very efficient solution. (Ctl-K to activate the markers then Ctrl-P to have a small losange centered on your selected object).
This shows your subpoint with precision, even it is not centered on screen.
Last edited by jogad on 11.04.2010, 19:34, edited 1 time in total.

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files form Celestia's data

Post #2by Fenerit » 10.04.2010, 11:55

- Of course you can add a target or whatever you want :wink: but a celestia marker is a very simple and very efficient solution. (Ctl-K to activate the markers then Ctrl-P to have a small losange centered on your selected object).
This shows your subpoint with precision, even it is not centered on screen.

Right!

:arrow: The only work of your script is to take the coordinates and write them via the io.write command.

:roll: I'll get a look.
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files form Celestia's data

Post #3by Fenerit » 10.04.2010, 15:01

Hi Jo?l; look at this :wink:

Image

That are gotten simply by clicking/unclicking upon the two orange arrows (right toggle displacement here are large, just to test). I've left the redundant text only for showing where I do act. I'm stay commenting several lines of code (upon ver. 1.0) and this was the root in asking for your help :wink: Now, for what concern the marker as sight, I'm not sure, though, since it is centered on the object even when the object is displaced from the center of the screen; this could get misleadings.
The button bar is really "ready for start" as tools; expecially if one wish to close the perimeter, since in this case must be repeated the first coordinate. Manually is easy (copy/paste) but I'm not sure how to do in automatic (the expert in text string's manipulation are you, not me :D )

P.S.
My test with the celx script got errors on io.open :?: :roll:
Never at rest.
Massimo

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

Re: Building files form Celestia's data

Post #4by jogad » 10.04.2010, 19:24

I see that you got it!
Good :D

Fenerit wrote:Now, for what concern the marker as sight, I'm not sure, though, since it is centered on the object even when the object is displaced from the center of the screen; this could get misleadings.
In my opinion, this is much better than the screen's center because the coordinates you get are those of the object and not those of the center of the screen.

Fenerit wrote:The button bar is really "ready for start" as tools; expecially if one wish to close the perimeter, since in this case must be repeated the first coordinate. Manually is easy (copy/paste) but I'm not sure how to do in automatic
I recognize that if you choose the pluging solution this is easier to achive than with the celx script solution. (but you get a far longer code :( ):
:idea: Just record the first time coodinates and when your click on then "close perimeter button", write them instead of the actual coordinates.(No string manipulation in that :wink: )

Fenerit wrote:My test with the celx script got errors on io.open :?: :roll:

This is the celx script that appends the coordinates to the files "coordinates.txt" each time you launch it.

An easy way to proceed is to record it in the Celestia main directory and to modify in "celestia.cfg" the line
DemoScript "demo.cel"
to
DemoScript "coordinates.celx"
so that it is run when you press the "d" key.

Maybe it is also advisable to modify in "celestia.cfg" the line
ScriptSystemAccessPolicy "ask"
to
ScriptSystemAccessPolicy "allow"


Code: Select all

celestia:requestsystemaccess()
wait(0)

get_long_lat = function (obs, source)
    local f = source:getinfo().oblateness
    if not f then f = 0 end;
    u_pos = obs:getposition()
    e_frame = celestia:newframe("bodyfixed", source)
    e_pos = e_frame:to(u_pos)
    local lambda = -math.atan2(e_pos.z, e_pos.x);
    local beta = math.pi / 2 - math.atan2(math.sqrt(e_pos.x * e_pos.x + e_pos.z * e_pos.z), e_pos.y)
    local phi = math.atan2(math.tan(beta), (1 - f));
    local long = math.deg(lambda)
    local lat = math.deg(phi)
    return long, lat
end

obs = celestia:getobserver();
refObj = obs:getframe():getrefobject();
long, lat = get_long_lat(obs, refObj);

file=io.open("coordinates.txt","a")
file:write(long.."  "..lat.."\n")
file:close()

(Almost all this code is directly copied from the original Lua Plug-ins)
:mrgreen:

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files form Celestia's data

Post #5by Fenerit » 10.04.2010, 23:02

Is done! But you didn't said that with math was unconcerning? :D Thanks alot for the script; it work flawlessy. Being a bit brain dead, now I've understood the meaning of the marker. Anyway upon a thing I was sure: that the code was small. :mrgreen:
Now the interesting thing is whether to assign at buttons also the automation of the building of the CMOD, by previous conversion Perl > Lua or not. :roll:
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files form Celestia's data

Post #6by Fenerit » 11.04.2010, 02:48

Hi Jo?l, now we can try to figure out its applications (in prospective) :wink:
- geological, political, social contours (flora and fauna) Earth and further;
- Spaceships/stations lights (point sprites, planetographic mode);
- Minimal local placements of emitters (particle system) so one can add engine's effects to the spacecrafts;
(continue... :?: )
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files form Celestia's data

Post #7by Fenerit » 11.04.2010, 12:23

Just an example:

Image

Tracing has been made at 660 km. No bad.
Never at rest.
Massimo

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

Re: Building files form Celestia's data

Post #8by jogad » 11.04.2010, 19:43

Fenerit wrote:Hi Jo?l, now we can try to figure out its applications (in prospective) :wink:
- geological, political, social contours (flora and fauna) Earth and further;
- Spaceships/stations lights (point sprites, planetographic mode);
- Minimal local placements of emitters (particle system) so one can add engine's effects to the spacecrafts;
(continue... :?: )
I see that you have a lot of work to do. :mrgreen:

I have customized a little plugin that may help you (an maybe also other than you :?: ) if you need several functions that can work together.

devtools.png

- Just add the functions that you need and the same number of buttons will be shown on the tool
- You have a configuration file to change the key shorcut or the icons of the buttons.

As an example to see how it works, the plugin is provided with 2 famous functions :wink: :
- one to add the longitude and the latitude of a point in a file
- the other to close the perimeter by rewriting the first point and prepare to a next set of data on the same file.

Code: Select all

local my_function = {}
-----------------------------------------------------------
--             DEV. TOOLS
--
-- Put here your private variables and functions
-- in order to run friendly with other plug-ins
-- your variables and functions must be declared as "local"
--
-- functions called by the tool buttons must be:
-- my_function[1], my_function[2] etc...
-- you can also require other tools...
-----------------------------------------------------------

-- example of usage : adding coordinates to coordinates.txt
-- in the main Celestia directory

require "celutil"  -- long & lat calculation are already there

  -- user's variables
local long1, lat1  -- first point's long and lat

local write_coord = function(long, lat, spc)  -- user's subroutine
   if lat and long then
      local file = io.open("coordinates.txt","a")
      file:write(long.."  "..lat.."\n")
      if spc then
         file:write(spc) -- additional data if any
      end
      file:close()
   end
end

-- button 1 function
my_function[1]=function() -- get longitude and latitude
   local obs = celestia:getobserver();
   local refObj = obs:getframe():getrefobject();
   if not(empty(refObj)) then
      if refObj:type() == "location" or refObj:type() == "spacecraft" then
         refObj = refObj:getinfo().parent;
      end
      local long, lat = celutil.get_long_lat(obs, refObj);
      if not long1 then -- save first coordinates
         long1, lat1 = long, lat
      end
      write_coord(long, lat) -- write on file
      celestia:print("written in coordinates.txt\n"..long.."  "..lat,4)
   else
      celestia:print("No reference found!",5)
   end
end

-- button 2 function
my_function[2] = function() -- close perimeter and get ready for new surface
   if long1 and lat1 then
      write_coord(long1, lat1,"\n")
      celestia:print("perimeter closed at\n"..long1.."  "..lat1,4)
      long1, lat1 = nil, nil
   end
end

In this case the tool will have two buttons.

- You can add as many functions as you want.
- An interesting thing is that instead of celx scripts, functions can share variables, functions, and more data...

- this is a "do it yoursef" addon that lets you make your own set of useful functions. If you develop an interesting set of functions, you can easily release it as a new plugin 8)

-installation
    - unzip in the "extras" directory. A "devtools" directory is created.
    - add an entry "devtools" in the config.lua
      - in the "plugins = " section for Lua Plug-ins
      - in the "toolset = " section for Lua Edu Tools

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files from Celestia's data

Post #9by Fenerit » 11.04.2010, 21:39

Jo?l, you are incredible! The next time I come up in Paris, we go at Lido, pay myself. :wink: Thanks!
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files from Celestia's data

Post #10by Fenerit » 12.04.2010, 21:30

Some eye-candy and tools:

Image

1) Start new path. Make the TXT from scratch or erase the content and does enable the marker; in this step no points have been written yet. User must place the location under the "plus" marker.

2) Must be clicked once on target; marker call for all the successive points.

3) Optional; whether the user need to close the path or not, and meanwhile do repeat the step 2) or jumping back to 1)

Since they can be processed as lines and points as well (and the placeholder), to the CMOD's builder will be reserved further buttons.
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files from Celestia's data

Post #11by Fenerit » 14.04.2010, 23:52

A working prototype released. It use a mix of Lua and Perl.
REQUIREMENTS:
- Celestia 1.6 or above, either the LUATOOLS toolkit or the LUA plug-ins.

- OS WINDOWS:
CMODtracer require that Perl be installed on your system. Users can install the Perl language and its interpreter from several distributions freely availables on the net.

http://www.activestate.com/activeperl/
http://strawberryperl.com/
http://cygwin.com/setup.html

In order to have the Perl language under the DOS window (cmd.exe), it must be installed along with the "add to the path" option; done this, simply typing "perl" (without quotes) at prompt; that does switch from DOS to Perl environment within the same console (not required for the plug-in since there are two batch file, just informative).

- OSx and LINUX:
They comes with Perl already installed; please set properly the os.execute string within "cmod_builder.lua" file in order to get your favorite console and automatizing the scripts.

INSTALLATION:
Unzip within the main Celestia root; while two Windows batch files (.bat) will be installed there, CMODtracer will be placed inside the ../extras folder. OSx and LINUX users can remove or modifying such files. Is assumed that the LUATOOLS or the LUA plug-ins already are on your system. In case of plug-ins add into config.lua:

Code: Select all

plugins =
    {
      "compassBox",
      "KeplerParamBox",
      "coordinateBox",
      "pictureBox",
      "HRBox",
      "slideshow",
      "cmod_tracer",    -- string to add
      -- ephemerides group
      "ephemerisBox",
      "moonBox",
      "sunposBox",
      "constBox",
      "meteorBox",
   }

in case of LUATOOLS add into config.lua:

toolset =
    {
       "timeBox",
          "lightBox",
          "magnitudeBox",
          "galaxyLightBox",
          "renderBox",
          "obsModeBox",
          "solarSystemBox",
          "fovBox",
          "addsBox",
          "infoBox",
          "coordinatesBox",
          "distanceBox",
          "magnificationBox",
          "HRBox",
          "KeplerParamBox",
         "virtualPadBox",
   "cmod_tracer",   -- string to add
        "compassBox",
    }


See the readme.txt and the PDF guide for more explanations and usages.

Image

http://marauder.webng.com/files/cmod_tracer.zip (84.5 Kb)
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files from Celestia's data

Post #12by Fenerit » 19.04.2010, 03:24

From the CMODtracer as well as from whatelse dataset of coordinates could be useful to have the traced shape as an image contour for textures' layer and colorations. I've build 3 Perl scripts for converting such coordinates in SVG (Scalable Vector Graphics). Like the lineup of CMODtracer:

1) phsvg.pl make the placeholder 360x180px
2) asvg.pl append the shape(s) inside the container
3) svg.pl convert an entire list of cartesian coordinates in SVG (placeholder + append);

The test has been made with Inkscape but the SVG is very basic and without the parts relevant to it, so it must be open also by other programs. Unfortunately, I do not have other program than that for testing SVG.

Image
The option window is relevant to the document's setup.

Image
After this step, once you are aligned with the underlying traced feature, you can remove the "placeholder" (the 360x180 rectangle) by "split" o "separe" the shape's layer (I don't know how such menu option is wrote in english).

Image
The output can be just a PNG with transparent part for using with the OverlayTexture directive

The zip contain also the coordinates.txt for the Ontong-Java plateau, just for users' testing. You can unpack it where you wish.
http://marauder.webng.com/files/coords2svg.zip
Last edited by Fenerit on 21.04.2010, 14:37, edited 1 time in total.
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files from Celestia's data

Post #13by Fenerit » 19.04.2010, 12:49

Just some precisations about the SVG manipulations. Once the file is imported into a suitable graphic program, it is completely editable exploiting all the tools the program allow. In this way, if one don't wish to export as image format the underlying texture too, he can leave the placeholder after to have made it transparent or by locking the shape(s) in its positions. The lines contours can be thicked/thinned, colored or made transparents; the nodes (coordinates points) can be splitted, "splined", as well as removed or added; the shape(s) can be moved, skewed, rotated and so on.
Never at rest.
Massimo

Avatar
Marco Klunder
Posts: 181
Joined: 20.02.2008
Age: 62
With us: 16 years 9 months
Location: The Netherlands

Re: Building files from Celestia's data

Post #14by Marco Klunder » 19.04.2010, 19:07

Massimo,

Good job and coorporation with Jo?l here.

I'm studing your CMODtracer and I was wondering if it could be used to produce something like this:

I'm using the following CELX script part (without text here) in Celestia v161 SVN to explain the apparent retrograde motion in my "Conjunctions and Occultations" script.

Code: Select all

--
-- Apparent retrograde motion
--

obs=celestia:getobserver()
celestia:seturl("cel://Follow/Sol:Earth/2009-10-13T21:46:54.52112?x=AED6RiQGC/v//////////w&y=0gXgwPyXKw&z=AMCwZD6s9Pb//////////w&ow=0.934899&ox=-0.00929311&oy=-0.354791&oz=-0.000359816&select=Sol:Mars&fov=25.7243&ts=0&ltd=0&p=0&rf=18947&lm=1243138&tsrc=0&ver=3", obs)
celestia:showlabel("planets")
celestia:settimescale(270000)
wait(21.0)
celestia:settimescale(300000)
wait(24.0)
celestia:settimescale(320000)
wait(22.0)
celestia:hidelabel("planets")


What I like to show is a trace of the planet movement, that result in a picture like this:
Retrograde_Motion_2.jpg


I'm aware of the content of thread http://www.shatters.net/forum/viewtopic.php?f=10&t=15688&start=30, but I'm not sure that will solve it, if it ever will be implemented. When I saw the (potential) possibilities of this CMODtracer, I thought that this might also be a way.
But also reading the documentation, I saw that time is stopped, when your tool starts. As you can see on the script, The line(s) I want to draw on the screen are time dependent...

Marco
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files from Celestia's data

Post #15by Fenerit » 19.04.2010, 19:42

Well, sincerely, I do not have thought the CMODtracer for astronomical purposes BUT in effect you could take the astro coords and building a model with or without a placeholder... :roll:

For activating the time, do comment line 22 into cmod_tracer.lua: --celestia:settimescale(0);
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files from Celestia's data

Post #16by Fenerit » 20.04.2010, 14:14

Marco Klunder wrote: As you can see on the script, The line(s) I want to draw on the screen are time dependent...
Marco

Whether it can help, within the ephemerides plug-in's functions there is also that for the Earth subpoint(s); now I wonder whether you project can, if only, take into account such input for displaying the planetary path onto the Earth's surface (even though, with an huge model's radius like the semi-orbit, the path shouldn't elliptical unless you specify the SemiAxis directive). In the case you take the astro coords, a button could be set to account both the time + 1day and its coords. :idea: :roll:
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Building files from Celestia's data

Post #17by Fenerit » 20.04.2010, 23:01

BTW, a ScriptedOrbit point sprites objects could parse the subpoints and the planetary symbols make a dance around the Earth...
Never at rest.
Massimo


Return to “Add-on development”