Jump to content

Moving (and rotating) a link relative to its own position


Beowulf Zessinthal
 Share

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

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

Recommended Posts

Hello, Im sure ive asked a similar question in the past, but i cannot get this one to work. 

Im better at making diagrams so i thought i would post this while i beaver away for the answer :)

I need a child prim start position (whatever it is) to serve as a base for a different relative position (with both a pos and rot change).

Thanks for any help!

rotation query.jpg

Link to comment
Share on other sites

i thought i had it with this.. but it may be a bit off?

 

 

//Join 2 prims and add this to child 'gerbil' prim


vector startpos= <-0.217, -0.229, 0.070>;//start
rotation startrot= <0.0, 0.0, 0.0, 1.0>;//start
vector diffpos;//relative move
rotation diffrot= <1,1,1,1>;//relative move
vector jumppos= <-0.149, -0.229, 0.117>;//target
rotation jumprot= <0.0, 0.317, -0.0, 0.948>;//target

   
default
{
    state_entry(){
        
    }
    
    touch_start(integer tch){

    startpos= (vector)llList2String( llGetLinkPrimitiveParams(LINK_THIS,[PRIM_POS_LOCAL]), 0);
    startrot= (rotation)llList2String( llGetLinkPrimitiveParams(LINK_THIS,[PRIM_ROT_LOCAL]), 0);

    llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL, startpos, PRIM_ROT_LOCAL, startrot]);
    llSetLinkPrimitiveParams(LINK_THIS, [PRIM_TEXT, "Start startposrot",<0,1,0>, 1]);
    llSleep(2);
    
        if(diffrot == <1,1,1,1>){//calculate the relative move if not already done
        diffrot= jumprot/startrot; 
        diffpos = (jumppos - startpos)/startrot;
        llOwnerSay("diffpos: "+ (string)diffpos);
        llOwnerSay("diffrot: "+ (string)diffrot);
        }
    
    llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL, startpos+ diffpos*startrot, PRIM_ROT_LOCAL, diffrot*startrot]);
    llSetLinkPrimitiveParams(LINK_THIS, [PRIM_TEXT, "Relative diffposrot try #1",<1,0,0>, 1]);
    llSleep(2);
    
    llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL, startpos, PRIM_ROT_LOCAL, startrot]);
    llSetLinkPrimitiveParams(LINK_THIS, [PRIM_TEXT, "Returned to startposrot",<1,1,1>, 1]); 
    }

}
 

Edited by Beowulf Zessinthal
may not be fully correct
Link to comment
Share on other sites

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