Jump to content
You are about to reply to a thread that has been inactive for 135 days.

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

Recommended Posts

Posted

I have a linked object which I've got all the starting positions and sizes for. The idea is to have all of the linked prims get smaller in size as they work their way down from their original position into the center of the root prim.

To help visualize, let's say I've got a tornado with debris; I want that debris to travel from the top of the tornado cone to the bottom center part of the funnel.

So far I can move and scale them downward. I've attempted to compute the difference between the original position of the linked prim and the position of the root prim, which has gotten me through the thick of the functionality I seek, but I'm not sure what type of math I need to incorporate to ensure the linked prims don't move beyond the center (X,Y) of the root prim.

Here's the current functionality I've got going so far; perhaps I'm missing something or just need a simple addition? Any help is most appreciated!

for(x = 1; x <= llGetNumberOfPrims(); x++)
{
    vector scale_orig = llList2Vector(start_scale, x);
    vector scale_steps = <(scale_orig.x / 25), (scale_orig.y / 25), (scale_orig.z / 25)>;
    vector scale_new = <(scale_steps.x * (25 - steps)), (scale_steps.y * (25 - steps)), (scale_steps.z * (25 - steps))>;
    vector pos_orig = llList2Vector(start_pos, x);
    vector pos_root = llList2Vector(start_pos, 0);
    vector difference = (pos_root - (pos_root + pos_orig));
    vector difference_steps = <(difference.x / 12.5 * (25 - steps)), (difference.y / 12.5 * (25 - steps)), (difference.z / 12.5 * steps)>;
    vector pos_new = <difference_steps.x, difference_steps.y, (pos_orig.z - (0.5 * steps))>;
    llSetLinkPrimitiveParamsFast((x+1), [PRIM_SIZE, scale_new, PRIM_POS_LOCAL, pos_new]);
}
Posted (edited)

I wonder if you could cheat by using llScaleByFactor at each step and then restoring only the size of the root prim.  That is, at each step:

1. Use llGetLinkPrimitiveParams(LINK_ROOT,[PRIM_SIZE]) to get the scale of the root prim  (original_size).

2. Use llScaleByFactor(scaling_factor) to shrink the entire linkset

3. Use llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_SIZE, original_size]) to restore the root to its starting size

I haven't tried this but it sounds easier than what you're doing, if it works.

Edited by Rolig Loon
typos. as always.
  • Thanks 1
Posted
32 minutes ago, Rhowin said:

The idea is to have all of the linked prims get smaller in size as they work their way down from their original position into the center of the root prim.

The local position of the root prim is always <0,0,0>, which makes the math pretty trivial:

// Option A: move a linked prim (for this example with link number 'link') a specific distance to the root prim:
vector posLink = llLIst2Vector(llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL]),0);
float mag = llVecMag(posLink);
float magNew = mag-distance;
if(mag_new <0) mag_new = 0; // do not move beyond root prim.
vector posNew = posLink*(magNew/mag);
llSetLinkPrimitiveParamsFast(link,[PRIM_POS_LOCAL,posNew]);

// Option B: relative (exponential) movement:
float factor = 0.75; // lower is faster movement to center.
vector posLink = llLIst2Vector(llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL]),0);
llSetLinkPrimitiveParamsFast(link,[PRIM_POS_LOCAL,posLink*factor]);

 

Posted

Thank you all for the replies!

I tried both options you provided, @Quistess Alpha, but didn't see a variable for "distance" in Option A. Is there something in particular I need for that spot? Trying with a value of 0.5 (the distance I was moving along the Z per step) but got errors about dividing by 0.

Posted
1 hour ago, Rhowin said:

got errors about dividing by 0.

if you're trying to move the root prim into itself or move a prim that's already at the root that'd happen, was off the top of my head, you'd need some sanity checks in there.

You are about to reply to a thread that has been inactive for 135 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
×
×
  • Create New...