An easier way to make Trekkish ship hull "Aztec" patterns

I'm always on the hunt for cheaper and easier ways to do things. If you're a Trek nut, you've probably given the special effects of the various movies a good hard look and noticed some exquisite texturing of the ship's hull. A fine example of a fan's work can be seen here. The thing to note is the repeating pattern of light and dark areas on the primary hull. Man, what a lot of work.

I found this site which had a pretty good tutorial on how to achieve the effect with fairly low effort. Low effort? Yah, right. It still was more than I wanted to invest. For starters, I haven't got enough experience with Illustrator to get the lines all lined up, and curved, and properly radial. Blek. I decided to come up with a trick that exploited the power of Lightwave (well, any 3D rendering app should be able to achieve the same results) and avoid even more work.

  • Lightwave can make cones.
  • Lightwave can project bitmaps onto surfaces using "cylindrical" mapping.
  • Lightwave can render orthographic projections.

Are you thinking what I'm thinking? I can make a pattern in just a few minutes. As in, perhaps five whole minutes.

Start up your favorite paint program (that can paint individual pixels) and make a very small bitmap. Black and white, 7 pixels across and 6 pixels down. I used Windows Paint. Paint a pattern of black and white pixels that has no intrinsic pattern to it and has a roughly 50-50 distribution of black and white. Something like this (It's zoomed in for clarity - those are really just single pixels):

Now, make a new bitmap that's twice as tall and four times as wide. Copy your base image into the upper-left corner. Then paste your base image again into the lower left corner. In the lower left, invert the black and the white (Windows Paint has no automatic feature to do this):

Now, Copy those pixels and drop them adjacent, and flip them left/right (Windows Paint does provide a method to do this automatically):

Now copy the pattern from the lower left to the upper right, and vice-versa:

We're now ready to exploit Lightwave. Save this image. Start up modeller and create a cone, on the Y axis, 500mm radius for all dimensions. Initially, give it a low number of sides, but we'll change that later. For the default texture, make an image map, cylindrical mapping on the Y axis, and use the little bitmap we've prepped. Turn off pixel blending and mipmapping. Click Auto Size. For the scale, set Y to 1/N, where N is how many concentric "stripes" you want (X and Z scale should already be set automatically). Set the Width Wrap Amount to how many radial repetitions you want. Save the object and start up Layout.

Load the cone into a new default scene. Change the default light to point straight down, and move the camera so it also points straight down, and then aim it over the cone. You may need to increase the light's intensity to get black and white results, as opposed to black and grey. Set your camera resolution to something square. If you're using Lightwave 9, set the camera type to Orthographic, and set the image height to 1m. If you're using an older version, set your camera very high up, and then zoom in so the cone occupies the whole image view. Render!

You may notice that yours doesn't quite look "round." This is because the cone isn't quite round. Go back to modeller and recreate it, only this time give it 1000 sides. That will make the base of the cone round enough that you won't end up with a pointy edge and an angular feel throughout the pattern.

I don't know about you, but I say that's a whole lot easier than playing for an hour in Illustrator. Of course, you might want a bit more control over exactly where things fall, and you may want a different pattern closer in to the center. This will take a bit more work, but you can easily figure that out on your own (slice the cone and define more surfaces).

A cheap way to make a geodesic dome

I've been paining myself on how folks have made geodesic domes. It seems like an awful lot of work to do, and it must be pretty difficult to get everything all lined up. Then it occurred to me that Lightwave Modeler has all the necessary tools to do this quickly and very easily.

Here's a quick cheat-sheet recipe:

  1. Open modeler and select the new Ball tool. Open the Numeric panel and change the type to Tessellation. Leave all the defaults alone. Close the tool.
  2. Select the bottom half of the sphere and delete it.
  3. Select all the polygons and change the surface name to Beams.
  4. Select the Bevel tool and open the Numeric panel.
  5. Apply a bevel of 1.25mm shift and 1.25mm inset.
  6. Apply another bevel of -1.25mm shift and 1.25mm inset.
  7. Apply another bevel of -1.25mm shift and -1.25mm inset.
  8. Apply another bevel of 1.25mm shift and -1.25mm inset.
  9. Change the surface name to Glass.
  10. Deselect all polygons.
  11. You're now ready to apply appropriate surface attributes to the beams and glass.

Presto! One geodesic dome!

Free Password Safe

This is a followon to Counterpane Systems' free product Password Safe. It's a nifty tool, but it didn't do a few things that I wanted.

Then the source code was made available. I glanced at it and noticed that:
  • it was a lot of code (more than seems necessary) and
  • it had a few (minor) cryptographic mistakes.
Mostly because I was interested in writing my own version, I set off. This is written in C#, and uses the Microsoft .Net Framework. It's a bit smaller (well, tremendously larger if you count the framework download against it), and has several additional features:
  • All Unicode, all the time.
  • Uses the AES-256 (Rijndael) algorithm to encrypt everything.
  • Encryption is indirected: each string is encrypted using its own randomly generated key, and the keys are then encrypted using your passphrase.
  • All data is kept encrypted in memory and is only decrypted exactly when needed. Counterpane's version kept all the data in memory in an unencrypted state. Note, however, that my keeping things encrypted is only a minor security enhancement as the master decyption key itself (not your passphrase) must be kept in memory at all times and so a very determined hacker may yet still be able to extract sensitive data.
  • Files are stored as XML, which leads to future extensions without hackiness in the file format.
  • Can load/save to a web site (if you have permissions on the web site and the site supports the WebDAV verb 'PUT').
  • Can import v1.x Password Safe files.
  • Keeps password generation rules per entry (ie, this web site only allows lower case letters and numbers, and must be 8 characters long, etc).
  • Keeps a website per entry, and lets you directly launch the site from within Password Safe.
  • Keeps a secondary password per entry, for those sites that require another password to do certain things (stock trading sites usually have a trading PIN in addition to your account login).
  • Item categories. Distinguish between online stores and your online financial services. Keep credit card info seperate from product keys.
  • Keeps a password and PIN history per entry.
Future Features:
  • Nothing Planned at this time.

Bugs fixed:

  • No more opening the window offscreen! The window will now always open up fully on-screen.
Download Password Safe.zip (55KB, x86/x64, 4 Aug 2009)

Loopable Chaos

I've been working on a Stargate (see a few pictures) and one of the primary problems is the open wormhole. It's supposed to look like a water surface. The problem is it takes too long to render all that detail. I wanted to make an image sequence and then use that as a simple texture on a single polygon. The sequence had to be long enough that viewers can't notice the loop yet short enough that it doesn't take up too much disk space or too much time to render out.

This tutorial will cover how to make an image sequence that can be looped, yet still present the illusion of ongoing chaotic change. It will be a tutorial, not a recipe. Some amount of your own creativity is required.

Lightwave comes with many different flavors of fractal noise, and animating that noise in some way is pretty easy. Let's start with an example. Start Modeller and create a rectangle that's perpendicular to the Z axis:

OK, save it. Load that into Layout. Open the surface editor and set Double Sided (not strictly necessary, but it saves us the effort of properly aligning the polygon to the camera). Change the surface color to black. Assign a procedural color texure, and pick one of the myriad fractal noise functions. Set the scale to something appropriate so you can see some level of detail. Set the procedural texture color to white and do a test render. You should see something like this:

If you were to render several frames, they'd all come out the same since we haven't animated it yet. Since the rectangle was built perpendicular to the Z axis, changes in the texture's Z position will provide the best illusion of random variation. Moving the texture's position along the X or Y axes will only give the illusion that the texture is sliding around and not really changing.

Go back to the texture editor and click the Position tab. Then click on the E button to the right of Z. The graph editor will open with the Z axis selected.

Decide how many frames the animation will last. Note that if you plan on using the Ripples texture in your mix of procedurals, it will dictate how many frames you should use. The wavelength divided by the wave speed gives you the number of frames before the texture repeats itself. Be sure to choose useful values here so that the division results in an integer! Or, if you're going to use multiple Ripples textures, use the least common integral multiple for all instances to determine the frame count.

I'm not going to use Ripples in my mix so I'm going to arbitrarily use 60 frames. At frame 60, create another key and assign it a value:

Render out frames 1 through 60 (not 0 to 60) and you'll get something like this (you will need Windows Media Player v9 to view). However, there's a problem. The last frame rendered isn't the same as frame 0 would have been (had we rendered it) and so it won't "lead in" very well to frame 1. In fact, the whole tail end of the sequence has no relationship with the front end of the sequence. Consequently, the loop has abrupt jumps in it.

The solution is to use the Oscillator motion modifier. Delete the key at frame 60 and then click on the modifiers tab. Add Oscillator and open its property page. Set it up like so:

Note that the cycle time is 2 seconds (I'm using 30 fps), so the whole cycle will last the 60 frames. Also note that the start of the cycle is frame 0, but we'll be rendering starting with frame 1. This way, mathematically, frame 60 is the same as frame 0, and it'll loop nicely. Here is the result, and here is the loop.

It's better, in as much as the sequence loops nicely. However, this isn't good enough. It looks like it's see-sawing. The sinusoid is ridiculously obvious. We need to add to this to get rid of those pauses where the texture turns around. Go back to the texture editor and clone this layer twice. Set the two top layers' blending mode to additive and set all three layers' opacity to something between 30 and 50 percent (otherwise it'll get all washed out). To maximize the effect, we need to move all three textures to different base x,y positions (exact location is pretty much irrelevant - just as long as they're not overlapping):

Now change the oscillator settings so that the first one has a phase of zero (it should have that already), the 2nd has a phase of 120 degrees, and the third has a phase of 240 degrees. Looking at just the Z axes will show this:

The important thing to note here is that while any one of the textures is at a crest or a trough, the other two are changing rapidly. You can use any number of texture layers, as long as it's an odd number. I'll leave it as an exercise to determine why using an even number isn't helpful. The phase values for each layer should be L*360/C, where C is the count of layers and L is the layer number. When we render this out, the noise should be devoid of any noticable pattern. Here is the result, and here is the loop.

So there you have it. Now you know how to make a small sequence of apparent randomness that will actually loop for you. Watch for movies of my stargate that exploit this technique. You can apply it to clipmaps, bump maps, deformation maps - anywhere you can use a procedural texture.

UPDATE - It occurred to me that this can be done with just two layers where one has a phase of zero, and the other has a phase of 90. Any other even number of layers doesn't buy you anything (again, think this through for yourself).

ANOTHER UPDATE - There's an even easier way to do this. See my new tutorial for accomplishing this with whole volumes here.

Free Disk Defragmenter

OK, so I've never been very happy with the disk defragmenter that comes with Windows 2000 and XP. It's a "lite" version of Executive Software's Diskeeper. I haven't tried any recent versions of Diskeeper, but the v4 release didn't do a very good job if the disk was heavily fragmented and nearly full. Its basic algorithm is "for each file, find a free slot big enough to hold that file and move the file there. Repeat until bored." Of course, if you haven't got a free slot that's big enough, you're hosed.

I tried Norton's defragger once and it corrupted my NTFS volume. I haven't even dared try a newer version. Things may have improved, so I have no warnings or recommendations there.

Then I found detailed documentation on how the defraggers are implemented here. The site also provided a cheap defragger and source code. Unfortunately, it suffered the same basic design flaw as Diskeeper - if there wasn't enough free space to hold the whole file, you weren't going to get any better.

So, I got to work. Here is the result. My defragger employs the tried and true defragmenting algorithm of "evacuate and place". It first evacuates a large portion of contiguous free space, then starts placing files in the new empty hole. Repeat until defragged. However, in order to do this, it needs to repeatedly iterate over every file on your disk. This makes the overall process quite slow if you have many files, but the algorithm never fails to completely defrag your disk, no matter how full it is (well, you need some free space). My machine at work has a disk full of about 112,000 files and folders taking up about 15GB and it takes less than 8 hours to do a total disk defrag.

It works with any OS-supported file system* on any OS-supported writable media. It will only work on Windows XP and later versions of Windows. It's been tried on XP, Server 2003, Vista, and some prerelease versions of Server 2008 (Longhorn). This program will not work on any other line of Windows (2000, 9x, Win 3.1, etc). There is no 64-bit version at this time. I highly recommend against trying to run this on any 64-bit version of Windows.

Features:

  • Can be run by any user (service needs to be installed by an administrator).
  • Complete whole-disk defragging, including private operating system files.
  • Multiple instances can be run simultaneously (if you have multiple disks).
  • Individual file defragging, with wildcards and recursion. This mode is an opportunistic defragger, marginally better than Diskeeper in that it will at least defrag the file as best it can rather than not at all.
  • Defrags NTFS, FAT** and FAT32** filesystems on any media (HD, Flash, ZipTM/JazTM, Floppy, etc).
  • A "shotgun" mode, where it severely fragments files. Useful for testing or really annoying someone.
  • Individual file fragmentation analysis. Find out where on disk a file resides, and how many fragments it's in.
  • 100% safe and interruptable. This program doesn't actually move the files - the OS does it. Even if you suffer a power failure while it's working, you run no higher risk of file system corruption than you would if you had happened to be saving a file from any application.
  • Boot-time defragmentation.

Future Features:

  • Functionality on 64-bit Windows
  • Defragmentation of NTFS metadata files

Given that Windows "7" has substanitally improved built-in defragmentation, I won't be doing any work to ensure full compatability with that version of Windows. I expect the current version will work as-is on Windows "7", and I don't plan on fixing any issues that are found.

*At this time, the OS only supports defragging on FAT, FAT32, and NTFS volumes. I don't know how far-reaching HPFS volumes are, or if other file system drivers even exist. For this program to work with those filesystems, the filesystem driver needs to support the defragging APIs of the OS.

** The operating system doesn't provide for defragmenting directories on FAT and FAT32 drives. While all your files will be as defragmented as possible, the immobility of directories totally throws a wrench in the process. Unless you really need to be using either of these file systems, I suggest you don't. NTFS is substantially more robust (you rarely need to run chkdsk) and it supports a huge variety of extra features, like volume striping, journaling, transactioning and so on.

Download Defrag.zip (82.04 KB, x86, 23 May 2004)