Jump to content

Help needed positioning Prims


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

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

Recommended Posts

Hi All,

I am trying set up a mini-rezzer and am obviously too dense to understand how relative positions etc work. Basically I have a prim, that has two prims in its inventory. I want it to rez them in their correct positions and rotations relative to this base. So .. what have I done:

First with the two 'child prims' I positioned them where I wanted them .. linked them to the base, and then got their relative positions/rotations with the following code:

default
{
    touch_end(integer total_number)
    {
        vector pos = llGetLocalPos();
        rotation rot = llGetLocalRot();
        llSetObjectDesc((string)pos + "^" + (string)rot);
    }
}

Then in these prims I put a positioning script, which will be activated when they are rezzed (code to follow) and then put them into the inventory of the base prim. When called upon this base prim will rez the child prims with the following code:

//NEW_REZ is a constant that I use so the child prim knows when it has been rezzed by the base
llRezAtRoot(itemName, llGetPos(), <0.0, 0.0, 0.0>, llGetRot(), NEW_REZ);

Up to here all good ... then things start to get a bit lopsided. the code in the child prim that is activated once it is rezzed includes this snippet

//get my relative position and rotation
list data = llParseString2List(llGetObjectDesc(), [DATA_SEP], [EMPTY_STR]);
vector relPos = (vector)llList2String(data, 0);
rotation relRot = (rotation)llList2String(data, 1);

//get my current position and rotation
rotation myRot = llGetRot() * relRot;
vector myPos =llGetPos() + relPos * relRot;

//first set the rotation
llSetRot(myRot);

//then the position
llSetPos(myPos);

 


This works for the Child prim that was at the same (0 degree) rotation as the base when we took the relative values, but the child prim that had a rotation of 180 degrees (or 90 or 270) never gets to the right position. Quite obviously I am doing something wrong here but this all goes a bit beyond my ability to figure out.

I hope someone can explain to me what I am doing wrong.

Thanks in advance!

Wanda

 

  • Thanks 1
Link to post
Share on other sites

I can't go in world to check, but off the top of my head it seems like what you want to do is convert relRot to a global rotation rather than keeping it in the framework of the root, which is what you stored.  That should be

rotation myRot = relRot / llGetRot();

I think.

  • Like 1
Link to post
Share on other sites

If you want the rezzed objects' positional offsets to match the rotation of the root prim, you need to multiply by the root prim's rotation instead of the child prim's ultimate rotation.

vector myPos =llGetPos() + relPos * relRot;

should be:

vector myPos =llGetPos() + relPos * llGetRot();

You'll also want to either set the position first or store the data from the initial llGetRot() from your on_rez event in a variable. As you have it currently, setting the rotation first wipes the data you need to get the position rotated properly.

 

EDIT: clarity

Edited by Myrmidon Hasp
  • Like 3
  • Thanks 1
Link to post
Share on other sites

Thanks Myrmidion .. that was precisely the piece that was missing .. now works like a charm!

And thanks as always to Rolig and Innula for guidance .. wish I had seen your post on the Rezzer beforehand Innula .. would have likely saved me some earlier headaches.

Edited by Wandering Soulstar
Typos
  • Like 3
Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 1015 days.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...