Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSitTarget( vector P, rotation R);

Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
02-20-2008 07:11
I want to compute P and R for an A-Prim by sitting on another prim: B-Prim.
1. I sit on the B-Prim and edit its position just like you do with a Pose-Ball.
2. Now I have Aposition, Arotation for the A-Prim and Bposition, Brotation for the B-Prim
3. I claim: P = (Bposition - Aposition)/Arotation; and R = (Brotation / Arotation);

The rotation: R is all right no matter the positions and rotations of both prims, but the position: P is only right in special cases...
The position is off by 0.5 to 1m in some direction in most cases.

Where is my mistake? What is wrong? What am I overlooking?

NOTE: When sitting on the B-Prim I use: llSitTarget(<0.0, 0.0, 0.01>, ZERO_ROTATION); I take it that the small offset: 1cm can not make a big difference, so I ignore it.

I have read the LSLWiki and the LSL Portal -Second Life Wiki forward and backwards many times, but I am stranded on this...
HELP Please
_____________________
From Studio Dora
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-20-2008 09:59
My recollection is that there is a long-standing defect that affects sit positions. Lex Neva wrote a script to account for the defect. It does almost exactly what you are describing IIRC. I think you might be able to find it in these forums under a name like "Easy Sit Target Positioner", or something like that. I'm sure you could reuse that script, or analyze it to correct the calculations in your own.

Something like a <0.0, 0.0, -0.4> offset in local coordinates and a <0.0, 0.0, 0.186> in global coordinates. Very odd....
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-20-2008 13:40
the easy method is to set the target at zero vector and rotation, store the current pos/rot of the seat prim, then sit..

open edit, clicke edit linked parts, move the seat till it's where it should properly be, and have it report it's new position and rotation...

the correct sit target should be the difference between the old and new positions (or possibly the inverse of that) and the inverse of the difference in the rotations.

jesse barnett also wrote a version of this recently.
_____________________
|
| . "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...
| -
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
I tried
02-21-2008 08:06
From: Hewee Zetkin
My recollection is that there is a long-standing defect that affects sit positions. Lex Neva wrote a script to account for the defect. It does almost exactly what you are describing IIRC. I think you might be able to find it in these forums under a name like "Easy Sit Target Positioner", or something like that. I'm sure you could reuse that script, or analyze it to correct the calculations in your own.

Something like a <0.0, 0.0, -0.4> offset in local coordinates and a <0.0, 0.0, 0.186> in global coordinates. Very odd....


Thank you for helping!

I found 'Update sit Target' by Strife Onizuka in the LSL Portal -Second Life Wiki.
It has a correction like:

vector sit_at( vector sitpos, rotation sitrot, key sitter )
{ vector asize = llGetAgentSize( sitter );
sitpos.z += 0.4;
return sitpos - ( llRot2Up( sitrot ) * asize.z * 0.02638 ); }

Is that what you had on your mind?

I played around with it but am still baffled... I WILL continue to look for a solution
_____________________
From Studio Dora
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
02-21-2008 09:29
Hewee's right; I ran into exactly this problem trying to do exactly the same thing. Don't worry, your code looks right... it's llSitTarget() that's wrong.

Here's where I posted my findings and my workaround:

/54/6a/153963/1.html

I think that code of Strife's that you posted was based in part on my code and LearJeff's version of my code.
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
Oh my Dear
02-21-2008 10:16
From: Lex Neva
Hewee's right; I ran into exactly this problem trying to do exactly the same thing. Don't worry, your code looks right... it's llSitTarget() that's wrong.

Here's where I posted my findings and my workaround:

/54/6a/153963/1.html

I think that code of Strife's that you posted was based in part on my code and LearJeff's version of my code.


You are a Darling!

I read the code and it is so much like my own except for the corrections, so I have great hopes that my troubles will be over...

I can't wait to try it out
_____________________
From Studio Dora
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
Target has to be moved
02-22-2008 06:47
From: Void Singer
the easy method is to set the target at zero vector and rotation, store the current pos/rot of the seat prim, then sit..

open edit, clicke edit linked parts, move the seat till it's where it should properly be, and have it report it's new position and rotation...

the correct sit target should be the difference between the old and new positions (or possibly the inverse of that) and the inverse of the difference in the rotations.

jesse barnett also wrote a version of this recently.

This method is very smart in eliminating the the flaw in the llSitTarget script, but the target has to be moved in the process.
Furthermore it is hard to determine the sit position since the target is moved away from the place it will finally stay in.
Any way Jesse Barnett's script is interesting reading.
_____________________
From Studio Dora
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
So smooth
02-22-2008 07:02
From: Dora Gustafson
You are a Darling!

I read the code and it is so much like my own except for the corrections, so I have great hopes that my troubles will be over...

I can't wait to try it out

I applied Lex Neva's corrections in my own script and all is just working smoothly!

I tried to set the llSitTarget parameters using Lex's scripts as well as my own and I must recommend his scripts before mine to everybody.

Get them Inworld or from this forum!

Thanks for helping guys! I hope to pay back some day.
_____________________
From Studio Dora