removed useless _ folders
This commit is contained in:
3
Open_Prim_Animator/Open_Prim_Animator.sol
Normal file
3
Open_Prim_Animator/Open_Prim_Animator.sol
Normal file
@@ -0,0 +1,3 @@
|
||||
<Solution name="Open_Prim_Animator">
|
||||
<Project name="Open_Prim_Animator" path="Open_Prim_Animator\Open_Prim_Animator.prj" active="true"/>
|
||||
</Solution>
|
||||
@@ -0,0 +1,332 @@
|
||||
// :CATEGORY:Prim
|
||||
// :NAME:Open_Prim_Animator
|
||||
// :AUTHOR:Todd Borst
|
||||
// :CREATED:2011-03-02 10:01:11.283
|
||||
// :EDITED:2013-09-18 15:38:59
|
||||
// :ID:588
|
||||
// :NUM:806
|
||||
// :REV:1.0
|
||||
// :WORLD:Second Life
|
||||
// :DESCRIPTION:
|
||||
// This is provided AS IS without support. Please don't bug me demanding
|
||||
// help or custom work for this free script.
|
||||
//
|
||||
// Authors License:
|
||||
// You are welcome to use this anyway you like, even bring to other grids
|
||||
// outside of Second Life. If you try to sell what I'm giving away for
|
||||
// free, you will be cursed with unimaginably bad juju.
|
||||
//
|
||||
//
|
||||
This work uses content from the Second Life® Wiki article at http://wiki.secondlife.com/wiki/Open_Prim_Animatorand is Copyright © 2007-2009 Linden Research, Inc.
|
||||
// :CODE:
|
||||
|
||||
|
||||
integer COMMAND_CHANNEL = 32;
|
||||
|
||||
|
||||
|
||||
integer primCount = 0;
|
||||
|
||||
integer commandListenerHandle = -1;
|
||||
|
||||
|
||||
|
||||
list posList = [];
|
||||
|
||||
list rotList = [];
|
||||
|
||||
list scaleList = [];
|
||||
|
||||
integer currentSnapshot = 0;
|
||||
|
||||
integer recordedSnapshots = 0;
|
||||
|
||||
|
||||
|
||||
vector rootScale = ZERO_VECTOR;
|
||||
|
||||
vector scaleChange = <1,1,1>;
|
||||
|
||||
|
||||
|
||||
// For tracking memory usage. The amount of snapshots you can record is based
|
||||
|
||||
// on the number of prims and available memory. Less prims = more snapshots
|
||||
|
||||
integer maxMemory = 0;
|
||||
|
||||
integer freeMemory = 0;
|
||||
|
||||
|
||||
|
||||
integer playAnimationStyle = 0;
|
||||
|
||||
// The values for playAnimationStyle means
|
||||
|
||||
// 0 = no animation playing
|
||||
|
||||
// 1 = play animation once
|
||||
|
||||
// 2 = play animation looping
|
||||
|
||||
|
||||
|
||||
// This function is used to display a recorded snapshot
|
||||
|
||||
showSnapshot(integer snapNumber)
|
||||
|
||||
{
|
||||
|
||||
if(snapNumber > 0 && snapNumber <= recordedSnapshots )
|
||||
|
||||
{
|
||||
|
||||
integer i = 0;
|
||||
|
||||
vector pos;
|
||||
|
||||
rotation rot;
|
||||
|
||||
vector scale;
|
||||
|
||||
|
||||
|
||||
vector rootPos = llGetPos();
|
||||
|
||||
|
||||
|
||||
// Might want to move llGetRot() into the loop for fast rotating objects.
|
||||
|
||||
// Rotation during the animation playback may cause errors.
|
||||
|
||||
rotation rootRot = llGetRot();
|
||||
|
||||
|
||||
|
||||
//2 is the first linked prim number.
|
||||
|
||||
for( i = 2; i <= primCount; i++)
|
||||
|
||||
{
|
||||
|
||||
pos = llList2Vector(posList,((snapNumber-1)*(primCount-1))+(i-2));
|
||||
|
||||
rot = llList2Rot(rotList,((snapNumber-1)*(primCount-1))+(i-2));
|
||||
|
||||
scale = llList2Vector(scaleList,((snapNumber-1)*(primCount-1))+(i-2));
|
||||
|
||||
|
||||
|
||||
//Adjust for scale changes
|
||||
|
||||
if( rootScale.x != 1.0 || rootScale.y != 1.0 || rootScale.z != 1.0 )
|
||||
|
||||
{
|
||||
|
||||
pos.x *= scaleChange.x;
|
||||
|
||||
pos.y *= scaleChange.y;
|
||||
|
||||
pos.z *= scaleChange.z;
|
||||
|
||||
scale.x *= scaleChange.x;
|
||||
|
||||
scale.y *= scaleChange.y;
|
||||
|
||||
scale.z *= scaleChange.z;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
llSetLinkPrimitiveParamsFast( i, [ PRIM_POSITION, pos, PRIM_ROTATION, rot/rootRot, PRIM_SIZE, scale ] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This function is used to start a sequential animation playback.
|
||||
|
||||
// If the delay speed is set too low, the script might not be able to keep up.
|
||||
|
||||
playAnimation(float delay, integer loop)
|
||||
|
||||
{
|
||||
|
||||
if(delay < 0.1) delay = 1.0;
|
||||
|
||||
|
||||
|
||||
if( loop == FALSE)
|
||||
|
||||
playAnimationStyle = 1;
|
||||
|
||||
else
|
||||
|
||||
playAnimationStyle = 2;
|
||||
|
||||
|
||||
|
||||
if (recordedSnapshots >= 1)
|
||||
|
||||
llSetTimerEvent(delay);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This shows the edit menu
|
||||
|
||||
showMenuDialog()
|
||||
|
||||
{
|
||||
|
||||
string temp = (string)((float)freeMemory/(float)maxMemory * 100.0);
|
||||
|
||||
string menuText = "Available Memory: " + (string)freeMemory + " (" + llGetSubString(temp, 0, 4) +"%)" +
|
||||
|
||||
"\nCurrent Snapshot: " + (string)currentSnapshot +"\tSnapshots Recorded: " + (string)recordedSnapshots +
|
||||
|
||||
"\n\n[ Record ] - Record a snapshot of prim positions\n[ Play ] - Play back all the recorded snapshots\n[ Publish ] - Finish the recording process\n[ Show Next ] - Show the next snapshot\n[ Show Prev ] - Show the previous snapshot";
|
||||
|
||||
|
||||
|
||||
llDialog(llGetOwner(), menuText, ["Record","Play","Publish","Show Prev","Show Next"], COMMAND_CHANNEL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
default
|
||||
|
||||
{
|
||||
|
||||
state_entry()
|
||||
|
||||
{
|
||||
|
||||
maxMemory = llGetFreeMemory();
|
||||
|
||||
freeMemory = llGetFreeMemory();
|
||||
|
||||
|
||||
|
||||
primCount = llGetNumberOfPrims();
|
||||
|
||||
commandListenerHandle = llListen(COMMAND_CHANNEL,"", llGetOwner(), "");
|
||||
|
||||
showMenuDialog();
|
||||
|
||||
|
||||
|
||||
//setting initial root scale. this allows the animation to scale if the root size is changed afterwards.
|
||||
|
||||
rootScale = llGetScale();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Feel free to remove this on-touch trigger if you are using your own script to control playback
|
||||
|
||||
touch_start(integer num_detected)
|
||||
|
||||
{
|
||||
|
||||
//only activate after publish.
|
||||
|
||||
if (commandListenerHandle == -1)
|
||||
|
||||
{
|
||||
|
||||
//if animation not playing start it, else stop it.
|
||||
|
||||
if( playAnimationStyle == 0)
|
||||
|
||||
playAnimation(1.0,TRUE);
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
playAnimationStyle = 0;
|
||||
|
||||
llSetTimerEvent(0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
changed(integer change)
|
||||
|
||||
{
|
||||
|
||||
//this is needed to detect scale changes and record the differences in order to adjust the animation accordingly.
|
||||
|
||||
if (change & CHANGED_SCALE)
|
||||
|
||||
{
|
||||
|
||||
if (rootScale != ZERO_VECTOR)
|
||||
|
||||
{
|
||||
|
||||
vector newScale = llGetScale();
|
||||
|
||||
//since change_scale is triggered even with linked prim changes,
|
||||
|
||||
//this is to filter out non-root changes.
|
||||
|
||||
if( ( newScale.x / rootScale.x) != scaleChange.x ||
|
||||
|
||||
( newScale.y / rootScale.y) != scaleChange.y ||
|
||||
|
||||
( newScale.z / rootScale.z) != scaleChange.z )
|
||||
|
||||
{
|
||||
|
||||
scaleChange.x = newScale.x / rootScale.x;
|
||||
|
||||
scaleChange.y = newScale.y / rootScale.y;
|
||||
|
||||
scaleChange.z = newScale.z / rootScale.z;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if new prims are added or removed from this object then the script resets
|
||||
|
||||
// because the animations are now broken.
|
||||
|
||||
else if (change & CHANGED_LINK)
|
||||
|
||||
{
|
||||
|
||||
if( primCount != llGetNumberOfPrims() )
|
||||
|
||||
{
|
||||
|
||||
llOwnerSay("Link change detected, reseting script.");
|
||||
|
||||
llResetScript();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//The message link function is to allow other scripts to control the snapshot playback
|
||||
@@ -0,0 +1,6 @@
|
||||
<Project name="Open_Prim_Animator" guid="1300CB6A-6C00-1014-BD12-880004C60A89">
|
||||
<Object name="Object" guid="1300CC3E-6C00-1014-BD12-880004C60A89">
|
||||
<Script name="Open_Prim_Animator_1.lsl" guid="13011BEC-6C00-1014-BD12-880004C60A89">
|
||||
</Script>
|
||||
</Object>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user