Difference between revisions of "Key Frame Animator"
Jump to navigation
Jump to search
m (<lsl> tag to <source>) |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{LSL Header}} | {{LSL Header}} | ||
This is a KeyFrame Animator Script to simplify construction of keyframed animations. | 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 | ||
--[[User:Jasper Flossberg|Jasper Flossberg]] | --[[User:Jasper Flossberg|Jasper Flossberg]] | ||
< | <source lang="lsl2"> | ||
integer channel | integer channel; | ||
list keys=[]; | |||
list keys=[]; | vector last_pos; | ||
vector last_pos; | |||
rotation last_rot; | rotation last_rot; | ||
vector start_pos; | |||
vector start_pos; | |||
rotation start_rot; | rotation start_rot; | ||
default | default | ||
Line 24: | Line 16: | ||
state_entry() | state_entry() | ||
{ | { | ||
llSay(0, "Welcome to the KeyFrame Setter | llSay(0, "Welcome to the KeyFrame Setter v2.0 by Jasper Flossberg and others\nTouch to start"); | ||
llListen(0,"", | llListen(0, "", llGetOwner(), ""); // Listen on channel 0 for 'set' commands from owner only | ||
channel = (integer) llFrand(4000000); | |||
llListen(channel, "", llGetOwner(), ""); | |||
// Must use 'prim equivalency' for KFM | |||
llSetPrimitiveParams([PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_CONVEX]); | |||
llSetKeyframedMotion([],[]); | |||
last_pos = start_pos = llGetPos(); | |||
last_rot = start_rot = llGetRot(); | |||
} | |||
on_rez(integer p) | |||
{ | |||
llResetScript(); | |||
} | } | ||
touch_start(integer total_number) | touch_start(integer total_number) | ||
{ | { | ||
if (llDetectedKey(0) != llGetOwner() ) | |||
llDialog(llDetectedKey(0),"Please choose option",["Init","Run","Export"],channel | return; | ||
llDialog(llDetectedKey(0), "Please choose option",["Init","Run","Export"],channel); | |||
} | } | ||
listen(integer channel, string name, key id, string message) | listen(integer channel, string name, key id, string message) | ||
{ | { | ||
if(message=="Init") | if(message == "Init") | ||
{ | { | ||
llSay(0,"Intializing KeyFrame Setter"); | llSay(0, "Re-Intializing KeyFrame Setter"); | ||
llSleep(1); | |||
llResetScript(); | |||
} | } | ||
if(llGetSubString(message,0,2)=="set") | if(llToLower(llGetSubString(message,0,2) ) == "set") | ||
{ | { | ||
string time = llList2String(llParseString2List(message, [" "], []), 1); | |||
llSay(0, "Setting new KeyFrame with " + time); | |||
keys += [llGetPos() - last_pos, llGetRot() / last_rot, (integer) time]; | |||
last_pos = llGetPos(); | |||
last_rot = llGetRot(); | |||
} | } | ||
if(message=="Run") | if(message == "Run") | ||
{ | { | ||
llSetPrimitiveParams([PRIM_POSITION, start_pos, PRIM_ROTATION, start_rot]); | |||
llSetPrimitiveParams([PRIM_POSITION,start_pos,PRIM_ROTATION,start_rot]); | |||
llSetKeyframedMotion(keys,[KFM_MODE,KFM_LOOP]); | llSetKeyframedMotion(keys,[KFM_MODE,KFM_LOOP]); | ||
} | } | ||
if(message=="Export") | if(message == "Export") | ||
{ | { | ||
llSay(0,( | llSay(0, llList2CSV(keys) ); | ||
} | } | ||
} | } | ||
} | } | ||
</ | </source> |
Latest revision as of 22:17, 24 January 2015
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
integer channel;
list keys=[];
vector last_pos;
rotation last_rot;
vector start_pos;
rotation start_rot;
default
{
state_entry()
{
llSay(0, "Welcome to the KeyFrame Setter v2.0 by Jasper Flossberg and others\nTouch to start");
llListen(0, "", llGetOwner(), ""); // Listen on channel 0 for 'set' commands from owner only
channel = (integer) llFrand(4000000);
llListen(channel, "", llGetOwner(), "");
// Must use 'prim equivalency' for KFM
llSetPrimitiveParams([PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_CONVEX]);
llSetKeyframedMotion([],[]);
last_pos = start_pos = llGetPos();
last_rot = start_rot = llGetRot();
}
on_rez(integer p)
{
llResetScript();
}
touch_start(integer total_number)
{
if (llDetectedKey(0) != llGetOwner() )
return;
llDialog(llDetectedKey(0), "Please choose option",["Init","Run","Export"],channel);
}
listen(integer channel, string name, key id, string message)
{
if(message == "Init")
{
llSay(0, "Re-Intializing KeyFrame Setter");
llSleep(1);
llResetScript();
}
if(llToLower(llGetSubString(message,0,2) ) == "set")
{
string time = llList2String(llParseString2List(message, [" "], []), 1);
llSay(0, "Setting new KeyFrame with " + time);
keys += [llGetPos() - last_pos, llGetRot() / last_rot, (integer) time];
last_pos = llGetPos();
last_rot = llGetRot();
}
if(message == "Run")
{
llSetPrimitiveParams([PRIM_POSITION, start_pos, PRIM_ROTATION, start_rot]);
llSetKeyframedMotion(keys,[KFM_MODE,KFM_LOOP]);
}
if(message == "Export")
{
llSay(0, llList2CSV(keys) );
}
}
}