.comment-link {margin-left:.6em;}
Moriash Moreau: My Second Life
Friday, September 30, 2005
 
Throwing the First Stone
As a break from crossing my eyes for hours on end, I've been busy churning through the mechanics of simulating a completely pointless activity: tossing pebbles into the ocean. I don't really know what possessed me to do so. I think part of it was the old standby, "because it was there." The Garden of Mo (see the link there on the right if you want to visit) recently expanded to include a small segment of oceanfront property. Or, more specifically, a piece of land at the end of the world. If you look at the grid map, you'll see that Louise is located at the easternmost edge of the mainland continent. So, if you look to the east, all you can see is calm blue ocean stretching off to the horizon. This is one of the reasons why Louise is a less-than-desirable piece of property: it's far off the normal flight paths, and right on the edge of the nearest telehub service range. But it is a compelling view, nonetheless. I'm hoping to improve it.

I suppose it's part of the developing theme of the Garden. Right now, it's covered in trees and modern concrete picnic tables, with nothing else visible at ground level. (My main builds are 50 or more meters above ground, out of casual view from ground level.) It's turning into a fairly good simulation of a smallish, poorly funded state park. I'm already coming up with weathered wooden signs that say "scenic overlook" and "nature trail" and such. Maybe I need a small, tasteful historical marker around somewhere.


From a technical standpoint, it was a somewhat more interesting problem than it first appeared. If the water were inland, I could simply have thrown a physical rock. Have it detect when it has fallen to water level, and trigger the splash effects. But, since there's an invisible barrier at the edge of the world, such a device would merely bounce off and fall to the ground. However, in trying to work around this, I discovered two things. First, particles can pass right through this barrier. Second, so can prims, provided the insertion point for the root prim remains inside the sim. I suppose both of these are obvious extensions of normal behavior. Particles are client side, and are thus not limited by the server's need to keep all its prims inside its own boundaries. And I'm sure we all have - either accidentally or on purpose - parked an object across a sim boundary. I just hadn't really made the connection until recently. These little epiphanies are the start of many a project.

In this case, I ended up sticking a particle emitter on the end of a 25m pole. The user sits down on the bench, and the bench captures his mouse button to trigger throws. He presses his mouse button, and the splash emitter rezzes itself and moves into position with its root prim just inside the sim border, and its emitter well out beyond the edge of the sim. (The splash emitter assembly is coded to vary its coordinates somewhat each time its rezzed, so its never in precisely the same place twice.) Once in place, the splash emitter shouts its key, and the stone throwing emitter (an invisible prim built into the bench, placed approximately where the user's hand is located at the end of the throw animation) sets it as the target. Once the target is set, the throw animation is activated, and the thrower emitter launches a single blob of particles (the stone itself) in a long pseudo-ballistic arc, with the splash emitter at its end. After a set time interval, approximately when the stone particles hit the splash emitter (determined in advance by trial and error), the user sees and hears a splash out in the water. Then the splash emitter deletes itself, and we're ready for another throw. Kind of a circuitous route for something as simple as creating the illusion of a thrown rock, but it seems to work pretty well.

I suppose this wasn't the simplest way to do things, all told, but my narrative requirements ended up painting me into a corner. See, I wanted as few impediments between the user and his casual ability to toss a pebble into the drink. I expect that I put entirely too much thought into this, honestly. I blame it on my fond childhood memories of lobbing rocks into the pond and scaring away all the fish, much to my relatives' consternation. By its very nature, it's a casual, unpremeditated thing. You see a stone, you pick it up, you toss it into the water and watch the splash. I didn't want to add "you touch the rock thrower dispenser, click 'yes' to accept the object, attach the resulting rock throwing attachment, and answer the permissions box" to that list. (I also didn't want to either make an attachment that only worked on my land, or was sophisticated and self-contained enough to work on any body of Linden water. Maybe later on the latter.) So I settled for a fixed "rock cannon" on a bench. When a user sits down on a scripted object, the system assumes that he allows animations, key captures, and such. Otherwise, players would be bugged by permission windows every time he sat on a pose-enabled chair. Now, all the user must do is have a seat and click to toss a rock. There's even a convenient pile of (inert prop) stones on the bench to make the suggestion. I think that's probably casual enough.

Another approach might have been to mathematically predict the ballistic arc of the rock particle (using some basic high school physics- this is the ideal friction-free environment the teacher always told you to assume) and toss the splash emitter at its expected point of splashdown. I don't see any reason this wouldn't work, and I may end up doing it at some point, but for now the cheater method I used (having the rock attract itself to a randomly determined set of coordinates) looks pretty good.


The most maddening thing about the project was the animations. If you look at the Linden "throw_r" animation, you'll see that it pivots the torso 45 degrees to the left as the avatar throws. This is natural for a baseball pitch, where your whole body is put behind the throw. But when you're just casually chucking something from a seated position, it looks pretty odd. The avatar, for no apparent reason, decides to twist 45 degrees to the left to throw his rock. After an hour or so of shopping, I could find no alternate throw animations. (Yes, I know I could hire someone to do it custom and/or buy and learn how to use Poser. Umm... No. Not to throw rocks.) So, well, the user just throws his pebbles off to the left. Not a big deal. Just a matter set design. That's what the trees and rocks off to the avatar's right are there for. His line-of-sight on the right is blocked, so he tosses to the left instead. Good enough!

And, well, there you go. That's how I added the ability to throw rocks off the edge of the world to the Garden of Mo. You can wake up now. It's over.
Comments: Post a Comment

Links to this post:

Create a Link



Return to Main Page