Rotations, again... :)
|
|
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
|
10-06-2008 01:49
I hope I'll ever get my head around rotations...
I'm pulling some data off a database which provides me with a value «heading» which is a number in degrees and another value which indicates the vertical movement. What I need to do is rotate the SL-object to face a) the heading and b) the vertical direction. (Think of an airplane that is starting. Its nose points upwards and to the direction it's flying to).
I managed to rotate it to match the heading - but as soon as I add the vertical movement, the thing gets out of control. The object is a tube (ok it IS an airplane with wings attached). When I add the vertical rotation now, the tube starts to rotate around it's fwd-axes making the plane turn, instead of pointing upwards...
What functions do I have to use to make it rotate the way I want it?
Thanks for your help!
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
10-06-2008 03:39
To stop the plane rolling you could try: llSetStatus( STATUS_ROTATE_X, FALSE); I would use llLookAt if it is possible to calculate a point where the nose should point and if the nose and z axis are pointing the same way. llRotLookAt could be used as well, I don't think I ever tried it 
_____________________
From Studio Dora
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
10-06-2008 08:11
Take the direction you're going to be pointing in as a vector and llVecNorm it, (or use llRot2Fwd() on it to get this from a rotation), and call it direction. Then.. vector left = llVecNorm(<0.0, 0.0, 1.0> % direction); rotation upright = llAxes2Rot(direction, left, direction % left);
Then you can use upright as a rotation that will keep your plane thinger from rolling.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-06-2008 09:32
I think the important part here is calculating the rotation at which you want the vehicle to wind up. Once you've done that you can decide whether to use llSetRot() or llRotLookAt() or whatever. Assuming the vehicle is setup in the usual x-forward, y-left, z-up configuration, you will most likely want a rotation of: // Parameters: // headingAngle - Direction of heading around world's z-axis; counter-clockwise from due East; degrees. // pitchAngle - Pitch upward from horizontal; positive upward, negative downward; degrees. rotation yawAndPitchToRotation(float headingAngle, float pitchAngle) { headingAngle *= DEG_TO_RAD; pitchAngle *= DEG_TO_RAD;
return llAxisAngle2Rot(<0.0, 1.0, 0.0>, -pitchAngle)*llAxisAngle2Rot(<0.0, 0.0, 1.0>, headingAngle); }
I suspect what might have gotten in your way was the order of multiplication of the two rotations (or trying to use Euler angles--almost always a bad idea). The above function SHOULD give you the correct multiplication. See http://www.lslwiki.net/lslwiki/wakka.php?wakka=rotation
|
|
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
|
10-06-2008 16:34
Thanks everybody for the hints... it's not really working, yet - but I guess I just have to build my plane in a different way... At least, I have some stuff to play with, now 
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-06-2008 17:20
From: Haruki Watanabe Thanks everybody for the hints... it's not really working, yet - but I guess I just have to build my plane in a different way... At least, I have some stuff to play with, now  Sorry you are frustrated Haruki. Just for giggles, take the script and put it in a single prim cylinder, nothing fancy. If I remember right, orientations of tubes and cylinders are different. See if it works right then? EDIT Never mind on the cylinder Haruki. Per the other thread, the orientation on the tube i s the correct one. It's been a long time since I built anything in world.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
|
10-08-2008 05:00
Thanks everybody for the help - it's working now. Obviously, the alignment of my plane was some 90 degrees different from the heading-var I used. With a little tweaking, Hewee's function works wonderful now... If anybody is interested in what this was about: There's a live flight-tracker on the web, made by some ETH-Students in Zurich. It shows the actual flights over Zurich, Switzerland (they're using some receiver to get the airplanes transponder-signals and then place the planes over a google map). I thought, it'd be a nice project to build this in SL...  The Web-app can be found here: http://radar.zhaw.ch/You can visit the 3d-Tracker here: http://slurl.com/secondlife/Golden%20Business%20Area/41.104/201.858/322.428/?title=Flight%20Trackeractivate Video to see the map. Click on the map to start the tracker (please, turn it off before you leave as it produces quite a lot of traffic on their server). There's a red ball in the upper left corner of the map - when you click on it, you can choose 3 different map-types. Next step will be to apply the carrier-logos to the planes  P.S. to actually see some airplanes, you need to visit it during european daytime (SLT + 9), there's not that much traffic during the night 
|