Jump to content
VirtualKitten

problems setting two links to absolute degree position

Recommended Posts

Hi everyone I have been posting in LSL scripting groups hopeful for a solution and am starting to believe we are loosing a generation of scripters that i am supposed to fill their shoes one-day.

My problem is with a rotation I am using the following script from an brilliant person on LSL who has moved onto other ventures. This was her creation . a friend Zambe made this gif for me showing what i require it to do:  https://gyazo.com/055061a745dd16534dad968c9a6943f9

The problem is that upon asking several key scripters they all returned what i already had , which sequentially reads the position of an object and adds a rotation to it. 

This is unhelpful as one cal loose track of rotation easily and the only answer was to capture the previous rotation angle and move forward with next angle by deleting the previous . This would work but is no rotation solution I feel you should be able to set a llRotUp() option on the pink axis and then move  from this ZERO_ROTATION to a new absolute angle now this problem is compounded by two boxes which have to stay synced to each other and both need adjustment  as below:

float rotClickAngle = 5;

do_rotate(){
    list L = llGetLinkPrimitiveParams(link_axis,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Axis = llList2Rot(L,0);
    vector posRoot2Axis = llList2Vector(L,1);
    vector axisAxis=<0,0,1>*rotRoot2Axis;
    rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, rotClickAngle *DEG_TO_RAD);
    // for body.
    L = llGetLinkPrimitiveParams(link_box1,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Body = llList2Rot(L,0);
    vector posRoot2Body = llList2Vector(L,1);
    rotation newrotRoot2Body = rotRoot2Body * rotClick_inRootFrame;
    vector offsetBody_inRootFrame = posRoot2Body - posRoot2Axis;
    vector newoffsetBody_inRootFrame = offsetBody_inRootFrame* rotClick_inRootFrame;
       //Beam.
    L = llGetLinkPrimitiveParams(link_box2,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Beam = llList2Rot(L,0);
    vector posRoot2Beam = llList2Vector(L,1);
    rotation newrotRoot2Beam = rotRoot2Body * rotClick_inRootFrame;
    vector offsetBeam_inRootFrame = posRoot2Beam - posRoot2Axis;
    vector newoffsetBeam_inRootFrame = offsetBeam_inRootFrame * rotClick_inRootFrame;
    
    llSetLinkPrimitiveParamsFast(1,[
         PRIM_LINK_TARGET,link_box1,PRIM_ROT_LOCAL,newrotRoot2Body,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBody_inRootFrame,
         PRIM_LINK_TARGET, link_box2,PRIM_ROT_LOCAL,llEuler2Rot(<-90,0,0>*DEG_TO_RAD)*newrotRoot2Beam,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBeam_inRootFrame]);
}

 

I would be grateful for some help as some day i am going to have to explain this myself :)

Share this post


Link to post
Share on other sites
Posted (edited)

I don't quite understand what you're asking.

Does the code actually do what you want? Do you just want to understand what it does? Or does it not do what you want and you need something changed?

Edited by Wulfie Reanimator

Share this post


Link to post
Share on other sites

Don't feel too frustrated by the fact that you don't understand how rotations work.  If you start comparing notes with other scripters, I think you'll find that we've all been there (and still find ourselves in rotation hell from time to time).  I can only think of a small number of scripters (Void Singer, Dora Gustafson, Grandma Bates, .... ) who seem to have reached rotation Nirvana. The quest to get there yourself, though, is a powerful motivation.

I'm not sure how much enlightenment you may get from it, but take a look at the short example that Chalice Yao posted several years ago when someone posted a challenge related to yours >>> https://www.virtualverse.one/forums/threads/kept-simple-rotate-object-towards-another-object.178/  She's describing a simpler setup than yours, because she's dealing only with the case where the Z axis is vertical.  Still, it might help.

  • Like 1

Share this post


Link to post
Share on other sites

algorithmically the OP posted code is pretty good as wrote. The code could be inlined a little to reduce the code but as a algorithm is a sound design

read the exact rot with a function call. Calculate the new next rot. Write the new next with a function call. Repeat

if we don't do this exact read-write with function calls then we can get prim drift due to rounding errors. Similar to the drift we get with KFM

Share this post


Link to post
Share on other sites

Hi , everyone thank you for the replies , yes the code does function but not how I want it too . It takes an angle in rotClickAngle repeated calls to do_rotate make these two linked object rotate about pink axis however if you look at this closely and every other example I have seen they all work by getting the position of the two prim and move them forward incrementing the position so for example:

1.  if rotClickAngle = 10 , the two objects rotate ten around z axis of pink axis rod and ends up at 10 degrees

2.   if rotClickAngle = 20 , is then applied the two objects rotate 20 degrees  further around z axis of pink axis rod and ends up at 30 degrees.

3.   if rotClickAngle = 10 , the two objects rotate ten degrees further  around z axis of pink axis rod and ends up at 40 degrees.

NOT USING ABSOLUTE ROTATIONS

I had to remember last-rotation  and subtract this angle from the first to get an absolute position i.e 20 -10 gives rotation at 2.  of 20 degrees  however this does depend on object starting at RotUp() and is not really helpful. without a starting pint of 0 being at llRotUP().

I have received some advice on ZERO_ROTATION but could not currently  understand how to apply it to my code as i think this is maybe the fiddly bit i am missing  and wondered if it would help as a reverse, but all the examples i received was not helpful and worked as my code above . I wonder if this is clear  what i wanted to do now as in ABSOLUTE ROTATIONS which this code I put up does not do.

i hope some one is able to help as its very frustrating  and i am eager to learn . Molly i did construct it with just using lists  and non variables but this runs slower than extracting to variables :) As i tried both, Rolig yes I know but we need to maintain knowledge in LSL otherwise we will loose creativity please note this is rotating two objects not one around a axis all being child links :) It is a challenge i realize this however there need to be good examples :)

Thanks I am hopeful that this can be done better.

 

Share this post


Link to post
Share on other sites
Posted (edited)

Oh, I get it now. You want the objects to not move if the function is called repeatedly with the same angle.

I'd also appreciate an answer then, because I asked the same question some time ago and nobody had the answer back then. 

I might be able to figure it out now, I have an idea in my head, but no time to get on SL to try it. 

Edited by Wulfie Reanimator

Share this post


Link to post
Share on other sites
Posted (edited)

If you want to add a rotation you need to multiply the quaternions.

 

You need to change this line:

 

 

    // rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, rotClickAngle *DEG_TO_RAD);
    rotation rotClick_inRootFrame = llEuler2Rot(<0, 0, rotClickAngle> *DEG_TO_RAD);

 

Edited by Sabrina Tamerlane

Share this post


Link to post
Share on other sites

Sabrina thanks if this is the bit i do not understand at presence what is the difference here between: 

rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, rotClickAngle *DEG_TO_RAD); and 
rotation rotClick_inRootFrame = llEuler2Rot(<0, 0, rotClickAngle> *DEG_TO_RAD);

please in lay persons terms as this made no difference  to what it did perceived watching two next to each other I expected one with this change  in this to set it position and stay at angle there it still moves up incrementing like other when I specify an angle :). Thank you for your assistance . 

Wulfie yes thats it :)

 

Share this post


Link to post
Share on other sites
Posted (edited)

I was wrong about llAxisAngle2Rot, you need that one to get the correct rotation.

Okay, rotations are very easy to understand when they are expressed in Euler angles (X, Y, Z) but they are very hard to compute that way. So we use quaternions instead that are very hard to understand but very easy to compute because you simply need to multiply quaternions to add rotations.

So, for example, if you want to rotate 30° along z axis, you will first calculate the vector, so it is <0, 0, 1> * 30.0 * DEG_TO_RAD, because the angles are expressed in radians. And then you use llAxisAngle2Rot to convert this vector into a quaternion. You can also write <0, 0, 30.0> * DEG_TO_RAD.

Now that you have this, lets call this q30z = llAxisAngle2Rot(<0, 0, 30> * DEG_TO_RAD), any rotation that you have you can make it rotate 30° along Z axis by multiplying it with q30z.

You see that in your code you have:

  vector newoffsetBody_inRootFrame = offsetBody_inRootFrame* rotClick_inRootFrame;

so if you want to rotate it 30° along z axis, you will use offsetBody_inRootFrame* q30t

If you don't want to add a rotation, but instead rotate by a given amount, you will need to save the rotations at the start of the program then apply the rotations from that point:

  list L = llGetLinkPrimitiveParams(link_axis,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Axis = llList2Rot(L,0);
    vector posRoot2Axis = llList2Vector(L,1);

This has to be removed and put in state_entry. Make rotRoot2Axis and posRoot2Axis global.

 

  L = llGetLinkPrimitiveParams(link_box1,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Body = llList2Rot(L,0);
    vector posRoot2Body = llList2Vector(L,1);

  L = llGetLinkPrimitiveParams(link_box2,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Beam = llList2Rot(L,0);
    vector posRoot2Beam = llList2Vector(L,1);

This too has to be made global.

 

 

Edited by Sabrina Tamerlane
llAxisAngle2Rot instead

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, VirtualKitten said:

Sabrina thanks if this is the bit i do not understand at presence what is the difference here between: 


rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, rotClickAngle *DEG_TO_RAD); and 

rotation rotClick_inRootFrame = llEuler2Rot(<0, 0, rotClickAngle> *DEG_TO_RAD);

please in lay persons terms as this made no difference  to what it did perceived watching two next to each other I expected one with this change  in this to set it position and stay at angle there it still moves up incrementing like other when I specify an angle :). Thank you for your assistance . 

Wulfie yes thats it :)

 

The difference in those two bits of code is that one uses a specific axis to rotate around (axisAxis), while the second always rotates around the world Z axis (axisAxis = <0,0,1>).

If the axis is supposed to be tilted, the second one will break. 

Edited by Wulfie Reanimator

Share this post


Link to post
Share on other sites
Posted (edited)

Yes Sabrina I understand the removal of the previous rotation angle and the rotation angle per rotation angle but didn't understand why you used llEuler2Rot instead of llAxisAnglle2Rot do they not do the same thing as my example did exactly same thing . From my scripting group NCIScripters a nice man gave me a script with numbers in it which are rotations and vectors he hard coded this used :

    rotation reverse = ZERO_ROTATION/axis;

    float angle = 100;
    rotation increment = llEuler2Rot(<0, 0, angle>*DEG_TO_RAD);
    rotation center_rot = reverse*llEuler2Rot(<0, 0, angle>*DEG_TO_RAD)*axis;

This did somehow achieve this movement . I do not understand how to implement this into my code to make it work but as unusable because of hard coding as everything i have tried makes the two boxes  work like this go wobbly and offline go off line.

Edited by VirtualKitten

Share this post


Link to post
Share on other sites

I have made a mistake with llAxisAnglle2Rot and edited my answer... Yes, you can subtract a rotation with divide just like you add with multiply.

You need to change your function do_rotate like this:

 

do_rotate(float angle){
    rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, angle *DEG_TO_RAD);
    // for body.
    vector offsetBody_inRootFrame = posRoot2Body - posRoot2Axis;
    vector newoffsetBody_inRootFrame = offsetBody_inRootFrame* rotClick_inRootFrame;
       //Beam.
    vector offsetBeam_inRootFrame = posRoot2Beam - posRoot2Axis;
    vector newoffsetBeam_inRootFrame = offsetBeam_inRootFrame * rotClick_inRootFrame;
    
    llSetLinkPrimitiveParamsFast(1,[
         PRIM_LINK_TARGET,link_box1,PRIM_ROT_LOCAL,newrotRoot2Body,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBody_inRootFrame,
         PRIM_LINK_TARGET, link_box2,PRIM_ROT_LOCAL,llEuler2Rot(<-90,0,0>*DEG_TO_RAD)*newrotRoot2Beam,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBeam_inRootFrame]);
}

The missing variables should be made global as I explained before.

I didn't test it so there may be errors, however this is the idea :)

Share this post


Link to post
Share on other sites

Hi Sabrina , thanks for your help i tried  from your example :

float rotClickAngle = 70;
do_rotate(){
    list L = llGetLinkPrimitiveParams(link_axis,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Axis = llList2Rot(L,0);
    vector posRoot2Axis = llList2Vector(L,1);
    vector axisAxis=<0,0,1>*rotRoot2Axis;
    L = llGetLinkPrimitiveParams(link_body,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Body = llList2Rot(L,0);
    vector posRoot2Body = llList2Vector(L,1);
    L = llGetLinkPrimitiveParams(link_beam,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Beam = llList2Rot(L,0);
    vector posRoot2Beam = llList2Vector(L,1);
    
    rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, rotClickAngle *DEG_TO_RAD);
    // for body.
    vector offsetBody_inRootFrame = posRoot2Body - posRoot2Axis;
    vector newoffsetBody_inRootFrame = offsetBody_inRootFrame* rotClick_inRootFrame;
       //Beam.
    vector offsetBeam_inRootFrame = posRoot2Beam - posRoot2Axis;
    vector newoffsetBeam_inRootFrame = offsetBeam_inRootFrame * rotClick_inRootFrame;
    rotation newrotRoot2Body = rotRoot2Body * rotClick_inRootFrame; 
    rotation newrotRoot2Beam = rotRoot2Beam * rotClick_inRootFrame; 
    llSetLinkPrimitiveParamsFast(1,[
         PRIM_LINK_TARGET,link_body,PRIM_ROT_LOCAL,newrotRoot2Body,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBody_inRootFrame,
         PRIM_LINK_TARGET, link_beam,PRIM_ROT_LOCAL,llEuler2Rot(<-90,0,0>*DEG_TO_RAD)*newrotRoot2Beam,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBeam_inRootFrame]);

}

Which resulted in box 2 rotating to back of box1 only when it was run and the box one rotating in the wrong axis  , I am a bit confused as to why which then box1  rotate wrong axis?

I tried removing  llEuler2Rot(<-90,0,0>*DEG_TO_RAD)* i tried removing  which caused it not to move at all  with changes to  the only thing that seemed to be moving was box 2  not moving and  box 1 spinning? i think something is broken with your code. Thanks.

 

Share this post


Link to post
Share on other sites
Posted (edited)

Lines like these need to go away from the function and put in state_entry for example, and you need to make the rotation and vector globals as I explained before.

  list L = llGetLinkPrimitiveParams(link_axis,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Axis = llList2Rot(L,0);
    vector posRoot2Axis = llList2Vector(L,1);

 

 

Edited by Sabrina Tamerlane

Share this post


Link to post
Share on other sites
Posted (edited)

Um Why do they need to be in state_entry, the axis moves, did i not explain that sorry. Also the box one is rotating upon its center diameter not as it was before. box 2 is flipping in front or behind box 1.

I am not sure this is helping as mcarp Mavendorf said i needed these  lines above to be included:

rotation reverse = ZERO_ROTATION/axis;

    float angle = 100;
    rotation increment = llEuler2Rot(<0, 0, angle>*DEG_TO_RAD);
    rotation center_rot = reverse*llEuler2Rot(<0, 0, angle>*DEG_TO_RAD)*axis;

Sadly I  don't see this in your code and I could not implement it in it so think i may not have understood at all?

my original code :

 

float rotClickAngle = 5;

do_rotate(){
    list L = llGetLinkPrimitiveParams(link_axis,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Axis = llList2Rot(L,0);
    vector posRoot2Axis = llList2Vector(L,1);
    vector axisAxis=<0,0,1>*rotRoot2Axis;
    rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, rotClickAngle *DEG_TO_RAD);
    // for body.
    L = llGetLinkPrimitiveParams(link_box1,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Body = llList2Rot(L,0);
    vector posRoot2Body = llList2Vector(L,1);
    rotation newrotRoot2Body = rotRoot2Body * rotClick_inRootFrame;
    vector offsetBody_inRootFrame = posRoot2Body - posRoot2Axis;
    vector newoffsetBody_inRootFrame = offsetBody_inRootFrame* rotClick_inRootFrame;
       //Beam.
    L = llGetLinkPrimitiveParams(link_box2,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Beam = llList2Rot(L,0);
    vector posRoot2Beam = llList2Vector(L,1);
    rotation newrotRoot2Beam = rotRoot2Body * rotClick_inRootFrame;
    vector offsetBeam_inRootFrame = posRoot2Beam - posRoot2Axis;
    vector newoffsetBeam_inRootFrame = offsetBeam_inRootFrame * rotClick_inRootFrame;
    
    llSetLinkPrimitiveParamsFast(1,[
         PRIM_LINK_TARGET,link_box1,PRIM_ROT_LOCAL,newrotRoot2Body,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBody_inRootFrame,
         PRIM_LINK_TARGET, link_box2,PRIM_ROT_LOCAL,llEuler2Rot(<-90,0,0>*DEG_TO_RAD)*newrotRoot2Beam,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBeam_inRootFrame]);
}

It worked from my old code above  but as i stated was not setting a absolute angle for the movement of the two boxes  and was incrementing their movement each time. Your code does not so far do the same thing at all and spins things in strange directions ?

 

 

Edited by VirtualKitten
To add more

Share this post


Link to post
Share on other sites
Posted (edited)
integer link_axis = 3; // set this to real prim number
integer link_box1 = 2; // set this to real prim number
integer link_box2 = 4; // set this to real prim number
float rotClickAngle = 5;

rotation rotRoot2Axis;
vector posRoot2Axis;
vector axisAxis;

rotation rotRoot2Body;
vector posRoot2Body;
    
rotation rotRoot2Beam;
vector posRoot2Beam;


do_rotate(float angle){
    rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, rotClickAngle *DEG_TO_RAD);
    // rotation rotClick_inRootFrame = llEuler2Rot(<0, 0, angle> *DEG_TO_RAD);
    
    // for body.
    rotation newrotRoot2Body = rotRoot2Body * rotClick_inRootFrame;
    vector offsetBody_inRootFrame = posRoot2Body - posRoot2Axis;
    vector newoffsetBody_inRootFrame = offsetBody_inRootFrame* rotClick_inRootFrame;
       //Beam.
    rotation newrotRoot2Beam = rotRoot2Body * rotClick_inRootFrame;
    vector offsetBeam_inRootFrame = posRoot2Beam - posRoot2Axis;
    vector newoffsetBeam_inRootFrame = offsetBeam_inRootFrame * rotClick_inRootFrame;
    
    llSetLinkPrimitiveParamsFast(1,[
         PRIM_LINK_TARGET,link_box1,PRIM_ROT_LOCAL,newrotRoot2Body,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBody_inRootFrame,
         PRIM_LINK_TARGET, link_box2,PRIM_ROT_LOCAL,llEuler2Rot(<-90,0,0>*DEG_TO_RAD)*newrotRoot2Beam,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBeam_inRootFrame]);
} 

integer rotating = FALSE;

default
{
    state_entry()
    {
    list L = llGetLinkPrimitiveParams(link_axis,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotRoot2Axis = llList2Rot(L,0);
    posRoot2Axis = llList2Vector(L,1);
    axisAxis=<0,0,1>*rotRoot2Axis;

    L = llGetLinkPrimitiveParams(link_box1,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotRoot2Body = llList2Rot(L,0);
    posRoot2Body = llList2Vector(L,1);
    
    L = llGetLinkPrimitiveParams(link_box2,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotRoot2Beam = llList2Rot(L,0);
    posRoot2Beam = llList2Vector(L,1);

    }

    touch_start(integer total_number)
    {
        if (!rotating) {
            rotating = TRUE ;        
            llSetTimerEvent(1.0) ;
        }
        else {
            rotating = FALSE ;        
            llSetTimerEvent(0.0) ;
        }
    }
    
    timer() 
    {
        rotClickAngle += 5 ;
        if (rotClickAngle > 359.0) {
            rotClickAngle = 0;
        }
        
        do_rotate(rotClickAngle) ;
    }    
}

They need to be in state_entry so that you would rotate from the original position, and not increment it.

Edited by Sabrina Tamerlane
llAxisAngle2Rot instead

Share this post


Link to post
Share on other sites

Sabrina Hi, thanks for your reply however  Your code still doesnt work it rotates box 1 in a z axis now but also rotates he box2 about the centre  and about itself too  not at its end like my first script i showed you.  This version also increments and does not set an absolute angle and is incremental like mine :(

 

 

I am not sure this is helping as mcarp Mavendorf said i needed these  lines above to be included: 

rotation reverse = ZERO_ROTATION/axis;

    float angle = 100;
    rotation increment = llEuler2Rot(<0, 0, angle>*DEG_TO_RAD);
    rotation center_rot = reverse*llEuler2Rot(<0, 0, angle>*DEG_TO_RAD)*axis;

His version worked in his own example,  and I could not re code it with actual prim originated positions successfully as it was hard wired with vectors and rotations as below as you see :

run()
{
    float originalsize = 0.500000;
    vector size = llList2Vector(llGetLinkPrimitiveParams(1, [PRIM_SIZE]), 0);
    float scale = size.x/originalsize;
    
    vector axispos = <-0.10080, 0.17149, 1.06105>*scale;
    vector centerboxpos = <-0.24112, 0.41020, 1.73940>*scale;
    vector outsideboxpos = <-0.34071, 0.90477, 1.54477>*scale;    
    
    rotation axis = <-0.17578, -0.07861, 0.10860, 0.97526>;
    rotation reverse = ZERO_ROTATION/axis;

    float angle = 120;
    rotation increment = llEuler2Rot(<0, 0, angle>*DEG_TO_RAD);
    
    rotation centerrot = reverse*increment*axis;
    
    vector outsideboxposoffset = centerboxpos + (outsideboxpos - centerboxpos)*centerrot;    
    
    llSetLinkPrimitiveParamsFast(1, [PRIM_TEXT, "time: " + (string)time, <1, 1, 1>, 1,
        //PRIM_LINK_TARGET, axis, PRIM_POSITION, axispos, PRIM_ROT_LOCAL, <-0.17578, -0.07861, 0.10860, 0.97526>, //<-- axis came from here
        PRIM_LINK_TARGET, centerbox, PRIM_POSITION, centerboxpos, PRIM_ROT_LOCAL, <-0.17578, -0.07861, 0.10860, 0.97526>*centerrot,
        PRIM_LINK_TARGET, outsidebox, PRIM_POSITION, outsideboxposoffset, PRIM_ROT_LOCAL, <-0.17578, -0.07861, 0.10860, 0.97526>*centerrot  
        ]);
}

 

 

I hope this helps you :)

 

 

 

Share this post


Link to post
Share on other sites
Posted (edited)

I tried to un hard code this but this didn't work either  and made a mess of the boxs so i think we have t work off my coding and not supply different ones as its just not helping :):

run()
{
    float originalsize = 0.500000;
    vector data = llList2Vector(llGetLinkPrimitiveParams(1, [PRIM_SIZE,PRIM_POS_LOCAL,PRIM_ROT_LOCAL]), 0);
    float scale = data.x/originalsize;
    
    vector axispos =llList2Vector(llGetLinkPrimitiveParams(axis, [PRIM_POS_LOCAL]), 0);//<-0.10080, 0.17149, 1.06105>*scale;
    vector center_box_pos = llList2Vector(llGetLinkPrimitiveParams(center_box, [PRIM_POS_LOCAL]), 0); //*scale;//<-0.24112, 0.41020, 1.73940>*scale;
    vector outside_box_pos = llList2Vector(llGetLinkPrimitiveParams(outside_box, [PRIM_POS_LOCAL]), 0);//*scale;// <-0.34071, 0.90477, 1.54477>*scale;    
    
    rotation axis = llList2Rot(llGetLinkPrimitiveParams(axis,[PRIM_ROT_LOCAL]), 0); //<-0.17578, -0.07861, 0.10860, 0.97526>;
    rotation reverse = ZERO_ROTATION/axis;

    float angle = 100;
    rotation increment = llEuler2Rot(<0, 0, angle>*DEG_TO_RAD);
    rotation center_rot = reverse*llEuler2Rot(<0, 0, angle>*DEG_TO_RAD)*axis;
    
    //vector outside_box_pos_offset = center_box_pos + (outside_box_pos - center_box_pos)*center_rot;    
    vector _box1_pos_offset = (center_box_pos - axispos)*center_rot;// (outside_box_pos - center_box_pos)*center_rot;
    vector _box2_pos_offset = (outside_box_pos - axispos)*center_rot; //(outside_box_pos - center_box_pos)*center_rot;   
    llSetLinkPrimitiveParamsFast(1, [PRIM_TEXT, "time: " + (string)time, <1, 1, 1>, 1,
       // PRIM_LINK_TARGET, axis, PRIM_POSITION, outside_box1_pos_offset, PRIM_ROT_LOCAL, axis, //<-0.17578, -0.07861, 0.10860, 0.97526>, //<-- axis came from here
        PRIM_LINK_TARGET, center_box, PRIM_POS_LOCAL, _box1_pos_offset, PRIM_ROT_LOCAL, center_rot /*<-0.17578, -0.07861, 0.10860, 0.97526>*/*center_rot,
        PRIM_LINK_TARGET, outside_box, PRIM_POS_LOCAL, _box2_pos_offset, PRIM_ROT_LOCAL, center_rot/*<-0.17578, -0.07861, 0.10860, 0.97526>*/*center_rot  
        ]);
}

Edited by VirtualKitten
NA

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, VirtualKitten said:

  This version also increments and does not set an absolute angle and is incremental like mine :(

 

 

The increment is in the timer, you can set any angle that you wish. If it does not work with your prims, make sure to set the right numbers.

 

For example, if you would like to rotate 45° then you would call:

do_rotate(45.0);
Edited by Sabrina Tamerlane
added example

Share this post


Link to post
Share on other sites

Please NOTE!  It didn't work your version Sabrina  as I stated earlier!  It rotated the box one up on its center and the second box  about its center too. This is not  the same my script does  (see https://gyazo.com/055061a745dd16534dad968c9a6943f9) is what mine does Your does not  do this and your script  is not working the same as mine in first message  please note? I tried it in the same script in  my script that ran in perfectly incrementing  yours did not do this  and is malfunctioning .  I did not place the other parts state entry as it was not working  to even do same thing as mine   I added it as follows please read my answers thank you:

float rotClickAngle = 70;
do_rotate(){
    list L = llGetLinkPrimitiveParams(link_axis,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Axis = llList2Rot(L,0);
    vector posRoot2Axis = llList2Vector(L,1);
    vector axisAxis=<0,0,1>*rotRoot2Axis;
    L = llGetLinkPrimitiveParams(link_body,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Body = llList2Rot(L,0);
    vector posRoot2Body = llList2Vector(L,1);
    L = llGetLinkPrimitiveParams(link_beam,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]);
    rotation rotRoot2Beam = llList2Rot(L,0);
    vector posRoot2Beam = llList2Vector(L,1);
    
 
    // rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, rotClickAngle *DEG_TO_RAD);
    rotation rotClick_inRootFrame = llEuler2Rot(<0, 0, rotClickAngle> *DEG_TO_RAD);
    
    // for body.
    rotation newrotRoot2Body = rotRoot2Body * rotClick_inRootFrame;
    vector offsetBody_inRootFrame = posRoot2Body - posRoot2Axis;
    vector newoffsetBody_inRootFrame = offsetBody_inRootFrame* rotClick_inRootFrame;
       //Beam.
    rotation newrotRoot2Beam = rotRoot2Body * rotClick_inRootFrame;
    vector offsetBeam_inRootFrame = posRoot2Beam - posRoot2Axis;
    vector newoffsetBeam_inRootFrame = offsetBeam_inRootFrame * rotClick_inRootFrame;
    
    llSetLinkPrimitiveParamsFast(1,[
         PRIM_LINK_TARGET,link_body,PRIM_ROT_LOCAL,newrotRoot2Body,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBody_inRootFrame,
         PRIM_LINK_TARGET, link_beam,PRIM_ROT_LOCAL,llEuler2Rot(<-90,0,0>*DEG_TO_RAD)*newrotRoot2Beam,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBeam_inRootFrame]);
}

 

 

Share this post


Link to post
Share on other sites
22 minutes ago, VirtualKitten said:

Please NOTE!  It didn't work your version Sabrina  as I stated earlier!  It rotated the box one up on its center and the second box  about its center too. This is not  the same my script does  (see https://gyazo.com/055061a745dd16534dad968c9a6943f9) is what mine does Your

 

 

https://gyazo.com/aedaf265a113c9bdc61b79e1ab9c7f83

As I said earlier, if it does not work for you, double check the prim numbers at the start of the script :)

Share this post


Link to post
Share on other sites

Sabrina Thank you for your response  all my prim numbers work with my script at the start of this request for help . 

THIS CODE YOU SENT DOES NOT FUNCTION MOVING HE ITEMS IN THE LINK IE THE TWO BOXES > PLEASE SEE MY SCRIPT FOR PROPER FUNCTIONALITY I HAVE SENT YOU IN WORLD EXAMPLE OF MY CODE WORKING

Share this post


Link to post
Share on other sites

I have modified the script so that it would collect the right link numbers, and it also restores the starting position on touch. There is an issue because the position is changed. I am not available to look at it right now but it should not be too hard to fix :)

Share this post


Link to post
Share on other sites

@Sabrina , I sent you the example in world . You can drop it into script and use the links in it to see it doesn't work for yourself.

Everyone else, please if you can help @Wulfie with my code in initial message  requesting help and additional post below.

Can you help as  as mcarp Mavendorf said i needed these  lines above to be included to make it have a zero start point at llRotUP() : 

rotation reverse = ZERO_ROTATION/axis;

    float angle = 100;
    rotation increment = llEuler2Rot(<0, 0, angle>*DEG_TO_RAD);
    rotation center_rot = reverse*llEuler2Rot(<0, 0, angle>*DEG_TO_RAD)*axis;

 

Thank you I have asked this several times but am not getting any epigrammatic help?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...