12 August 2011

Designing a Ferris Wheel

I've been building a ferris wheel for a customer. Design-wise it's an interesting puzzle. The wheel turns, but the cars/seats/carriages remain upright with the passengers inside.

The only way it was viable in the old days was to make each of the cars an object, and to have the wheel be an object. A seated avatar moves with the object it sits on, so the avatar would move naturally with the car. The movements of the cars could be coordinated according to messages spoken on a channel (requiring listeners in every car,) or they could use llGetObjectDetails() on the wheel to determine its rotation every so often and then place themselves in the proper locations. If you were a gambler, you could simply have the cars move along at every X time interval and pray they never got out of sync.

A ferris wheel using physics to allow the cars to hang as objects from the wheel is a disaster. Smaller sized physics objects (like a pole and ring for the car to hang with) develop strange urges to spasm wildly and fling themselves across a sim. When the pieces are large enough to behave, they are too far out of scale. I do recommend trying this - it's very entertaining!

Before llSetLinkPrimitiveParamsFast() was added to LSL, the 0.2 second delay for each prim would have broken the illusion of the spinning wheel if it was all one object. The other difficulty is that you must also move the avatars as if they were part of the linkset - moving a prim in a linkset with a sit target does not move the avatar sitting on it.

I made a demonstration one-object wheel using llSetLinkPrimitiveParamsFast() and four one-prim cars. I suspect quaternions are the lovechild of an insane mathematician and Cthulhu.

Moving prims in a linked object generates a surprising amount of scripting lag if you aren't just moving the entire object. The demo wheel with one avatar (5 individually moving prims in the linkset) averaged about 0.035s of script time. Surprisingly, sizing up to eight cars and five avatars (13 moving prims in the linkset) only used about 0.065s.

I've passed the eight car version on to one of the texturers on the team, and am looking forward to seeing the final product.

No comments: