OpenGL and Geometry Generation

Today I was thinking about 3D rendering (in part because of the recent work I’ve been doing with ray tracing). I worked out all the math for drawing a polygon based on a list of vertices and a camera. I was considering coding it up, but then I realized that I was very unfamiliar in working with Windows (because I sure as hell wasn’t going to do this in Java). So I spent the greater portion of the afternoon reading a tutorial on Windows programming and using OpenGL, at which point I abandoned my original. I was just going to finally figure out how to use OpenGL.

I had worked with GLUT before when working on a Parallel Computing lab. However, I only used pixel control in that case; I was rendering subsections of a Mandelbrot set. However, that was easier because all the requisite libraries were already installed in the major lab at school (which has workstations with Gentoo installed). Working at home, I have been confounded. I just can’t get the linker to use all the requisite libraries.

The whole thing that got me thinking about 3D engines was my working on a HL2 level. Often I will import brushwork (pieces of the level) from the game’s campaign levels; it saves time and adds a nice level of detail to the environment. However, I was thinking about common elements such as stairs, doors, windows, and grates. It’s a multi-step process to cut a hole in a brush, unless you use carve (but nobody uses carve because it doesn’t give you control over how the geometry cuts). Doors are tedious to cut out and then line up with the texture. Non-solid stairs are the most painful to make, however. You have to arrange the steps and make sure the sidings match up, and for each new type of turn you have to rework the geometry. The whole idea of hand-making all the geometry in a level is ridiculous. I haven’t seen a single FPS level editor than lets you define procedures for geometry generation.

A screenshot of the Hammer UI

A screenshot of the Hammer UI


I feel like it would be relatively simple to define a generation process for buildings, for example. Each building is spaced a certain distance in from the sidewalk. There are maybe two or three justifications for things like planters and doors. Then windows are spaced evenly apart, with buffer spaces on either side of the building. You could attach balconies or planters on to every windows, awnings above doors, and even outdoor area layouts for cafes. After meticulously defining a couple of building styles, you could almost instantly generate entire blocks. Then come the nested procedures. A street, for example, would have periodic drains and manholes, distributions of building types based on the neighborhood type, and junctions to more streets. Signs, traffic lights, road markings, and crosswalks would all be placed correctly at street corners. Coul-de-sacs could fill up empty space. Interiors could be set as well for buildings. Floor plans could be modular. Rooms with distributions of room types and different layout permutations would combine into floors. A building type could have a sequence of floor types defined, such as bottom level stores and top level apartments. Central structures like stairwells would only need to be made once.

Although the procedural parameter definitions might take a while longer than making regular geometry, it would be a huge time saver. Not only could full geometries be generated, but intricate, custom-designed battle areas could be laid out faster. Common terrain pieces like walls, fortifications, stairs, railings, gates, and hedges could be created with the use of a single spline. Suddenly a task like designing the maps for my strategy game becomes less daunting. The pipeline for map production is shortened. General map layouts can be quickly sketched out and then directly generated. Beta testing would be infinitely easier, as map adjustments could be made in hours, rather than days.

Map Design

I’ve always been highly interested in creating levels for games. Computer games enchant people with their story, gameplay, and graphics. Some designer created everything I see in it. It would be incredibly fun and rewarding to wield the same power as the game designers.

Ever since I was a little kid, level design has occupied me as much, if not more than, the game itself.
I started out with games that came with easily accessible editors. Strategy games such as the Age of Empires (and Age of Mythology) have drag and drop editors accessible from within the game. Command and Conquer: Generals has an easy-to-use editor, accessible through its root directory. As I grew older I began to experiment with triggers more, crafting a crude story or giving a gratifying gameplay experience.

Most of these maps were for single-player games, with one exception. I would often hang out at my friend’s house and invite he and his siblings to compete in map-making competitions. We would take the turns crafting Super Smash Bros. Brawl maps, with a rather short time limit. The we would play a quick match on it. The best would get saved and played often. I made quite a few enticing designs in those sessions. My levels created unique gameplay situations that weren’t achieved in the default maps.

My attention slowly fixed on a new game. While I had been familiar with Halo: Combat Evolved for a while, it suddenly occurred to me that I could create single-player levels with story as interesting as the game’s campaign. I looked into it and discovered Halo: Custom Edition. I got involved in the community, and tried my hand at non-drag-and-drop map creators. While I didn’t know it at the time, Halo’s utilities are extremely obtuse. I never had much success in creating my own levels, although I experimented with new kinds of enemy formations and scripting on pre-existing custom multiplayer levels, although I met with little success in the latter. I had an entire 5-part campaign planned out, including overhead sketches, concept art, the beginnings of a 3D model (although I was still a newbie at modeling), and enticing characters. Needless to say, it never got off the ground. To this day, I dream about how cool it would have been.

A step up from Brawl, but a step down from Halo, came Halo 3 Forge. Although it was purely multi-player and was not very powerful, Forge let me create a blend of the epic Brawl maps I had forged and the Halo campaign I had brawled with. I would Forge until my friends got tired with me (I am a PC gamer to the heart, and don’t own any consoles). The recent Halo: Reach called me back to that, although the Reach Forge was so much more powerful that I never had the time to truly explore it.

After Halo, I discovered the Orange Box. Boy, did that open up a whole new world to me. I soon after discovered the Source SDK and began to explore the glorious world of Source map-making. To this day I have a campaign planned out for Half-Life 2 that follows a rebel operative as he subverts Combine operations in the American heartland. The only thing that disappointed me about HL2 was the limited capacity for storytelling (no first-person dialogue, cutscenes, or interaction). TF2, on the other hand, tells a great story, despite being purely multi-player. I am in the starting stages of figuring out how to bring a single-player story experience to TF2.

In addition to Source, Steam let me find Crysis. The Sandbox2 editor truly lives up to its name. I spent hours in that editor, sculpting tropical islands and scripting helicopter fights, beach assaults, and stealth insertions. The great thing about Sandbox2 is that it was extremely to pick up, requiring only a few tutorials from someone like Xanthochori. Crysis 2 with Sandbox3 was disappointingly more complex.


To check out some videos of maps I’ve made and other videos (I’m also into video production), see my YouTube channel.

Epic-scale Strategy Game

One idea for a game that has stuck with me for over a year has been that of a massive-scale strategy game. A crude way to describe it would be a cross between World in Conflict(WiC) and Spore (except it wouldn’t be as lackluster as Spore). The idea behind it is that players start out at a low rank, and are promoted based combat proficiency on the battlefield. When I have described this idea to people, they have likened it to America’s Army.

Each round of the game takes place on large battlefields covering a multitude of environments. The game would undoubtedly be set in the future, so the environments could range from undeveloped farm worlds and water worlds to urban centers and various theaters of space. A single player presides over the whole battlefield as a general, setting basic goals and deciding strategy. Each battlefield is in turn broken up into districts, which ranges in size from a WiC map (usually a couple miles across) to four WiC maps. Up to 8 commanders control 0 to 6 squads (they can order more based on reinforcement points) within each district. Each squad consists of 4 to 8 players, with one squad leader.

Screenshot of World in Conflict

Screenshot of World in Conflict


The basic foot soldier is expected to focus on objectives set by the squad leader. The squad leader is in charge of directing which positions to take and which enemies to focus on. A commander sets goals such as strategic objectives (defined by the game), rally points, and drop zones to secure. They are also in charge of ordering more troops. Their basic strategic goals are determined by the general above them, or perhaps an intermediary presiding over the district.

One major problem that becomes immediately apparent is discipline. How does one keep a player on task? The first solution that comes to mind is to let superior officers give or take promotion points based on the performance of players below them. However, this is easily abusable, both in the giving or taking of too many points and in the complete disregard for dealing with promotion points. The best solution is to have proficiency judged by the game. So what kind of criteria does the game have?

  1. Completion of given objectives

  2. Objectives are judged by the difficulty regarding enemy presence in the area and a number of other minor variables, the most important of which is subordinate proficiency. Failure to complete an objective due to it being impossibly difficult or having an inept team would barely count against a player. Conversely, failure to complete simple objectives would be counted against a player.

  3. Rendition of reasonable objectives

  4. A commander, whether at a high strategic level or as a squad leader, has a responsibility to give orders which make sense. If a commander is extremely incompetent, his commanding officer can choose to temporarily demote him, allowing another to take his place. In addition, sound tactical decisions are encouraged. Deciding to attack a position without much intel, even if the position is strategically important, is a bad choice. If a commander has access to tactical aid, poor placement will result in removal of promotion points.

  5. Combat Proficiency

  6. If the player is a grunt, he is also be promoted based on statistics like accuracy, deaths, and kills. Heroism and initiative may also be rewarded, such as single-handedly taking an objective or destroying a vehicle.

A player who accrues enough promotion points will be promoted to the next rank. There may be multiple ranks per command level to ensure that there will most likely be a command hierarchy even if two decimated squads are merged. Even if a player is promoted, though, it is possible that he will fill a slot lower down in the structure. If there are already enough commanders, someone qualified to be a general may be forced to serve as a grunt. However, if his squad leader is killed then he will instantly fill that slot (unless someone is of a higher rank than him). When a soldier dies, he is placed in a reserve pool. Until a commander orders another squad, he has to wait. Fortunately, battlefields are huge, and most likely, especially at the height of the battle, someone will need a new squad. Nonetheless, a delay time while waiting to be ordered also acts as natural motivation to stay alive. Be warned though, cowardice will be punished highly! Soldiers who pass qualification courses for things like vehicle piloting, administering first aid, and sniping will be able to fill special support slots.

Alongside infantry, commanders will be able to order a range of vehicles, including tanks, transports, and dropships. Other vehicles, like helicopters and ships, will be available as a special unit which must leave after a period of time. Tactical aid not delivered by a player includes artillery (including orbital strikes), airstrikes, and reconnaissance. All tactical aid (i.e. units and abilities not able to be ordered with reinforcement points) is able to be gained through spending tactical aid points, which a commander receives for performing well on the battlefield. Tactical aid points are different from promotion points in that they do not stick from game to game and that they are awarded for quantitative properties, such as objectives completed and enemy units destroyed.

The first person gameplay of the grunts would mirror other mainstream shooters. Each soldier has an array of guns, with the maximum weight decided by the planet’s gravity. Secondary weapons such as grenades and tactical devices (repair kits, radar kits, radios, medkits, etc) are available. A soldier can resort to melee if he runs out of bullets or is restricted by the environment (close quarters, pressurized space environment, presence of volatile props). The game’s varying environments also heavily affects gameplay. For instance, combat in space is an entirely different experience. Players would be able to move almost infinitely far (but would be penalized for abandoning objectives), and combat would be a lot slower. Players would have to worry about keeping their suits intact as well as jetpacks. Vehicles would also play a larger role. Alongside dropships becoming more versatile and critical, spaceships would start playing a role. In some cases the commanders might even be able to control large cruisers with a deadly array of weapons. Space stations would also hold a lot of firepower for whichever side’s soldiers could maintain control of it.

The story of the game would revolve around two distinct sides. Two budding empires emerge from different sectors but end up clashing for control of the core colonies. Whichever side dominates the colonies gains ultimate control over known space, since the colonies are the main centers of knowledge and raw material production. Humans have developed faster-than-light travel, but have not yet perfected material synthesization, so the majority of humans still rely on farm worlds and other such production centers to get metal, food, and leisure products. The FTL will probably be like The Mote in God’s Eye, in which ships can manipulate certain zones of space determined by gravitational fields to jump between stars. These jump points are hard to calculate, and only one exists between each set of stars. FTL communications have not been developed, so the only way to get a message to another system is to send a ship (a jump disables electronics and requires a sentient being to boot the systems back up).