RELEASE: The Flight of Buran
chris wrote:Would it be useful to have a script that allows you to modify the orientation of the selected object interactively and then record those orientations for use in a SampledOrientation .q file?
--Chris
Of course ! And what about the "edit mode" of Celestia (alt-@, in OS X) ? We should take advantage of this *probably* unknown and under-used function of our favorite software.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
-
- Site Admin
- Posts: 4211
- Joined: 28.01.2002
- With us: 22 years 9 months
- Location: Seattle, Washington, USA
Here's the first version of the Rotator tool:
http://www.celestiaproject.net/~claurel/celest ... or-0.1.zip
I hope that it's useful. Usage information from the readme (included in the zip file):
== Rotator for Celestia ==
Rotator is a tool for interactively rotating objects inside Celestia and
capturing the orientations to a file for use in a SampledOrientation. It is
designed to help add-on creators correctly orient their models.
== Installation ==
Rotator uses Celestia's Lua hook mechanism. The file luarotate.lua must be
installed in the same folder as celestia.cfg. You'll have to edit celestia.cfg
and add the following line someplace:
LuaHook "luarotate.lua"
When you start Celestia with this hook script, the usual functions of the
number keys and the ! key will be overridden. You'll have to remove the LuaHook
line to reset these keys to their usual functions.
In your add-on folder, you should copy the celxx folder included with this
package. It contains a single script file called keyboardrotation.lua that
defines a ScriptedRotation function. The structure of your add-on folder
should look like something like this:
Next, you'll need to modify the definition for object in your ssc file that
you want to orient. Comment out any rotation model--FixedRotation,
UniformRotation, SampledOrientation, etc., and add the following lines:
...replacing NAME with whatever the name of your object actually is.
You can do this for all objects that you want to orient interactively with the
Rotator tool.
== Running Rotator ==
After installation, start up Celestia and select the object you're interested
in rotating. The following keys are now active:
1 / 2 : Rotate selected object about x-axis
3 / 4 : Rotate selected object about y-axis
5 / 6 : Rotate selected object about z-axis
0 : Reset the orientation of the selected object
! : Log the rotation to a file
Use the number keys to rotate the selected object to the desired orientation.
When it's where you want it, press ! to log that orientation to a file. Repeat
for as many orientations and objects as you like.
Note that because of the way Celestia caches rotations, pausing Celestia
will prevent the orientation of objects from being update. Instead of pausing
time to edit, you can slow it down by 100x.
== Using Rotator Ouput ==
When you're done orienting objects, close Celestia and look for the file
rotations.txt. By default, the file will be located in the current folder.
You can modify this line in luarotate.lua:
logfile = "rotations.txt"
...to place the log file somewhere else (such as your home directory.) The
file will contain a list of records like this:
The four numbers on each line are a quaternion that can be pasted into a
.q file for a SampledOrientation. A SampledOrientation file contains a list
of time+quaternion records (where the times are Julian dates). A sample .q
file looks like this:
The last four numbers are each line are the quaternion components.
http://www.celestiaproject.net/~claurel/celest ... or-0.1.zip
I hope that it's useful. Usage information from the readme (included in the zip file):
== Rotator for Celestia ==
Rotator is a tool for interactively rotating objects inside Celestia and
capturing the orientations to a file for use in a SampledOrientation. It is
designed to help add-on creators correctly orient their models.
== Installation ==
Rotator uses Celestia's Lua hook mechanism. The file luarotate.lua must be
installed in the same folder as celestia.cfg. You'll have to edit celestia.cfg
and add the following line someplace:
LuaHook "luarotate.lua"
When you start Celestia with this hook script, the usual functions of the
number keys and the ! key will be overridden. You'll have to remove the LuaHook
line to reset these keys to their usual functions.
In your add-on folder, you should copy the celxx folder included with this
package. It contains a single script file called keyboardrotation.lua that
defines a ScriptedRotation function. The structure of your add-on folder
should look like something like this:
Code: Select all
addon/
addon.ssc
data/
traj.xyz
textures/
texture1.jpg
texture2.jpg
celxx/
keyboardrotation.lua
Next, you'll need to modify the definition for object in your ssc file that
you want to orient. Comment out any rotation model--FixedRotation,
UniformRotation, SampledOrientation, etc., and add the following lines:
Code: Select all
ScriptedRotation
{
Module "keyboardrotation"
Function "kbrotation"
Id "NAME"
}
...replacing NAME with whatever the name of your object actually is.
You can do this for all objects that you want to orient interactively with the
Rotator tool.
== Running Rotator ==
After installation, start up Celestia and select the object you're interested
in rotating. The following keys are now active:
1 / 2 : Rotate selected object about x-axis
3 / 4 : Rotate selected object about y-axis
5 / 6 : Rotate selected object about z-axis
0 : Reset the orientation of the selected object
! : Log the rotation to a file
Use the number keys to rotate the selected object to the desired orientation.
When it's where you want it, press ! to log that orientation to a file. Repeat
for as many orientations and objects as you like.
Note that because of the way Celestia caches rotations, pausing Celestia
will prevent the orientation of objects from being update. Instead of pausing
time to edit, you can slow it down by 100x.
== Using Rotator Ouput ==
When you're done orienting objects, close Celestia and look for the file
rotations.txt. By default, the file will be located in the current folder.
You can modify this line in luarotate.lua:
logfile = "rotations.txt"
...to place the log file somewhere else (such as your home directory.) The
file will contain a list of records like this:
Code: Select all
ObjectName 0.390731 -0.920505 0.000000 0.000000
ObjectName 0.379935 -0.895071 0.091214 0.214888
ObjectName 0.237783 -0.836056 -0.332390 0.366042
The four numbers on each line are a quaternion that can be pasted into a
.q file for a SampledOrientation. A SampledOrientation file contains a list
of time+quaternion records (where the times are Julian dates). A sample .q
file looks like this:
Code: Select all
2452564.751168 -0.258753 -0.531801 -0.546416 0.593012
2452564.751261 -0.258753 -0.531801 -0.546416 0.593012
2452564.857906 -0.258753 -0.531801 -0.546416 0.593012
2452564.962073 -0.259154 -0.531602 -0.545973 0.593424
2452565.066426 -0.259020 -0.531667 -0.546122 0.593287
2452565.078741 -0.258753 -0.531801 -0.546416 0.593012
2452565.081241 -0.259837 -0.516241 -0.557344 0.596111
2452565.185500 -0.259837 -0.516241 -0.557344 0.596111
The last four numbers are each line are the quaternion components.
Last edited by chris on 16.02.2008, 00:47, edited 1 time in total.
-
- Site Admin
- Posts: 4211
- Joined: 28.01.2002
- With us: 22 years 9 months
- Location: Seattle, Washington, USA
A couple more things regarding add-on construction and using rotator. First of all, you can usually get by without modifying the Orientation property of an object. In fact, it will be easier to use Rotator if you omit it completely. The end goal is to have the SampledOrientation file replace both Orientation and FixedRotations you've been using for Buran.
--Chris
--Chris
-
- Developer
- Posts: 3776
- Joined: 04.02.2005
- With us: 19 years 9 months
Hmmm, I've set up a test addon to try the rotation tool, and I'm yet unable to make it to work. I followed all of your instructions (editing the config file, etc), and Celestia do nothing when I'm typing the number keys. I also tried the numeric keypad, and it's working the usual way (tilt, etc). The number keys on the left aren't working at all (do nothing).
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
-
- Site Admin
- Posts: 4211
- Joined: 28.01.2002
- With us: 22 years 9 months
- Location: Seattle, Washington, USA
Cham wrote:Hmmm, I've set up a test addon to try the rotation tool, and I'm yet unable to make it to work. I followed all of your instructions (editing the config file, etc), and Celestia do nothing when I'm typing the number keys. I also tried the numeric keypad, and it's working the usual way (tilt, etc). The number keys on the left aren't working at all (do nothing).
Are there any messages showing up in the log?
EDIT: Nevermind. I just realized that you also need to set the ScriptSystemAccessPolicy to "allow". That's the only way that you can share information between ScriptedOrbits/Rotations and the Lua hook right now. I've been looking at other ways to address this problem, but for now just change the ScriptSystemAccessPolicy in celestia.cfg.
--Chris
Last edited by chris on 16.02.2008, 01:16, edited 1 time in total.
Chris,
I can now rotate the model using the number keys, and use the ! to make an output. There's a file called "rotations.txt" which is then created in the base folder, but it's empty. Nothing is written in that file. Something is wrong.
I can now rotate the model using the number keys, and use the ! to make an output. There's a file called "rotations.txt" which is then created in the base folder, but it's empty. Nothing is written in that file. Something is wrong.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
chris wrote:I can flush after each line so that output is available immediately. Let me know how else this tool can be improved. Would it be helpful to output the current time along with the rotation?
It would be preferable to get the output file instantaneously, without the need to quit Celestia. Also, what is the time saved with the rotation parameters ? I think it should be preferable to have the actual time, at which the rotation is done.
EDIT : ok, I just noticed that the four numbers are just parts of a quaternion, and don't include the julian date. I suggest to add the time also in the output.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
Chris:
This tool will be very useful for add-on creators. That said, I don't want to sound dumb, but I am having trouble learning what the many new ssc commands do in 1.5.0. As such, I have no idea where in an ssc file to paste the data from the rotations.txt file. Does it follow the command "SampledOrientation"? Do I insert each rotations line in some kind of sequence?
Perhaps the better question to ask is whether anyone has yet written a new outline or guide of what all of the commands in an ssc for 1.5.0 do? ... something we could study and learn from?
Frank
This tool will be very useful for add-on creators. That said, I don't want to sound dumb, but I am having trouble learning what the many new ssc commands do in 1.5.0. As such, I have no idea where in an ssc file to paste the data from the rotations.txt file. Does it follow the command "SampledOrientation"? Do I insert each rotations line in some kind of sequence?
Perhaps the better question to ask is whether anyone has yet written a new outline or guide of what all of the commands in an ssc for 1.5.0 do? ... something we could study and learn from?
Frank
-
- Site Admin
- Posts: 4211
- Joined: 28.01.2002
- With us: 22 years 9 months
- Location: Seattle, Washington, USA
fsgregs wrote:Chris:
This tool will be very useful for add-on creators. That said, I don't want to sound dumb, but I am having trouble learning what the many new ssc commands do in 1.5.0. As such, I have no idea where in an ssc file to paste the data from the rotations.txt file. Does it follow the command "SampledOrientation"? Do I insert each rotations line in some kind of sequence?
Perhaps the better question to ask is whether anyone has yet written a new outline or guide of what all of the commands in an ssc for 1.5.0 do? ... something we could study and learn from?
Frank
Documentation on all SSC body properties is in the Celestia WikiBook:
http://en.wikibooks.org/wiki/Celestia/SSC_File
If there's anything that's not clear, let me know and I can add examples or explanations to the documentation.
Documentation on SampledOrientation is in the section on Rotation Models, though the section on SampledOrientation is a little thin right now:
http://en.wikibooks.org/wiki/Celestia/Rotation_Models
--Chris