Jump to content
Sign in to follow this  
Wandering Soulstar

Help Please .. Prim movement confusion

Recommended Posts

Afternoon all,

I have a situation that I am trying to get my head around and just cannot seemt ot get it clear, and ws hoping someone could point out the errors of my way :-) .. Basically I have two prims to create a blind, one is the blind and the other a bar across the bottom, with the script being in the main blind. When the blind is clicked it 'moves' up by reducing its size and adjusting position (top staying in the same place. While the blind moves upwards the bar moves as well.

All works well and good when I have just the two, but my problems come when I want to link more prims, which should not move or when I link the blinds to another set of prims thus the blind no longer being root. In the first case the other prims (apart from the blind and the bar) move as well, while in the later the blind does not movve (resize) at all.

I am using : llGetLinkPrimitiveParams(LINK_THIS, [PRIM_SIZE, PRIM_POSITION])  and lSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_SIZE, sizeBlind, PRIM_POSITION, posBlind]) on the main blind prim to size and move it ....

Any ideas as to what I am doing wrong?

 

Thanks in advance!

Wanda Soulstar

Share this post


Link to post
Share on other sites

llGetPos or llGetLinkPrimitiveParams... [PRIM_POSITION return the region coordinates

llSetPos or llSetLinkPrimitiveParams... [PRIM_POSITION
- set the region pos if used on the root
- set the local pos relative to the root if used on a child prim

So that will not work when linked.

There is a snippet in the wiki for a local move: http://wiki.secondlife.com/wiki/LlGetLocalPos

 

 

Share this post


Link to post
Share on other sites

Nova,

For the second issue I figured that likely that was it, and so since the code is meant to be general, i.e. I want it to work for the simple 2 prim blind scenario, as well as if the blind is linked to a larger set, then I assume I am going to have to use different code depending on if the blind prim is root or not.

BUT .. what about the first pronlem I am having? i.e the blind is root and I am moving it as indicated and the child linked prims are moving as well ...

Share this post


Link to post
Share on other sites

You can't make the blind the root. Moving the root moves the whole linkset.

Something like this will make the curtain/blinds move/resize thing:

vector  offset = <0,0,1>;float   minsize = 0.2;integer steps = 100;  default {    state_entry() {        offset *= ((1.0 - minsize) / steps) * (offset * llGetScale());    }     touch_start(integer detected) {        integer i;        do  {            llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_SIZE, llGetScale() - offset, PRIM_POSITION, llGetLocalPos() + ((0.5 * offset) * llGetLocalRot())]);            llSleep(0.04);        }        while ((++i) < steps);                   offset = - offset;    }}

You can link that but it must NOT be the root.
For the bar the same script will work (without the resize and without the 0.5 factor)
Doing that in a single script that works in a linkset with multiple of that blinds is maybe a little challenge though.

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

So with Nova clearing up the differences for me, I was able to quickly fix the code. Atttached is the bare bones of the routine, where it easily covers both scenarios (blind as root and not as root in a linkedset)

 

float chgBlindSize = (MAX_HEIGHT * ADJ_PERC) * dirMod;float chgChildPos = chgBlindSize;//if the blind is root we only need to move the child 1/2 the distanceif (IS_ROOT){    chgChildPos = chgChildPos/2;}float chgBlindPos = (MAX_HEIGHT * ADJ_PERC)/(-2 * dirMod);//by calling loc pos we either get global (for root) or relative (for linked)vector posBlind = llList2Vector(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_POS_LOCAL]), 0);while (sizeBlind.z != newSize){    //Calculate values    sizeBlind.z = sizeBlind.z + chgBlindSize;    posBlind.z = posBlind.z + chgBlindPos;    //Check if we have gone past the target size    if ((sizeBlind.z  > newSize && chgBlindSize > 0) || (sizeBlind.z  < newSize && chgBlindSize < 0))    {        sizeBlind.z = newSize;    }    vector posChild;    //This is if we have a linked child prim to the blind to adjust its position    if (CHILD_LINK != -1)    {        posChild = llList2Vector(llGetLinkPrimitiveParams(CHILD_LINK, [PRIM_POS_LOCAL]), 0);         posChild.z = posChild.z - chgChildPos;    }    //Do the change    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_SIZE, sizeBlind, PRIM_POSITION, posBlind]);    if (CHILD_LINK != -1)    {        llSetLinkPrimitiveParamsFast(CHILD_LINK, [PRIM_POSITION, posChild]);    }}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...