Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Repositioning prims - How do I get this to work?

Keera Zenovka
Registered User
Join date: 23 Mar 2007
Posts: 35
12-08-2008 18:20
This is the first time I've tried repositioning prims and could someone kindly tell me how to get this to work.....
I've made a sculpty prim necklace with one layer of prims sitting on top of another. I just want the *top* layer of prims to move either outwards or inwards along the x-axis in very small increments...(the wearer has the option to move these prims either way which creates the effect of a different design when the top prims move over top the bottom ones.)

The root prim is invisible and centered in the middle of the avi's neck. To widen the top layer of the necklace I want the child prims on the avi's right to move right along x, and the prims on the left side going left on x. The wearer can also move the prims back in again along x to narrow the top layer, as narrow as they want to go.

First I tried just using llSetPos to reposition the child prims. In the root prim to narrow the necklace by 1% I have

llMessageLinked(LINK_SET, 1999, "0.99", NULL_KEY);

and to widen it 1%

llMessageLinked(LINK_SET, 1999, "1.01", NULL_KEY);


Then in the Child prims to be repositioned:

CODE

default
{
link_message(integer sender_num, integer num, string str, key id)
{

if (num == 1999)
{
float position = (float)str;
vector currentposition = llGetLocalPos();
vector newposition = currentposition * position;


if (llGetLinkNumber() > 1) // only move if not the root object
{
llSetPos(<newposition.x,0,0>); // reposition
}
}
}
}



But this initially displaced the prims away from the necklace and after that only the right prims moved.


2nd Attempt:

I then tried using llSetPrimitiveParams instead of llSetPos.


CODE

default
{
link_message(integer sender_num, integer num, string str, key id)
{

if (num == 1999)
{
float position = (float)str;
vector currentposition = llGetPos();
vector newposition = currentposition * position;
list primparams = [];
primparams += [PRIM_POSITION, newposition]; // reposition

if (llGetLinkNumber() > 1)
{
primparams += [PRIM_POSITION, llGetLocalPos() * position]; // reposition
}

llSetPrimitiveParams(primparams);
}
}
}



This came the closest to working - the child prims on the right side widened and narrowed seemingly along x axis like I wanted (I *think*, but I don't know how to target just x coordinate using llSetPrimitiveParams), but the child prims on the left moved in and out on a 45 degree angle relative to the root prim.

Help?
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
12-08-2008 19:19
you can change a single componet in a vector
from the wiki:

To change a single float component of a vector, declare a variable, then address it by referring to the x, y, or z components in the form "vector_name.x", "vector_name.y" and "vector_name.z". These components will be treated as if they were ordinary floats.
Example:
vector foo = llGetPos();
foo.z += 1;
// or:
foo.z += <0,0,1>;
// or
foo.z++;
//or
++foo.z;
Any of the above methods will cause 1 to be added to the .z component of foo, although the last way is the fastest.


in your case use:
vector position = llGetLocalPos();
float position.x = (float)str;
this will put your link_message in the x only positon of your vector
_____________________
L$ is the root of all evil
videos work! thanks SL :)
Keera Zenovka
Registered User
Join date: 23 Mar 2007
Posts: 35
12-08-2008 20:12
Thx Lightwave! I'm trying to test it out but I get a syntax error pointing at

float position.x


For some reason can't compile because of this .x component. :(
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-08-2008 20:39
you don't initalize the single element of a vector, it's already there when the vector is created, so you don't need the float keyword

position.x = 3;
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -