Discussion: Easy Sit Target Positioner
|
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
|
03-23-2007 14:22
I don't think you need to correct for <0,0,0.186> value. I developed my own and only used the <0,0,0.4> offset values in my equations to figure the sit position. I believe if you combine your equations all into one you will find they cancel each other out. Is this value 0.186 value the Avatars offset position from the 0.4 position? if it is you will find it is a different value for each Avatar.
After I got mine working I found this post. go figure.
|
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
|
03-23-2007 15:34
This is what i had come up with. Just touch the helper prim HELPER PRIM SCRIPTdefault { state_entry() { llSitTarget(<0.0, 0.0 ,0.00001>, ZERO_ROTATION); llSetStatus(STATUS_PHANTOM, TRUE); } changed(integer change) { if(change & CHANGED_LINK) { key sitter_key = llAvatarOnSitTarget(); if(sitter_key != NULL_KEY) llRequestPermissions(sitter_key, PERMISSION_TRIGGER_ANIMATION); } } run_time_permissions(integer perms) { if(perms) { llStopAnimation("sit"); llStopAnimation("sit_generic"); llStopAnimation("sit_female"); llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0)); } } touch_start(integer num) { llSay(-1654820, "find"); } } PLACED IN PRIM TO FIND SIT POSITIONdefault { state_entry() { llListen(-1654820, "", NULL_KEY, "find"); llSetStatus(STATUS_PHANTOM, TRUE); } changed(integer change) { if(change & CHANGED_LINK) { key id = llAvatarOnSitTarget(); if(id != NULL_KEY) llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION); else llUnSit(id); } } run_time_permissions(integer perms) { if(perms) { llStopAnimation("sit"); llStopAnimation("sit_generic"); llStopAnimation("sit_female"); llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0)); } } listen(integer ch, string name, key id, string data) { llSensor ("", id, ACTIVE, 20.0, PI); } sensor(integer detected) { vector helper_pos = llDetectedPos(0); rotation helper_rot = llDetectedRot(0); vector my_pos = llGetPos(); rotation my_rot = llGetRot(); vector sit_pos = (((helper_pos + <0.0, 0.0, 0.4> * helper_rot) - my_pos) / my_rot) - <0.0, 0.0, 0.4>; rotation sit_rot = helper_rot / my_rot;
llSitTarget (sit_pos, sit_rot); vector rot_rad = llRot2Euler(sit_rot); vector rot_deg = rot_rad * RAD_TO_DEG; llSay(0, "------------------------------\nllSitTarget (<" + llList2CSV([sit_pos.x, sit_pos.y, sit_pos.z]) + ">, <" + llList2CSV([sit_rot.x, sit_rot.y, sit_rot.z, sit_rot.s]) + ">;\nSit Target = <" + llList2CSV([sit_pos.x, sit_pos.y, sit_pos.z]) + ">\nRotation Quaternion = <" + llList2CSV([sit_rot.x, sit_rot.y, sit_rot.z, sit_rot.s]) + ">\nRotation in Radian = <" + llList2CSV([rot_rad.x, rot_rad.y, rot_rad.z]) + ">\nRotation in Degrees = <" + llList2CSV([rot_deg.x, rot_deg.y, rot_deg.z]) + ">"); } }
|
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
|
03-23-2007 16:04
From: Lex Neva One big reason: shift-dragging. If you shift-drag an object with a sit target set, it's blown away in the copy process (this doesn't happen if you take/rez a copy). All sorts of things get "blown away" Set text, Particles, texture animation, just to mention a few.
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
03-23-2007 17:20
This is an awful lot of words and an awful lot of code. But I am pretty confident we will look back in years to come and reach the same conclusion that I did back in December in the thread where this whole episode began. i.e. /54/21/152434/1.html
_____________________
http://slurl.com/secondlife/Together
|
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
|
03-23-2007 18:05
From: Escort DeFarge This is an awful lot of words and an awful lot of code. But I am pretty confident we will look back in years to come and reach the same conclusion that I did back in December in the thread where this whole episode began... That we are crazy? but ya just simplify the formula into one line for the sit position. ignoring that 0.186 offset since it cancels itself out. also used a small value for the Helper Prims sit position so I would not have to solve for that as well. 0.00001 difference I don't think would kill any one unless you where to splice genes under a microscope, then there might be some harm done.
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
04-23-2007 13:00
After tons of requests to make this a little more non-scripter friendly, I've incorporated a basic sit-pose script into the system. All of the changes are in the "sit target setter" script. HEre's the new script: // Sit target system by Lex Neva. Please distribute willy-nilly.
default { touch_start(integer total_number) { llSensor("Sit Target Helper", NULL_KEY, ACTIVE|PASSIVE, 96, PI); llSay(0, "Searching for Sit Target Helper..."); } no_sensor() { llSay(0, "Sit Target Helper not found. No sit target set."); llSitTarget(ZERO_VECTOR, ZERO_ROTATION); } sensor(integer num) { if (num > 1) { llSay(0, "Multiple Sit Target Helpers found. Using closest helper."); } else { llSay(0, "Sit Target Helper found. Setting sit target."); } vector helper_pos = llDetectedPos(0); rotation helper_rot = llDetectedRot(0); vector my_pos = llGetPos(); rotation my_rot = llGetRot(); // calculate where the avatar actually is vector avatar_pos = helper_pos + <0,0,1> * helper_rot; // due to helper's sit target avatar_pos = avatar_pos - <0,0,0.186> + <0,0,0.4> * helper_rot; // correct for a bug in llSitTarget(), for helper sit target vector target_pos = (avatar_pos - my_pos) / my_rot; target_pos = target_pos + <0,0,0.186>/my_rot - <0,0,0.4>; // correct for the bug again, this time in my sit target rotation target_rot = helper_rot / my_rot; llSitTarget(target_pos, target_rot); llSay(0, "llSitTarget(" + (string)target_pos + ", " + (string)target_rot + ");"); llSay(0, " // Paste the following LSL code into a new script in this prim. Be sure to delete this \"" + llGetScriptName() + "\" script when you're done! // // Basic sit-pose script by Lex Neva default { state_entry() { llSitTarget(" + (string)target_pos + ", " + (string)target_rot + "); } changed(integer change) { if (llAvatarOnSitTarget() != NULL_KEY) llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION); } run_time_permissions(integer perm) { string anim = llGetInventoryName(INVENTORY_ANIMATION, 0); if (anim != \"\") { llStopAnimation(\"sit\"); llStartAnimation(anim); } } }"); } changed(integer change) { if (llAvatarOnSitTarget() != NULL_KEY) llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION); } run_time_permissions(integer perm) { string anim = llGetInventoryName(INVENTORY_ANIMATION, 0); if (anim != "") { llStopAnimation("sit"); llStartAnimation(anim); } } }
It gets a little sneaky, generating an entire sit-pose script including the sit target that it calculates. (Did you know LSL allows actual newlines in strings?) The script triggers the first animation it finds in its inventory when someone sits. This should make things a lot simpler.
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
05-09-2007 14:23
Ok, I must be missing something: Why do we need a Helper prim at all? Why not just use the avatar's position when sitting on the poseball, from llDetectedPos(0) and llDetectedRot(0) in the touch() handler?
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
05-09-2007 15:11
It is not the device to detect the current sitting avatar position. It is the device to know the position where you want your avatar to sit. Unless you can move it flexibly, you can't decide where it should sit.
_____________________
 Seagel Neville 
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
05-10-2007 13:56
Well, I was unintentionally cryptic. Yes, there needs to be a poseball-like thing holding the anim, which the helper prim provided, but I was kind of targeting pre-existing poseballs from which the anims would be ripped. So, to be clear, I've attached a script that *seems* to do the thing I understand to be the objective of this thread, modulo the non-scripter-friendliness. // Sit on a poseball, then touch the prim containing this script. // It reports your position and rotation and sets the llSitTarget() to replicate that pos & rot // Then sit on the scripted prim and touch it again to see how closely you match your previous position.
reportPosRot(vector pos, rotation rot) { vector rotVec = llRot2Euler(rot); vector degRotVec = <RAD_TO_DEG * rotVec.x, RAD_TO_DEG * rotVec.y, RAD_TO_DEG * rotVec.z>; llWhisper(0, "Pos = " +(string)pos+ ", Rot = <" +(string)degRotVec.x+ ", " +(string)degRotVec.y+ ", " +(string)degRotVec.z+ ">"); }
default { touch_start(integer total_number) { vector avPos = llDetectedPos(0); rotation avRot = llDetectedRot(0); reportPosRot(avPos, avRot); vector avSize = llGetAgentSize(llDetectedKey(0)); vector heightGlitch = <0, 0, (avSize.z/37.9)> ; vector myPos = llGetPos(); rotation myRot = llGetRot(); rotation targetRot = avRot / myRot; vector targetPos = (avPos + heightGlitch*avRot - myPos) / myRot - < 0, 0, 0.4> ; llSay(0, "llSitTarget(" +(string)targetPos+ ", " +(string)targetRot+ ");"); llSitTarget(targetPos, targetRot); state ready_to_sit; } }
state ready_to_sit { touch_start(integer total_number) { vector avPos = llDetectedPos(0); rotation avRot = llDetectedRot(0); reportPosRot(avPos, avRot); } }
This hasn''t been thoroughly tested, so if a rotation is wedged, sorry 'bout that. Also, it's still possible that I'm missing the whole point of the exercise, since my "heightGlitch" seems pretty unrelated to the magic 0.186 number in the postings. But this seems to work for a range of avatar sizes.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
05-10-2007 16:14
So is your point to avoid sensor? That's a good approach. hmm.. I said too much... there were a lot of things that I made mistakes. It was just one thing I should have said. You have to consider that what your own poseball's llSitTarget's value is, too. I don't think you can know the value of other people's poseballs in advance.
_____________________
 Seagel Neville 
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
05-15-2007 08:06
I made sure that Qui's script worked anyway. I made a mistake again to point out that he needed to consider the llSitTarget's value. It was not needed at all. But I found this llDetected method have an Achilles' heel thruogh several experiments. It was the inaccuracy. I guess it happens because it is involved with the Avatar's height. It must have been accurate for his own avatar.
_____________________
 Seagel Neville 
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
05-16-2007 16:06
 I've found that Qui's script perfect after his telling me personally. This is really a handy script. You need a poseball or at least a prim which has llSitTarget function as like a sit helper prim, but no matter with its name. To get llSitTarget value, I don't think that you need "ready_to_sit" state at all though.
_____________________
 Seagel Neville 
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
05-17-2007 05:45
Right, the ready_to_sit state is intended just for testing, to deactivate the default touch_start event handler, lest llSitTarget() get called again. In actual use, instead should probably do something like
llRemoveInventory(llGetScriptName());
as soon as the sit target is set.
Thanks to Seagel for all the help getting the concept tested.
--Qie
|
Learjeff Innis
musician & coder
Join date: 27 Nov 2006
Posts: 817
|
08-06-2007 10:58
See  for my version. You leave the setter in the furniture. It supports multiple anims (shift-arrow to cycle through). It also supports rotating mode; just put "rotat" anywhere in the description, and arrow keys will rotate the object. Comes complete with the set of freebie Poser sits, with those that are compatible already installed in the helper. Beta testers and code reviewers welcome. All free, no restrictions. Those who sell it unmodified will be despised, but that's about all.  Thanks! Jeff
|
Neurosis Sin
Registered User
Join date: 5 Sep 2006
Posts: 24
|
Holy Schmoly@!
09-30-2007 07:10
wow dude. Pure Genius. Works Great even with my wierded out chairs.
I still dont even know how to use llsittarget but with a free script i picked up and your helper I got my chairs working. THANKS!
Neurosis
|
Hg Beeks
llGetElement(80);
Join date: 13 Apr 2006
Posts: 134
|
10-02-2007 00:33
Has anyone else found that this is broken? The trick used in it (Moving the Agent as a linked prim) no longer seems to work. Has anyone else had this occur to them?
|
DanielFox Abernathy
Registered User
Join date: 20 Oct 2006
Posts: 212
|
10-02-2007 01:21
|
Hg Beeks
llGetElement(80);
Join date: 13 Apr 2006
Posts: 134
|
10-02-2007 01:24
Well, feckin' voted. This rolling restart seems to have been a bad move all around. Many sims were down for hours longer than needed, sims crashed in large numbers at the end of the night anyway, and the restart broke very useful features.
|
Alyx Sands
Mental Mentor Linguist
Join date: 17 Feb 2007
Posts: 2,432
|
10-02-2007 05:38
Dammit! And I was just about to build more chairs and stuff! *storms off to vote*
_____________________
~~I'm a linguist. RL sucks, but right now it's decided to be a little less nasty to me - you can still be nice to me if you want! ~~ ->Potestatem obscuri lateris nescitis.<-
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
10-02-2007 09:09
This code does not use the function mentioned. There should be NO PROBLEM using Easy Sit Target Positioner despite the bug. If anyone actually sees a problem using it, please post.
Thanks!
|
Tazmania Trefusis
Registered User
Join date: 13 Jan 2008
Posts: 85
|
Just that line only?
02-28-2008 02:49
So after the 'Sit Target Helper' producing these coordinates for sitting, you simply place in a new script of prim to be sat on? llSitTarget(<1.01583, -0.07531, -0.40000>, <-0.50000, -0.50000, 0.50000, 0.50000>  ; Do you have to place 'default {' etc before sittarget line? As I'm getting an error with the above SitTarget line line I know a noob dumb question, but bare with me Update: So put it like this in the prim?.. (and it was okay, although AV ended up metres below prim!!) default { state_entry() { llSitTarget(<-1.00583, -0.07531, -0.40000>, <-0.50000, -0.50000, 0.50000, 0.50000>  ; } }
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
02-28-2008 04:35
First, it's not absolutely necessary to embed the sit target in a script. After you set the target, you should be able to sit on the furniture and get the desired seat and animation (assuming you put the same anim in the furniture that you had in your helper).
However, there is one problem with that approach. If the owner shift-drags the furniture to copy it, it loses its sit target, and embedding the "llSitTarget" call in a script fixes that.
However, your simple script alone doesn't do the trick: you'd also need the code to apply the animation.
You have 3 options:
1) find a simpler sit script and add the llSitTarget line to its state_entry handler for default state (as in your script). Someone posted a sit-target setter that prints the whole script (but doesn't support multiple animations); try searching for sit target in this forum to find it.
2) You can also find a call to "llSitTarget" in the sit target setter that's commented out ("//" to the left of it). If you paste in your version and uncomment it, and leave the sit target setter in the furniture, that will work.
3) You can leave sit target setter in the furniture and simply add your little script above as a separate script. Your script would reset the sit target in case of shift-drag, and the sit target setter handles running the animation when someone sits.
BTW, sometimes sit targets and animations don't seem to work, and it's due to lag or SL messing up. It doesn't seem to work but come back later and it does. Or, one person will see it working and another won't see the animation.
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
02-28-2008 09:54
My latest version of this script outputs a complete script for you to paste in, including code that will trigger an animation when they sit. Look in my picks to find Lex Labs, my store, where you'll find a free vendor for the sit target positioner.
|
Vlad Bjornson
Virtual Gardener
Join date: 11 Nov 2005
Posts: 650
|
02-28-2008 10:29
Lex, you rock! Thanks so much for this tool. I use it every time I need to set a sit target and it has saved me from many Quaternion Headaches. I'm gonna go visit your lab and grab the latest version.
_____________________
I heart shiny ! http://www.shiny-life.com
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
02-28-2008 12:11
Oops, my post above was non-sequitur.
I thought this was another thread, about my version of Lex's sit target positioner, that includes a sit target helper and a setter script, and supports changing animations and rotating seats.
Find it for L$1 at SLX; search for "easy sit target positioner". It's listed under a differen't av's name, for reasons I won't go into.
And yes, Lex rocks. Many thanks to him for his work on this!
|