Page 1 of 1
.CelX equivalent to the Goto URL in .CEL ?
Posted: 09.04.2009, 21:22
by Chuft-Captain
In CEL scripts you can goto a URL by pasting the copied URL straight from Celestia into a "goto URL" command in your CEL script.
I can't find an obvious equivalent in CELX.
(ie. There should be an appropriate "observer" method IMO)
Can anyone point me in the right direction please.
Cheers
CC
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 10.04.2009, 00:09
by selden
I don't think there is a Method in CELX which invokes a URL.
However, it's a hack, but you can incorporate a .CEL script in a .CELX script.
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 10.04.2009, 02:01
by Chuft-Captain
selden wrote:I don't think there is a Method in CELX which invokes a URL.
Hmm... damned annoying!
selden wrote:However, it's a hack, but you can incorporate a .CEL script in a .CELX script.
Yep, I've never been too keen on that hack. It should work, but probably not with the speed I need.
There
are some methods for position:
http://en.wikibooks.org/wiki/Celestia/Celx_Scripting/CELX_Lua_Methods#positionbut there seems to be "get" methods only, no "set" methods.
Even if there were, then there's still orientation, frame, etc.. to set as well.
Cheers
CC
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 10.04.2009, 02:20
by chris
I think that this is an unfortunate omission from celx scripting. It shouldn't be hard to fix.
--Chris
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 10.04.2009, 03:02
by Chuft-Captain
chris wrote:I think that this is an unfortunate omission from celx scripting. It shouldn't be hard to fix.
--Chris
I'll look forward to that. Thanks.
(pls. let me know when fixed and I'll test)
CC
PS. Sent you a PM on another matter (infoURL's)
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 10.04.2009, 09:18
by Vincent
CC,
Here's an example that shows how to set celURL parameters using a celx script:
Code: Select all
--"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<d=0&p=0&rf=18470279&lm=2017986560&tsrc=0&ver=3"
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)
-- Set frame of reference
obs:synchronous(earth)
-- Set time
t = celestia:utctotdb(2008, 6, 21, 3, 21, 5.18439)
celestia:settime(t)
-- Set fov
obs:setfov(math.rad(60))
-- Set timescale
celestia:settimescale(0)
However, I agree that using a celestia:seturl function would be handier.
Another issue is that celURLs include some rendering options that can't be
"decoded" by the user to be used in the script.
So, if you can compile your own version of celestia, you can try to apply
the following short patch that adds the celestia:seturl function to celx scripting:
Code: Select all
Index: celx.cpp
===================================================================
--- celx.cpp (revision 4698)
+++ celx.cpp (working copy)
@@ -3303,7 +3303,18 @@
return 0;
}
+static int celestia_seturl(lua_State* l)
+{
+ Celx_CheckArgs(l, 2, 2, "One argument expected for celestia:seturl()");
+ CelestiaCore* appCore = this_celestia(l);
+ string url = Celx_SafeGetString(l, 2, AllErrors, "Argument to celestia:seturl() must be a string");
+ appCore->goToUrl(url);
+
+ return 0;
+}
+
+
static void CreateCelestiaMetaTable(lua_State* l)
{
Celx_CreateClassMetatable(l, Celx_Celestia);
@@ -3388,6 +3399,7 @@
Celx_RegisterMethod(l, "dsos", celestia_dsos);
Celx_RegisterMethod(l, "windowbordersvisible", celestia_windowbordersvisible);
Celx_RegisterMethod(l, "setwindowbordersvisible", celestia_setwindowbordersvisible);
+ Celx_RegisterMethod(l, "seturl", celestia_seturl);
lua_pop(l, 1);
}
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 11.04.2009, 00:20
by Chuft-Captain
Thanks for the example Vincent.
That's saved me quite a bit of time. See here:
http://shatters.net/forum/viewtopic.php?f=2&t=13666CC
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 11.04.2009, 01:07
by selden
Vincent,
I just now tested Celestia after applying your patch, and the Celx code
celestia:seturl
works great!
(Of course celestia:geturl would be helpful, too, so one could script their capture.)
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 11.04.2009, 09:28
by Vincent
CC,
You're welcome. And that's a great video !
selden wrote:I just now tested Celestia after applying your patch, and the Celx code
celestia:seturl
works great!
Selden,
Once again, thanks for testing the patch.
selden wrote:(Of course celestia:geturl would be helpful, too, so one could script their capture.)
Yes, that would be indeed a useful feature.
However, copying an URL to clipboard is a platform dependant process, so I'd suggest to
wait for the Qt cross-platform version before adding the celestia:geturl function to celx.
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 18.07.2009, 09:45
by Vincent
The seturl/geturl and synchronizetime/istimesynchronized methods have been added to the celestia object in celx scripting.
This concerns the current development versions, i.e., both the trunk and the 1.6.1 branch in SVN.
More information about how to use these commands can be found here:
http://en.wikibooks.org/wiki/Celestia/C ... tia#seturlThe following celx script gives an example about how to use these commands.
It shows the day/night length in Paris on the equinoxes and solstices.
Code: Select all
-- Title: Show day/night length in Paris on equinoxes and solstices
-- Author: Vincent <vince.gian@free.fr>
obs = celestia:getobserver()
obs:singleview()
wait(1)
obs:splitview("h", 0.5)
obs:splitview("v", 0.5)
obs = celestia:getobservers()
obs[2]:splitview("v", 0.5)
celestia:synchronizetime(false)
celestia:unmarkall()
sol = celestia:find("Sol")
earth = celestia:find("Sol/Earth")
loc = celestia:find("Sol/Earth/Paris")
earth:addreferencemark{type = "visible region", color = "yellow", opacity = 0.5, tag = "terminator", target = sol}
loc:mark("red", "disk", 10, 0.8, "", false)
-- Autumn Equinox
url1 = "cel://Follow/Sol:Earth/2009-09-22T11:00:0?x=mH9RlBJa&y=NzOFNqGfVQE&z=J9A3FXnja////////////w&ow=0.388908&ox=0.591889&oy=-0.590386&oz=-0.387121&select=Sol:Earth:Paris&fov=16.0765&ts=1000<d=0&p=0&rf=1693063&lm=2017986688&tsrc=0&ver=3"
-- Spring Equinox
url2 = "cel://Follow/Sol:Earth/2009-03-20T11:00:0?x=0/pVMFtV&y=wLI7PKGfVQE&z=+ARbV3bja////////////w&ow=0.389986&ox=0.593566&oy=-0.5887&oz=-0.386035&select=Sol:Earth:Paris&fov=16.0765&ts=1000<d=0&p=0&rf=1693063&lm=2017986688&tsrc=0&ver=3"
-- Winter Solstice
url3 = "cel://Follow/Sol:Earth/2009-12-21T11:00:0?x=Dn3js1lc&y=sE1o0KCfVQE&z=WObLkHnja////////////w&ow=0.393271&ox=0.598528&oy=-0.583654&oz=-0.382688&select=Sol:Earth:Paris&fov=16.0765&ts=1000<d=0&p=0&rf=1693063&lm=2017986688&tsrc=0&ver=3"
-- Summer Solstice
url4 = "cel://Follow/Sol:Earth/2009-06-21T11:00:0?x=4tT717VX&y=ILGVqKGfVQE&z=IIpesXjja////////////w&ow=0.390284&ox=0.594004&oy=-0.588258&oz=-0.385734&select=Sol:Earth:Paris&fov=16.0765&ts=1000<d=0&p=0&rf=1693063&lm=2017986688&tsrc=0&ver=3"
obs = celestia:getobservers()
celestia:seturl(url1, obs[1])
celestia:seturl(url2, obs[2])
celestia:seturl(url3, obs[3])
celestia:seturl(url4, obs[4])
text = [[
Spring Equinox Summer Solstice
Autumn Equinox Winter Solstice
]]
while true do
celestia:print(text, 1, 0.5, 0.5, -11, 1)
wait(0)
end
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 18.07.2009, 12:53
by Chuft-Captain
Vincent,
Did these make it into 1.6.0 final? ... or just miss?
CC
EDIT: OK, I just gave it a try and it looks like it didn't make it into 1.6.0.
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 25.07.2009, 14:07
by chris
Chuft-Captain wrote:Vincent,
Did these make it into 1.6.0 final? ... or just miss?
CC
EDIT: OK, I just gave it a try and it looks like it didn't make it into 1.6.0.
The changes are already in the 1.6.1 branch, so you won't have to wait too long...
--Chris
Re: .CelX equivalent to the Goto URL in .CEL ?
Posted: 26.07.2009, 04:14
by Chuft-Captain
chris wrote:Chuft-Captain wrote:Vincent,
Did these make it into 1.6.0 final? ... or just miss?
CC
EDIT: OK, I just gave it a try and it looks like it didn't make it into 1.6.0.
The changes are already in the 1.6.1 branch, so you won't have to wait too long...
--Chris
In fact, I don't have to wait at all! (I have finally installed the IDE and Tortoise
)
SetURL confirmed working in svn 4814:
Wormhole Travel... and it looks like either yourself or Vincent has also fixed an orientation problem which was causing an approx 90deg rotation when capturing URL's.
Cheers
CC