Jump to content

Moving Locally Outward


Ruthven Ravenhurst
 Share

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

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

Recommended Posts

I'm trying to figure out how to move child prims outward from the center of the root based on their initial local position. I'm terrible with rotations, and I'm sure that's what this script needs to figure out the new position, so I'm not sure how to go about it. If I'm going about it all wrong, what would you suggest?

Basically, I have say, a center pillar with satellite spheres around it at varying heights. I want them to retain the height (z offset), but move outward based on a given radius along the X and Y axis. Currently what it's doing is moving them all in the same direction, which obviously isn't right

float radius = 0.25;
float max = 1.5;
list linknums;
list localposdef;
default
{
    state_entry()
    {
        integer num = llGetNumberOfPrims();
        do
        {
            string name = llGetLinkName(num);
            if(llToLower(name) == "ribbon")
            {
                linknums += [num];
                localposdef += llGetLinkPrimitiveParams(num,[PRIM_POS_LOCAL]);
            }
        }
        while(num-- > 1);
    }

    touch_start(integer total_number)
    {
        radius += 0.1;
        if(radius > max){radius = 0;}
        integer num = llGetNumberOfPrims();
        do
        {
            string name = llGetLinkName(num);
            if(llToLower(name) == "ribbon")
            {
                integer idx = llListFindList(linknums,[num]);
                if(~idx)
                {
                    vector pos = llList2Vector(localposdef,idx);
                    pos = <radius,radius,0>+pos;
                    llSetLinkPrimitiveParamsFast(num,[PRIM_POS_LOCAL,pos]);
                }
            }
        }
        while(num-- > 1);
    }
}

 

Link to comment
Share on other sites

Ha, nevermind, no rotation needed. I need to multiply the original offset by the new radius.

float radius = 1.0;
float max = 5.0;
list linknums;
list localposdef;
default
{
    state_entry()
    {
        integer num = llGetNumberOfPrims();
        do
        {
            string name = llGetLinkName(num);
            if(llToLower(name) == "ribbon")
            {
                linknums += [num];
                localposdef += llGetLinkPrimitiveParams(num,[PRIM_POS_LOCAL]);
            }
        }
        while(num-- > 1);
    }

    touch_start(integer total_number)
    {
        radius += 0.1;
        if(radius > max){radius = 0;}
        integer num = llGetNumberOfPrims();
        do
        {
            string name = llGetLinkName(num);
            if(llToLower(name) == "ribbon")
            {
                integer idx = llListFindList(linknums,[num]);
                if(~idx)
                {
                    vector pos = llList2Vector(localposdef,idx);
                    pos = <pos.x*radius,pos.y*radius,pos.z>;//multiply x and y times radius, and retain the original z position
                    llSetLinkPrimitiveParamsFast(num,[PRIM_POS_LOCAL,pos]);
                }
            }
        }
        while(num-- > 1);
    }
}

 

  • Like 3
Link to comment
Share on other sites

Adding my own thanks for sharing, because it really helps other people later. That was thoughtful.

Worst thing in the world is when someone says "Aha! I've solved it!" and then they leave without telling anyone what the solution was... Thanks for not being one of those people!

  • Like 3
Link to comment
Share on other sites

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