Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How do you get the angle in which the wind is blowing?

Grantly Hamilton
Registered User
Join date: 31 Mar 2004
Posts: 38
06-12-2006 04:13
?
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
06-12-2006 04:16
http://secondlife.com/badgeo/wakka.php?wakka=llWind
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
06-12-2006 08:50
This is the code I use for a wind vane:

CODE

default
{
state_entry()
{
llSetTimerEvent(15.0);
}

timer()
{
llSetRot(llRotBetween(<-1,0,0>,llWind(ZERO_VECTOR)));
}
}


with the code in the root prim (a vertical cylinder, i.e. the pole on which the wind vane sits).

And for wind velocity:
CODE

float windspeed = llVecMag(llWind(ZERO_VECTOR));
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
06-12-2006 13:52
Although now, with flexiprims, there's no excuse to use that for a wind vane.
Grantly Hamilton
Registered User
Join date: 31 Mar 2004
Posts: 38
06-13-2006 04:07
Ahh... TY! Nand. Exactly what I was looking for... Ordinal, I know the wiki, I just never bothered to understand the math behind what I needed...

... And Keknehv, there are other reasons why it is still needed... Perhaps a flag on a pole that spins around on the o-rings, which is what I am doing.

Thanks again Nand.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
06-13-2006 06:46
From: Keknehv Psaltery
Although now, with flexiprims, there's no excuse to use that for a wind vane.


Actually I made a flag using a flexiprim and needed a variant on it... the flexiprims aren't flexi enough to let the flag stream in properly in all directions, and the wind in SL is a shifty SOB that goes round the full two-pi fairly quickly. I don't fire it often, but the flagpole now shifts, simulating the flag being more able to swing around the pole than the flexiprim can.
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
06-13-2006 07:53
Yes, of course, for things like rotating rings and flags, it's useful. I was only pointing out that a simple weather vane (e.g. a cone) didn't need it.
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
06-13-2006 09:07
Very valid point Keknehv and a solution which is quick to respond to changes in wind direction and also can display wind velocity (i.e. amount the wind bends your weather vane (cone)).

The weather vane I had in mind is attached, and shows the vane and anemometer and the wind turbine they are attached to. It was my intention to script the turbine blades to turn depending on wind speed and velocity and also to attempt to maintain a constant velocity using variable pitch. Never did get around to doing that though.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
RichD Tomsen
Photographer / Builder
Join date: 18 Nov 2007
Posts: 24
OK But.....
01-09-2009 23:24
From: nand Nerd
This is the code I use for a wind vane:

CODE

default
{
state_entry()
{
llSetTimerEvent(15.0);
}

timer()
{
llSetRot(llRotBetween(<-1,0,0>,llWind(ZERO_VECTOR)));
}
}


with the code in the root prim (a vertical cylinder, i.e. the pole on which the wind vane sits).

And for wind velocity:
CODE

float windspeed = llVecMag(llWind(ZERO_VECTOR));


This is good.... This causes the prim to rotate around its Z axis. But... I'd like it to rotate around its X or Y... lets say I wanted to make a dial pointer as part of a weather station. how would I cause the rotation to be like the hand on a clock? also make it so the whole prim didn't reset its orientation should I tip the prim and not have it vertical. Sorry if this is a simple question, but vectors are new to me.
_____________________
STOP THE MADNESS... Have Linden Labs Halt all implementation of Adult Content by Voting for

http://jira.secondlife.com/browse/MISC-2727

RichD Tomsen - Photographer
Owner / Operator - Endeavour Cove Mall, Earpoint, Mainland
“Explore & Discover”