Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Getting the Avatar position on attach.

Leopard Loveless
Script Kitty
Join date: 30 Sep 2004
Posts: 57
10-20-2004 14:19
Hi!

I am currently coding an attachment that needs to be positions pretty precicely on the avatar. Right now, without adjustments, it sometimes happens the object is hidden inside the avatar, and sometimes it sticks out of it, the like, mostly depending on the size of the avatar, I guess.

To counter this effect, I wanted to have an attach event that gets the position of the object with llGetPos() and get the position of the avatar that it got attached to. The attach event gives me the key of the avatar it is attached to, which is llGetOwner() anyway.. and I can get the height of this avatar. But I cannot get its position.

I tried to start up a sensor event that detects the avatar, but the object could not detect me. It seems attached objects that use a sensor to scan cannot detect the agent it is attached to.

So, how to get the position of the avatar that wears the object from withing the attach event of the object?

Thanks in advance for your help!

*meow*
Leopard!
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-20-2004 15:24
When i first joined i found this limit to be annoying. I think llGetLocalPos should return the distance between the attach point and the object also llGetLocalRot should return the rotation of the attachment relative to the the attachpoint. More over it would be nice to be able to have llSetPos & llSetLocalRot work to move the object relative to the attachpoint (I don't care if llSetPos & llSetLocalRot have an extra script delay added to them; I want to be able to strictly control this info) Would also be nice to have a dataserver function that returns skeleton info for the owner.

So...
Me wants these extended for attachment root prims...
llGetLocalPos
llGetLocalRot

llSetPos
llSetLocalRot

list llQuerySkeletonInfo()

hmmm maybe there should be a llSetLocalPos just for consistancy, It's effect on root prims should be to move the object what ever the vector that is passed to it (as long as it's less then 10 meters in distance) with respect to it's current rotation?
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
10-20-2004 17:26
I would love any of those, expecially llQuerySkeletonInfo().
Ardith Mifflin
Mecha Fiend
Join date: 5 Jun 2004
Posts: 1,416
10-20-2004 19:22
Really, I think that these functions are absolutely necessary. We've got the proper tools for building everything else with precision, but we're still stuck with a very imprecise method of positioning attachments which cannot be scripted and which is entirely too primitive.

When it comes to building, I am strictly a by-the-numbers kind of person. Why can't the same functionality be extended to attachments?
Leopard Loveless
Script Kitty
Join date: 30 Sep 2004
Posts: 57
10-20-2004 22:23
Hi there,

okay, by reading the posts so far I assume that there is no solution for this yet.. too bad, as this means that the wearer has to manually adjust the attachment for now.

Well, let's hope there are ways in a later version of the client.

Than you for the replies!

*purrs*
Leopard Loveless

PS: Strife? As a mad scientist, wouldn't Washuu fit in more than the anthro version of Ryo-Oki? (smiles)
Chandra Page
Build! Code. Sleep?
Join date: 7 Oct 2004
Posts: 360
10-21-2004 08:38
Is there any way to get the position of an avatar, given the av's key? I'm building an item that isn't an attachment, but orbits around its owner. Getting the owner's key is trivial with llGetOwner, and I'd assumed that with that information, it would be easy to get the av's position. Not so, apparently.

I'm toying with the idea of calling llGetBoundingBox, which does take an object key, then averaging its corner vectors to get an approximate position for the avatar. Looks something like this so far:

CODE
list ownerBox;
vector corner1;
vector corner2;

ownerBox = llGetBoundingBox(llGetOwner());
corner1 = llList2Vector(ownerBox, 0);
corner2 = llList2Vector(ownerBox, 1);


My problem is getting an average between the two corners. I though that I'd just be able to add the two vectors together, then divide them by a vector containing 2s:

CODE
vector position;

position = (corner1 + corner 2) / <2,2,2>;


This produces a syntax error, though, so I'm obviously mis-reading the documentation for operators. Any ideas?
Ardith Mifflin
Mecha Fiend
Join date: 5 Jun 2004
Posts: 1,416
10-21-2004 09:04
I think that llSensor and a sensor event with llDetectedPos would do what you're requesting. I've not worked much with sensors, though. You can wait for someone else to fill in the details, or you could read the wiki on these functions and do a little dabbling.
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
10-21-2004 10:21
From: Chandra Page
My problem is getting an average between the two corners. I though that I'd just be able to add the two vectors together, then divide them by a vector containing 2s:

CODE
vector position;

position = (corner1 + corner 2) / <2,2,2>;


This produces a syntax error, though, so I'm obviously mis-reading the documentation for operators. Any ideas?


I don't think you can divide a vector by another vector, can you? Try:

CODE
vector position;

position = ( corner1 + corner2 ) / 2 ;


...and see if that works?
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
Chandra Page
Build! Code. Sleep?
Join date: 7 Oct 2004
Posts: 360
10-21-2004 10:25
From: Ardith Mifflin
I think that llSensor and a sensor event with llDetectedPos would do what you're requesting.


I have no doubt they would. It just seems utterly lame that I need to take up extra sim processing cycles with a sensor, just to get information that I should already have access to.

llGetPosKey would be a nice function to have. Takes an object key, returns its position.
Chandra Page
Build! Code. Sleep?
Join date: 7 Oct 2004
Posts: 360
Vector division
10-21-2004 10:51
From: Cross Lament
I don't think you can divide a vector by another vector, can you?


According to the LSL Wiki's Operators page, dividing a vector by another vector should result in division of the vector's individual components. For example, "<a, b, c> / <x, y, z>" should result in "<a/x, b/y, c/z>". The same page also says you can't divide a vector by an integer, so "<a, b, c> / 2" wouldn't work.

However, the Wiki's vector type page, and the LSL Scripting Language Guide itself, only list +, -, *, and % operators for the vector type, so there's a good chance that the vector division described in the Operators page does not exist.

I'm guessing that the Operators page is inaccurate. I'll have to do a little experimental coding before I'm comfortable correcting the Wiki; I've only got one data point, after all. I'm away from SL so I can't check up on this right now.
Chandra Page
Build! Code. Sleep?
Join date: 7 Oct 2004
Posts: 360
More vector division
10-21-2004 10:56
Oooh, I may have solved my vector division problem. Reading a bit further on the Wiki's vector page, I see that you can scale a vector if you multiply it by a float. I don't need to use a division operator at all; something like this would work:

CODE

// Should return the vector <0.5, 1.0, 1.5>
vector result = <1,2,3> * 0.5;


I still want to experiment a bit with using the division operator with vectors before altering the Wiki, but I'm pretty sure I've got a solution to my problem now.
Leopard Loveless
Script Kitty
Join date: 30 Sep 2004
Posts: 57
10-21-2004 22:15
No, the sensor thing does not work.

Put a sensor on an object. Put the object on the ground. Activate the sensor. It will sense you, no problem.
Now _wear_ the same object, and suddenly is will not find your Avatar anymore. So.. warn objects cannot find the wearer in a sensor-event.

The second thing I have wondered is if even if I get the coordinates of the avatar... can I move the object that is attached relative to the avatar, or will the avatar move with me or will nothing happen at all and llSetPos cannot be used on a attached object?

*meow*
Leopard!
Mike Zidane
Registered User
Join date: 10 Apr 2004
Posts: 255
10-22-2004 05:36
If an object is attached to an avatar, llGetPos() will return the position of the avatar, not the object. Am I wrong about that?
Ardith Mifflin
Mecha Fiend
Join date: 5 Jun 2004
Posts: 1,416
10-22-2004 05:48
Chandra specifically states that her object was not an attachment. And yes, getpos returns the av's location when called from the parent prim of an attachment.