|
Barrington John
Yorkshire guy
Join date: 17 Nov 2007
Posts: 119
|
07-07-2008 09:35
I really should be able to figure this one out by myself, but my head's spinning, so I thought I'd ask the kindly folks here for help.
What I need to be able to do is to rotate a child prim with llSetLocalRot() such that it's precisely in line with the wind direction, as in the vector returned by llWind(). It only needs to work in horizontal 2D; that is, values for X and Y axes causing a rotation on the Z axis. In other words, if the wind's blowing NNE, that's the direction the object should be rotated to. Something like a weather-vane, for example.
In this context, how can I best convert the velocity vector llWind() returns into a rotational quaternion for use in llSetLocalRot()?
Many thanks in advance!
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
07-07-2008 09:55
From: Barrington John how can I best convert the velocity vector llWind() returns into a rotational quaternion Try this ( you will not get your money back if it doesn't work )  rotation vector2rot( vector V ); { // not for vertical V V.z = 0.0; V = llVecNorm( V ); vector UP = < 0.0, 0.0, 1.0 >; return llAxes2Rot(V, UP % V, UP); }
_____________________
From Studio Dora
|
|
Barrington John
Yorkshire guy
Join date: 17 Nov 2007
Posts: 119
|
07-07-2008 10:10
Thanks, Dora - I'll give that a spin.
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
07-08-2008 06:27
This works for an object: vector rotAxis = < 1.0, 0.0, 0.0 >; //the direction the object points, when not rotated vector wind;
default { state_entry() { llSetTimerEvent( 5.0 ); }
timer() { wind = llWind( ZERO_VECTOR ); llSetRot( llRotBetween( rotAxis, wind )); // turn object axis in the wind's direction } }
If you want to turn a child prim with llSetLocalRot() I suggest you eliminates the root rotation: llSetLocalRot( llRotBetween( rotAxis, wind )/llGetRootRotation());
_____________________
From Studio Dora
|
|
Barrington John
Yorkshire guy
Join date: 17 Nov 2007
Posts: 119
|
07-09-2008 09:24
Thanks again, Dora - this is getting close. I've tested your second example in an object, with a linked flexi hanging off it (like a flag) to give a visual indication of wind direction. The root prim (with the script) almost always points in a different direction to the flexi, although both respond to changes in wind direction at the same time. I can't make out a pattern in the relationship - sometimes the object's pointing at roughly right angles to the flexi, sometimes at nearly 180 degrees, sometimes at almost the same angle. I can't figure it out!
If Dora, or anyone, would like a copy of the test object to try out, please IM me in-world and I'll gladly pass you one.
|