Jump to content

llSetLinkPrimitiveParamsFast, Pos & Rot problem when resize


Rhemah
 Share

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

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

Recommended Posts

I'm trying to rotate and position child prims from its current rot&pos to another; however, when i use llScalebyfactor to resize it the pos&rot is ruined, can someone help me?

OriginalPosandRot(){
    llSetLinkPrimitiveParamsFast(2,[
    PRIM_POS_LOCAL,<0.06420, -0.13936, 0.02051>,
    PRIM_ROT_LOCAL,<0.97959, 0.19486, -0.04837, -0.00959>
    ]);
    llSetLinkPrimitiveParamsFast(3,[
    PRIM_POS_LOCAL,<-0.04510, 0.12622, 0.03101>,
    PRIM_ROT_LOCAL,<0.69950, 0.17172, 0.10364, 0.68590>
    ]); 
}

TempPosandRot(){
    llSetLinkPrimitiveParamsFast(2,[
    PRIM_POS_LOCAL,<-0.02694, -0.13941, 0.00664>,
    PRIM_ROT_LOCAL,<-0.98022, 0.19539, 0.03016, -0.00898>
    ]);
    llSetLinkPrimitiveParamsFast(3,[
    PRIM_POS_LOCAL,<0.08319, 0.12573, -0.00209>,
    PRIM_ROT_LOCAL,<-0.68671, 0.11715, 0.15947, -0.69948>
    ]); 
}

// i also tried using PRIM_POSTION and PRIM_ROTATION for global pos& rot but it says here: http://wiki.secondlife.com/wiki/LlSetPrimitiveParams#llSetLinkPrimitiveParamsFast
that it will be broken for childprims, but i did tried it anyway and the effects are still the same
Link to comment
Share on other sites

That's what I would expect.  If you change the scale of an object, the local positions of parts of the object will all change.  Local rotations shouldn't, as long as the object rescales by the same factor on all three axes.  If you want to have the child prims move back and forth reliably between two positions after you've changed the scale of your object, you're going to have to do a bunch of math each time or store preset values of the local positions for a range of preset scale factors. If it were me, I'd go with storing presets.

Link to comment
Share on other sites

For me i don t see any mathematics :

 

scalebyfactor is in fact an homothetie with center , the center of the root prim .

So :

- it lets invariant the rotations centered on the root prim ; your rotations returned by PRIM_ROT_LOCAL  before the call of  scalebyfactor don t need to be changed after scalebyfactor

- it scales the transformations uniformely in the frame with center the root prim  ; so if you have scaled with scalebyfactor by X  , your posistions of your child prims returned by PRIM_POS_LOCAL   before the call of  scalebyfactor need to be multiplied by X  after scalebyfactor

- for the same reason , rotations and translations in coordinates region  ( so with a center who doesn t match with the center of the root prim ) should be avoided ( PRIM_POS , PRIM_ROTATION ) because the centers of coordinates are different , so the composition of transformations ( translation + rotation + homothetie ) may be complex

 

For instance 

OriginalPosandRot(){
llSetLinkPrimitiveParamsFast(2,[
PRIM_POS_LOCAL,<0.06420, -0.13936, 0.02051>,
PRIM_ROT_LOCAL,<0.97959, 0.19486, -0.04837, -0.00959>
]);
llSetLinkPrimitiveParamsFast(3,[
PRIM_POS_LOCAL,<-0.04510, 0.12622, 0.03101>,
PRIM_ROT_LOCAL,<0.69950, 0.17172, 0.10364, 0.68590>
]);
}

You scale the object by scalefactor = 3

Your object will have the new coordinates :
child 2 :
PRIM_POS_LOCAL = 3 * <0.06420, -0.13936, 0.02051>
PRIM_ROT_LOCAL = <0.97959, 0.19486, -0.04837, -0.00959>
child 3 :
PRIM_POS_LOCAL = 3 * <-0.04510, 0.12622, 0.03101>
PRIM_ROT_LOCAL = <0.69950, 0.17172, 0.10364, 0.68590>

Link to comment
Share on other sites

The operation is simple but only if the center of the root is the center of the resize operation. If that's not the case and if llScaleByFactor doesn't work like expected it is not the case - then things become ugly.

The ll functions are all designed to work relative to the root's center. If that is not wanted there are 3 choices.

1. Not so simple calculations for every prim.

2. Store presets and move/rotate to that presets.

3. Add another prim and make it the root. At exact the spot you need. If i't's in the way it's always possible to use hollow and cut path operations to get that prim out of the way without changing it's position.

 

  • Like 1
Link to comment
Share on other sites

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