Jump to content

My rotation in llSitTarget


Rolig Loon
 Share

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

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

Recommended Posts

I feel so dumb today.  I never have trouble with sit targets (well, almost never), but I am having a heck of a time trying to figure this one out.  My 3-prim object is oriented with its local Y axis pointing down and I want to always be "seated" facing in the same direction as its +Z axis, regardless of which way the object's regional axes point.  This does it just fine....

        llSitTarget(<0.0,0.0,-2.0>,llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD)/llGetLocalRot());

as long as I have oriented my object with its local +Z pointing southward (S, SE, SW...).  As soon as I orient its +Z axis to point northward, I'm seated upside down. I have to reverse the Euler vector to <0.0,0.0,90.0> to be right-side up again.  I have chased this one around and around and can find several ways to get the rotation correct some of the time, but none to get it correct all of the time.  I have long since abandoned a logical approach to the problem and have gone empirical, which is a sign that I am fully confused.  Can someone show me the error of my ways?

Link to comment
Share on other sites

I really don't know but I have a hunch, what happens if you use not 90 deg but a bit off 90?
It may lay in the conversion to rot

Edit:
I have thought a bit more about it
It can't be right to subtract the local rotation, shouldn't it be the object's(the prim's global) rotation?

llSitTarget(<0.0,0.0,-2.0>,llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD)/llGetRot());

Link to comment
Share on other sites


Dora Gustafson wrote:

I really don't know but I have a hunch, what happens if you use not 90 deg but a bit off 90?

It may lay in the conversion to rot

Hmmm... I hadn't thought of that, Dora.  Yes, if this was a sort of gimbal lock problem, that would be the right approach.  I'll try that as son as I get home again this evening.  Thanks.

Edit:

I have thought a bit more about it

It can't be right to subtract the local rotation, shouldn't it be the object's(the prim's global) rotation?

llSitTarget(<0.0,0.0,-2.0>,llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD)/llGetRot());

I did try that. In fact, that's what I tried first, because it seemed the most logical solution.  It doesn't work any better.  That is, I can change the Euler vector to make it work when my object is in one orientation, but I still sit upside down when I change the object's orientation.

Link to comment
Share on other sites

Could you not just use another prim as a pose ball and link it as the root? This way you would not have to add any extra scripting to be read and carried out but it would cost a prim. I usually make a 'thing', link it all then make a new pose ball, edit it, sit on it and move it to where the position of my av looks good, stand and link it as root, then edit linked part to make the pose ball prim invisible.

Link to comment
Share on other sites

if east == +x, north == +z, and down == +y...

so default (for your purpose) prim axis is rotated -90 around the X axis....

which would put your avatar at default east, with their head north. to correct you'd need two axis rotations...

so I believe that rotation should be <90, 0, 90> (here's hoping)

 

(and I can see how you got your 90 Z only axis figure, by derotating the offset and then applying needed rots, to get it facing north, but you have to reapply the reverse of the x adjustment)

Link to comment
Share on other sites

Nice idea, but not in this case.  Not only would that add an unnecessary pose ball (which I swore off a couple of years ago), but I'd have the same problem if I did use a pose ball.  Whether the llSitTarget script is in the root prim of my object or in a linked pose ball I'd still have to define the orientation of the sit relative to global axes.

Link to comment
Share on other sites

btw, my assumption was that the sit target is in the root.... local and global axis are the same for roots, because "global" is the "local" parent frame for the root....the parent frame for a child is the root, so it can be potentially different. if you just substitue the word "local" with "parent" it becomes much more clear, since the region is always the parent of all roots.

Link to comment
Share on other sites

I think I have probably tried that in my many empirical tests, Void, but I can't swear to it.  I'm away from the house for the afternoon, letting my brain cool down, but I'll try that again tonight.  It still doesn't explain why that solution doesn't stick when I turn my object completely around. I would have expected the sit target's orientation to track with the object's.

Link to comment
Share on other sites


Void Singer wrote:

btw, my assumption was that the sit target is in the root.... local and global axis are the same for roots, because "global" is the "local" parent frame for the root....the parent frame for a child is the root, so it can be potentially different. if you just substitue the word "local" with "parent" it becomes much more clear, since the region is always the parent of all roots.


True. In retrospect, that's why it didn't really make any difference whether I used llGetRot or llGetLocalRot.  My script is in the root.

Link to comment
Share on other sites

Innula, that was just the kick in the pants that I needed.  Thank you.  I must have been half asleep this morning.  I somehow got it into my head to subtract the object's global rotation from the Euler vector.  Don't ask why.  Just one of those days......

It's working fine now.

Link to comment
Share on other sites

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