Jump to content

HUD Object Rezzer help...


Life Camino
 Share

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

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

Recommended Posts

I'm trying to write a HUD object rezzer script that will always rez an object in the same position relative to the avatar, regardless of the avatar's rotation.  In other words, if the avatar is facing east and I want the object rezzed 5m in front of the avatar every time, then the HUD needs to rez the object at avatar_pos + <5.0,0.0,0.0>.  But, if the avatar is facing north, it would need to be rezzed at avatar_pos + <0.0,5.0,0.0>.  I also need the object to be rotated the same relative to the avatar each time.  For example, if the object is a little space ship, I always want the avatar to be facing the side of the ship, and not the front or the back when it's rezzed from the HUD.

The approach I'm trying to use is to have a positioning script dropped into the object that remembers where it was in relation to the avatar when the script was dropped into the object.  So, the avatar need only position the object where they want it when the HUD rezzes it, drop the script into it, then take it back to inventory and then drag and drop it into the HUD's inventory.  Then, when the HUD rezzes the object, it will detect the avatar's position and move to the correct relative position and rotation.

I can get the object to always move to the correct relative position in region coordinates, but, I can't get it to take into account which direction the avatar is facing.  This is what I have, so far and at this point I'm stuck:

 

vector my_pos;
vector owner_pos;
vector offset;
rotation my_rot;
rotation owner_rot;

 
default
{
    state_entry()
    {
        
    }
    on_rez(integer start_param)
    {
        owner_pos = llList2Vector(llGetObjectDetails(llGetOwner(), [OBJECT_POS]), 0);
        owner_rot = llList2Rot(llGetObjectDetails(llGetOwner(), [OBJECT_ROT]), 0);
        llSetRot(my_rot);
        llSetRegionPos(owner_pos + offset);
    }
        
    touch_start(integer total_number)
    {
        my_pos = llGetPos();
        my_rot = llGetRot();
        owner_pos = llList2Vector(llGetObjectDetails(llGetOwner(), [OBJECT_POS]), 0);
        offset = my_pos - owner_pos;
        float distance = llVecDist(my_pos, owner_pos);
        llOwnerSay("Owner Pos = " + (string)owner_pos);
        llOwnerSay("My Pos = " + (string)my_pos);
        llOwnerSay("Offset Pos = " + (string)offset);
        llOwnerSay("Distance = " + (string)distance + "m");
    }
}

 

Link to comment
Share on other sites

You ought to be able to get the object to rez in the same position relative to the av by just writing

llRezAtRoot("My_Object", llGetPos() + offset*llGetRot(), ZERO_VECTOR, pick_a_rotation,0);

(You may need to write pick_a_rotation *llGetRot() Can't be sure without popping in world to test, but that sounds right.)

In any case, multiplying your offset vector by llGetRot, which is the rotation of the avatar, ought to get the newly-rezzed object positioned correctly.

Link to comment
Share on other sites

Yes, I think that would work, as long as my rezzing position is less than 10 meters away.   The reason I wanted to use a positioning script and have the object move into position on its own is to circumvent the 10M rez position limit.  If the object is small, 10M is probably sufficient.  But, if the object is large, 10M may not be sufficient.    And, different objects are going to have different positioning requirements. My goal is to be able to properly position any object regardless of its size or its distance from the avatar.  So, how might I get the rezzed object to move to the correct position and rotation?

Link to comment
Share on other sites

The only problem I see with that suggestion is that the script that will be rezzing the object does not know where it is supposed to go.  The positioning script in the object is supposed to know what it's offset should be from the avatar.  And, it gets that when the avatar positions the object and clicks it.  The avatar then takes the object back to inventory and then drags it into the object rezzer HUD.

When the object is rezzed, it can get the avatar's position and rotation and it already has its own recorded offset position and rotation.  So, the problem I'm having is getting the object to always move to the correct position and rotation after being rezzed.  I can get the object to move to the relative position in region coordinates, but not while taking the avatar's rotation into account.  If I always want the object rezzed in front of the avatar, it is not acceptable to simply place it at the relative position in region coordinates.  The avatar may be facing in a different direction.  So, where the object moves after being rezzed is going to be dependent on both the avatar's rotation and the relative offset recorded when the positioning script was placed into the object.

I hope I'm making myself clear.

Link to comment
Share on other sites

Hi Rolig.  I'm still having trouble.  This is the script I'm using as a positioning script for the object.  The avatar drops this script into the object to be rezzed and clicks it to store the offset and original rotation.  The avatar then takes the object back to inventory to be rezzed from the HUD at the avatar's center.  When the HUD rezzes the object, I want it to move to a position relative to the front of the avatar.  But, so far, the best I can do is have it move to the relative position of the avatar in region coordinates, regardless of the direction the avatar is facing.  If the avatar is facing west, the object will rotate itself 180 degrees, but it then moves behind the avatar to the region coordinates represented by the avatar's position plus the offset.

 

vector my_pos;vector owner_pos;vector offset;rotation my_rot;rotation owner_rot; default{    state_entry()    {            }    on_rez(integer start_param)    {        owner_pos = llList2Vector(llGetObjectDetails(llGetOwner(), [OBJECT_POS]), 0);        owner_rot = llList2Rot(llGetObjectDetails(llGetOwner(), [OBJECT_ROT]), 0);        llSetRot(my_rot * owner_rot);        llSetRegionPos(llGetPos() + offset);    }            touch_start(integer total_number)    {        my_pos = llGetPos();        my_rot = llGetRot();        owner_pos = llList2Vector(llGetObjectDetails(llGetOwner(), [OBJECT_POS]), 0);        offset = my_pos - owner_pos;        float distance = llVecDist(my_pos, owner_pos);        llOwnerSay("Owner Pos = " + (string)owner_pos);        llOwnerSay("My Pos = " + (string)my_pos);        llOwnerSay("Offset = " + (string)offset);        llOwnerSay("Distance = " + (string)distance + "m");    }}

How do I get the object to move to be in front of the avatar regardless of which direction it is facing?  Or, behind the avatar, if that is where it was when it's position and rotation were originally recorded?

 

Link to comment
Share on other sites

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