Hi,
maybe this can be of some help to understand the various frames of reference available:
I wrote a script which will always put the observer on (and make him look in the direction of) one of the axis (x,y or z) for the currently active frame of reference. This can help visualize the axis. These keys are used to control the script (other keys work as expected):
- X,Y,Z (upper case): select and move to x,y,z-axis
- F, G: select next/previous frame of reference (using the currently selected planet as reference-object).
Here it is:
FramesOfReference_v1.0.celx
or via my celestia-page:
http://www.h-schmidt.net/celestia/
As always, please report errors and problems here.
HTH,
Harald
New Script about Frames of Reference
Howdy Harald!
Very nice script. It may take me another hundred years or so to understand all this stuff about vectors and coordinate systems / frames of reference. I can see the variable names, understand the variable names, copy and paste the variables around to change what happens ... but when it comes time to make the camera travel in a simple straight line, towards the center of the screen, with nothing selected ... I'm totally lost.
I'll just keep playing here and there, and eventually it will sink in ... I hope!
Very nice script. It may take me another hundred years or so to understand all this stuff about vectors and coordinate systems / frames of reference. I can see the variable names, understand the variable names, copy and paste the variables around to change what happens ... but when it comes time to make the camera travel in a simple straight line, towards the center of the screen, with nothing selected ... I'm totally lost.
I'll just keep playing here and there, and eventually it will sink in ... I hope!
-Don G.
My Celestia Scripting Resources page
Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.
My Celestia Scripting Resources page
Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.
don wrote:but when it comes time to make the camera travel in a simple straight line, towards the center of the screen, with nothing selected ... I'm totally lost.
A straight line is simple (simply add the same vector to the current position again and again), but "towards the center of the screen" is hard! The direction of the center of the screen depends on the current orientation of the observer, so you have to get the observer-orientation and then use that to create the needed vector. Oh, and the method needed to transform a vector using a rotation is currently only in CVS (rotation:transform), so you may have to use a Lua-only implementation...
Maybe you should try moving from the current position to some planet/moon. Then you can simply compute a vector pointing from the observer to the object, multiply it by e.g. 0.0001 and then start adding it over and over to your current position. Of course if the used object is in the center of the screen, you even get what you actually wanted
Another possibility is to make the observer look in the direction of movement.
Harald
Hi Harald,
Could you provide some *simple*, short examples of moving in a straight line, towards center of screen, both with and without anything selected? Just a couple of lines, nothing fancy please.
Thank you!
Could you provide some *simple*, short examples of moving in a straight line, towards center of screen, both with and without anything selected? Just a couple of lines, nothing fancy please.
Thank you!
-Don G.
My Celestia Scripting Resources page
Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.
My Celestia Scripting Resources page
Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.
don wrote:Could you provide some *simple*, short examples of moving in a straight line, towards center of screen, both with and without anything selected? Just a couple of lines, nothing fancy please.
Toti gave a good example of how to do it if you don't care about the current orientation of the observer (i.e. his script makes the center of the screen the point the observer is moving to, not the other way around).
If you want to keep the current orientation, you have to mess around with the rotation-object. To make the example shorter I use a feature (rotation:transform) which is not yet in a prerelease, i.e. this example won't run even on 1.3.2pre7 - it's possible to replace that new method by a pure Lua-function, but that would make the example much longer...
Code: Select all
obs = celestia:getobserver()
Z_AXIS = celestia:newvector(0,0,-1)
-- speed in micro_ly / s:
speed = 300000 / KM_PER_MICROLY
while true do
viewing_direction = obs:getorientation():transform(Z_AXIS)
obs:setposition(obs:getposition() + viewing_direction * (0.05*speed))
wait(0.05)
end
The interesting stuff happens inside the loop. First it gets the current orientation of the observer. Then it uses this orientation (which actually is a rotation object) to transform the vector (0,0,-1) - which pretty much per definition of how orientations work gives us the direction in which the observer is looking. This is some kind of transformation to a different coordinates system - from the observers coordinate system, where the vector (0,1,0) is always to the upper side of the screen, to the universal coordinate system, which we need to modify the observer's position.
Once you have the vector in which to move in UCS, you simply take the current position, add the vector, and use the result to set the new position. However this would move you forward the length of the vector per step - that's why it's multiplied with a speed-value first (which itself is multiplied with the duration of one step). For smoother and more exact movement you would have to use the time passed between two steps to adjust the length of the vector, using celestia:getscripttime().
Harald
Thank you Harald. This is a very good example!
Is there a reason for selecting the Z axis versus the X axis, and why -1 instead of positive 1?
Is there a reason for selecting the Z axis versus the X axis, and why -1 instead of positive 1?
-Don G.
My Celestia Scripting Resources page
Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.
My Celestia Scripting Resources page
Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.
Maybe I just answered my own questions ...
Using the X axis makes us move sideways instead of straight. Using a positive 1 puts us in reverse, instead of forward.
This vector stuff sure is strange!
Using the X axis makes us move sideways instead of straight. Using a positive 1 puts us in reverse, instead of forward.
This vector stuff sure is strange!
-Don G.
My Celestia Scripting Resources page
Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.
My Celestia Scripting Resources page
Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.