Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Makes the wind work on physical objects.

Goapinoa Primeau
Addict
Join date: 29 Jun 2006
Posts: 58
09-07-2006 17:55
CODE
// Wind affects avatar clothing/hair, trees, and can affect particles and flexible prims.
// Wind "naturally" (programatically) varies in velocity and direction.
// Wind does not cause friction. (from the wiki)
//
// This script takes the vector returned by llWind, which represents the
// speed and direction of the wind at the current position (it doesnt' use any
// offset hence 'ZERO_VECTOR'),
// and applys an impulse to the object to match it, simulating the impulse that
// would be applied by the wind.
//
// It doesnt really work well unless youre object is small/light enough to be actually
// moved by the impulse. Otherwise it tends to just sit there and vibrate.
//
// Of course the '/35' is the result of my own experimentation, you will probably
// want to play with this value until it suits your own object.

default
{

state_entry()
{
llApplyImpulse(llWind(ZERO_VECTOR)/35,TRUE);
llResetScript();
}

}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
09-10-2006 13:32
/15/96/135629/1.html
_____________________
i've got nothing. ;)
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
Strange Loop
09-10-2006 14:36
From: Goapinoa Primeau
CODE

default
{

state_entry()
{
llApplyImpulse(llWind(ZERO_VECTOR)/35,TRUE);
llResetScript();
}

}
This is a very strange infinite loop. Why tear down and rebuild the entire script environment continiously? Wouldn`t something like this be better?
CODE
default
{
state_entry() {llSetTimerEvent(3);}
timer() {llApplyImpulse(llWind(ZERO_VECTOR)/35,TRUE);}
}
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
09-11-2006 13:24
My thoughts exactly, Llauren. But props for a creative premise, certainly.
_____________________
Psyra Extraordinaire
Corra Nacunda Chieftain
Join date: 24 Jul 2004
Posts: 1,533
09-11-2006 13:34
How about this...? (I'm at work so I'm not 100% sure of the loop code on the @a; here) :D

CODE

default
{
state_entry()
{
@a;
llApplyImpulse(llWind(ZERO_VECTOR)/35,TRUE);
llSleep(3);
jump a;
}
}
_____________________
E-Mail Psyra at psyralbakor_at_yahoo_dot_com, Visit my Webpage at www.psyra.ca :)

Visit me in-world at the Avaria sims, in Grendel's Children! ^^
Armandi Goodliffe
Fantasy Mechanic
Join date: 2 Jan 2006
Posts: 144
09-11-2006 14:22
¡no! goto es malo.

It could work. . .but why commit the cardinal sin of programming?
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
09-13-2006 10:27
From: Goapinoa Primeau
CODE
// Wind affects avatar clothing/hair, trees, and can affect particles and flexible prims.
// Wind "naturally" (programatically) varies in velocity and direction.
// Wind does not cause friction. (from the wiki)
//
// This script takes the vector returned by llWind, which represents the
// speed and direction of the wind at the current position (it doesnt' use any
// offset hence 'ZERO_VECTOR'),
// and applys an impulse to the object to match it, simulating the impulse that
// would be applied by the wind.
//
// It doesnt really work well unless youre object is small/light enough to be actually
// moved by the impulse. Otherwise it tends to just sit there and vibrate.
//
// Of course the '/35' is the result of my own experimentation, you will probably
// want to play with this value until it suits your own object.

default
{

state_entry()
{
llApplyImpulse(llWind(ZERO_VECTOR)/35,TRUE);
llResetScript();
}

}


I tried this in world in a .5x.5x.5 sphere and it did nothing, I made the prim smaller, .1x.1x.1 and it still just sat there. ?? I got nothing...
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Goapinoa Primeau
Addict
Join date: 29 Jun 2006
Posts: 58
09-14-2006 17:44
From: ArchTx Edo
I tried this in world in a .5x.5x.5 sphere and it did nothing, I made the prim smaller, .1x.1x.1 and it still just sat there. ?? I got nothing...



Did you set the physical checkbox on the sphere? only works on physical objects.

Thanks for feedback all, certainly a timer loop would be better.


default
{

state_entry()
{
llSetPrimitiveParams([PRIM_PHYSICS,TRUE]);
llSetTimerEvent(2.0);
}

timer()
{
llApplyImpulse(llWind(ZERO_VECTOR)/35,TRUE);
}

}
Isebella Dallagio
Registered User
Join date: 15 Aug 2007
Posts: 5
04-09-2008 03:00
this works great, the only problem I found is that objects go off-world and get returned to lost and found folder
Boreal Latte
Registered User
Join date: 15 Nov 2007
Posts: 104
Remember turbulence
04-09-2008 04:42
The beauty of the original code:
From: Goapinoa Primeau
llApplyImpulse(llWind(ZERO_VECTOR)/35,TRUE);

is that it returns the wind at the position of the prim in which the script is placed, so I do not have to look it up myself.

(I believe one should remove wrong code - so this post have been edited to remove my previous misunderstanding tx. Hewee Zetkin).
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-09-2008 09:40
According to http://www.lslwiki.net/lslwiki/wakka.php?wakka=llWind the parameter represents an offset from the prim's current position, so the original logic was correct. I find it pretty annoying how some functions like this use such an offset and some use true region coordinates, but I guess it'll keep us going back to the documentation consistently at least.... :rolleyes:
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
04-09-2008 12:33
From: Armandi Goodliffe
¡no! goto es malo.

It could work. . .but why commit the cardinal sin of programming?


It's only a sin if it makes the code hard to read. In this instance, it is quite simple to understand. :)
_____________________
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
04-09-2008 13:05
From: Goapinoa Primeau
Did you set the physical checkbox on the sphere? only works on physical objects.

Thanks for feedback all, certainly a timer loop would be better.


default
{

state_entry()
{
llSetPrimitiveParams([PRIM_PHYSICS,TRUE]);
llSetTimerEvent(2.0);
}

timer()
{
llApplyImpulse(llWind(ZERO_VECTOR)/35,TRUE);
}

}

Glad someone caught that.. was about to do essentially this myself, but thought to give the thread another look-over
_____________________
Tutorials for Sculpties using Blender!
Http://www.youtube.com/user/BlenderSL
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
04-10-2008 17:45
From the rpgstats wiki...

Most coders recommend avoiding jumps where possible and you'll find that they are rarely necessary in well-structured code. LSL lacks a "break" feature that is standard in most languages for leaving a loop early so this is one case where a jump can be useful. Careful coders will avoid jumping backwards or too far forwards in their code.
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
04-10-2008 20:54
From: Keira Wells
Glad someone caught that.. was about to do essentially this myself, but thought to give the thread another look-over


This works great for me now, especially after changing this line
lApplyImpulse(llWind(ZERO_VECTOR)/35,TRUE);
to

lApplyImpulse(llWind(ZERO_VECTOR)/0.5,TRUE);
now I have a default 0.5 sphere bouncing happily all around the interior of my skybox. :)
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-10-2008 21:39
I wrote a tumbleweed script a while back. I believe it did pretty much the same thing, and also gave a small angular impulse so it would roll well. I'll have to look it up when I get in world again.