Jump to content

prim scalable with the prim in front connected


phippsj10
 Share

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

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

Recommended Posts

I want to make a prim you click on get as large as the prim behind it, then when you click it again, the prim gets smaller.  I want the larger and smaller action of the prim to be scaleable with the back board prim, this is what I have so far, what else do I need?

integer on = TRUE;
default
{
touch_start(integer total_number)
{
if(on == TRUE)
{
llSetScale(llGetScale()+<2.82,0,1.7>);
llSetPos(llGetLocalPos()+<.45,0.01,-.8>);
on=FALSE;
}
else if(on == FALSE)
{
llSetScale(llGetScale()-<2.82,0,1.7>);
llSetPos(llGetLocalPos()-<.45,.01,-.8>);
on=TRUE;
}
}
}

 

Link to comment
Share on other sites

Ah... on reflection, I realize I was wrong about needing to correct for rotation of the linkset, since you're using local position and not rotatiing the prim as you're expanding and shrinking it.  So here's a possible way to generalize your script, assuming that

(1) You have 2 prims in the linkset and

(2) This script is in the child prim (the one that will expand/contract) and

(3) The child prim is offset from the root prim along the root's Y axis.

integer on;vector gMyScale;vector gRootScale;default{    touch_start(integer total_number)    {        if(!on)        {            gRootScale = llList2Vector(llGetLinkPrimitiveParams(1,[PRIM_SIZE]),0);            gMyScale = llGetScale();            llSetLinkPrimitiveParamsFast(2,[PRIM_POS_LOCAL, llGetLocalPos() + <0.0,(gRootScale.y-gMyScale.y)/2.0,0.0>,PRIM_SIZE,gRootScale]);            on=TRUE;        }        else        {            llSetLinkPrimitiveParamsFast(2,[PRIM_POS_LOCAL,llGetLocalPos() - <0.0,(gRootScale.y-gMyScale.y)/2.0,0.0>,PRIM_SIZE,gMyScale]);            on=FALSE;        }    }}

 This will offset the child prim as it changes size, always keeping its outward-facing surface at the same distance from the root prim.

EDIT: Repaired typo

Link to comment
Share on other sites

example.jpgIf you see on the right it does not stay to scale. The two viewers on the right are the same thing it just shows what the prims look like when they are touched, and then the smaller boxes are after they go back to their origional shape.  I think what i am trying to say is how do i get the prim to stay to scale when i resize the back board?

Link to comment
Share on other sites

The example I posted should do exactly that.  It does in my test linkset. The only difference is that my child prim (the one that has to expand or contract) is centered on the root prim (the screen).  If you wanted to expand a non-centered child prim, you'd need to add X and Z offsets to the PRIM_POS_LOCAL vector so that it moves to the center of the screen as it's enlarged.  And, of course, since you have 16 child prims your script would have to be generalized to include different offsets for each of them.

Link to comment
Share on other sites


Rolig Loon wrote:

[ ... ] And, of course, since you have 16 child prims your script would have to be generalized to include different offsets for each of them.

It's actually simpler than that, now that I think about it.  Each of your 16 child prims has to snap to exactly the same position relative to the root prim as it expands, so you only need one local position vector, not 16 offsets.  Record the child prim's local starting position (shrunk) and then just move it from there to <0.0,Yoffset,0.0> and back.

Link to comment
Share on other sites

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