One prim clock, revisited

I have more or less dropped my attempts at making a single-prim analog clock, until I have abruptly bumped into a solution, used expressly for this purpose in the Japanese lands. All credit for this trick goes to kit Pizzicato, who sells them under the label *chronokit* — whether the original inventor of the trick is the maker of the clock, I don’t know, but, I’ve figured out how they did it and am going to tell anyone who cares, now. 🙂

To the left is the original, my replica of the prim is to the right.

To the left is the original, my replica of the prim is to the right.

The mystery shape is a Ring type prim, with around 75.0 hollow, Triangle hollow shape, and a 0.25-0.75 profile cut. Chopping a ring up like that results in a round object with at least three individually texturable faces visible from one direction, depending on other parameters — the limit you can twist it into would be five. By default, the texture on these faces is distorted in a non-linear fashion. However, if you switch the texture mapping to planar, on at least three of the faces the distortion will become linear, and you can use a rotated flat texture to create a clock face and a minutes and seconds hand with no unusual scripting required.

Discrepancy

I have a special relationship with time. ‘Clock’ was the first word I ever said, and since then, they are afraid of me. Wall clocks don’t survive for long around me, generally dying from mechanical failures in about a month, and if I don’t keep my computer’s time synchronized to a time server, it can jump forward three hours in three minutes of real time when I look away.

So I notice these things. And today, I noticed that SL time displayed in the menu bar while in my home sim is approximately 90 seconds behind the real time.

That wouldn’t be all that odd, since everybody knows how borked Second Life can be — though, I must say that time being out of sync can lead to some very interesting kinds of borkage, especially in a system that is supposed to deal with financial transactions — but what caught my attention to it was the chime of my scripted wall clock.

And that happened another 30-50 seconds earlier than even the SL time rolled into an even hour.

While I didn’t write that particular script myself, and cannot look inside, I do suspect that the coder went the easy way and did not account for the time it takes to play the hourly chime sound and just triggered it upon reaching an even hour.

And that means that LSL functions that return system time do not correspond even to the time you see in the menu bar!

The question is, why?!

Prim torture

I’ve been trying to make a single-prim analog clock.

There are numerous ways an analog clock can be made in Second Life. So far, the ones I have seen included two different approaches..

The first approach is the obvious one — you create a primitive for each clock hand, and rotate them over the clock face. This looks good, but results in three prims at the very least, and often, quite a bit more for added detail, or at least for the seconds hand.

The second approach layers three minimal thickness boxes upon each other, using the front face of each to display a rotating texture.

While it is obviously impossible to create a single prim clock using the first approach, I’ve been thinking of ways to get more than one texture visible overlaid on the same side of an object. After many unsuccessful experiments with spheres, I have been able to get two textures on one side of a cube, actually:

Pretty trivial once you think of it.

Pretty trivial once you think of it.

While the inside of the hollow cube is counted as a single prim “face”, and is therefore distorted by stretching the texture across four faces that we see, it is distorted in a linear fashion, easy to compensate for by texture repeat settings while still drawing a texture as if it was perfectly flat and not distorted. If the face you see from the side of that hollow cube is transparent, you see the part of the inside face that is furthest away from you, or, to be technical, you see the part of it that has the polygon normals pointing towards the camera and don’t see the part that has the normals pointing away from camera. Squish the cube flat in that direction, and you’ve got an almost flat sheet with two overlaid textures which can be manipulated separately.

There are multiple things this could be used for beside a clock face, for example, for crossfading two arbitrary textures, or assembling fabric patterns from separately tinted textures.

Unfortunately this will only bring the minimal clock primitive count down by one, since you still need another texture for the clock face. I keep hoping there’s some way to do it similar to the technique to get a prim with five separate “faces” side by side, as used commonly for billboards of various ilk, however, it does not seem to be possible without some high wizardry I do not yet know.