I was originally going to keep my mouth firmly shut about this, but after EasilyConfused posted his nifty little "Box World" and set the bar, I had no choice but to shake my fist and reveal one of my other side projects: a raycaster. Not as flashy as EC's, but we'll see who can develop theirs faster. ;)
If you aren't familiar with the term, then you still surely know of it. Anyone who has played the wonderful iD legends such as Wolfenstein 3D, DooM, or Rise of the Triad* already know of raycasting and its historical glory.
Raycasting was the traditional way of simulating a first-person 3D view using a purely 2D map at reasonably fast speeds, given the hardware of the time. The idea was to 'shoot' out rays from the player's view-point and extend them until they hit a wall or somesort of opaque obstacle. It would then render a single pixel-wide sliver of wall, with its size dependent on how far away the wall was. Repeated for as many pixels across as the display is, this technique yields a final image that's fairly convincing of a true 3D environment. Here's the one I've been hacking away at for the last few days:
I know this isn't very impressive in the grand scheme of things, but I, for one, am literally beaming with pride at this accomplishment on my behalf. My math not being as strong as I would like, I've been attempting to create raycasters for literally years now. For years it remained the holy grail of programming feats, that I was never able to get to work properly. Whether it was faulty intersection-detection or the dreaded fish-bowl effect, I was just never able to get it looking anything like the classics like Wolfenstein 3D. So once my Linear Algebra course picked up a little this term, and I dusted off my Discrete Math notes from Grade 12, I finally hunkered down and decided that I'd make one: for reals! [smile]
It's still not quite perfect, but I don't think most people can notice. With wall textures especially it's hard to see the flaws.
One of the most exciting parts about a raycaster (or any "3D" engine) is that there's no shortage of cool potential features to add. I'm extremely excited about getting in floor/ceiling textures, distance fogging, skymaps, lighting, decals, and anything else implemented. I'll probably start with optimizations, however. [smile]
Luckily this adventure also technically satisfies one of my New Years' resolutions: that being that I get started on learning 3D math/programming this year. I fully plan on getting into OpenGL/Direct3D in more depth than I have been at some point, but in case I don't make it this year, I'm now still covered!
You may be wondering how exactly I have time for all of these side projects. I don't really think I do! Currently I'm trying to finish Membrane Massacre, working on a Scheme-like scripting language, writing a raycaster, rewriting a 2D collision system for Stencyl, and y'know, doing full-time university student stuff. Hopefully I can get MM out the door really soon and trim that list down a little. I'm aiming to beat Stompy to a release because I -- well, no reason really. I had had to plug his journal for all of his great progress. Darn moral obligations! [smile]
EDIT: Oh yeah. Raycasting Demo for sure.