revochen Mayne Posted December 10, 2013 Share Posted December 10, 2013 Greetings! I need to make an object orbit based on its orientation. I figured how to do it along the global axis but not based on the objects local rotation.Any help and advise is much appreciated. vector VECTOR_ORIGIN; float angle; float radius = 1.4; //in meters out from the start float increment = -1; // positive = counterclockwise float spin_rate = 0.1; default { state_entry() { angle = sp; VECTOR_ORIGIN = llGetPos(); llSetTimerEvent(spin_rate); } timer() { llSetPos( <0, llSin(angle * DEG_TO_RAD),llCos(angle * DEG_TO_RAD)> * radius + VECTOR_ORIGIN ); angle += increment; } } Link to comment Share on other sites More sharing options...
steph Arnott Posted December 10, 2013 Share Posted December 10, 2013 You want the object to rotate and in an orbit? Link to comment Share on other sites More sharing options...
revochen Mayne Posted December 10, 2013 Author Share Posted December 10, 2013 No, it has to keep its rotation but orbit around a fix point along its local object axis only. Currently its orbiting along the global world axis. Link to comment Share on other sites More sharing options...
steph Arnott Posted December 10, 2013 Share Posted December 10, 2013 Do a rotation offset. ADDED: What does angle = sp; it means nothing, there no assignment for it. ADDED: Do people actually make any effort to study? The wiki has all the answers, understanding it is hard but then one asks for clarity. I need, I want, do others understand this insistent demands by people with bad manners? What happened to "Please i need help, or "i not understand, could anyone assist me" etc. Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2013 Share Posted December 10, 2013 Take a look at the discussion and examples under the heading Position of Object Rotated Around A Relative Point in the LSL wiki at https://wiki.secondlife.com/wiki/Rotation That's a very intense article, worth spending countless hours of study. The solution to that specific question, though, is fairly easy to understand, though, so you should have no trouble. Link to comment Share on other sites More sharing options...
revochen Mayne Posted December 10, 2013 Author Share Posted December 10, 2013 steph, its a left over because the original script was much larger. This script is even missing its llSetTimer call to start the timer. And what do you mean by "Do people actually make any effort to study? "? I was looking for a solution for some time now and thought its a good idea to request some advises at the scripting forum. Whats wrong with? No need to be that offensive, steph. I am requesting for help and already appreciate any help. You're posts wasnt helpfull yet, sorry. Link to comment Share on other sites More sharing options...
revochen Mayne Posted December 10, 2013 Author Share Posted December 10, 2013 steph Arnott wrote: Do a rotation offset. Please explain me, what do you mean by a "rotation offset" and how does that work? :matte-motes-nerdy: I know you cant because "rotation offset" is just nonsense. steph, please just resist in answering if you cant provide any help. At least on my requests. Thank You! Link to comment Share on other sites More sharing options...
steph Arnott Posted December 10, 2013 Share Posted December 10, 2013 It not directed at you. Sorry. Link to comment Share on other sites More sharing options...
steph Arnott Posted December 10, 2013 Share Posted December 10, 2013 You need the prims offset from the root prim. In ratations, simplisticaly this * means add and this means / deduct UPDATED: Not my script vector centerPos;rotation vRotArc;float axis;default{ state_entry() { llListen(0,"","",""); centerPos = <0,0,0>; } listen(integer c, string n, key id, string msg) { list msg_parts = llParseString2List(msg,[" "],[""]); centerPos = <llList2Float(msg_parts,0),llList2Float(msg_parts,1),llList2Float(msg_parts,2)>; axis = llList2Float(msg_parts,3); vRotArc = llEuler2Rot(<90.0,0.0,0.0>*DEG_TO_RAD); } touch_start(integer i) { rotation localRotNew = (llGetRot() / llEuler2Rot(<0,0,axis>))* vRotArc * llEuler2Rot(<0,0,axis>); vector pos = llGetPos(); vector newPos = pos - centerPos; vector vPosRotOffset = (newPos / llEuler2Rot(<0,0,axis>)) * (vRotArc * llEuler2Rot(<0,0,axis>)); vector vPosOffsetDiff = centerPos + vPosRotOffset; llSetPrimitiveParams([PRIM_POSITION,vPosOffsetDiff,PRIM_ROTATION,localRotNew]); }} Link to comment Share on other sites More sharing options...
revochen Mayne Posted December 10, 2013 Author Share Posted December 10, 2013 I dont want to rotate a link prim based on its root prim rotation. Just think of a ferris wheel. The gondolas are separate objects but have to rotate around the wheels center depending on the wheels rotation. Link to comment Share on other sites More sharing options...
steph Arnott Posted December 10, 2013 Share Posted December 10, 2013 vector Adjpos = offSet * wereYouWantItRot; Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2013 Share Posted December 10, 2013 Didn't that wiki article I pointed you to do the job, Revochen? It's just a few lines of code, pretty well laid out. It's basically what Steph has put in her posts. Let me know if it doesn't make sense. Link to comment Share on other sites More sharing options...
revochen Mayne Posted December 10, 2013 Author Share Posted December 10, 2013 Thank You, Rolig! Yes, it doesnt seems to do it yet. The object is orbiting around a fix point using the sample code from your link but its also rotating now. If i exclude the rotation part then it just moves the object forward. :matte-motes-confused: Link to comment Share on other sites More sharing options...
ObviousAltIsObvious Posted December 10, 2013 Share Posted December 10, 2013 I think you can pull the parts you need out of this example. http://www.heatonresearch.com/content/ferris-wheels-second-life Link to comment Share on other sites More sharing options...
revochen Mayne Posted December 10, 2013 Author Share Posted December 10, 2013 Hello Obvious! Thats great, thank you! I did a google search befor but seems like i used the wrong keywords. :smileylol: I might have to change it though to a start and stop command structure only. Currently your script is sending a "spin" command every half second to each gondola. Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2013 Share Posted December 10, 2013 OK, then. If I understand you correctly, all you need to do at each time step is to make any changes in your orbiting object's rotation be the opposite of changes in the rotation of the root. So, if your root prim (the planet) turns clockwise 2 degrees in a time step, you rotate the satellite 2 degrees anticlockwise. That will keep it facing the same direction, relative to region coordinates, as it turns. Link to comment Share on other sites More sharing options...
steph Arnott Posted December 10, 2013 Share Posted December 10, 2013 Easiest way is make a cylinder, ( the root prim) chop it lengthwise in half, add a prim on the end and rotate it. No math. ADDED: Make the cylinder invisable. Link to comment Share on other sites More sharing options...
revochen Mayne Posted December 10, 2013 Author Share Posted December 10, 2013 I rather thought of a sinus and cosinus calculation based on the objects/gondolas forward orientation and set its result as position offset just like the script code i posted does but on global world coordinates. I just doesnt seem to get it yet. :matte-motes-bashful: Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2013 Share Posted December 10, 2013 Too complicated. You obviously calculate an incremental change in the rotation of your parent body, so you already know what that is. Just apply exactly the opposite rotation to your satellite. llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROTATION, llGetRot() * llEuler2Rot(<0.0,0.0,2.0*DEG_TO_RAD)]); llSetLinkPrimitiveParamsFast(2,[PRIM_ROTATION,llGetRot() * llEuler2Rot(<0.0,0.0,-2.0*DEG_TO_RAD>)]); That should work. Plus your PRIM_POS_LOCAL calculation to determine the orbital position of the satellite, of course. Link to comment Share on other sites More sharing options...
revochen Mayne Posted December 10, 2013 Author Share Posted December 10, 2013 Although the object is orbiting its not for a solar system. In fact its really for a ferris wheel and the gondolas are separate to the wheel, not linked as they are made by multiple prims. Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2013 Share Posted December 10, 2013 Aha! That makes the problem significantly more difficult. At this point, my instinctive solution (other than running in circles and wailing) is to make the seats as single mesh objects that I can link to the parent wheel. Link to comment Share on other sites More sharing options...
steph Arnott Posted December 11, 2013 Share Posted December 11, 2013 You just winding people up. Link to comment Share on other sites More sharing options...
revochen Mayne Posted December 11, 2013 Author Share Posted December 11, 2013 Yes, i cant think of any better solution than having one-prim gondolas linked to the wheel. Even to avoid redundant timers or listeners. I'm just not the creator of it but might help him with changing it to mesh instead of messing with the scripts. :smileylol: Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 11, 2013 Share Posted December 11, 2013 I did a bit of research on Google, and turned up this. I've not done anything with them, but I have seen the original build, so I think it would repay study: http://www.heatonresearch.com/content/ferris-wheels-second-life Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted December 11, 2013 Share Posted December 11, 2013 Years ago, I participated in one of Builder's Brewery's (I think it was BB) speed building parties. Someone used those scripts (or something similar) to build a ferris wheel. None of us realized what it was until he started it, as the cars were lined up on the ground in a row (from shift-dragging). There was laughter all around when the thing assembled itself and starting spinning. I recall the creator saying that his next step would be to have the base rez the wheel and cars, and I see that the scripts do that. I wonder if was the same fella. Yet another example of what we're missing by not having hierarchical linking. 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