The last thing the gaming development community needs is probably another 3-D graphics engine designed for first-person shooters. After all, there are lots of them in the market. Some, such as the original Quake engine, have even been released as open source (although long after they became technically outdated and were no longer of value to license for game development). Cube, however, stands apart because it was targeted at Linux since its inception, and has always been free.
This isn't a project in the experimental stage. Cube is already a fully playable first-person shooter that you can download and play. It even supports Deathmatch, online competitions where human opponents blast each other. It also requires modest hardware: a 500 MHz processor, 64 MB of RAM, and a graphics card with recent and compliant OpenGL drivers. nVIDIA's TNT2 and GeForce cards work very well.
Deathmatching with Cube.
Even better, the source code is released under a license functionally equivalent to the new BSD/MIT/ZLIB licenses. This means that anyone can create an original game using the Cube engine and distribute it. You can make your own game maps, models, and scripts for Cube to build your own action game from the ground up. You can even release it commercially without having to pay licensing fees.
This remarkable piece of software was developed by Wouter van Oortmerssen, a 30-year-old Dutchman. He works as a programmer for a games company in Coburg, Germany and started developing Cube in Fall 2001. Van Oortmerssen didn't intend to frag commercial graphics engines with his open source alternative. Rather, he was motivated by a personal challenge to create "the absolutely simplest engine structure I could get away with, to have some fun programming, and try out some ideas I had without getting bogged down in writing a complex (graphics) renderer."
Because the engine is intended to power first-person shooters, it works best at generating interior locations rather than simulating the outdoors. A future release will allow adjustments to the engine's "camera" perspective. This could be used to create a Tomb Raider-style platform game with a third-person view. This feature is possible, but not yet implemented, in the present release.
It's only an 8MB download, but Cube manages to pack in the basics to satisfy most first-person shooter enthusiasts. There are five weapon types: the super shotgun (similar to the one in DOOM II), the rocket launcher (a clone of Quake's), the chain gun (with similarities to the lightning gun in Quake III), the rifle (a counterpart of the railgun in Quake II and III), and the fist (like Quake III's gauntlet). These were chosen with the criteria of being diverse, uncompromising, and fun to use for Deathmatch play.
Cube's various Deathmatch modes provide a frantic play experience akin to Quake or DOOM. (Those seeking slower, more tactical, or "realistic" multi-player game play, like that of Counter-Strike or Rainbow Six, might be disappointed.) Cube has over 20 Deathmatch maps to frag on, and the netcode makes for enjoyable play over the Internet, even at pings over 200. The single-player game play resembles the original DOOM most closely and is designed to force constant movement and fighting.
The engine does not have Deathmatch bots, per se. It does have traditional single-player monsters and enemy characters that can be used in Deathmatch maps. While individual monster characters aren't a big threat to the player, their collective behaviors can pose a threat.
"It's not easy to directly compare Cube with commercially produced 3-D graphics gaming engines. Cube is technically very different from most other FPS engines. It does some things better than Quake III, yet does some things worse than DOOM II, so it's hard to say where it fits," says van Oortmerssen. On average, he guesses, Cube is similar to the Quake II engine in terms of features and capability.
That said, Cube does outperform most of its competitors in several areas:
Its occlusion culling is very precise, fast, and fully dynamic. This results in minimal overdraw, more freedom in level design, and allows for arbitrary modifications to the geometry during game play.
The lighting system, though limited in some ways, allows for dynamic soft shadows from many light sources.
Cube delivers a multi-player experience smoother than most commercial games.
The engine handles maps very efficiently. Load times are measured in fractions of a second. Maps can also be edited in the midst of games.
Dynamic lighting from several sources.
In upcoming versions of Cube, van Oortmerssen plans to include new features such as server browsing, demo recording, role-playing game extensions for the single-player mode, and simple shaders to enhance the graphics.
Most of Cube is van Oortmerssen's own original work, but it includes pieces from other projects. He built the entire multi-player code, which works over the Internet or on a LAN, but the network layer itself is enet. The enet library implements a portable interface for UDP traffic, performing all of the necessary bookkeeping and bandwidth management.
Lee Salzman, a 20-year-old undergraduate student at Carnegie-Mellon University in Pittsburgh, Pennsylvania, developed enet for Cube. He explains that "Cube's earlier networking used TCP, which ended up being rather disastrous due to buffering and synchronization provided by the protocol. This caused a substantial amount of lag when data was sent at even moderately frequent rates."
Opening Up the PlayStation 2 with Linux -- Howard Wen takes a look at Sony's upcoming Linux distribution kit for the PlayStation 2.
Linux Gaming Resources -- All work and no play makes for dull penguins. Liven up your Linux box with these invigorating game resources.
An individual Cube client sends out a seemingly insignificant amount of data, only about 1K/s. The bulk of these messages are small object position updates sent to the server up to 30 times per second (30Hz), for the server to broadcast to other clients. Position updates are sent frequently, and any given updates may subsume a previous one. Cube's networking layer tries to optimize for this case of frequent, redundant data. Salzman chose to implement a mostly unreliable packet model over UDP that provides sequencing of packets and optional re-transmission.
Another major technical issue that didn't work out exactly as planned is the LOD, or Level of Detail system. This subsystem calculates the time needed to render a particular piece of geometry in relation to the amount of space it takes up on the screen. For example, a nearby object should be more detailed than an object that is farther away. LOD maximizes the processing time for more detailed objects and minimizes that for less detailed ones.
Implementing this system successfully in Cube was a challenge. Changing the number of polygons on an object is not easy to do seamlessly without having distracting visual artifacts ("popping") appear. This is especially prevalent on slower processors. Van Oortmerssen settled on having the engine calculate how much it should scale back on its use of the LOD system when the polygon processing load becomes too heavy.
"LOD is less useful that I thought, but it's still useful," says van Oortmerssen. "Recomputing LOD in Cube is not a problem at all, only visual artifacts are."
Compared to most commercially made 3-D graphics engines, Cube is not as sophisticated in the eye candy department. Its geometry is somewhat limited. For one, it doesn't support advanced shader techniques. (Van Oortmerssen himself chose not to add these features since he wanted to keep Cube's original code design as elegantly simple as possible. They may be added by other developers in the future.) The attractiveness of the included maps is due to the skill of their artists.
An attractive map location.
Those interested in creating their own game with Cube should try their hand at editing maps for the engine first. Using the engine's map-making tool is a very quick and direct, WYSIWYG process. It gives you the ability to edit a map from within the game itself and to see immediately how things look. With most commercial engine editors, there is a substantial delay between editing the geometry and seeing the compiled level with rendered lighting and shadows.
"This immediate feedback cycle is one of the main advantages to Cube mapping," says John Fitzgibbons, a 24-year-old Web developer in Seattle, WA, who created two of the maps included with Cube. He has also made game maps for the DOOM and Quake engines. "It's probably most significant for lighting, because most Quake series editors show what the geometry looks like but have no provision for previewing the lighting."
Though you can generate simple map architecture rapidly, doing anything that pushes the graphical limits of Cube can be an artistic challenge. "You really have to think hard about how to implement some of the more interesting architectural features," says van Oortmerssen. "But limitations tend to bring out the best in mappers. If you look through some of the maps, you'll see that mappers have gotten rather creative with Cube's minimalistic features."
Regardless of the engine being used, negotiating creativity within technical limitations is forever an issue in game development. Cube's likeliest appeal may be to hobbyists who make original maps, models, and other elements for the Quake III, Unreal Tournament and Half-Life engines. Van Oortmerssen has provided this scene the means to create an entire game--not just a "mod"--from scratch, unrestricted by the licenses and costs of a commercially produced engine.
It may be yet another first-person shooter engine, but Cube is one that the game mod community can use, without limitations, as the basis for their own creations.
Howard Wen is a freelance writer who has contributed frequently to O'Reilly Network and written for Salon.com, Playboy.com, and Wired, among others.
Return to the Linux DevCenter.
Copyright © 2009 O'Reilly Media, Inc.