JF make 248
JF Nav
JF Nav
Creation Date: 2003-01-16
If you want a little peek into what my nightmares look like, here's a good picture. Below is another picture directly imported from my nightmares.

It is 3 AM now and nightmares are certainly on my mind. I fell asleep at 8 PM tonight and woke at 1:30 AM and have had nightmares until I finally gave up to write you this.
Did I just invent an alpha wave interpreter for Linux? I'd be a trillionaire if I did. Actually, I got this by a bit of an accident. You see, I wanted soft things in AltSci Terrain Works v4. So I went into GIMP and just airbrushed a bit and came out with this:

It's pretty smooth, right? Wrong. That is what generated these spikes. That image became the heightmap and texture for that terrible looking scene. The heightmap technique is very simple. You simply draw a greyscale picture like this and it is instantly translated into 2d surface with heights related to the intensity. The darker, the lower the z component, the lighter, the higher the z component. It took me two days (two days means that after school I came home and spent 4 hours on it twice) to write AltSci3D Terrain Works which produced this picture using the AltSci3D engine which I designed. It's not finished by a long shot, but it has basic functionality. Functionality that I have to add is: lossless design-time LOD, lossy design-time LOD, manual editing, addition of buildings, and save to usable file (probably a ms3d file). Currently, it's just rendering vertices in triangle strips. I really like it because it is much cleaner than the previous version of Terrain Works (AS3D TW 1).

Of course, the previous version of TW was written in Visual Basic 6 and DirectX8. Ha ha ha! My father probably would not get such a kick out of that. Right now, he writes code professionally in the next iteration of VB, VB.NET. Yes, it still is ugly code. Yes, it is still a compiled scripting language. No, it is not object oriented. No, it does not compile to the same machine code as C# and C++. If I wanted programming to be easy, I would write PHP or Python scripts. If you are a real programmer, you want control of the computer. Entering in machine code is control. Assembly is control. C/C++ is control. Using open source libraries is control. When you have control, you know what is going to happen and why. You will know if the process will take a millionth of a second or one hour because you have counted the iterations of each loop and you know how many instructions each thing in each loop takes. A JPEG encoder you write will take exactly 0.312 seconds because it has to do loops of iDCT matrix operations on exactly 640 columns and 480 rows on your picture and you know. A VB.NET programmer tells his program to draw a pie chart and to encode it into GIF format (yelch, PNG is so much better). He only knows that it is going to slow down the server enough to make people complain. So what does he do? He makes the GIF smaller and tells his client to buy a faster server (a non-beowulf cluster of Quad 2 GHz Xeon). Not that a real programmer wouldn't have that problem if he did the same, but the real programmer could probably solve the problem by speeding up the pie chart algorithm. The VB.NET programmer doesn't have that luxury.

The lesson of today is to make things that work solidly. That is a very tough thing for people getting started. They usually think that just getting things working is enough. No, and I'll tell you why. If you want to use something temporarily, like a script sloppy works, but if you wish to use something generally, you have to put some effort to making it work. A program like Terrain Works cannot be hard scripted to only handle heightmaps that are 512x512x8. You can get that data from the image itself, that is what headers are for. And you don't want to hard code it to only open ./data/height.bmp, right? You want to be able to use /home/jvoss/usgs/los_angeles.png, right? Sure. So how do you do it? You simply put a string grabber somewhere in your program so that the user, not the coder, can tell you what image. I have the AS3D Data File Format (*.ASD) which is a text file that tells me everything. Then I put it through my general AS3DTexture class wringer that has png and bmp loading depending on the filename. It outputs the data to an array and I use it to generate the heightmap. The idea is the concept that user-defined things are given to the user to decide and the coder works around that fact. For example, if the user has multiple asd files, how will the coder find which one to use and parse? Simple, I just parse the command line arguments. So when you type in ./AS3DTW ./data/scene1page1.asd, you get the correct asd file. But if you don't use the command line, what do you do? Well, there's a default called as3dv4r9.asd. You can also click a file.asd and it will load up AS3D with that asd loaded. Of course, Manga Director, Terrain Works, and AS3D use asd files, so I have three different headers for each program that they use. So what is the lesson? Your code should be robust. Think of every impossible problem that could come up and you'll get a list of the bugs that you'll find in non-robust code. Crashes, root exploits, slow-downs, and general chaos can be attributed to bad programming, not to the computer, but to the programmer. So what did I do for you to further explain this example? I wrote a bash script for all you Linux heads out there. It converts a directory full of mp3s to oggs.

I decided to convert my mp3 collection to oggs today. I have a gig, so it's a bit of a task. You see, most people just delete their entire mp3 collection and re-rip them to oggs. There are some sweet tools for doing exactly that. KDE3 comes with this ogg ripper that is drag and drop. If that isn't sweet, I frankly don't know what is. But I don't want to go through the pain of ripping the thirty some CDs I have, even if it will give better quality than converting (I'll eventually do it when I'm bored). I have a gig of mp3s and I want it to magically become a gig of oggs. So this script does it. Almost. I turned 156 mp3s (613.1 MB, 128 kbps) into 156 oggs (472.6 MB, Quality 3 VBR, 77% compression) using this script. The quality is good. I can notice difference, but maybe it's just me. First off, it doesn't set any of the tags. Of course, the naming tells me enough. My Off the Hook mp3s can't use this to convert because they are 16 kHz and ogg doesn't know that. No problem, I just use oggenc -B 16 -C 1 -R 16000 -q 1 -r -o "ogg/$1.ogg" - instead of the normal oggenc -r -o "ogg/$1.ogg" - I found that the Off the Hook episodes are quite a bit larger in ogg format, even at quality 1*. The last problem is that it leaves the mp3 extension on the ogg. It won't effect it other than cosmetically. Perhaps I can do something about that, but I don't think so now. So you see... you have complete control over how it rips. But it definately is the fastest way that I know of other than writing a full command line c program with mp3 decoder and ogg encoder. And from what I've heard, it's technically illegal. Uh oh! I'm doing something illegal by posting this, aren't I? Oh well, let the RIAA come knock down my door. #!/bin/bash # mp3_to_ogg_dir.sh # bash script to convert a # directory full of mp3 to ogg. # requires oggenc (oggtools) and mpg123 # definately the fastest way I know of. # This does not delete them mp3s, it # moves them to a new directory. function makeOgg () { # Check if file exists. if [ ! -e "ogg/$1.ogg" ] then mpg123 -s "$1" | oggenc -r -o "ogg/$1.ogg" - mv "$1" no_use else echo "Error, ogg file exists." echo "Delete if you wish to overwrite." fi } if [ ! -e "ogg" ] then mkdir ogg fi if [ ! -e "no_use" ] then mkdir no_use fi for file in *.mp3 do if [ -e "$file" ] then echo "Converting file: $file;" makeOgg "$file" else echo "Error, file not found: $file;" fi done exit 0
* I might try quality 0.5 or I might go wild and try the Ogg codec for low bit rate, low frequency voice, Speex. It's in Beta 3 right now, so it'd be a bit of fun. I want to use it for my game, Hack Mars since it will have a lot of speech. Who knows, by the time I get JF Anime done, it may be the low quality/streaming audio choice. JF Anime will definately be downloadable.
Home Characters Making Of Technical Mail News Links |< First < Prev Next > Latest >|  bandwidth version Goto Scene