Jump to content

April 2017 »

23 24 2526272829
- - - - -

Computer Animation - from 1 bit to 64

4: Adsense

From the time I started building and programming computers ... [this space intentionally left blank] years ago, I've always been interested in computer animation.

My first computer was a prototype board, wire-wrapped, scratch-built using an Fairchild F8 (8-bit) processor. I added [hang onto your hats] 64 bytes of external static ram! Yeah, you read that right - 64 bytes. The F8 had 64 bytes of internal ram for a whopping total of 128 bytes! And I had that cpu humming along at 128KHz. I was working at Oak Ridge National Lab (ORNL) at the time and was able to program a UV EEPROM (maybe a 1702?) for my BIOS, an additional 256 bytes of memory. I added a 4 character hex display (that took some power) and a hex-key input pad.

The F8 had bunches of bidirectional IO (16 bits?), and I added a 1-bit speaker, the hex-pad and the hex display to it. The keypad was a 6x4 cross-bar scanned input with debouncing done in the BIOS. The hex display was 4 seven-segment displays. Each segment drew 15mA (~ 1/2 amp total). I built a 1-amp 6-volt (filament transformer) power supply (huge) with a 1F (yeah, 1 Farad) filter capacitor. At the time, I was also into ham radio and had shelves of parts I bought at hamfests at prices of a dollar-a-pound. Transistors, scavenged from discarded main-frame computer memory boards, were a penny apiece at a local electronics second-hand shop.

My first program (took me days to program it - and no way to save it after power-off) was my first shot at computer animation. By timed toggling of one IO bit, I got one segment of one of the four seven-segment displays to blink! Within weeks, I expanded my repertoire of programs to including blinking the seven segments of one display in a figure-eight pattern.

At ORNL at the time, there was some "advanced" animation work going on. We were trying to build a graphics based control station (a GUI) for a uranium reprocessing plant, as the plant operators would be remote but still need real-time updating of the process. By storing 32 images of a stick-man in various walking poses and blitting the images continuously from the disk to the screen, one of the programmers actually displayed character animation! I was hooked.

I graduated from the F8 to an Intel 8080 with 16K of dynamic ram and a 32K bios. That was still 8-bit IO but the 8080 had a couple 16-bit registers which could be used for some real computing power, and it ran in the multi-MHz range. It was still a home-brew machine, but my output was to a ray-traced O-scope with actual letters displayed on-screen. My animation programs included Lissajous patterns and even a rotating square!

As my salary increased slowly, I was able to afford a commercially made computer! I bought a Radio Shack TRS-80 (Tandy Radio Shack) Color Computer (the C64 was the biggest competitor then), a beautiful machine. It had 32K RAM, 32K ROM (holding the Color Basic interpreter), output to a TV "monitor," ADC (analog-to-digital converter, successive-approximation with resistors) port, a tape-recorder connection, and an external (5-1/4) floppy drive connection. I couldn't afford a floppy just then, but I was actually able to save my programs to cassette tape!

I could draw geometric shapes (filled or "wire-frame,") and text, all in any of a dozen or so colors. I graduated from 2D to 3D animations and managed to display a rotating cube, using sines and cosines and all kinds of math functions. I think I even got it to display at one or two frames-per-second by storing patterns in ram. That was my introduction to graphics eating up memory at a prodigious rate! I needed more RAM.

Another "feature" of the TRS-80 was a warranty-violation sticker over one of the chassis screws. However, it was easily penetrated by a Phillips-head screwdriver and I installed (a proto-board wire-wrapped) 64K shadow RAM circuit. Programmatically, from the lower 32K memory space, I could copy (byte-by-byte) the (PROM) BIOS to RAM, and use some of the RAM above the Basic interpreter code! I even found a way to switch from 32K to 64K, read the shadowed RAM, switch back to 32K mode and now had 32K of extra RAM! All that just for better graphics.

Now I needed to store some of the graphics offline. After adding a floppy drive, I could store up to 128K of data to a one-sided floppy. With a little trickery, one could even cut holes in the other side of a floppy, insert it backwards into the drive and use those "expensive" one-sided floppies as two-sided "flippies" to store an incredible 256K of data! However, that was also my introduction to bleed-through. When you write to one side of thin magnetic media, the possibility exists that the same signal can be written sort-of upside-down and backwards, on the other side of that media. Simply put - "data loss." sigh.

Then came the wonderful years, extending to the present, of 16-bit, 32-bit and 64-bit machines, DirectX and OpenGL, internal hard drives, and ( can you believe it? ) monitors capable of displaying 64K color images at an incredible rate! I could display that walking stick-man of the past so fast the screen would tear.

My introduction to honest-to-goodness animated skinned meshes was through Frank Luna's book, Introduction to 3D Game Programming With DirectX 9.0c - A Shader Approach. I had read about "real-time mesh deformation" and spent hours modifying code and trashing perfectly good shaders, just to see how it was all done. So much of it was hidden beneath D3D9 objects like the skininfo object and ID3DXAnimationController. It seemed like it took forever to figure what "semantics" were about and why you had to convert to an indexed-blended mesh with a particular vertex declaration. However, D3DXLoadMeshHierarchyFromX and Luna's SkinnedMesh class were the best things that had happened to me since I had been bitten by the bug so many years earlier.

I learned how to use Blender (after a fashion) to create a model other than "tiny.x" to really see what's happening under the hood. I've written my own file-loader, hierarchy-builder, skininfo class and animation controller to support my need to understand it all. Nothing I've done is as efficient as the API stuff, but I'm moving on to D3D11 and, without the API built-in functions, that effort will serve me well.

Some time ago (again, the time frame is intentionally left blank,) I graduated from just trying to program the stuff, to learning the theory behind the stuff. As with just about all programming I do, having an understanding of the concept I'm implementing is the key to efficient use of my time.

Note to those responsible for innumerable posts asking for help getting this or that to work, having tried using sine instead of cosine, reversing the order of function calls, and all sorts of hacking attempts, hoping to stumble on something that works - save yourself a lot of time and grief with a simple process - UTCTRTFM.
Understand The Concept, Then Read The Friggin' Manual
- Understand the concept of what you're trying to do. Explain it out loud to someone who hasn't a clue what a matrix is, much less the inverse-of-the-transpose of same. Use your native language, not in terms related to Java or C or Python. You may be pleasantly surprised when you do that, as you force yourself to think in non-programming terms about what you're trying to accomplish.

- RTFM ( Read The Friggin' Manual ). How many posts have you seen quoting the docs - "The description of that function states you can't use managed memory for that" - followed (perhaps a day later) by "Thanks! Changed to system memory and it works now." A day of your life wasted.

Note: GameDev.net moderates comments.