Jump to content

Moving and rotating an object using llSetLinkPrimitiveParamsFast() for a worn object


Zen Muliaina
 Share

You are about to reply to a thread that has been inactive for 4111 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi looking for some help I must be doing something wrong.

I an using llSetLinkPrimitiveParamsFast() to increment local coordinates of position and rotation making a simple short animation of a worn object. The co-ordinates are initially set when worn and a timer is used to make small movements.

The max time between movements is 10 sec and the min 0.4.

The problem is only some movements actually take place, those that do work OK and are moved to the right accumulated positions.I display the coordinates of each movement using llGetLocalPos() and they show the object as moved even though it hasnt.

 

integer b;
integer PChannel;
integer Pkey;
integer c;
vector xyz;
vector erot;


reset()
{
    rotation rot;
    
    erot = <4, 9, 0>;
    rot = llEuler2Rot(erot * DEG_TO_RAD);
    xyz = <-0.02, 0.0, -0.178>;

    PChannel = 6733;
    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                            PRIM_ROTATION,rot]);
    llSetTimerEvent(1);
    b = 0;
    c = 50;
}

default
{
    state_entry()
    {
        reset();

    }
    
    attach(key id)
    {
        if (id != NULL_KEY)
        {
            reset();
        }
    }
            
    timer()
    {
        if (c > 10)
        {
            llSay(PChannel,"1");
            c -= 10;
            llSetTimerEvent(c);            
        }
        else
        {
            if (b < 20) 
            {
                                
                // set animations timing
                
                if (b < 6)
                {
                    llSay(PChannel,"1");
                    llSetTimerEvent(10);
                }
                else if (b == 6)
                {
                    llSay(PChannel,"2");
                    llSetTimerEvent(10);
                }
                else if (b < 18)
                {
                    if (b == 7) 
                    {
                        llSay(PChannel,"3");
                    }
                    llSetTimerEvent(0.4);
                }
                else if (b == 18)
                {
                    llSetTimerEvent(20);
                }
                else 
                {
                    llSetTimerEvent(10);
                }
                                
                // movement
                
                if (b == 6)
                {
                    erot.z += 10;
                    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                                            PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD)]);
                }
                else if (b == 9)
                {
                    erot.z += 20;
                    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                                            PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD)]);
                }
                else if (b == 10)
                {
                    erot.z += 30;
                    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                                            PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD)]);
                }
                else if (b == 11)
                {
                    erot.z += 30;
                    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                                            PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD)]);
                }
                else if (b == 12)
                {
                    xyz.z -= 0.016;
                    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                                            PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD)]);
                }
                else if (b == 13)
                {
                    xyz.z -= 0.016;
                    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                                            PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD)]);
                }
                else if (b == 18)
                {
                    erot.z = 180;
                    xyz = <-0.23,0,-0.45>;
                    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                                            PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD)]);
                }
                else if (b == 19)
                {
                    erot = <275, 0, 1>;
                    xyz = <0.07, -0.09, 0.154>;
                    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                                            PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD)]);
                }
                else
                {
                    xyz.z -= 0.008;
                    llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POS_LOCAL,xyz,
                                                            PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD)]);
                }
                
                llSay(0,(string)b+" "+(string)xyz);
                llOwnerSay((string)llGetLocalPos());

                b++; 
            }
            else
            {
                llSay(0,(string)b+" "+(string)xyz);
                llSetTimerEvent(0);
            }
        }    
    }
}

 

Also if the object is in edit it works correctly all movements are as programmed. I tired larger movements and they didn't move either, just the same ones that worked before.

 What possible could I be doing wrong? 

Thanks for looking

Zen

Link to comment
Share on other sites

There's two possible causes,  I think.   I know there's sometimes some funkiness with LINK_ROOT, so I've changed it to 1 to be on the safe side (though I don't think that's the issue).

There's also a long-standing bug that causes small movements (and some of these movement are pretty small) in attachments  not to be updates in the viewer unless you do something to force the viewer to update stuff.

The usual work-round is to change invisible hovertext, which forces the necessary changes, even though you can't see it.

I had a go, changing all the llSetLinkPrimitiveParamsFast calls to this format

	llSetLinkPrimitiveParamsFast(1,[PRIM_POS_LOCAL,xyz,						PRIM_ROTATION,llEuler2Rot(erot * DEG_TO_RAD),PRIM_TEXT,(string)b,<1.0,1.0,1.0>,0.0]);

 and the movements became apparent.   I am not sure how it's supposed to look, but the movements were a lot easier to see after I did that.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4111 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...