Difference between revisions of "Key Frame Animator"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) m (cleanup) |
m (<lsl> tag to <source>) |
||
(One intermediate revision by one other user not shown) | |||
Line 4: | Line 4: | ||
--[[User:Jasper Flossberg|Jasper Flossberg]] | --[[User:Jasper Flossberg|Jasper Flossberg]] | ||
< | <source lang="lsl2"> | ||
integer channel; | |||
list keys=[]; | |||
vector last_pos; | |||
rotation last_rot; | |||
vector start_pos; | |||
integer | |||
list keys; | |||
rotation start_rot; | rotation start_rot; | ||
default | 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) | |||
touch_start(integer | |||
{ | { | ||
if (llDetectedKey(0) != llGetOwner() ) | |||
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, "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(); | |||
keys += [llGetPos()-last_pos,llGetRot()/last_rot,(integer)time]; | |||
} | } | ||
if (message == "Run") | if(message == "Run") | ||
{ | { | ||
llSetPrimitiveParams([PRIM_POSITION, start_pos, PRIM_ROTATION, start_rot]); | |||
llSetKeyframedMotion(keys,[KFM_MODE,KFM_LOOP]); | |||
llSetKeyframedMotion(keys, [ | |||
} | } | ||
if (message == "Export") | if(message == "Export") | ||
{ | { | ||
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) );
}
}
}