Christina Halpin Posted November 17, 2022 Share Posted November 17, 2022 In theory this rotates an obect 90 degrees around the z-axis. llTargetOmega(<.0,.0,1.0>,PI/(2.0*rotationtime),1.0); llSleep(rotationtime); I think the math is right, because it sometimes does 90 degrees. But it sometimes falls a little short (and then errors accumulate). Is there a way I can fix that? Otherwise, I could use a command that tells me which direction the object is facing. I think. (It should be in LlGetObjectDetails, but apparently is not.) Thanks. Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 17, 2022 Share Posted November 17, 2022 "Rotate" isn't exactly the right word in this context. llTargetOmega spins the object continually around the local axis that you define for it. If you simply want the object to turn 90 degrees and then stop, you ought to be using llSetRot or llSetLocalRot, or using appropriate parameters with llSetLinkPrimitiveParams. If you truly do want the object to spin around its local Z axis, or if you are using it in a script that creates a slow, smooth rotation, then you will indeed find that it's not 100% precise. You will end up with roundoff errors. For that reason, it's a good idea to end the movement by using llSetRot (or another appropriate function) to set the object's final rotation accurately. The problem is that llTargetOmega is doing its work client-side. As far as the servers are concerned, the object is not rotating at all. They will set the object's actual rotation as closely as possible (given the accumulated errors) when you stop llTargetOmega. You can get the object's current rotation with llGetLinkPrimitiveParams, using either PRIM_ROTATION or PRIM_ROT_LOCAL as appropriate. Then perform the target rotation, llEuler2Rot(<0.0,0.0,PI/2>) * current_rot, with the appropriate rotation function. 1 Link to comment Share on other sites More sharing options...
Christina Halpin Posted November 17, 2022 Author Share Posted November 17, 2022 Yes, I need a smooth motion. I thought llGetLinkPrimitiveParams gave me the spin rate. If it gives me facing direction, I can cope, I think. Thanks Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted November 17, 2022 Share Posted November 17, 2022 Key Framed Motion my be another option, depending on the scenario. float rotationtime = 2.0; default { touch_start(integer total_number) { llSetKeyframedMotion( [llEuler2Rot(<0,0,90> * DEG_TO_RAD), rotationtime], [KFM_DATA, KFM_ROTATION] ); } } Link to comment Share on other sites More sharing options...
Christina Halpin Posted November 17, 2022 Author Share Posted November 17, 2022 Ugh, actually I tried that before, and now I am running into the same problem. The following, and every variation I can think of, just gives me a zero rotation no matter which direction the object and I are facing. list templist = llGetObjectDetails( llGetKey(),[OBJECT_ROT] ); string rotobj = llList2String(templist,0); llOwnerSay ("facing towards " + rotobj); Link to comment Share on other sites More sharing options...
Christina Halpin Posted November 17, 2022 Author Share Posted November 17, 2022 thanks Fenix. I had tried a more complicated version, and yours was simpler, but they both seemed very inconsistent in how far the spining went (or they paused). I also got an error with both "Cannot use a script to move a linkset while it is playing an animation. Stop the animation first.." I do not know what that is. But thnks again. Link to comment Share on other sites More sharing options...
Quistess Alpha Posted November 17, 2022 Share Posted November 17, 2022 Just now, Christina Halpin said: Cannot use a script to move a linkset while it is playing an animation. Stop the animation first. Is your thing an "animesh" object? Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted November 18, 2022 Share Posted November 18, 2022 Yup, there are several caveats to KFM, and that is one of them (see the wiki page I linked above for all of them). You can't use scripted commands to move any part of the linkset while the KFM is going. You need to wait for it to fully complete or stop it with one of the KFM commands. In fact, that's how several of the smooth door rotation examples work if I recall correctly. Link to comment Share on other sites More sharing options...
Quistess Alpha Posted November 18, 2022 Share Posted November 18, 2022 (edited) 2 hours ago, Christina Halpin said: rotates an object 90 degrees around the z-axis. // setup. float angle = 90.0; vector axis = <0,0,1>; float time = 2.0; integer reps = 4; // convert units. angle *= DEG_TO_RAD/ reps; time = time/reps; rotation r = llAxisAngle2Rot(axis, angle); while(~--reps) { llResetTime(); llSetRot(llGetRot()*r); // swap r and llGetRot() to rotate on the objects own z-axis. // llSetRot has a 0.2 forced delay. llSleep(time-llGetTime()); } or so is a not so uncommon technique. Edited November 18, 2022 by Quistess Alpha Link to comment Share on other sites More sharing options...
Christina Halpin Posted November 18, 2022 Author Share Posted November 18, 2022 (edited) It is a bench with poses. I think I understand. If I use llGetRot() to find out if it has rotated the full 90 degrees, I will get back the answer that it hasn't rotated at al, it's still at the starting position. Because the almost 90 degree rotation I see on my screen is "client-side". (Because I was using llTargetOmega.) Edited November 18, 2022 by Christina Halpin 2 Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 18, 2022 Share Posted November 18, 2022 1 minute ago, Christina Halpin said: If I use llGetRot() to find out if it has rotated the full 90 degrees, I will get back the answer that it hasn't rotated at al, it's still at the starting position. Because the almost 90 degree rotation I see on my screen is "client-side". Right. So you can use llTargetOmega to do the slow apparent rotation client-side. Simultaneously, use a method like the one that Tessa suggested to do the actual rotation in three or four steps. If you time things so that the llTargetOmega action takes exactly the same time that the stepped rotations do, the result will be a smooth rotation that stops on a dime --- right where you want it. That's the way some of the popular smooth-rotating doors work. Toy Wiley wrote one of the earliest LSL scripts that use this approach. You'll find an updated version in the wiki at https://wiki.secondlife.com/wiki/Smooth_Rotating_Door if you want to study how he did it. 1 Link to comment Share on other sites More sharing options...
Christina Halpin Posted November 18, 2022 Author Share Posted November 18, 2022 Thanks. I never would have figured this out. (I ended up putting the realignment-jerk at the start of each90 degree rotation, so it fits with the natural jerk from starting motion. But that's just a detail. It was a really tough day, but . . . smiling now.) 1 Link to comment Share on other sites More sharing options...
RJ Muni Posted Thursday at 09:53 PM Share Posted Thursday at 09:53 PM (edited) After some experimenting I found that this works: vector rot_old = llRot2Euler( llGetRot() ) * RAD_TO_DEG; // get the original rotation in Euler format vector rot_new = rot_old + <0,0,1>; // calculate new rotation, turned 90 DEG over Z-axis llSetLinkPrimitiveParamsFast( LINK_THIS, [ PRIM_ROTATION, <1,0,0,1> * llEuler2Rot( rot_new * DEG_TO_RAD ) ] ); // apply new rotation good luck!, RJ Edited Thursday at 10:27 PM by RJ Muni 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted Friday at 12:31 AM Share Posted Friday at 12:31 AM 2 hours ago, RJ Muni said: vector rot_old = llRot2Euler( llGetRot() ) * RAD_TO_DEG; // get the original rotation in Euler format vector rot_new = rot_old + <0,0,1>; // calculate new rotation, turned 90 DEG over Z-axis llSetLinkPrimitiveParamsFast( LINK_THIS, [ PRIM_ROTATION, <1,0,0,1> * llEuler2Rot( rot_new * DEG_TO_RAD ) ] ); // apply new rotation I think that's more-or-less just llSetRot(<1,0,0,1>*llGetRot()); // rotate 90 degrees on intrinsic x-axis with some obfuscation thrown in. <1,0,0,1> is a non-normalized 90-degree x-axis rotation. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now