Friday, November 7, 2008

Scripted Physical Vehicles in OpenSim

First, to establish a bit of context on this report, I am referring to any vehicle that moves under the influence of the physics simulation. This specifically excludes llSetPos and like techniques.

While my experiments did not involve e.g., llSetVehicleType, they are still physical vehicles too - and dont worry, we'll examine the status of llSetVehicleType and friends while we're at it.

The first trouble I encountered in attempting to make a physical vehicle in OpenSim, is that there are no llVehicle* style functions implemented in the script engine. Or are there? a casual glance at the source code (if there is such a thing) would lead one to believe so. A closer investigation, though, will show that while the 'Not Implemented' stubs have been replaced with meaningful code that passes values up to the wooly innards of OpenSim, the afore-mentioned innards don't actually pass it on to the physics engine. But just about everything is in place to do so.

Why hasn't this last step been done? The answer to that is a bit complicated.

The short story is, the wooly innards are about to get rearranged, hopefully into a somewhat less wooly form. And as this is where all that physical script plumbing empties out, it's arrangement has considerable bearing on how llSetVehicle and friends are implemented.

Hold that thought while we take a stress breaker :)

What I *have* had at least some moderate success with is making a flying prim that is a physical vehicle. I know, but it's a start. How can this be done? Why, with llApplyImpulse and llTargetOmega.

Ok, it's an utter kludge LOL but it works.

Why llTargetOmega? it's the only LSL function currently implemented that can physically rotate a prim. llApplyImpulse provides both the lift and the forward thrust. I use the standard vehicle 'control' event to obtain the users inputs via 'llTakeControls', and I use llTargetOmega to stop and start a rotation of the prim when the appropriate keys are pressed to turn left and right.

Why dont I post that script here and now? It's just too ugly. When I spend a bit more time with it, I *might* actually have a reasonably manueverable flying prim - but as it is now, it's just barely proof-of-concept.

Now, stressbreaker is over!

Basically, the work on the OpenSim 'wooly innards' I referred to above is highly complex, represents a huge change to the core codebase, and must be worked over and discussed by at minimum 10 different software engineers. It's going to take a bit of time, I'm afraid. Be patient, it'll be worth the wait.

In the interim, I hope to properly implement llSetRotaionalImpulse and llSetRotationalVelocity, both of which bear enough resemblance to llTargetOmega that I should be able use it as a reference in the source code; if I am successfull, this should give us sufficient tools to implement some very useable vehicles based on llSetForce and llApplyImpulse.

Crude, I know. But better than a foot-race :)

Cheers for now!

1 comment:

Gwynn said...

Ugly or not, I'd still like to see it to prevent me inventing an equally kludgy wheel :(