Jump to content

Sabrina Tamerlane

Resident
  • Content Count

    45
  • Joined

  • Last visited

Community Reputation

16 Good

About Sabrina Tamerlane

  • Rank
    Advanced Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. 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
  2. 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
  3. 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);
  4. 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.
  5. 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);
  6. 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
  7. 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.
  8. 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);
  9. I have noticed that if you pass KFM_CMD_STOP without a KFM_CMD_LOOP before then the moving end event will not be triggered.
  10. Does this fix your problem? float PERIOD = 4.0; float AMP = 0.1; integer KFM_STEPS = 25; list kfmCommands; vector savePos; default { state_entry() { // set up KFM command list to bounce up and back float interval = (integer)((PERIOD / KFM_STEPS) * 45.0) / 45.0; float lastZ = llSin(0.0); integer step = 1; for (step = 1; step < KFM_STEPS; ++step) { float x = (TWO_PI * step) / KFM_STEPS; float newZ = AMP * llSin(x); kfmCommands += [ <0, 0, newZ - lastZ>, interval]; lastZ = newZ; } savePos = llGetPos(); llSetKeyframedMotion(kfmCommands, [KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_LOOP]); } touch_start(integer num_detected) { llSetKeyframedMotion([], [KFM_COMMAND, KFM_CMD_STOP]); // Doesn't help } moving_end() { vector atPos = llGetPos(); llSetLinkPrimitiveParams(LINK_THIS, [PRIM_POSITION, savePos]); // Restore position vector setPos = llGetPos(); llOwnerSay((string)atPos.z+" --> "+(string)setPos.z); llSetKeyframedMotion(kfmCommands, [KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_LOOP]); } }
  11. On the wiki they say this: So, I think that if you reach moving_end you are at a known position. Alternatively, you can do llGetPos() to figure out what is the frame number and then make a new motion starting from that frame.
  12. Is it acceptable to wait until the animation is completed before stopping it? If not then you need to know at which frame it stopped.
  13. I have changed pictures on my items and the listed order changed as well, so it's difficult to order them properly.
  14. If the names are stored in the script it is a memory hog. So, it can be very easy to do, but it can crash also very easily. Now if you are looking for a specific person like a dancer or host then it's different.
  15. The early years are the most cheerful. When they leave the academy it becomes darker.
×
×
  • Create New...