Sun vs. Planets - size comparison script

All about writing scripts for Celestia in Lua and the .cel system
Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #41by don » 19.11.2003, 19:31

Howdy Bob,

This is GOOD news! Thank you for your update.

I just e-mailed you the neptune.jpg file from my "basic" install. Hope the add-on *looks* different, so this answers that question also. But if this is the case, then one would logically ask, "which one is right?"

Three good lessons, indeed <smile>.

Adding a couple more lessons that I learned...

4. Keep your lines of text short enough so they will display properly on an 800 x 600 resolution window (or a little shorter) ... because the text will run off the edge of the display without wrapping (won't be seen).

5. Don't print text when a yellow sun is taking up the display screen. White text does not display on a yellow sun. Probably not blue either.

6. It REALLY PAYS to have others test your script to see if they get the same results you do.

7. If you want to modify someone elses script, be prepared to spend 3 times as much time on it as you thought it would take, and plan on learning some lessons along the way. :)

8. If you want *REALLY* precise distance values, ask Bob Hegwood, the distance expert! :wink:

-Don G.

Bob Hegwood
Posts: 1048
Joined: 19.10.2003
With us: 21 years 3 months
Location: Germantown, Ohio - USA

Post #42by Bob Hegwood » 20.11.2003, 07:39

don wrote:8. If you want *REALLY* precise distance values, ask Bob Hegwood, the distance expert! :wink:


Sigh...
I wouldn't get too excited yet, Don. Since I changed the radii of Uranus and Pluto on my system, those two 2-million km distances are now no longer correct. :oops:
I'll get them fixed as soon as I can, and I'll post the finished script on my web page. Probably this weekend again, as I'm working 12-hour days now. Whew!

The version of Neptune you sent to me is basically the same texture that I have, only it's at a smaller resolution. I *still* don't see the dark spot when I should, so the difference *has* to lie in the SSC parameters. As soon as I figure it out, I'll let you know what the deal is.

By the way, I *also* learned of some new scripting tools from your version, - "\n" for example - so I have even more good reasons for playing with this script.
Bob Hegwood
Windows XP-SP2, 256Meg 1024x768 Resolution
Intel Celeron 1400 MHz CPU
Intel 82815 Graphics Controller
OpenGL Version: 1.1.2 - Build 4.13.01.3196
Celestia 1.4.0 Pre6 FT1

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #43by don » 21.11.2003, 08:27

Howdy Bob,

Bob Hegwood wrote:Since I changed the radii of Uranus and Pluto on my system, those two 2-million km distances are now no longer correct. :oops:
Well, that wasn't very nice of them!

Sounds like you must be on a Holiday Shift, to be working 12-hour days. Scripts can wait, just make sure you stay healthy. :)

Here are the distance values I get with 1.0.3...

Code: Select all

 Object  Init Dist  2M km Dist
-------  ---------  ----------
Sun..... 6,998,800   2,000,500
Mercury.    17,080   2,000,000
Venus...    42,364   2,000,200
Earth...    44,647   2,000,500
Mars....    23,772   2,001,600
Jupiter.   500,440   2,003,200
Saturn..   421,880   1,998,500
Uranus..   178,910   1,951,???
Neptune.   173,360   2,000,600
Pluto...     8,057   2,024,700



Bob Hegwood wrote:By the way, I *also* learned of some new scripting tools from your version, - "\n" for example - so I have even more good reasons for playing with this script.

When you add more lines, remember to start the text higher or you end up in the Celestia text display area.

Have fun, and don't pull out too much hair! :lol: 8O

-Don G.

Bob Hegwood
Posts: 1048
Joined: 19.10.2003
With us: 21 years 3 months
Location: Germantown, Ohio - USA

Post #44by Bob Hegwood » 23.11.2003, 05:53

Don,

Got the finished version of the Size Comparison script on my web page now: http://www.home.earthlink.net/~bobhegwood

Thanks for all of the good advice. The script now behaves as it should. :)

I'm still working on the Mars script... It'll be out there shortly.

Thanks again, Bob
Bob Hegwood

Windows XP-SP2, 256Meg 1024x768 Resolution

Intel Celeron 1400 MHz CPU

Intel 82815 Graphics Controller

OpenGL Version: 1.1.2 - Build 4.13.01.3196

Celestia 1.4.0 Pre6 FT1

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #45by don » 23.11.2003, 20:45

Howdy Bob,

Thank you for the final distance adjustments, and for catching those pesky spelling corrections too. :D

It looks great!

-Don G.

Bob Hegwood
Posts: 1048
Joined: 19.10.2003
With us: 21 years 3 months
Location: Germantown, Ohio - USA

Post #46by Bob Hegwood » 29.12.2003, 04:36

Just so you know Mr. Goyette,

With the latest release of Celestia, your script is no longer accurate as far as the 2million km distances go.

Once again, the planetary radii have been changed, and therefore screwed up our distance measuring routines.

I'll see if I can correct it before you get back from wherever you're at now.

Come back willya? I MISS your comments.

Take care, Bob
Bob Hegwood

Windows XP-SP2, 256Meg 1024x768 Resolution

Intel Celeron 1400 MHz CPU

Intel 82815 Graphics Controller

OpenGL Version: 1.1.2 - Build 4.13.01.3196

Celestia 1.4.0 Pre6 FT1

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #47by don » 29.12.2003, 10:15

Ooooooh nooooooo, not again! :(

If Lua has some way to set an *exact* distance, maybe this script would be better off ported to Lua? I've not explored Lua very much, but Harald would know.

Sorry I've been away. My wife has two 4-day weekends (Christmas and New Year's) so I've been doing things other than the PC, and will be this week also. I should be back to "normal" around the 5th or 6th.

Happy New Year!

-Don G.

Harry
Posts: 559
Joined: 05.09.2003
With us: 21 years 4 months
Location: Germany

Post #48by Harry » 29.12.2003, 10:59

don wrote:If Lua has some way to set an *exact* distance, maybe this script would be better off ported to Lua? I've not explored Lua very much, but Harald would know.


Sure you can... but right now the goto-command in lua doesn't accept distances, so you have to work around this. If you look at my solarsystem tour, there is not a single goto-command in there.

Now simply setting the observer to the right distance (without journey to that position) is easy - I have been using it to preload textures (which isn't available as a command) :wink:

Harald

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #49by don » 29.12.2003, 11:27

Howdy Harald,

Can you provide an example of how to set the camera to an exact distance from an object? Thanks!

-Don G.

Harry
Posts: 559
Joined: 05.09.2003
With us: 21 years 4 months
Location: Germany

Post #50by Harry » 29.12.2003, 11:58

don wrote:Can you provide an example of how to set the camera to an exact distance from an object? Thanks!


I'll try ("--" introduces a comment), and be more verbose than necessary:

Code: Select all

-- Need this to convert between kilometer (radius)
-- and microlightyears (vectors)
KM_PER_MLY=9466411.842
obs = celestia:getobserver()
planet = celestia:find("Earth")
position = planet:getposition()
distance = 5 * planet:radius()
-- create vector with length 1 mly:
unit_vector = celestia:newvector(1,0,0)

new_position = position + distance / KM_PER_MLY * unit_vector
obs:setposition(new_position)
up = celestia:newvector(0,1,0)
obs:lookat(position, up)


or somewhat shorter:



Code: Select all

earth = celestia:find("Earth")
obs = celestia:getobserver()
obs:setposition(earth:getposition() + 5*earth:radius()/9466411.842*celestia:newvector(1,0,0))
obs:lookat(earth:getposition(), celestia:newvector(0,1,0))


This sets the position to 5*radius from earth-center, or 4*radius from surface. I probably will post a more useful example later...

UPDATE:

Arrrgh... I should stop trying to do more than one thing at the same time... you wanted exact distance, not same apparent radius. Luckily, the change is simple:

Set distance to the number of kilometers you want be away from the center of the planet:

Code: Select all

distance = 2000000

or if you want to have a distance relative to the surface:

Code: Select all

distance = 2000000 + planet:radius()


Similar for the second codeblock... Sorry for the confusion.

Update to the Update: Changed the "-" to "+" in my correction. Ahem...

Harald[/i]

Bob Hegwood
Posts: 1048
Joined: 19.10.2003
With us: 21 years 3 months
Location: Germantown, Ohio - USA

Post #51by Bob Hegwood » 29.12.2003, 17:23

Set distance to the number of kilometers you want be away from the center of the planet:

Code: Select all

 distance = 2000000


or if you want to have a distance relative to the surface:

Code: Select all

 distance = 2000000 + planet:radius()


Harry, the first example is what we're after. If the distance is based on the planetary radii, the script is no longer accurate because Chris keeps changing the radii with each release of Celestia.

Thanks, Bob

PS-I'm still looking at the celx method, but the examples I have downloaded didn't do much for me. I'll need to become more familiar with the instruction set before I jump on that wagon. 8)

Thanks, Bob
Bob Hegwood

Windows XP-SP2, 256Meg 1024x768 Resolution

Intel Celeron 1400 MHz CPU

Intel 82815 Graphics Controller

OpenGL Version: 1.1.2 - Build 4.13.01.3196

Celestia 1.4.0 Pre6 FT1

Harry
Posts: 559
Joined: 05.09.2003
With us: 21 years 4 months
Location: Germany

Post #52by Harry » 29.12.2003, 17:57

Bob Hegwood wrote:Harry, the first example is what we're after. If the distance is based on the planetary radii, the script is no longer accurate because Chris keeps changing the radii with each release of Celestia.

But then celestia will display a distance of (2million km - radius), because it displays the distance to the surface, not to the center of the planet. If this is what you are after, I think you can do it in .cel-scripting to, using gotoloc relative to a planet (i.e. by setting the frame of reference correctly) - but I would have to try it to be sure.

Bob Hegwood wrote:PS-I'm still looking at the celx method, but the examples I have downloaded didn't do much for me. I'll need to become more familiar with the instruction set before I jump on that wagon. 8)


I hope the examples were at least nice to look at :wink: Feel free to ask about it, though better not in this crowded thread... Lua is not (yet?) a replacement for .cel-scripts, it is more powerful, but OTOH "simple" things (like goto) require more work.

Harald

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #53by don » 29.12.2003, 21:18

Howdy Harald and Bob,

It is actually the second example that gets us what we want. Since Lua provides variables and allows us to obtain the *current* radius of the object (unlike .CEL), this works perfectly.

Thank you for the example code Harald <big smile>!

-Don G.

Harry
Posts: 559
Joined: 05.09.2003
With us: 21 years 4 months
Location: Germany

Post #54by Harry » 30.12.2003, 00:06

don wrote:It is actually the second example that gets us what we want. Since Lua provides variables and allows us to obtain the *current* radius of the object (unlike .CEL), this works perfectly.

I am still not sure what the best solution would be: I would assume that it's best to measure the distance to the center of the planet for size-comparison (because that is where its apparent diameter can be found), but OTOH this distance-display of celestia measures distances to the surface.

Maybe the comparison should be done from infinitely far away with an infinitely small field-of-view? 8)

don wrote:Thank you for the example code Harald <big smile>!


Actually I am still hoping for some feedback on Lua-scripting or the example scripts - the thread about it is pretty quiet :( Therefore I am glad to write about it here :oops: . I guess the days between christmas and new year isn't prime time for celestia...

Harald

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #55by don » 30.12.2003, 00:19

Harry wrote:I am still not sure what the best solution would be:
Since the script is an "optical" comparison, I think distance to the surface is okay.

Harry wrote:I guess the days between christmas and new year isn't prime time for celestia...

Over here, there is usually a lot of time off from work for family get-togethers, holiday traveling, and out of town visiting during this time of year. I would expect it to be a bit "slow" until after the first of the year.

Happy New Year!

-Don G.


Return to “Scripting”