Jump to content

Help with rezzing an object in the same position relative to its rezzer even if the rezzer is moved


Emma Krokus
 Share

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

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

Recommended Posts

I thought I had my new toy working brilliantly - until I moved the rezzer. When I then tried to rez my object, it was in the wrong place!! Resetting the script after moving it did not help... :(.

So... combined scripting brain powers of SL Forum, please could you help me out?

Here's my script ( ok, cobbled together from a number of sources :D - but it works - sort of... ):

 

vector sittarget =<0.0, 0.0, 0.0>;
rotation sitrotation =<0.0, 0.0, 0.0>;

key agent;

default
{
    state_entry()
    {
    llSitTarget(sittarget,sitrotation);
       
    }

    changed(integer n)
    {
        if(n & CHANGED_LINK)
        {
            agent=llAvatarOnSitTarget();
            if(agent!=NULL_KEY)
            {
            llRequestPermissions(agent,PERMISSION_TRIGGER_ANIMATION);
            llRezObject("Feed", llGetPos() + <-.55, 0, -.46>, ZERO_VECTOR, ZERO_ROTATION, 0);

            }
            else
            {
                llSay(0,"Thanks!");
            }
        }
        if(n & CHANGED_INVENTORY)
        {
            agent=llAvatarOnSitTarget();
            if(agent!=NULL_KEY)
            {
                llUnSit(agent);
                
            }
        }
    }
    
        
    run_time_permissions(integer n)
    {
        llStopAnimation("sit");
        llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
    }
}

 Thank you so much!

Emma :)

Link to comment
Share on other sites

Change this line:

llRezObject("Feed", llGetPos() + <-.55, 0, -.46>, ZERO_VECTOR, ZERO_ROTATION, 0);

to this:

llRezObject("Feed", llGetPos() + <-.55, 0, -.46>*llGetRot(), ZERO_VECTOR, ZERO_ROTATION*llGetRot(), 0);

Another thing is, that with your values for llSitTarget() the Sit target will be cancelled.
If that is what you want all is fine
Otherwise set the vector to something different from the ZERO_VECTOR

You may consider to use llRezAtRoot for llRezObject.

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

Thank you Dora :)

The rezzed object will now appear at the same spot relative to the rezzer regardless of where that's been moved. Works with llRezObject and llRezAtRoot the same... Yay!!

BUT... I tried all sorts of variations on the numbers (converted the ZERO_VECTOR and ZERO_ROTATION to numbers) and still I can't work out how to make the object rezz in the right orientation - which needs to be a 90 degree turn towards the ground. I've tried 45, 90 & 180 in various places of the above sets but only managed to turn the object face backwards or forwards, not do the quarter turn down.

Another pointer would be much appreciated! Thank you...

Emma :)

Link to comment
Share on other sites

In this line:

llRezObject("Feed", llGetPos() + <-.55, 0, -.46>*llGetRot(), ZERO_VECTOR, ZERO_ROTATION*llGetRot(), 0);

replace ZERO_ROTATION with the rotation you want
If you want to turn the forward direction, the nose, downward you can use: < 0.0, -0.70710678, 0.0, 0.70710678>
< 0.0, -0.70710678, 0.0, 0.70710678> equals llEuler2Rot( 0.0, -90.0*DEG_TO_RAD, 0.0)

So the line becomes

llRezObject("Feed", llGetPos() + <-.55, 0, -.46>*llGetRot(), ZERO_VECTOR, < 0.0, -0.70710678, 0.0, 0.70710678>*llGetRot(), 0);

If that turns the nose up, try < 0.0, 0.70710678, 0.0, 0.70710678> or llEuler2Rot( 0.0, 90.0*DEG_TO_RAD, 0.0)

 :smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

Not that it's anything to do with the rezzing problem, but 

vector sittarget =<0.0, 0.0, 0.0>;rotation sitrotation =<0.0, 0.0, 0.0>;

 can't possibly be right.  

It wouldn't -- shouldn't anyway -- compile with 

rotation sitrotation =<0.0, 0.0, 0.0>;  because that's a vector, not a rotation, and setting vector sittarget to <0.0,0.0,0.0> clears any existing sit target, with the result that llAvatarOnSitTarget is always going to be NULL_KEY.

Try changing it to 

vector sittarget = <0.0,0.0,0.1>;

rotation sitrotation = ZERO_ROTATION;

Link to comment
Share on other sites

Erm.... it isn't right...

I wasn't first going to include it and then I was too lazy to go back and copy the numbers... :D

Sorry to confuse everybody!! I did mean to add something in my reply to Dora's first post....

Thanks though for pointing it out, I learned a little more from you - like SL doesn't like all noughts in a sit target !

Emma :)

 

Link to comment
Share on other sites

  • 3 years later...

OK, I don't know why this is so difficult. I've been working with rotations for over 9 years and I still can't wrap my brain around them. I have a rezzer that simply needs to rez an object in the same orientation relative to the rezzer, no matter what direction the rezzer is pointed. In my case in needs to be <0,90,90> degrees relative to a ZERO_ROTATION rezzer. What I have is this:

llRezObject(obj, llGetPos()+<0,0,0.8>*llGetRot(), ZERO_VECTOR,llGetRot()* llEuler2Rot(<0,90,90>* DEG_TO_RAD),0 );

It works fine with no rotation in the rezzer. When the rezzer is rotated 90 degrees on its Z axis the object rezzes with a rotation of <0,90,180> when it should read <270,0,180> as it does when I manually turn it left 90 degrees. It has rotated around its own local Z axis instead of the rezzer's Z. What am I doing wrong??

Link to comment
Share on other sites

So all you want is to have the rezzed object end up rotated facing global North and rotated 90 degrees around its Y axis?  Not relative to the rezzer's rotation, but simply relative to global coordinates?

llEuler2Rot<0.0,90.0,90.0>*DEG_TO_RAD  or, more simply, llEuler2Rot(<0.0,PI/2,PI/2>)

Link to comment
Share on other sites


FreeWee Ling wrote:

.. rez an object in the same orientation relative to the rezzer...

... which doesn't seem as if it's to be static in global coords (as in Rolig's response).

My hunch is that, rather, the confusion here is about how the quaternion "*" operator looks deceptively as if it should be commutative, but isn't. So, instead, try:

llEuler2Rot(<0,90,90>* DEG_TO_RAD) * llGetRot()

 

  • Like 1
Link to comment
Share on other sites

Thank you Qie. Exactly right. Rollig misunderstood. Your solution seems to be exactly what was needed.

My grasp of the use of * and / in rotations is marginal at best. In normal math, order matters in division, but not in multiplication. So the reason this example is non-commutative is because it was applying the rezzer's rotation first, and then the offset. Which results in a different rotation than if the rezzed object was givern the offset rotation first and then brought into alignment with the rezzer. Sheesh.. This also explains why some of the solutions above include " * llGetRot()" in the position vector. I've learned something important here. Thanks very much!

 

 

Link to comment
Share on other sites

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