Difference between revisions of "Key Frame Animator"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) m (cleanup) |
|||
Line 5: | Line 5: | ||
<lsl> | <lsl> | ||
// MODE: | |||
// 0 = NonInit | |||
list keys | // 1 = Init | ||
vector | // 2 = Run | ||
integer MODE; | |||
list keys; | |||
rotation start_rot; | |||
vector start_pos; | |||
rotation last_rot; | rotation last_rot; | ||
vector last_pos; | |||
integer dialogChannel; | |||
integer dialogHandle; | |||
init() | |||
{ | |||
say("Welcome to the KeyFrame Setter v1.0 by Jasper Flossberg"); | |||
say("Touch to get started!"); | |||
} | |||
update_start() | |||
{ | |||
start_pos = llGetPos(); | |||
start_rot = llGetRot(); | |||
} | |||
update_last() | |||
{ | |||
last_pos = llGetPos(); | |||
last_rot = llGetRot(); | |||
} | |||
open_menu(key id, string dialogString, list dialogButtons) | |||
{ | |||
close_menu();// make sure it's closed before (re-)opening | |||
dialogChannel = (integer)llFrand(4000000); | |||
dialogHandle = llListen(dialogChannel, "", id, ""); | |||
llDialog(id, dialogString, dialogButtons, dialogChannel); | |||
llSetTimerEvent(30.0); | |||
} | |||
close_menu() | |||
{ | |||
// disable timer by setting 0.0 | |||
llSetTimerEvent((float)FALSE); | |||
llListenRemove(dialogHandle); | |||
} | |||
say(string message) | |||
{ | { | ||
llSay(PUBLIC_CHANNEL, message); | |||
} | } | ||
default | default | ||
{ | { | ||
on_rez(integer start_param) | |||
{ | |||
llResetScript(); | |||
} | |||
state_entry() | state_entry() | ||
{ | { | ||
init(); | |||
} | } | ||
touch_start(integer | touch_start(integer num_detected) | ||
{ | { | ||
key id = llDetectedKey(0); | |||
open_menu(id, "Please choose option", ["Init", "Run", "Export"]); | |||
} | } | ||
listen(integer channel, string name, key id, string message) | listen(integer channel, string name, key id, string message) | ||
{ | { | ||
if( | // ignore spam | ||
if (channel != dialogChannel) | |||
{ | { | ||
return; | |||
} | |||
// all info we could need is in the event params, so close early | |||
close_menu(); | |||
if (message == "Init") | |||
{ | |||
MODE = 1; | |||
say("Intializing KeyFrame Setter"); | |||
llSetKeyframedMotion([], []); | |||
keys = []; | |||
update_last(); | |||
update_start(); | |||
} | } | ||
if(llGetSubString(message,0,2)=="set") | if (llGetSubString(message, 0, 2) == "set" && MODE == 1) | ||
{ | { | ||
list params = llParseString2List(message,[" "], []); | |||
string time = llList2String(params, 1); | |||
say("Setting new KeyFrame with "+time); | |||
keys += [llGetPos()-last_pos,llGetRot()/last_rot,(integer)time]; | |||
update_last(); | |||
} | } | ||
if(message=="Run") | if (message == "Run") | ||
{ | { | ||
MODE=2; | MODE = 2; | ||
llSetKeyframedMotion(keys,[KFM_MODE,KFM_LOOP]); | llSetLinkPrimitiveParamsFast(LINK_THIS, [ | ||
PRIM_POSITION, start_pos, | |||
PRIM_ROTATION, start_rot]); | |||
llSetKeyframedMotion(keys, [ | |||
KFM_MODE, KFM_LOOP]); | |||
} | } | ||
if(message=="Export") | if (message == "Export") | ||
{ | { | ||
say((string)keys); | |||
} | } | ||
} | |||
timer() | |||
{ | |||
close_menu(); | |||
} | } | ||
} | } | ||
</lsl> | </lsl> |
Revision as of 12:33, 31 July 2013
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
This is a KeyFrame Animator Script to simplify construction of keyframed animations. To get the much better PRO version with after frame editing features and more, contact --Jasper Flossberg
<lsl> // MODE: // 0 = NonInit // 1 = Init // 2 = Run
integer MODE; list keys;
rotation start_rot; vector start_pos;
rotation last_rot; vector last_pos;
integer dialogChannel; integer dialogHandle;
init() {
say("Welcome to the KeyFrame Setter v1.0 by Jasper Flossberg"); say("Touch to get started!");
}
update_start() {
start_pos = llGetPos(); start_rot = llGetRot();
}
update_last() {
last_pos = llGetPos(); last_rot = llGetRot();
}
open_menu(key id, string dialogString, list dialogButtons) {
close_menu();// make sure it's closed before (re-)opening
dialogChannel = (integer)llFrand(4000000); dialogHandle = llListen(dialogChannel, "", id, "");
llDialog(id, dialogString, dialogButtons, dialogChannel);
llSetTimerEvent(30.0);
}
close_menu() {
// disable timer by setting 0.0 llSetTimerEvent((float)FALSE); llListenRemove(dialogHandle);
}
say(string message) {
llSay(PUBLIC_CHANNEL, message);
}
default {
on_rez(integer start_param) { llResetScript(); }
state_entry() { init(); }
touch_start(integer num_detected) { key id = llDetectedKey(0); open_menu(id, "Please choose option", ["Init", "Run", "Export"]); }
listen(integer channel, string name, key id, string message) { // ignore spam if (channel != dialogChannel) { return; }
// all info we could need is in the event params, so close early close_menu();
if (message == "Init") { MODE = 1;
say("Intializing KeyFrame Setter");
llSetKeyframedMotion([], []);
keys = [];
update_last(); update_start(); } if (llGetSubString(message, 0, 2) == "set" && MODE == 1) { list params = llParseString2List(message,[" "], []); string time = llList2String(params, 1);
say("Setting new KeyFrame with "+time);
keys += [llGetPos()-last_pos,llGetRot()/last_rot,(integer)time];
update_last(); } if (message == "Run") { MODE = 2;
llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_POSITION, start_pos, PRIM_ROTATION, start_rot]);
llSetKeyframedMotion(keys, [ KFM_MODE, KFM_LOOP]); } if (message == "Export") { say((string)keys); } }
timer() { close_menu(); }
} </lsl>