Difference between revisions of "Key Frame Animator"
Jump to navigation
Jump to search
(Created page with "{{LSL Header}} This is a KeyFrame Animator Script to simplify construction of keyframed animations. --Jasper Flossberg <lsl> integer channel=0; intege…") |
|||
Line 53: | Line 53: | ||
string time=llList2String(llParseString2List(message,[" "],[]),1); | string time=llList2String(llParseString2List(message,[" "],[]),1); | ||
llSay(0,"Setting new KeyFrame with "+time); | llSay(0,"Setting new KeyFrame with "+time); | ||
keys+=[llGetPos()-last_pos, | keys+=[llGetPos()-last_pos,llGetRot()/last_rot,(integer)time]; | ||
update_loc(); | update_loc(); | ||
} | } | ||
Line 68: | Line 68: | ||
llSay(0,(string)keys); | llSay(0,(string)keys); | ||
} | } | ||
if(channel!=0) | |||
llListenRemove(channel); | |||
} | } | ||
} | } | ||
</lsl> | </lsl> |
Revision as of 01:53, 29 April 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. --Jasper Flossberg
<lsl> integer channel=0; integer MODE=0; // 0 NonInit 1 Init 2 Run list keys=[]; vector last_pos; rotation last_rot;
vector start_pos; rotation start_rot;
update_loc() {
last_pos=llGetPos(); last_rot=llGetRot();
}
default {
state_entry() { llSay(0, "Welcome to the KeyFrame Setter v1.0 by Jasper Flossberg"); llListen(0,"",NULL_KEY,""); }
touch_start(integer total_number) { channel=(integer)llFrand(4000000); llDialog(llDetectedKey(0),"Please choose option",["Init","Run","Export"],channel); llListen(channel,"",NULL_KEY,""); } listen(integer channel, string name, key id, string message) { if(message=="Init") { llSay(0,"Intializing KeyFrame Setter"); llSetKeyframedMotion([],[]); keys=[]; update_loc(); start_pos=llGetPos(); start_rot=llGetRot(); MODE=1;
} if(llGetSubString(message,0,2)=="set") { if(MODE==1) { string time=llList2String(llParseString2List(message,[" "],[]),1); llSay(0,"Setting new KeyFrame with "+time); keys+=[llGetPos()-last_pos,llGetRot()/last_rot,(integer)time]; update_loc(); } } if(message=="Run") { MODE=2; llSetPrimitiveParams([PRIM_POSITION,start_pos,PRIM_ROTATION,start_rot]); llSetKeyframedMotion(keys,[KFM_MODE,KFM_LOOP]); } if(message=="Export") { llSay(0,(string)keys); } if(channel!=0) llListenRemove(channel); }
} </lsl>