Post Sat Feb 17, 2007 6:37 pm

Turning/orienting objects in .thn intro scripts

Note: If this post does not belong in this section, feel free to move it.

I have noticed that there is not a whole lot of technical information out there about object orientations when modding the FL .thn intro scripts. "BobTheDog's .thn Tutorial" has a lot of good information on .thn objects, but lacks detail about how to orient them.

I had to figure out how they work by myself, so allow me to share it with you:

An orientation section in an object definition in a .thn file looks like this:
<pre><font size=1 face=Courier>orient={
{
1,
0,
0
},
{
0,
1,
0
},
{
0,
0,
1
} </font></pre>

"BobTheDog"'s tutorial states that these sections are "rotational coordinates". Actually, that's not quite correct. Technically, they make a transformational matrix that works on the X, Y, and Z vectors.

Okay, let me see if I can put this in easier terms:

First, If you have the above orientation in the "SCENE" declaration in your .thn file, the view will be the following:
X-axis: Left/Right, positive X is right, vector {1,0,0}
Y-axis: Up/Down, positive Y is up, vector {0,1,0}
Z-axis: Forward/Back, positive Z is toward you, vector {0,0,1}
(So, if an object has (X,Y,Z) coordinates of pos={500,800,-1000}, it will be 500 units to the right, 800 units up, and 1000 units away from you)

Now, let's say you have a ship object which you place in the .thn, but it faces away from you, and you want to turn it 90-degrees counter-clockwise (to face left). What you need to do is set the orient section of the object so that it's [ucurrent[/u X,Y,Z axes (where it's facing now) become the [unew[/u X,Y,Z axes (where you want it to face).

How do you do this? Well, take the axes one at a time:

X-axis: if you turn the ship 90-degrees counter-clockwise, "right" becomes "facing away". So X {1,0,0} should change to negative Z, or {0,0,-1}.

Y-axis: if you turn the ship 90-degrees counter-clockwise, "up" stays "up", so leave Y {0,1,0} alone.

Z-axis: if you turn the ship 90-degrees counter-clockwise, "toward you" becomes "right". So Z {0,0,1} should become positive X, or {1,0,0}.

Thus, you change the orientation to:
<pre><font size=1 face=Courier>orient={
{
0,
0,
-1
},
{
0,
1,
0
},
{
1,
0,
0
} </font></pre>

Other rotations/turns work the same way.

One note: If you accidentally mess up which vectors/axes go where, you can seriously twist/skew an object or turn it "inside-out" (which results in some really strange things)!

I hope that helps!

Foil


Edited by - Foil on 2/17/2007 6:42:56 PM