Difference between revisions of "User:Dora Gustafson/Replacing llTargetOmega"

From Second Life Wiki
Jump to navigation Jump to search
(Replacing llTargetOmega)
 
(Replaced content with "== Content moved == Moved to LlTargetOmega_Replacement : ~~~~")
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{LSL Header}}
== Content moved ==
== Replacing llTargetOmega with a Key Framed Motion ==
Moved to [[LlTargetOmega_Replacement]]
: This doesn't make [[llTargetOmega]] redundant but in some cases a Key Framed motion may be preferred
: [[User:Dora Gustafson|Dora Gustafson]] 05:15, 1 October 2014 (PDT)
: The routine: "KeyFrameOmega" is easy to use for [[llTargetOmega]]: It takes the first two parameters in [[llTargetOmega]]: axis and spinrate
: The included script shows how to use the routine to start, stop and reverse a spin on repeated touches
<lsl>
// llTargetOmega substitution by Dora Gustafson, Studio Dora 2014
// The script must be in the root prim
// It can not spin child prims
// The object must be convex hull physics type
// Can not spin physical objects
// The parameters are the same as the two first for llTargetOmega
// All viewers will see the same spin and rotation
// The object will keep the rotation it has when spin is stopped
// A spin will continue even when the script is deleted
 
integer P;
 
KeyFrameOmega( vector axis, float spinrate)
{
    llSetKeyframedMotion( [], []);
    if ( spinrate )
    {
        float v = TWO_PI/3.0;
        if ( spinrate < 0 ) v = -v;
        list L = [llAxisAngle2Rot( axis/llGetRot(), v), v/spinrate];
        llSetKeyframedMotion( L+L+L, [KFM_DATA, KFM_ROTATION, KFM_MODE, KFM_LOOP]);
    }
}
 
default
{
    state_entry()
    {
        llSetPrimitiveParams([PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_CONVEX]);
    }
    touch_end( integer n)
    {
        P = ++P%4;
        if ( P == 1 ) KeyFrameOmega( <0,0,1>, 2.0);      // Positive spin
        else if ( P == 3 ) KeyFrameOmega( <0,0,1>, -2.0); // Negative spin
        else KeyFrameOmega( <0,0,1>, 0.0);                // Stop spin
    }
}
</lsl>
{{LSLC|Library}}

Latest revision as of 04:15, 1 October 2014

Content moved

Moved to LlTargetOmega_Replacement

Dora Gustafson 05:15, 1 October 2014 (PDT)