« Return to Thread: Repulsion between physical and other objects

Re: Programming a natural looking swing (was Repulsion between physical and other objects)

by logan.park :: Rate this Message:

Reply to Author | View in Thread

I think the issue of timered setRot leads to jerkiness-- there's a 0.2 second builtin script delay after you call that function, according to http://lslwiki.net/lslwiki/wakka.php?wakka=llSetRot

So at very best you'd get five updates per second.  Not sure how good that would look with any degree of damping clientside.
K

On Thu, Sep 4, 2008 at 1:12 PM, G <gcanaday@...> wrote:

Ouch, that's a lot of work. It might be easier to simply use two llSetRots on a timer that's a little too short to actually complete the rotation, thus relying on the built-in smoothing for the direction change rather than having the abrupt stop when rotation completes, since it never completes... haven't tried it that way though, and there's no way to change the rotation speed since the llSetRot() calls are pretty static in how long they take to complete.

omg that was a long sentence.

G


AnnMarie@... wrote:
It is a long time since I did one and mine was a vertical motion but from memory, here is an outline on how to go about it.

The program has two segments.  The first to generate a list of numbers that runs only if you change swing parameters.
This list of numbers is used by the second program segment that moves the swing.
For the first part that generates the data list:-
You decide how many steps you want to do from peak to peak on the swing.
This can be user-setable if you want to adjust smoothness.
Divide 180 degrees by this number to get the step angle for looking up.
Start at 90 degrees and step to -90 degrees (converted to radians) and look up the llSin() of these angles and put them in a list.
This will give you a list of numbers starting at +1 and ending at -1.
You now step through this list to create a second list.
You need to scale and convert the numbers from +1 through -1 to an angle for llSetRot().
So +1 will correspond to the highest point on the swing, say 35 degrees (which can be user adjustable too).
zero will correspond to swing vertical
-1 corresponds to swing back 35 degrees, all converted to radians.

You run this segment as needed to create the working list that contains the angles that are plugged into llSetRot() only on rez, or when user wants to change one of the parameters.

To run the swing have it sit at half way through the list (vertical) if you want it to be able to stop.
When it starts, step through the list using a timer set to total swing time divided by the number of steps (can be user adjustable).
You will be stepping from mid point on the list to the bottom, then reverse and step through to the top, then reverse again.
On each step put the list angle value into llSetRot().

Although it is not physical, there is some smoothing built into llSetRot() changes, they don't move instantaneoulsy so experiment to find the minimum number of steps that looks smooth and reduces computing overhead.

If you want to get REALLY fancy, you can let the swing accelerate/decelerate on start/stop by changing the 35 degree angle in increasing/decreasing steps from/to zero, recalculating the angle list each time.

I'm sure the above could be written to calculate the angles on the fly instead of using the list look-up but I did it this way.  It is easier to understand and is probably less processing load on the sim computer.

AnnMarie Otoole.


----- Original Message ----- From: "G" <gcanaday@...>
To: <secondlifescripters@...>
Sent: Thursday, September 04, 2008 11:22 AM
Subject: Re: Repulsion between physical and other objects



Ann,

oo? How does that work? /me looks for example...

G




_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters


_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

 « Return to Thread: Repulsion between physical and other objects