|
Wildthrust Mathilde
Registered User
Join date: 22 Nov 2006
Posts: 49
|
06-05-2007 06:30
Im trying to create a compass dial that point's north all the time even though its a child prim of a HUD. I know it's possible, I just can't figure out the right combination of commands to calculate the rotation I should apply to it at any paticular time to get it to keep pointing North.
I know I need llGetLocalRot, im guessing I would use a world rotation of <0,0,0,0>, the have to compute the rot needed to line it up with north as it seems llSetLocalRot is realative to the root prim instead of world coordinates. I am guessing I need to get the angle differance between <0,0,0,0> and llGetLocalRot as an angle. Then figure out the rot of the child prim to the main prim by either adding or subtracting the angle converted to a rotation to the llGetLocalRot.
Just not sure what commands to use to do it.
Help? Thanks
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
06-05-2007 07:05
llGetRot -IS- the rotation from ZERO_ROTATION for the object. The simplest way to handle it would simply to make the rotation of the child prim be ZERO_ROTATION then there is no need to convert it at all. What exactly are you attempting to display? The direction that the avatar is facing? The direction the camera is facing? The direction the attachment is facing? The traditional 4-point compasses is designed to be viewed from above. If you are trying to devise a HUD item to display the direction the player is facing, you may wan to use a 360 degree globe type of compass instead. Like this: http://www.magnifier.com.tw/proimages/w89.jpgThis should be very easy to fake within SL by using texture animation.
|
|
Wildthrust Mathilde
Registered User
Join date: 22 Nov 2006
Posts: 49
|
06-05-2007 08:31
I tried llSetLocalRot on teh child prim of ZERO_ROTATION but it wouldn't rotate, it was realative to the root prim, so it was always ZERO_ROTATION. This is a hud attachment that is only visible when in mouselook. It is a cylinder viewed from it's side/edge. I created an edge texture for it to wrap around with E and W reversed so it will show the direction you are pointing and will rotate right or left as you move. So only tracking rotation around the Z Axis.
So basicly making a aircraft heading compass
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
06-05-2007 08:46
As I said, rather than rotating the object you may want to simply alter the texture offset, which would in effect rotate it around the cylinder.
Other than that suggestion I'd need to see your code.. and probably be in world to mess with the rotations. I can usually work rotations out, but not without alot of tweaking =)
|
|
Wildthrust Mathilde
Registered User
Join date: 22 Nov 2006
Posts: 49
|
06-05-2007 09:51
Im at work so I can't get in game unfortuately, but I threw together a little code. default { state_entry() { llSetTimerEvent(0.5); } timer() { float angle; rotation = currentrot; currentrot = llGetLocalRot(); angle = llAngleBetween(ZERO_ROTATION, currentrot); llOffsetTexture(angle,0,?); // ? can't think offhand what the side number for a cylinder is } } Here is a simple sketch. Of course it would be a hud item, so you wouldn't see the entire thing http://152.2.89.137/index.php
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
06-05-2007 10:08
Try dis:
default { state_entry() { llSetTimerEvent(0.5); }
timer() { float offset; rotation currentrot = llGetLocalRot(); // Get the x component of the Euler form of the rotation (this should be the copass direction I think). // Convertiing it to Degrees just because that is easier for me to visualize. // Note: 0.0 = EAST, 90.0 = North, 180.0 = West, 270 = South offset = llRot2Euler(currentrot).x * RAD_TO_DEG; // Divide by 360 to convert the degrees into a fraction around a circle. offset /= 360; llOffsetTexture(offset,0,?); // ? can't think offhand what the side number for a cylinder is } }
|
|
Wildthrust Mathilde
Registered User
Join date: 22 Nov 2006
Posts: 49
|
06-05-2007 10:24
kk tnks, Ill try that when I get home in *checks clock* 4 1/2 hours :/
Ultimate goal is a hud with build in scanner, wind vein, compass, and indicators for a gun im going to build for an army.
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
06-05-2007 10:31
The above code assumes your texture will be pointing at "E" with an offset of 0, which should be easy enough to do just by Editing the cylinder prim and rotating it until "e" lines up with your indicator. Alternatively you can add whatever value is needed to the offset.
|