Jump to content

ho to extend a prim cylinder down starting from the top edge increasing on Z length


VirtualKitten
 Share

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

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

Recommended Posts

ok then how do i do this  can i do this moving it fast and resizing it after or ither or . What is the best method to achieve this 

I have  this that works on touch to extend or reverse to starting size .30597  or extending to 29.9. Its going to need to change its position but have not figured this much out 

float start = 0.30597;
float end_bottom = 26.99000; 
integer max_steps = 700;
integer extend = TRUE;
default
{
    state_entry()
    {
        
    }

    touch_start(integer total_number)
    {
       list l;
       vector size;
       vector gp;
       vector pos;
       float delay = 1.0/max_steps;
       float interpolation;
       integer step = 0;
       float actual_steps;
       if(extend == TRUE) actual_steps = max_steps/(end_bottom-start);
       else actual_steps = -max_steps/(end_bottom-start);
       for(step = 0; step <= max_steps; ++step) 
       {
            interpolation = (float)step/max_steps;
            l = llGetLinkPrimitiveParams(LINK_THIS,[PRIM_SIZE,PRIM_POSITION,PRIM_POS_LOCAL]);
            size = llList2Vector(l,0);
            gp =  llList2Vector(l,1);
            pos =  llList2Vector(l,2);
            //  gp.z + 0.5
            llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_SIZE,<size.x,size.x, size.z+actual_steps>,PRIM_POS_LOCAL,gp]);
            llSleep(delay);
            if (size.z+actual_steps == start) {
                size.z = start;
                step = max_steps;
            }
            
        }
    }
}

 

Link to comment
Share on other sites

It's really hard to understand what you're trying to do, but to extend a rod without moving one of it's ends, you either slice the rod in half with the PRIM_SLICE attribute (or the build menu) and double the lengths you want it to have, or, you translate the rod by a factor of half of the difference between the lengths,

llSetPos(0.5*(lengthNew-lengthOld)*llRot2Up(llGetRot()) + llGetPos()); or so for maintaining the +z edge, reverse the order of New and Old for maintaining the -z edge.

Edited by Quistess Alpha
I'm not sure if vector*scalar is valid in LSL, so changed to scalar*vector to be safe.
  • Thanks 1
Link to comment
Share on other sites

Thanks Quistess i i tried this but no luck

float start = 0.30597;
float end_bottom = 26.99000; 
integer max_steps = 700;
integer extend = TRUE;
default
{
    state_entry()
    {
        
    }

    touch_start(integer total_number)
    {
       list l;
       vector size;
       vector gp;
       vector pos;
       float delay = 1.0/max_steps;
       float interpolation;
       integer step = 0;
       float actual_steps;
       if(extend == TRUE) actual_steps = max_steps/(end_bottom-start);
       else actual_steps = -max_steps/(end_bottom-start);
       for(step = 0; step <= max_steps; ++step) 
       {
            interpolation = (float)step/max_steps;
            l = llGetLinkPrimitiveParams(LINK_THIS,[PRIM_SIZE,PRIM_POSITION,PRIM_POS_LOCAL]);
            size = llList2Vector(l,0);
            gp =  llList2Vector(l,1);
            pos =  llList2Vector(l,2);
            vector lengthOld = size;
            //  gp.z + 0.5
            llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_SIZE,<size.x,size.x, size.z+actual_steps>]);
            llSetPos(0.5*(size.z-lengthOld.z)*llRot2Up(llGetRot()) + llGetPos());
            llSleep(delay);
            if (size.z+actual_steps == start) {
                size.z = start;
                step = max_steps;
            }
            
        }
    }
}

 

Link to comment
Share on other sites

11 minutes ago, VirtualKitten said:
l = llGetLinkPrimitiveParams(LINK_THIS,[PRIM_SIZE,PRIM_POSITION,PRIM_POS_LOCAL]);
            size = llList2Vector(l,0);
            gp =  llList2Vector(l,1);
            pos =  llList2Vector(l,2);
            vector lengthOld = size;

You shouldn't collect the initial information for every step in the for loop, just once before the loop.

Link to comment
Share on other sites

Hmm I tried this but it in creased in side but did that fast and would not move

float start = 0.30597;
float end_bottom = 26.99000; 
integer max_steps = 700;
integer extend = TRUE;
default
{
    state_entry()
    {
        
    }

    touch_start(integer total_number)
    {
       list l;
       vector size;
       vector gp;
       vector pos;
       float delay = 1.0/max_steps;
       float interpolation;
       integer step = 0;
       float actual_steps;
       if(extend == TRUE) actual_steps = max_steps/(end_bottom-start);
       else actual_steps = -max_steps/(end_bottom-start);
       interpolation = (float)step/max_steps;
       l = llGetLinkPrimitiveParams(LINK_THIS,[PRIM_SIZE,PRIM_POSITION,PRIM_POS_LOCAL]);
       size = llList2Vector(l,0);
       gp =  llList2Vector(l,1);
       pos =  llList2Vector(l,2);
       vector lengthOld = size;
       for(step = 0; step <= max_steps; ++step) 
       {
            llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_SIZE,<size.x,size.x, size.z+actual_steps>]);
            llSetPos(0.5*(size.z-lengthOld.z)*llRot2Up(llGetRot()) + llGetPos());
            llSleep(delay);
            if (size.z+actual_steps == start) {
                size.z = start;
                step = max_steps;
            }
            
        }
    }
}
 

 

Link to comment
Share on other sites

list lengths = [0.5, 5.5];
integer duration = 2; // in seconds.

integer isLong = FALSE;
default
{
    touch_start(integer total_number)
    {   vector posStart = llGetPos();
        float  lenStart = llList2Float(lengths,isLong);
        isLong=!isLong;
        float lenEnd = llList2Float(lengths,isLong);
        
        float lenDelta = (lenEnd-lenStart)/(5*duration); // 5 == 1.0/0.2
        vector axis = llRot2Up(llGetRot());
        vector axisDelta =  axis*lenDelta*-0.5 ; // remove '-' for opposite end.
        
        integer i;
        for(i=1;i<5*duration;++i)
        {   llSetLinkPrimitiveParams(LINK_THIS, // rely on built-in delay of 0.2 seconds. (N.B. 5 == 1.0/0.2)
                // 0.1 might be a bit smoother, but less friendly.
                // faster than that will create more lag for little to no visual gain.
            [   PRIM_SIZE, <0.1,0.1,  lenStart+(i*lenDelta)>,
                PRIM_POSITION, posStart + i*axisDelta
            ]);
        }
        llSetLinkPrimitiveParams(LINK_THIS, // final manual adjustment to (hopefully) prevent floating point drift.
        [   PRIM_SIZE, <0.1,0.1, lenEnd>,
            PRIM_POSITION, posStart+axis*((lenEnd-lenStart)*-0.5) // remove '-' for opposite end, as above.
        ]);
    }
}

 

Link to comment
Share on other sites

Thats brilliant Quistess Alpha  and works brilliantly apart from the texture but dont mind that I am using this as dont like KDM however it giving my dime differences in rope length as it appears to be taking longer up than down

I just need to get other part moving the same

           // granularity of movement
            integer max_steps = 900;
            // delay = travel time/max steps
            float delay = 1.0/max_steps; 
            float interpolation;
            llSay(-556757656756,"LETOUTROPE");
            for(step = 0; step <= max_steps; ++step) {
               interpolation = (float)step/max_steps;
                // lerp between locations
               llSetRegionPos((1-interpolation)*here+interpolation*there);
               llSleep(delay);
            
            }

 

 

 

Link to comment
Share on other sites

This is commonly done for better garage doors in SL. They move upward and the upper edge disappears. It's usually done by building the object maximum length, and then updating PRIM_SLICE and PRIM_POS on every update. Then the effect looks right, with the texture moving, rather than shrinking. If you shorten the object, the texture will compress. There are low-end garage doors in SL which do that, and they look bad.

  • Like 2
Link to comment
Share on other sites

Also this is running a different speed to rope . I had to unlink the lift as i could not move it with this. Is there a better way to move it to keep pace with rope please?

 

/ granularity of movement
            integer max_steps = 900;
            // delay = travel time/max steps
            float delay = 1.0/max_steps; 
            float interpolation;
            llSay(-556757656756,"LETOUTROPE");
            for(step = 0; step <= max_steps; ++step) {
               interpolation = (float)step/max_steps;
                // lerp between locations
               llSetRegionPos((1-interpolation)*here+interpolation*there);
               llSleep(delay);
            
            }

Link to comment
Share on other sites

I tried this in the Lift  i altered it to this  even though its the same code  a but its making the avatar jump as its not smooth movement does anyone have any better ideas?

        vector posStart = llGetPos();
        float  lenStart = llList2Float(lengths,isLong);
        isLong=!isLong;
        float lenEnd = llList2Float(lengths,isLong);
        
        float lenDelta = (lenEnd-lenStart)/(5*duration); // 5 == 1.0/0.2
        vector axis = llRot2Up(llGetRot());
        vector axisDelta =  axis*lenDelta*-1 ; // remove '-' for opposite end.
        
        integer i;
        for(i=1;i<5*duration;++i)
        {   llSetLinkPrimitiveParams(LINK_THIS, // rely on built-in delay of 0.2 seconds. (N.B. 5 == 1.0/0.2)
                // 0.1 might be a bit smoother, but less friendly.
                // faster than that will create more lag for little to no visual gain.
            [     PRIM_POSITION, posStart + i*axisDelta
            ]);
        }
        llSetLinkPrimitiveParams(LINK_THIS, // final manual adjustment to (hopefully) prevent floating point drift.
        [  
            PRIM_POSITION, posStart+axis*((lenEnd-lenStart)*-1) // remove '-' for opposite end, as above.
        ]); 
            

 

 

 

Edited by VirtualKitten
Link to comment
Share on other sites

sometimes things can go appear to go more smoothly

On 7/8/2023 at 10:06 PM, VirtualKitten said:

 smooth movement

the smoothest movement is KFM

use a linked cylinder prim for the rope

with KFM we know the timing when the lift goes up and down.  Using the KFM timing we can script the same timing to SLICE the cylinder prim

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 354 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...