VirtualKitten Posted March 23, 2023 Share Posted March 23, 2023 (edited) I have this script which kind of works but it rotates the child object right round first and am unsure why as otherwise if it didnt it would be ok. I want to just rotate it around Y list p; float rotClickAngle = 10; float height=0; rotate(integer link) { list L = llGetLinkPrimitiveParams(link,[PRIM_ROT_LOCAL, PRIM_POS_LOCAL]); rotation rotRoot2Axis = llList2Rot(L,0); vector posRoot2Axis = llList2Vector(L,1); vector axisAxis=<0,1,0>*rotRoot2Axis; rotation rotClick_inRootFrame = llAxisAngle2Rot(axisAxis, rotClickAngle *DEG_TO_RAD); // for body. L = llGetLinkPrimitiveParams(1,[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; llSetLinkPrimitiveParamsFast(link,[PRIM_ROT_LOCAL,newrotRoot2Body,PRIM_POS_LOCAL, posRoot2Axis + newoffsetBody_inRootFrame]); } default { touch_start(integer total_number) { integer touchFace = llDetectedTouchFace(0); vector touchST = llDetectedTouchST(0); integer link = llDetectedLinkNumber(0); height=0; rotClickAngle = 10; rotate(link); } touch_end(integer total_number) { integer touchFace = llDetectedTouchFace(0); vector touchST = llDetectedTouchST(0); integer link = llDetectedLinkNumber(0); height=0; rotClickAngle = -10; rotate(link); } } Edited March 23, 2023 by VirtualKitten Link to comment Share on other sites More sharing options...
VirtualKitten Posted March 23, 2023 Author Share Posted March 23, 2023 I dont know why its rotating the child before working properly anyone Link to comment Share on other sites More sharing options...
VirtualKitten Posted March 23, 2023 Author Share Posted March 23, 2023 Can any one help please Link to comment Share on other sites More sharing options...
Quistess Alpha Posted March 23, 2023 Share Posted March 23, 2023 It would help if you were more clear about what you want it to do; you have a lot of weird irrelevant stuff in the script. float rotClickAngle = 10; default { state_entry() { rotClickAngle*=DEG_TO_RAD; } touch_start(integer total_number) { integer link = llDetectedLinkNumber(0); rotation rot = llList2Rot(llGetLinkPrimitiveParams(link,[PRIM_ROT_LOCAL]),0); rotation apply = llAxisAngle2Rot(<0,1,0>,rotClickAngle); llSetLinkPrimitiveParams(link,[PRIM_ROT_LOCAL,apply*rot]); // reverse the order of apply and rot to use root axes instead of link axes. } touch_end(integer total_number) { integer link = llDetectedLinkNumber(0); rotation rot = llList2Rot(llGetLinkPrimitiveParams(link,[PRIM_ROT_LOCAL]),0); rotation apply = llAxisAngle2Rot(<0,-1,0>,rotClickAngle); // use negative axis for reverse. llSetLinkPrimitiveParams(link,[PRIM_ROT_LOCAL,apply*rot]); // reverse the order of apply and rot to use root axes instead of link axes. } } 1 Link to comment Share on other sites More sharing options...
VirtualKitten Posted March 23, 2023 Author Share Posted March 23, 2023 Quistess Alpha Thanks am making a keyboard but they start to curve with your script idk https://i.gyazo.com/35acaea728edeb0a8b2da711b7757648.mp4 But thanks for looking i hope this helps Link to comment Share on other sites More sharing options...
Quistess Alpha Posted March 23, 2023 Share Posted March 23, 2023 13 minutes ago, VirtualKitten said: i hope this helps oh, your keys seem to have a bad intrinsic rotation. try reversing the order of apply and rot as suggested in the script's comments. 1 Link to comment Share on other sites More sharing options...
VirtualKitten Posted March 23, 2023 Author Share Posted March 23, 2023 Uh I dont understand why its rotating those it didn't with the other one after it rotated it is most peculiar Do you think they need to be set rotation scale etc would this cure it? Link to comment Share on other sites More sharing options...
VirtualKitten Posted March 23, 2023 Author Share Posted March 23, 2023 Yes it solved it thank you so much i tried in beta grid as usually uploaded to many things loosing my lindens Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted March 24, 2023 Share Posted March 24, 2023 20 hours ago, Quistess Alpha said: you have a lot of weird irrelevant stuff in the script. No! Surely not! Seriously though I remember ages ago reading that rotations attempt to find the shortest path, but from my own experiences moving the Y-axis will often also alter the other two axis values. The order in which you alter the three axes can be significant. As an experiment, try rezzing an object that has values already in the three fields, then rezz a prim, and set the same values into the X and Z fields, then alter the Y value appropriately, and it frequently changes the X and Z values as a result. I am starting to think that you need to be a witch to cope with SL rotations. (Not looking at Tessa, mind you, I was thinking more of Grandma Bates). Link to comment Share on other sites More sharing options...
Quistess Alpha Posted March 24, 2023 Share Posted March 24, 2023 4 hours ago, Profaitchikenz Haiku said: moving the Y-axis will often also alter the other two axis values. That's (more-or-less) a result of the 'gimbal lock' problem with euler-vectors; there are multiple values of x,y,z that correspond to the same orientation, and converting between them is, non-intuitive. It's even less intuitive that Linden-euler-vectors are not in the relatively easy to conceptualize pitch-yaw-roll format. If you wrap your head around axis-angle form, quaternions are (IHMO) actually easier to reason about. I've heard a 'orientation mixing' mental model can also be useful: Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted March 25, 2023 Share Posted March 25, 2023 18 hours ago, Quistess Alpha said: If you wrap your head around axis-angle form, quaternions are (IHMO) actually easier to reason about. It's a shame the build floater values are in Euler form in that case. I would find it easier to understand the way the three components varied with rotation if those values were the ones displayed. I made a rotation visualiser some time ago with hovertext showing the Euler degrees and quaternian radian values, but it was a bit clumsy to alter in order to watch those transitions. As you say, there is a gimbal effect where X and/or Z values snap through 180 degrees with the variations in the Y axis. That is why I tend to view Y as the governing one of the three. Link to comment Share on other sites More sharing options...
Recommended Posts
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