Macie Forzane Posted July 27, 2015 Share Posted July 27, 2015 Hi, i'm very new to scripting and having a real problem with rotations.I thought it would be easy to make a 2 piece object where prim 2 orbits prims 1(the root) - basically like a moon orbiting a planet.However, it seems more complicated because i need the rotations to be done server side and not client side, so that anyone viewing it will see the same result.It seems the objects have to be physical and llTargetOmega won't work, is this true ?Is this orbiting possible, and if so any suggestions would be welcome.Thank you,Macie Link to comment Share on other sites More sharing options...
Dora Gustafson Posted July 27, 2015 Share Posted July 27, 2015 If you do not need the planet and moon to be linked you can replace llTargetOmega() with KeyFramedOmega() This is a user function you must include in your scriptThis is the function :smileysurprised::smileyvery-happy: 1 Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted July 28, 2015 Share Posted July 28, 2015 Perfectly possible. This was touched on in the recent post about rotating items around a rezzer. "Have a look at http://wiki.secondlife.com/wiki/Rotation this page , in particular the section headed Position of Object Rotated Around A Relative Point" Link to comment Share on other sites More sharing options...
Macie Forzane Posted July 28, 2015 Author Share Posted July 28, 2015 @Dora - thank you so much for your function - I learnt a lot from it - especially about KeyFrames as I never knew they existed. I put a your function in a simple script that I found on web and it works really smoothly. // LSL script to rotate an orbiting object// If the rotating object is two linked spheres, the result// can resemble lunar motion around a planet (depending on// timer settings and network performance, etc.).vector rotationCenter;rotation Z_15;integer count;KeyFramedOmega( vector axis, float spinrate){ llSetKeyframedMotion( [], []); if ( spinrate ) { float v = TWO_PI/3.142; if ( spinrate < 0 ) v = -v; list L = [llAxisAngle2Rot( axis/llGetRot(), v), v/spinrate]; llSetKeyframedMotion( L+L+L, [KFM_DATA, KFM_ROTATION, KFM_MODE, KFM_LOOP]); }}default{ state_entry() { llSetTimerEvent( 0.025 ); vector startPoint = llGetPos(); rotationCenter = startPoint + < 0.25,0.25,0.25 >; Z_15 = llEuler2Rot( < 0, 0, 30 * DEG_TO_RAD > ); } touch_start(integer total_number ) { count=0; //llTargetOmega( < 0, 1, 1 >, .2 * PI, 1.0 ); KeyFramedOmega( < 0, 1, 1 >, 1.0 ); } timer() { count=count+1; if (count<100) { vector currentPosition = llGetPos(); vector currentOffset = currentPosition - rotationCenter; // rotate the offset vector in the X-Y plane around the // distant point of rotation. vector rotatedOffset = currentOffset * Z_15; vector newPosition = rotationCenter + rotatedOffset; llSetPos( newPosition ); } }} Link to comment Share on other sites More sharing options...
Macie Forzane Posted July 28, 2015 Author Share Posted July 28, 2015 thank you for your link and info - it saved me wading through a lot of info to get the script working Link to comment Share on other sites More sharing options...
Dora Gustafson Posted July 28, 2015 Share Posted July 28, 2015 I am happy you found good use for the function. Just tell me why you changed TWO_PI/3.0 to TWO_PI/3.142 ? The first is one third of a full circle and when llKeyFramedMotion is called it has 3 frames for a full circle so 'TWO_PI/3.142' makes no sense to me ( except that TWO_PI/PI equals 2 but that doesn't explain anything)) I didn't try your script and can't say how well it works I can say it doesn't eliminate tight looping which keeps the server busy :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
Macie Forzane Posted July 28, 2015 Author Share Posted July 28, 2015 Thank you for checking it for me and finding the bug i introduced that could have caught out others reading the script. About the 3.142, I was messing about and thought it might have been an approxiamtion for Pi - not realising it was 3 frames for a full circle I still don't understand all this and was trying to make it run faster - hence the fast timer - now the 3 frames for a full circle makes sense. I'll experiment with this tomorrow and look at the parameters more closely. Link to comment Share on other sites More sharing options...
JennferKoontz Posted June 25, 2019 Share Posted June 25, 2019 I am working on an animesh project, think of and animated dog walking in a circle, I have pieced together an orbiting script to get the "Dog" to move around a point in space, however the "Dog" is rotating on it's z axis (slow spin) as well. I need the "dog" to remain moving forward without the spin. Also rotation setting should remain x= 0, y=0 , z= movement in space so dog is always facing forward. here is what I have so far: (Credit goes to Kira for the base of the script.) As always your help is greatly appreciated! ////////////////////////////////////////////////////////// // [K] Kira Komarov - 2011, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// // CONFIGURATION // ////////////////////////////////////////////////////////// // How precise corners are? float DEFINITION = 0.1; // What range from the owner in // meters? float RADIUS = 10; // meters // How precise should the drift // towards the target be? float TARGET_AFFINITY = 0.8; // meters // When will the object consider // it has reached the target? float TARGET_DAMPENING = 0.5; ////////////////////////////////////////////////////////// // INTERNALS // ////////////////////////////////////////////////////////// vector dPos = <70.90073, 126.89610, 2501.30200>; float a = PI; float b = PI; vector nextPos(vector iPos) { // Circle Rotation if(a >= TWO_PI) a=0; if(b >= TWO_PI) b=0; return iPos + <RADIUS * llCos(a+=DEFINITION), RADIUS * llSin(b+=DEFINITION), 0>; } moveTo(vector position) { llTargetRemove(_targetID); _targetID = llTarget(position, TARGET_AFFINITY); llLookAt( <70.90073, 126.89610, 2501.30200> + <0.0, 0.0, 90.0>, 1.0, 1.0 ); llTargetOmega(<0.0,0.0,0.0>*llGetRot(),1.1,0.01); llMoveToTarget(position, TARGET_DAMPENING); } key _owner = NULL_KEY; integer _targetID = 0; default { state_entry() { llSetStatus(STATUS_PHYSICS, FALSE); _owner = llGetOwner(); llSensorRepeat("", _owner, AGENT, 20, TWO_PI, (1.2-llGetRegionTimeDilation())); _targetID = 0; } sensor(integer num) { dPos = <70.90073, 126.89610, 2501.30200>; } no_sensor() { llSetStatus(STATUS_PHYSICS, FALSE); } touch_start(integer total_number) { llSetStatus(STATUS_PHYSICS, TRUE); llSetForce(<0,0,9.81> * llGetMass(), 0); dPos = <70.90073, 126.89610, 2501.30200>; moveTo(nextPos(dPos)); } at_target(integer tnum, vector targetpos, vector ourpos) { if(tnum != _targetID) return; moveTo(nextPos(dPos)); } on_rez(integer param) { llSetStatus(STATUS_PHYSICS, FALSE); _owner = llGetOwner(); } changed(integer change) { if(change & CHANGED_OWNER) _owner = llGetOwner(); } } //End of script 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