MAX: A Half-Baked 3D Engine

Posted: January 5th, 2009 | Author: | Filed under: Education, Software | Tags: , , , , , , , , , , , , | No Comments »

Last term, I took the CP411 Computer Graphics course at Wilfrid Laurier from Professor Hongbing Fan. It was an introductory course to creating computer graphics systems using standard C++ and OpenGL technologies. All in all, it was probably the best course I’ve taken yet at WLU, and I learned an awful lot. As a final project, we were asked to create some 3D application, and I chose (without really considering the ramifications of such a commitment) to attempt a 3D graphics engine.

The result was MAX; a highly extensible, working 3D graphics engine that I would say is about par with an N64 in terms of graphics capabilities, and leaves enough room for improvement that I could probably spend another full year working solely on it. However, for 2 weeks development time, I think that what I came up with represents an excellent baseline for what is necessary of a 3D engine, and that it was a worthwhile project and a great learning experience.

Following are a number of screen shots from the project:

The engine itself, while simplistic, is robust. It relies on OpenGL for its lighting and backface removal functions, supports mouse and keyboard input, texturing, models (although I haven’t written any adapters for importing complex model formats yet – all of the models are hard-coded for now), collision detection, and basic physics such as gravity.

By and large, I had problems with the amount of work. When I decided to create a 3D engine, I made the mistake of not setting out some boundaries for what I wanted to get out of it. I had 2 weeks to work on the project, and just started throwing whatever I had at the project. This of course led to feature creep, poor organization, and a continuous reduction in expectations for the final product. That said, I really am proud of the result of the experiment, although I would definetly change my work habits next time around.

Finally, here is a quick list of improvements that I feel need to be made to the engine before it is ready to host any kind of game:

  • Improved Collision Detection: Current algorithms utilize a simplified object-aligned bounding box algorithm that simply checks whether any two bounding boxes intersect with each other. Pros of the method are that multiple bounding boxes are supported for any model, and that moving model collisions (colliders) are abstracted from non-moving model collisions (colidees), meaning that no two inanimate objects will ever be checked for a collision with each other. A better method is to project the model onto each of the axes, and check for collisions between the resulting 2D shapes. If the 2D shapes collide on every axis, then the two objects are colliding. For an awesome tutorial (albeit in flash script and for a 2D engine, but easily extensible, check out N Tutorials)
  • Object Collision Events: Currently, when any two objects in the game collide, they both stop in their tracks. This works, but it would be better to assign some scriptable action to this event, and to implement semi-complex interactions like friction and force and the ability for one object to push another. The engine already supports gravity on all moveable objects, as well as collision detection with the outer walls of the world area, so a little bit more physics would be nice.
  • Complex Model Support: This is a seriously trying thing to do. Models of more than about 50 polygons quickly become unwieldy to handle quickly in memory and require some fast code to display at a decent frame rate. At least that’s what I’ve read. Since I needed an engine fast, and didn’t want to waste my time modeling (heck, I can’t draw anyway), I created my models as hard-coded in-engine entities comprised of simplistic geometry and this did not become a concern. However, I would like to improve my model class to support a greater number of polygons and textures, and enable reading in from common model formats.
  • Texture and Lighting Class Wrappers: Currently these items are exposed right in the main class of the application. It would be nice to have some sort of abstraction around them that allows for simple palette and lighting switches, as well as for improved resource management. Also, dynamic shadows are cool, and require only one additional rendering pass that should be easy enough to implement.
  • Particle Engine and Visual Effects: An easy way to do really cool visual effects is with a simple, sturdy particle engine that supports textures, anti-aliasing, and swarm-like movement of the particles. This can be used for bugs, birds, magic spells, weather effects, leaves in the wind, tornadoes, or really most any other simple effect you can think of. NeHe has an interesting tutorial on the matter here.

Overall, I’m proud of what I accomplished in such a short period of time. As always, the code is available for download for those who wish to play with it or just check it out.

Enjoy,

Jon

Edit: Resized the images so that they aren’t all gross and stretched out. Also, my apologies to any non-programmers attempting to download the engine – all you’ll get is Dev C++ source code. I’ll compile it and up an *.exe file tonight for those who aren’t interested in the pain and anguish involved in attempting to use Dev.


Post-Midterms Class Roundup

Posted: November 1st, 2008 | Author: | Filed under: Education, Software | Tags: , , , , , , , , , , | No Comments »

So midterms are finished, and life goes on. As much as I’d love this post to be tech-oriented, showcasing some brilliant new software that I’ve written in my spare time, the truth is, I haven’t had enough spare time lately in which to write any software of value.

The small exception to that claim is this app, a neat little VB and XML oriented program that allows you to read an iTunes playlist file (as exported to XML), and auto-copy all of the songs in that playlist to any folder you wish, preserving the artist/album/song file structure.

I wrote the program to fill my brand new blackberry with a selection of excellent songs, because the built in Roxio media manager is great for pictures, but slow as sin when it comes to larger media files. After writing it, I realized that it could also be a useful piracy tool; but then again, a hammer could be a positively fantastic homicide tool in the wrong hands too. Of all the libraries I’ve ever written, my .NET XML parser has spawned off more crappy little programs, making it possibly the most useful bit of code I’ve created.

Other than that, my coding has lately been limited to some cool graphics stuff in with OpenGL and C++. So far we’ve constructed a classic spinning cube implementation, complete with a custom view pipeline that implements transformations, dynamic shading, and back face culling in software. The next topic that we’re studying is texturing, and eventually, ray tracing and shaders.

While none of my assignments for this course have been interesting enough to warrant posting, I’ll definetly up my final project for the course, which at this point, is probably going to be a 3D terrain generator, similar to that of Sim City 4 fame.


Start of Term Class Roundup

Posted: September 12th, 2008 | Author: | Filed under: Education | Tags: , , , , , , | No Comments »

I have to admit it – as a fourth year computer science student at Wilfrid Laurier, I pretty much hate school. Don’t get me wrong, I dig the computer science based courses in my program, and the courses I’ve been taking towards my history minor are intriguing. The campus is beautiful, and overall, the profs are excellent. These things said, math has never been my strong suit, but is a heavy requirement in my program, and the entire school experience is beginning to sour. I’d really just like to get on with my life and quit being a poor student. Ah well, only another year and a half to go.

In any case, my upcoming term looks alright. I’m taking the following courses:

  1. MA205 – Differential Equations I: Like most of my classmates, this is my second shot at MA205, a class that relies mostly on first year knowledge, but generally (and unwisely) isn’t taken until third or fourth year because most people don’t like taking two math courses per term – it’s just too stressful. My previous experience with this course was less than enjoyable. For those who have never taken a course on DE’s, imagine of a course that is about 80% Integration and 20% differentiation in a field of application where most real problems cannot be completed by hand, and are instead generally solved by handy software like Maple.
  2. CP411 – Computer Graphics: So far, this course has been excellent. It covers the basic concepts involved in computer graphics, including software, hardware, common algorithms and techniques, all with a focus on OpenGL in C++. Aside from my relative unfamiliarity with C++ (I haven’t worked much with C since first year), this should be an interesting course and an excellent learning opportunity, taught by one of my favourite professors at WLU.
  3. CP472 – Programming Languages: Another excellent course, this is a brief overview of the history of programming languages, from the very first machine code languages for IBM machines built in the 1950′s, through punch card languages, assembly languages, early (but still used) languages like FORTRAN and COBOL, right up to current high-level object-oriented interpretive languages like Java and the members of the .NET framework.
  4. HI248 – The Second World War: Another extremely interesting course that covers the history of WWII from the end of WWI and the treaty of Versailles, right up until the end of the war, with emphasis on strategy and geographic troop movements throughout the war. It has one of the coolest textbooks that I’ve ever had, which explains the entire war through maps, allowing you to visualize why battles were fought the way they were, and how the fronts moved throughout Europe, Asia, and Africa.

Aside from the math, this should be a very interesting term, with a lot of courses that I’ve been looking forward to taking for a long time.

Cheers,

Jon