Jump to content

Rotation of llRot2Fwd?


Moon Corrigible
 Share

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

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

Recommended Posts

Clearly I am missing something.

I want to be able to fire plungers from the bolster turret of my attached object pillow fort (obviously I am the height of maturity) and I want to avoid going into MouseLook to do so.  To elaborate a little: the pillow fort is an attached object which initiates an animation.   My avatar goes into an animation that *looks* like it is sitting but it does not actually sit - so I can roam around like a dalek in my pillow fort.  (see - icon of maturity I tell you!).   And my avatar is completely surrounded by pillows so seeing exactly which direction my nose is pointing is not  really easy.  The bolster turret is a child prim on the pillow fort - not the root prim of the attachment.  I am using:

Fire()
{
    float speed = 10.0;
    vector pos = llGetPos() + (<1.5, 0, 0> * llGetRot());
    vector vel = speed * llRot2Fwd(rot);
    rotation rot = llEuler2Rot(<0, 0, 270> * DEG_TO_RAD) * llGetRot();
    llPlaySound("dalekgun", 1.0);
    llRezObject(bullet, pos, vel, rot, 0);
}

This fires the plungers just fine.  But it seems to have little relation to the orientation of the linked, attached bolster turret.  Sometimes it lines up perfectly, sometimes it doesnt.  I would love to be able to reorient the bolster turret using llSetLinkPrimitiveFast.

So what I need is to figure out how to translate llRot2Fwd into a rotation that I can apply to the child prim of an attachment (I assume using llSetLinkPrimitiveFast)

Somehow I just can not see the forest for the trees on this so any help would be greatly appreciated!  Thanks in advance!

 

Link to comment
Share on other sites

I'm not sure if it is the whole story, but I'm getting encouraging results with this (hard-coded stuff may need altering, obviously; I was trying to get the rotation right.  This is called from the child prim that's firing the missile.

 

default{    state_entry()    {        //  llSay(0, "Hello, Avatar!");    }    touch_start(integer total_number)    {        rotation wearerRot = llGetRootRotation();        rotation rootRot = llList2Rot(llGetLinkPrimitiveParams(1,[PRIM_ROT_LOCAL]),0);        rotation myRot =llList2Rot(llGetPrimitiveParams([PRIM_ROT_LOCAL]),0);        vector pos = llGetPos();        vector offset=<0.0,0.0,0.75>;        // rotation rot = llList2Rot(l,1);             // rotation rot = llGetRot()/myRot;        rotation r90=llEuler2Rot(<0.0,90.0,0.0>*DEG_TO_RAD);        rotation combinedRot = myRot*rootRot*wearerRot;        vector force =<10,0,0>;        llRezAtRoot(            llGetInventoryName(INVENTORY_OBJECT,0),            pos+offset*combinedRot,            force/r90*combinedRot,            ZERO_ROTATION/r90*combinedRot,            99);    }}

 

It's never going to be quite right, I think, because all you can calculate is how the avatar is rotated in fact, not how any AO she's wearing may affect how she appears to be rotated, and also because calculating an avatar's rotation from an attachment (unless they're in mouselook) is not completely accurate -- it's often a couple of degrees out, I think.

ETA -- I am having problems working out the offset (other than hard-coding it) if I have the root prim of the attachment rotated at an arbitrary angle.   But at least I seem to have the plunger heading in the expected direction.

Link to comment
Share on other sites

Oh that is brilliant!!  You are the best thing since sliced bread!!  

I dont need or want it to be really accurate - I'm throwing plungers - hehehe.  But  I never would have thought of altering the direction the plunger is thrown in - I was too hyper focused on alterning the direction the pillow was pointing.  Plus I was all sorts of confused about which rotation was which.

 

Thank you so much!!!

 

Link to comment
Share on other sites

Hmmmm....  OK here is my issue:

You know how, if you use your arrow keys to rotate your avatar, there is a little bit of play there?  If you start with your camera directly in back of your avatar you can use the arrow keys a little bit left or right without actually moving the avatar - this moves your camera around and changes the direction of "Forward" but not *exactly* where your avatar's nose is pointing.  Put another way,  if you use the arrow keys to rotate your avatar, and just tap them a couple of times, the camera moves but the avatar doesnt *quite* face in that direction until the imcrement gets big enough and then it turns the whole avatar a bit.

If the camera is directly behind the pillow fort then the plungers fire out wonderfully forward and dahlek victory is assured (I'm such a nerd).   But if I find I am off a little bit and just tap the arrow keys a couple of times - the plungers come out in the new 'Forward' direction but the turret is still facing in the original position.   I do have an 'aim' command so I could easily just change the rotation of the turret alone to point to where the plungers will go.  But with my previous code and this new code, when I try to translate the vector at which the plungers will fire into a rotation to set the turret to, I keep getting the turrets rotation in relationship to the root prim of the attached pillow fort  (even though I thought the root prim was suppose to be the avatar for an attachment) when what I need is the rotational equivalent of forward for the avatar - not necessarily the attached object

Now none of this is a big deal obviously - I'm firing plungers not solving world  hunger *grin*.  It just feels like I am missing something obvious.

 

 

 

Link to comment
Share on other sites


Moon Corrigible wrote:

, I keep getting the turrets rotation in relationship to the root prim of the attached pillow fort  (even though I thought the root prim was suppose to be the avatar for an attachment) when what I need is the rotational equivalent of forward for the avatar - not necessarily the attached object
 

 

I think you need llRot2Fwd(llGetRootRotation()) if you're attempting to ascertain the avatar's rotation with a script in a child prim on an attachment.

See http://wiki.secondlife.com/wiki/Rotation#Single_or_Root_Prims_vs_Linked_Prims_vs_Attachments

Link to comment
Share on other sites

Sorry, I expressed myself unclearly.

If you want to use a script in the child prim of an attachment to determine the rotation of the avatar wearing it, then you need llGetRootRotation().   This will rez a prim 1 metre in front of the avatar, when called from a child prim, no matter how either the child prim or root prim of the attachment is rotated or placed:

default{    state_entry()    {       // llSay(0, "Hello, Avatar!");    }    touch_start(integer total_number)    {       vector pos = llGetRootPosition();//avatar's position;       rotation rot = llGetRootRotation();//avatar's rotation       llRezAtRoot(       llGetInventoryName(INVENTORY_OBJECT,0),       pos+llRot2Fwd(rot), // or pos + <1.0,0.0,0.0>*rot        ZERO_VECTOR,        rot,        99);       }}

 

  

 

Link to comment
Share on other sites

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