Jump to content
Sign in to follow this  
Rich Reynaud

Wind Direction

Recommended Posts

Hello,

LSL newbie here, though I have some experience with other languages.

I have an object that points in the direction that the wind is blowing TO by using the following line:

 

llLookAt(llGetPos()+llWind(ZERO_VECTOR),1,1);

 

I actually need to point the object in the direction that the wind is blowing FROM. Can anyone assist?

 

Regards,

Rich

Share this post


Link to post
Share on other sites

We had this discussion here not long ago, when I was trying to keep my wind vane from flipping upside down.  Here's a wind vane script that works.

default{    state_entry()    {        llSetTimerEvent(1.0);    }    timer()    {        vector wind = llWind(ZERO_VECTOR);        llSetRot(llEuler2Rot(<0.0, 0.0, llAtan2(wind.y, wind.x)>));    }}

 If you want to point the end of the vane in the opposite direction, just reverse the arithmetic sign on the Z element in that vector.

Share this post


Link to post
Share on other sites

Thanks Rolig. I was just reading that thread and tried the various scripts that were mentioned. The problem is that my object is already rotated on another axis and those scripts were causing the object to rotate in an unexpected manner.

In reading another post on rotation I found an easy way to do it. I simply multiplied by negative one to reverse the direction:

 

llLookAt(llGetPos()+llWind(ZERO_VECTOR)*-1,1,1);

 

I appreciate your response though.

 

Regards,

Rich

Share this post


Link to post
Share on other sites

This nice script to put in a prim, with a touch will output wind speed.

What change would be needed to output the wind direction?

Wolf.

=====================================================

default

{

     state_entry()

     {

            llSay(0, "Touch me for current sl wind speed.");

     }

     touch_start(integer total_number)

    {

            vector wind = llWind(<0,0,0>);

             llSay(0,"Wind speed: " + (string)llVecMag(wind) + " m/s");

    }

}

Share this post


Link to post
Share on other sites

Thanks for this script

using it I was able to get my windsock working they way they are suppose to

 

using a flexi for the sock and linked to a ring that spins on the mast

 

Dan

Share this post


Link to post
Share on other sites

I have similar problems to the original poster in that I'm making a Weathervane and despite the scripting being very commonplace, there are no clear answers provided here.  I've found this question (or simliiar) being asked multiple times on this and other forums and the answer is always the same.  It usually goes like this: 

Q - "I have script (shows code), and it works, but I need to know the wind direction." 

A - "Here's a script that works for weathervanes/windsocks that everyone (who is smart) uses." *

*(script doesn't actually include anything about determining SL wind direction)

This is not helpful.  Even the sorta helpful thing at the end where we are given code that outputs actual information, it's the wind SPEED that is output, not the direction.  

The problem with making a windsock/weathervane is that the bit that moves has to be TEXTURED (something the script kiddies don't think about perhaps), and it has to be included in a build, so that the prim could be facing anyone of several directions and still "work."  

The question being asked is how to determine which DIRECTION the wind is coming from or going to in SL so you canlook at the finished product, and tell if it's actually working correctly.  

Here's the actual problem:

1 - I can easily use any of the established scripts to make a weathervane that "points" either of two directions, that are in 90 degree opposition to each other, depending on how the prim is textured/cut, etc.  

2 - The weathervane in question is actually a plane, so there is also the question of which end of said plane, the arrow on the texture should point to.  

Using any of the established scripts and depending on the way the prim is formatted, cut, textured etc., there are actually FOUR completely different directions that the weathervane can "point."  All using the exact same script.  

Since these four possible directions are actually the four cardinal points of the compass, all the scripts provided are actually a complete fail in telling us which DIRECTION the SL wind is coming from or going to.  

So the advice here doesn't answer the actual question.  It allows a noob to make their weathervane work, but it says nothign about the accuracy of the result, and nothing about what direction the resulting vane is actually pointing.  

Surely, there must be code that simply tells us which way the SL Wind is pointing?  

 

 

Share this post


Link to post
Share on other sites

Replying to myown question as someone gave me the answer.  

flexi objects in SL alays point correctly in the SL wind, so the answer is to rez a flexi object and use that as an indication of the actual wind direction. 

Share this post


Link to post
Share on other sites

Your question was indeed answered in other posts in this thread.  The LSL function llWind yields a vector that is the wind velocity at that point. Recall that velocity is not the same thing as speed.

You can deconstruct the wind vector <wind.x, wind.y, wind.z> to get the magnitude in each of the component directions or, if you want to get the wind speed, you take the magnitude of that vector with llVecMag(llWind(offset))

Neither of those is relevant if you expect to get information from a flexi object, however, since flexi behavior takes place entirely in each user's viewer, not in SL servers.  A flexi object appears to move, but as far as the servers are concerned, it is perfectly rigid and stationary.  If you want to build a wind vane that actually responds to the SL wind, you have to use the approach that others in this thread are using.

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...