Jump to content

Recommended Posts

Posted (edited)

just wonderin if anyone has a rot lookat thing that doesn't rotate the y axis?

in the pic below, you can see the tilt.

5c8c740a663db518afada15b7935e027.jpg

 

I'm using this, so far..

vector pos;
vector tpos; 
vector Target;
key    uuid;

default
{
    state_entry()
    {     
    }
    touch_start(integer total_number)
    {  uuid = llDetectedKey(0);
       llSetTimerEvent(0.2);  
    }   
    timer()
    {  list details = llGetObjectDetails(uuid, ([OBJECT_POS]));
       tpos = llList2Vector( details, 0);      
       pos  = llGetPos();    
       llRotLookAt( llRotBetween( <1.0, 0.0, 0.0>, llVecNorm( tpos - pos ) )  , 1.0, 0.5 );  
    }
}

 

Edited by Xiija
  • Xiija changed the title to rot look at - constrain on 2 axis... how to?
Posted (edited)

replacing llSLPPF with rotLookAt should be pretty straight-forward:

// search
llSetLinkPrimitiveParamsFast(0,
    [   PRIM_ROTATION, (ZERO_ROTATION/rINTRINSIC)*look
    ]);
// replace
llRotLookAt((ZERO_ROTATION/rINTRINSIC)*look, 1.0, 0.5);

would probably work.

Edited by Quistess Alpha
Posted (edited)

I'm terrible at rotations,

is there any way to just adjust the Y value to zero after the main rotation is done?

... either that or do a basic lookat, then adjust the X value to point to the height of the target?

Edited by Xiija
  • Confused 1
Posted
19 minutes ago, Wulfie Reanimator said:

Also, completely unrelated to everything but I'm super curious, what's this code indentation style from?

I didn't even notice. I favor the old C/C++ style where the "{" is on the same line as the relevant code.

Posted (edited)
1 hour ago, Wulfie Reanimator said:

She wants to do this: (keep the Y-plane horizontal)

Which is basically done exactly as you have it in your animation, just you have to calculate the angles manually. The relevant calculation from what I linked to above (with some more comments):

// where direction is the vector pointing from the object to the target to look at.
rotation look = 
   llAxisAngle2Rot(<0,1,0>, -llAtan2(direction.z,llVecMag(<direction.x,direction.y,0>)) )* // y-axis, angle on the z,x plane.
   llAxisAngle2Rot(<0,0,1>, llAtan2(direction.y,direction.x) ) ; // z-axis, angle on the x,y plane
// rotates on (local==global) z axis and then the local y-axis. (which is the same as global y then global z)

A bit annoying that constructing this requires a bit of trig and maybe drawing a few diagrams to understand why it is what it is, but it works (assuming I get what we're looking for)

1 hour ago, Wulfie Reanimator said:

Also, completely unrelated to everything but I'm super curious, what's this code indentation style from?

from copy-pasting and being too lazy to fix. I agree, not a great indentation, but it didn't seem bad enough to go back and edit the post.

Edited by Quistess Alpha
  • Like 2
Posted
4 minutes ago, Quistess Alpha said:

from copy-pasting and being too lazy to fix. I agree, not a great indentation, but it didn't seem bad enough to go back and edit the post.

No no, your use of this style is way too consistent to be lazy! For example this long script from a couple months back, but all of your recent code matches.

Hopefully @Xiija will be happy with the example you gave, as it does exactly what she wants.

  • Like 1
Posted (edited)
16 minutes ago, Wulfie Reanimator said:

your use of this style is way too consistent to be lazy!

Oh, I usually try for Horstmann especially in forum posts where having needless mostly blank lines makes me feel like I'm taking up too much space. but I'm not religious about it, in that example for instance, the do statement is out of style.
ETA: also, In the abstract, I like tabs over spaces, but the in-world editor uses spaces and imports scripts with tabs badly, so, whatever the in-world defaults to for spaces (4 probably) for indent levels.

Edited by Quistess Alpha
  • Like 1
  • Thanks 1
Posted (edited)

tysm all, seems to work good :)

as for styles,  I use Horstmann in SL, and K&R when i code js :P

 

the finished code ...
 

vector   pos;
vector   tpos; 
vector   direction;
key      uuid;
default
{
    state_entry()
    {     
    }
    touch_start(integer total_number)
    {  uuid = llDetectedKey(0);
       llSetTimerEvent(0.25);  
    }   
    timer()
    {  list details  = llGetObjectDetails(uuid, ([OBJECT_POS]));
       tpos          = llList2Vector( details, 0);      
       pos           = llGetPos();      
       direction     = tpos - pos;
       rotation look = llAxisAngle2Rot(<0,1,0>, -llAtan2(direction.z,llVecMag(<direction.x,direction.y,0>)) )* 
                       llAxisAngle2Rot(<0,0,1>, llAtan2(direction.y,direction.x) ) ;  
       
       llSetLinkPrimitiveParamsFast(0,
        [   PRIM_ROTATION,  look
        ]);
    }
}

 

Edited by Xiija
  • Thanks 1

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...