Jump to content

Object orbiting


revochen Mayne
 Share

You are about to reply to a thread that has been inactive for 3801 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

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

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

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

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


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

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

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

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

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

You are about to reply to a thread that has been inactive for 3801 days.

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
 Share

×
×
  • Create New...