Created
August 21, 2016 23:38
-
-
Save Dante83/e793534dbb948013f53f23484e39b6c8 to your computer and use it in GitHub Desktop.
A lsl attempt at making a sign oscillate back and forth using a "sign wave" :P.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I'm so sorry to whomever works with this - yes, it's not even remotely perfect and I have much work to do | |
//Apologies ahead of time - Dante | |
float wind_speed; | |
float sign_period = 4.0; | |
float time = 0.0; | |
integer time_2 = 0; | |
float theta_min = 0.0; | |
float theta_max = 0.0; | |
float v_f = 0.0; | |
float frame_length = 0.2; | |
float wind_factor = 1.0; | |
float AMPLITUDE_CONST; | |
default | |
{ | |
on_rez(integer start_param) | |
{ | |
llResetScript(); | |
} | |
state_entry() | |
{ | |
//Reset the constants | |
time = 0.0; | |
time_2 = 0; | |
v_f = 0.0; | |
frame_length = 0.2; | |
//Determine the maximum velocity of the sign based on the speed of the wind | |
//perpindicular to this object. The max wind speed was about 60 m/s, but most of the time | |
//it's about 4 m/s. To limit this, I have placed an overall cap on the wind speed of 32 m/s. | |
wind_speed = llVecMag(llWind(<0,1,0>)); | |
if(wind_speed > 20){ | |
wind_speed = 20; | |
} | |
AMPLITUDE_CONST = 0.7 * PI / 100; | |
//TestingLet's find out the current wind velocity. | |
llSetText(" ", <1,1,1>, 0.75); | |
//llSetText("SIGN IN TEST\nWind Velocity\n" + (string) wind_speed, <1,1,1>, 0.75); | |
llSetTimerEvent(frame_length); | |
} | |
timer() | |
{ | |
//Determine the new velocity of the sign | |
v_f = AMPLITUDE_CONST * wind_speed * llCos(1.4 * (time) + 3 *PI / 4); | |
rotation rotation_value = llGetRot(); | |
llTargetOmega(<1,0,0>,v_f,0.5); | |
//Sleep for 1/16th of a second, for 16 frames of animation per second | |
time += 0.2; | |
time_2 += 1; | |
//if(time >= sign_period){ | |
// time = 0; | |
//} | |
//Every fifteen minutes, reset the wind settings | |
if(time_2 == 2500){ | |
//Testing: Let's find out the current wind velocity. | |
//llSetText("SIGN IN TEST\nWind Velocity\n" + (string) llVecMag(llWind(<0,1,0>)), <1, 1, 1>, 0.75); | |
llSetText(" ", <1, 1, 1>, 0.75); | |
//Let's also reset the wind velocity | |
float wind_s = llVecMag(llWind(<0,1,0>)); | |
if(wind_s > 20){ | |
wind_s = 20; | |
} | |
time_2 = 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment