Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Weather WeatherVane with Smoke trail  

WeatherVane with Smoke trail

Makes a prim rotate and face the wind with smoke trailing from it.

Category: Weather
By : Dana Moore
Created: 2014-01-20 Edited: 2014-01-20
Worlds: Second Life

the Zip file

Download all files for WeatherVane with Smoke trail
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl
1
2 // Copyright (c) 2008, Scripting Your World
3 // All rights reserved.
4 //
5 // Scripting Your World
6 // By Dana Moore, Michael Thome, and Dr. Karen Zita Haigh
7 // http://syw.fabulo.us
8 // http://www.amazon.com/Scripting-Your-World-Official-Second/dp/0470339837/
9 //
10 // You are permitted to use, share, and adapt this code under the
11 // terms of the Creative Commons Public License described in full
12 // at http://creativecommons.org/licenses/by/3.0/legalcode.
13 // That means you must keep the credits, do nothing to damage our
14 // reputation, and do not suggest that we endorse you or your work.
15
16 float gTimerInterval = 2.0; // check wind direction every 2 seconds
17
18 smokeParticleSystem()
19 {
23 PSYS_PART_START_COLOR, <0.6, 0.6, 0.6>,
24 PSYS_PART_END_COLOR, <0.8, 0.8, 0.8>,
27 PSYS_PART_START_SCALE, <0.1, 0.1, 0.0>,
28 PSYS_PART_END_SCALE, <0.5, 0.5, 0.0>,
30 PSYS_SRC_ACCEL, <0.0, 0.0, -0.01>,
31 PSYS_SRC_TEXTURE, "d1df5743-efa9-8fab-0d2f-8c206931299b",
39 ]);
40 }
41
42 float calcWindAngle() {
43 vector windVelocity = llWind(ZERO_VECTOR);
44 float windDir=llAtan2(windVelocity.y,windVelocity.x);
45
46 // adjust for rotation of root
48 vector currRotE=llRot2Euler(currRotQ);
49 float relativeWindAngle = windDir - currRotE.z;
50
51 return relativeWindAngle;
52 }
53
54 default
55 {
57 {
58 smokeParticleSystem();
59 llSetTimerEvent( gTimerInterval );
60 }
61
62 timer()
63 {
64 float windAngle = calcWindAngle();
65
66 quaternionwindAngleQ = llEuler2Rot(<0.0,0.0,windAngle>);
67 quaternioncurrentRotQ = llGetLocalRot();
68 quaterniondeltaRotQ = windAngleQ / currentRotQ;
69
70 quaternionnewRotQ = currentRotQ * deltaRotQ;
71 vector currentOffset = llGetLocalPos();
72 vector newOffset = currentOffset * deltaRotQ;
73
74 llSetLocalRot( newRotQ );
75 llSetPos( newOffset );
76 }
77 }

Back to the Best Free Tools in Second Life and OpenSim.