JANUARY 1998

GAME DEVELOPER MAGAZINE GAME PLAN What's Your .plan? EDITOR IN CHIEF Alex Dunne [email protected] n Hollywood, reading an interview ty, and developer name recognition. MANAGING EDITOR Tor Berg is the most common way to find Undoubtedly, all of these factors trans- [email protected] out about what's going on in a late in some way to increased sales. EDITORIAL ASSISTANT Wesley Hall whall@mfi.com star's life. Magazines such as People, At a personal level, authoring a .plan I EDITOR-AT-LARGE Chris Hecker Rolling Stone, Spin, and Interview are suc- can raise your personal stock — if it's [email protected] cessful because the public wants to know written consistently and intelligently. CONTRIBUTING EDITORS Brian Hook what's going on with the people behind And building name recognition within [email protected] the movies and music. There's a natural the industry and with customers Josh White [email protected] curiosity about what projects they're cur- should be a high priority for anyone ART DIRECTOR Azriel Hayes rently working on and what's going on who's serious about making a name for ahayes@mfi.com in their personal lives. With the excep- themselves. ADVISORY BOARD Hal Barwood tion of the rare autobiography, however, A word of caution, however. Noah Falstein it's rare to get first-hand information Remember that what the .plan giveth, Susan Lee-Merrow from well-known stars. the .plan can taketh away. Those who Mark Miller That's not true in the game develop- forget to engage their brains before 4 ment industry. Game developers putting mouths in action often learn COVER IMAGE Darwin 3D expound their opinions about life, the tough lessons about making derogatory universe, and everything via .plan files, public statements on the Net. Off-the- PUBLISHER KoAnn Vikören and outside of the academic world cuff comments have been misconstrued, ASSOCIATE PUBLISHER Cynthia A. Blair (where .plan and .project files were innocuous statements have been turned cblair@mfi.com probably first used to keep colleagues against authors, and 3AM rants have WESTERN REGIONAL SALES Tony Andrade across the country updated on research proven to be public relations messes the MANAGER (415) 905-2156 projects), this candor is fairly isolated to following day. As with anything you run tandrade@mfi.com our industry. Some may dismiss finger- up the flagpole on Usenet and the Web,

ing .plan files as an outdated mode of adopting a harsh tone or making inaccu- MARKETING MANAGER Susan McDonald communication now that web pages are rate statements can get authors and their AD. PRODUCTION COORDINATOR Dave Perrotti ubiquitous, but in terms of simplicity companies in hot water. Companies DIRECTOR OF PRODUCTION Andrew A. Mickus and beauty, there's nothing like pure whose developers author .plans should VICE PRESIDENT/CIRCULATION Jerry M. Okabe vanilla text to get your message across. adopt guidelines that spell out which GROUP CIRCULATION DIRECTOR Mike Poplardo To help disseminate the contents of topics are acceptable to write about and CIRCULATION MANAGER Stephanie Blake the various .plan files around the indus- which are not. This may sound authori- CIRCULATION ASSISTANT Kausha Jackson-Crain try, a number of web sites have been tarian and somewhat counter to the DIRECT MAIL MANAGER Claudia Curcio launched in the past two years, which open nature of .plan authorship, but it NEWSSTAND MANAGER Eric Alekman effectively market .plans to the masses. also prevents someone from exercising REPRINTS Stella Valdez A quick scan of the Stomped Finger poor judgement in a .plan. (916) 983-6971 Tracker at redwood.stomped.com My point is this: don't overlook the Miller Freeman reveals constantly updated .plan files obvious when you're trying to get some A United News & Media publication from id, Rogue Entertainment, Ritual attention in today's crowded market- Entertainment, Raven Software, place. Web sites are great customer ser- CEO - MILLER FREEMAN GLOBAL Tony Tillin 3DRealms/Apogee, ION Storm, vice tools and online product CHAIRMAN - MILLER FREEMAN INC. Marshall W. Freeman Quantum Axcess, and more. Over 100 brochures, but all too often they lack PRESIDENT Donald A. Pazour developers have .plan files listed on the soul. If you're management, encourage SENIOR VICE PRESIDENT/CFO Warren “Andy” Ambrose site, and about a quarter of those are .plan authorship within your develop- SENIOR VICE PRESIDENTS H. Ted Bahr, updated every week — quite a bit of ment teams' ranks. If you're creating a Darrell Denny, information. game and your company doesn't David Nussbaum, At a business level, there are so many already support the notion of .plans, Galen A. Poss, reasons to author a .plan that it's hard approach management with the idea. Wini D. Ragus, to know where to begin. A good .plan Doesn't it make sense for you and your Regina Starr Ridley brings developers closer to customers, company to do everything within your VICE PRESIDENT/PRODUCTION Andrew A. Mickus letting consumers tap into the thoughts power to generate consumer interest VICE PRESIDENT/CIRCULATION Jerry M. Okabe and feelings of the people behind the and loyalty, especially when all that's SENIOR VICE PRESIDENT/ Regina Starr Ridley SYSTEMS AND SOFTWARE games. .plans build excitement for required is a little time every week and DIVISION upcoming games and connect con- some space on your server? ■ sumers with the creators of shipping games. They bring game players closer to members of the development team, and they build company identity, loyal-

GAME DEVELOPER JANUARY 1998 www.gdmag.com SAYS YOU

What Dave Said gy companies. In fact, those interested her suppositions concerning what does enough to spend their own time learn- and does not interest men, and the dif- ing a subject are usually more capable ferences between what men and f we are to believe Dave Thielen than those force-fed in the classroom. women like are valid, how can she I ("Goodbye For Now," Soapbox, If the heart, soul, and passion driving explain my taste, as well as my friends' October 1997), then all of us in the the individual are missing, no amount taste, in video games? Women's tastes game industry are uneducated sloths of training or experience that the indi- in video games are, by and large, dif- who would do better to step aside and vidual has will help finish the project. ferent from men's. Not better, not let the "professional" programmers do Larry Dolyniuk worse, merely different. However, the the job! If that is the way Mr. Thielen via E-mail area of overlap is so large, I strongly wants it, then scratch ULTIMA: It was doubt that it’s necessary to specifically developed by a young Richard Garriott. target the female audience. And scratch many other successful As the hardware, software, and tools games while you're at it. What Nancie Said improve, so will the overall quality and I have seen many games programmed complexity of games of all genres. For by "professional" programmers. These that small bit of software that specifi- games all have "really slick code" — and feel compelled to write concerning cally targets women, there will be plen- that's about it. No heart, no soul, no I Nancie S. Martin's Soapbox (“Take the ty of programmers and design- passion. The game industry may Y Out of Computer Games,” ers, probably female, to create 6 change, but it will never completely September 1997”). My first it. For the rest of it, I think stamp out the Leonardos and reaction was insult the developers should Michaelangelos of the game industry. and anger, which has concentrate on telling These are the hearty souls that other quieted to mere hurt good stories. industries wish they had. They are the feelings. Imagine her Jim Williams pioneers with the raw talent and stami- article being written via E-mail na to overcome the persecution perpe- by a Nathaniel S. trated by the arrogance so often seen in Martin… imagine theT the attitudes of those who deem them- sneering tone and condescend- selves "professional." Many of the games ing attitude of the article being applied Wal-Mart and the RSAC that people love today were developed to females, rather than males. Instead of on an extremely tight budget. How this one, lonely missive in protest, you many programmers working in other would be flooded with e-mail, demand- s one of the members of the industries would go the extra yard to get ing blood payment. A committee who created the their product out even though they The nature of video games, to date, RSAC ratings system, I can tell you hadn't been paid for a month? has been largely determined by the that one of our committee members Concerning game publishers' will- audience, the nature of those writing met with Wal-Mart and received feed- ingness to decide for themselves the games, and the limitations of the back from their management before whether or not a product is worthy of hardware/software. Conflict, the heart moving forward with the system. We publishing: This problem isn’t isolated of storytelling (which is what video knew that publishers would not sup- to the game industry. Publishers in games are about), is difficult to pro- port a system that couldn't get them general have this problem. They have gram, except through violent, physical into Wal-Mart. I am therefore alarmed many products thrust at them, and activity. Consider the complexity of by your September editorial which when a product doesn’t stand out from the plot in an action movie vs. the plot suggests that RSAC ratings wouldn't the crowd, it gets overlooked. Rejection in a love story or contemplative drama. stand up to the scrutiny of the Wal- is part of the game; get used to it. The industry was Mart management. Concerning unqualified program- breech-born, in the spare time of real Johnny L. Wilson mers: Certainly there are some who are programmers doing “real” program- Editor-in-Chief, eccentric and maybe a few who are not ming. It's hardly surprising that video Computer Gaming World "right" for the job. But to brand most of games appealed to those writing them. the industry as "unqualified" shows a If Ms. Martin wishes for there to be EDITOR ALEX DUNNE RESPONDS: lack of reasoning. video games that appeal to her tastes, Rightfully admonished. Had I only dived Concerning self-taught program- let her write them. One of my all-time deeper into the RSAC web site mers: Every developer can benefit from favorite games is MYST. DOOM, and all (www.rsac.org), I would have uncovered an experience working with a senior of its spin-offs, literally leave me ill. old press release stating that Wal-Mart was developer. How can anyone invalidate DIABLO bores me. Granted, I do love one of the first on board to support the an individual's desire to learn whether the CRUSADER games, but consider the RSAC ratings. While I did not attempt to it is through formal classroom or inde- plot they have and the lengths to contact RSAC, my two messages with Wal- pendent studies? Mr. Thielen's concept which the authors went to draw the Mart itself were not returned, so I never got is both unreasonable and contradictory player into that plot. Most of my all- the opportunity to talk directly to store rep- to many of the educational programs time favorite games involve explo- resentatives. Apologies to you and the offered through mainstream technolo- ration rather than physical action. If other RSAC committee members.

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com BIT BB LL NEWS FROM THE WORLD

INDUSTRYINDUSTRY Organica

IMPULSE has announced the completion of Organica, a new 3D modeling pro- WATCHWATCHgram that supports 3D object file formats such as Imagine, LightWave, and 3D by Alex Dunne Studio MAX. In Organica, users build objects ROBERTS DIRECTS in a method based loosely on the WING metaball concept. The program COMMANDER gives you 25 different magic 8 MOVIE. blocks that you can put together, ChrisD bend, taper, twist, shear, or resize Roberts, who cut to meet your needs. Running in his teeth behind the cam- real time, the product lets you put era during production of the video seg- a high-quality 3D object together ments of WING COMMANDER 3 and 4, steps quickly. The images at right were behind the camera again this month as modeled in Organica by UK-based the director of the upcoming WING developer COMMANDER movie. This is Roberts' debut Synthetic at the helm of a feature-length film. The Dimensions for $27 million movie has been picked up by their upcoming Twentieth Century Fox for distribution in game. the US and UK, and Roberts' own Digital Organica runs Anvil is going to create the digital on Windows imagery for the film. No word yet on a 95/NT, and a release date or who appears in the MacOS version is movie. scheduled for BLIZZARD SAYS BYE-BYE TO release in January COMMERCIAL NETWORKS. With the 1998. The program intense popularity of Blizzard's has a suggested Battle.net, the company has announced retail price of $299. that it it will not license future titles such ■ Impulse Inc. as STARCRAFT out to third-party networks Minneapolis, MN such as Mpath and TEN, opting instead to (612) 425-0557 host them exclusively on their own free, www.coolfun.com proprietary network. The company also announced that the site — which recent- ly reached the 1.4 millionth unique user browser together with compilers and mark — will begin serving paid banner CodeWarrior linkers. It supports development for a advertisements. variety of target processors and oper- PGL SIGNING SPONSORS. TEN's Professional 2 ating systems using plug-in compilers Professional Gamers League (PGL) has and linkers from third-party vendors lined up over $2 million in sponsorships METROWERKS has just released and other CodeWarrior products. New so far (including Levi Strauss's Dockers CodeWarrior Professional 2, the newest features include: project files that are khakis), and this thing looks like it version of the company’s line of pro- interchangeable between Windows might have legs. Just as some game gramming tools that combines and MacOS, the ability to compare developers are reaching cult figure sta- Windows- and MacOS-hosted desktop two source files and merge changes, tus outside of our industry, the PGL has tools into a unified software develop- version 2.0 of Metrowerks’ C/C++ a good shot at turning highly-ranked ment package. compiler, a “current target” column in players into recognizable figures in the CodeWarrior Professional 2 com- the project window, a code browser mainstream. bines a project manager, a source-code that works across targets and subpro- editor, and a multilanguage code jects, and subproject caching that

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com AA SS TT SS OF GAME DEVELOPMENT

speeds multiproject builds and sup- personality with anothers. By doing MARKET REPORTS SIGNAL INDUS- ports browsing across subprojects. this, distinctive effects can be gener- TRY HEALTH. Recent market reports by CodeWarrior Professional 2, like all ated such as guitar talkboxes, robot PC Data and InfoTech indicate that both CodeWarrior products, also features vocals, and even pulsating rhythm online and shrinkwrap game sales are on the CodeWarrior two-machine source- parts derived from sustained chords. the uptick. First, PC Data reported that level debugger. The Windows 95/NT- fusion: VOCODE and the fusion: September's game software sales were hosted version also features support EFFECTS platform currently support up 27.5% over the previous period a year for debugging Java in Internet plug-in formats including Adobe earlier and were growing about about Explorer 4.0. Premiere, Audiosuite, and DirectX 40% faster than the overall software mar- CodeWarrior Professional 2 is avail- Media. The plug-ins run on both Mac ket compared to the same period in the able for MacOS or Windows 95/NT, OS and Windows 95. fusion: VOCODE prior year. Second, InfoTech forecast that 9 and is priced at $449. has a suggested retail price of $149.95. worldwide revenue for interactive soft- ■ Metrowerks Inc. ■ Opcode Systems Inc. ware publishing would reach $15.8 billion Austin, TX Palo Alto, CA and grow to $26 billion by 2001. InfoTech (512) 873-4700 (650) 865-3333 expects the fastest growth to come in the www.metrowerks.com www.opcode.com Internet multiplayer arena, at an estimat- ed compound annual growth rate of more than 70% (to $3.7 billion in revenue) through 2001. But that pales in comparison fusion: VOCODE Shag: Fur to their estimate for packaged sales, OPCODE recently released fusion: DIGIMATION is shipping Shag: Fur, a which InfoTech predicts will reach $22.3 VOCODE, a cross-platform DSP plug-in new environment plug-in for 3D Studio billion that year. designed to enhance digital audio MAX that adds fur (and even, to some AND I COMPLAIN ABOUT recording by bringing the classic ana- degree, long hair) to an object’s surface. DEADLINES. In conjunc- log vocoder effect onto the desktop. Shag: Fur generates fur with speed tion with the launch of without sacrificing realism. It doesn’t the movie Starship create geometry for individual hairs, so Troopers in it works quickly. However, even November, Sony though no real geometry is generated, Pictures the fur can cast and receive shadows Entertainment's and highlights. Other features allow Imageworks created h you to control exactly where fur is an VRML-based game for applied, as well as the density, color, the film's web site (www.starshiptroop- thickness, direction, leaning, and bend ers.com). While the game is a just simple of the hairs. Separate texture maps can 2D obstacle maze, what's impressive is be used for most of these options to that the game was written, developed, and provide complete control. For exam- staged in just eight weeks — by the same fusion: VOCODE launches ple, a texture map of a tiger skin can team that did the special effects for the Opcode’s new line of DSP plug-ins, be used for fur color, while a separate movie itself. called fusion: EFFECTS. The series map image is used to control where JIMMY JOHNSON, VR SPORTS TEAM provides a way to tailor individual the hairs are thick and thin. Almost all UP. To help promote their latest title and sounds and add texture to mixes. of these functions are animatable, so raise money for charity, VR Sports is VOCODE moves beyond the “hard- motion, growth and color changes are donating $1 to the United Way for every ware box” approach of most plug-ins all possible. copy of JIMMY JOHNSON VR FOOTBALL '98 (software reproductions of traditional Shag: Fur works with 3D Studio MAX that's sold. Kudos to VR Sports for this functions like reverb, chorus, and 1.2 and MAX 2.0, which run on gesture. We here at Game Developer are others). It includes control features Windows NT. Shag: Fur has a list price waiting for some publisher to pick up the not commonly found on analog of $295. rights to MIKE DITKA FOOTBALL '98 — you boxes, including level, resonance, ■ Digimation Inc. know the one, in which the Saints' AI is depth, and mix — in addition to five- St. Rose, LA hard-coded to lose every game and after band tonal control. VOCODE will (504) 468-7898 which Ditka exclaims "We suck!" also allow you to fuse one sound’s www.digimation.com

http://www.gdmag.com JANUARY 1998 GAME DEVELOPER by Brian Hook GRAPHIC CONTENT

How I Spent My Summer Vacation, or What I Learned While Working on QUAKE 2

lot of people in the game industry have asked me about the software devel- opment processes used at id software, so I thought I’d take the time to write an article about the processes and philosophies used at id software 11 while interspersing my own opinions and reflections on them. While the procedures in place at id are not handles all game-specific Aperfect, they have resulted in the time- stuff such as monster intelli- ly shipment of several popular prod- gence, weapon behavior, ucts, so take this for what you will. physics, and power-up This column is pretty dry and matter- effects. Finally, the “glue” of-fact — it’s more like a laundry list, code, which consists of win- to be honest — so while it may not be dow system interaction, amusing and entertaining, I hope input management, sound, many of you will find it informative. CD management, network And just to be clear, this is not a recipe protocols, and other not- for success. easy-to-categorize crud, is This month, I’ll be talking about located in the executable, some of the programming methodolo- QUAKE2.EXE. gies that we’ve used during QUAKE 2’S The sweet spot for our development. Next month, I plan to team size is working out to discuss the tools that we employ, both be three programmers. The software and hardware, and some relat- graphics subsystems are my ed issues. domain; the game logic is John Cash’s responsibility; and the glue code is usually Team Programming modified by any of us. John Carmack is the grand dicta- he programming staff at id consists tor and architect — he modifies broad your employees than arbitrary authori- T of three programmers: John expanses of all the code at any given ty over them. Also, by taking care of Carmack, John Cash, and myself. time and is responsible for the overall implementation details and minutiae, Programming tasks are split into three architecture and making sure that the Cash and I allow Carmack to concen- distinct groups: graphics, game logic, pieces of QUAKE 2 fit together logically trate almost exclusively on large, and “glue.” The graphics subsystems and efficiently. sweeping architectural issues. (OpenGL and software rendering) con- The current triangular hierarchy that Also, a key to making the team pro- sist of the actual code used to render a we have in place is extremely efficient gramming approach work, at least for scene and are encapsulated into two because John Carmack is the absolute id, is that John Carmack is responsible .DLLs, REF_GL.DLL and ruler of the programming team. Even for both the architecture and the initial REF_SOFT.DLL. The game logic is also though Carmack is the undisputed implementation of any new technolo- put in a .DLL, GAMEX86.DLL, which boss because of his position within id, gy. This lets him reconcile any unfore- both Cash and I have extreme respect seen implementation and design inter- Brian Hook’s last Game Developer col- for him, and it is this respect that actions that may have global umn will appear in next month’s issue. allows Carmack to manage the devel- repercussions within the code base. Tell him how much you’ll miss him via opment process effectively. It is far Another nice thing about the delega- e-mail at [email protected]. more important to have respect from tion of responsibilities is that there is http://www.gdmag.com JANUARY 1998 GAME DEVELOPER GRAPHIC CONTENT

however, I use Microsoft Visual SourceSafe on my main workstation simply because I like to have a history of my changes at all times. Another issue that arises when multiple program- mers work together is cod- ing style. It’s important not to get wrapped up in religious issues such as tab size, brace and parenthesis very little adversarial competition placement, or indentation style between programmers. Neither Cash — you should be able to adjust nor I is presumptuous enough to chal- to any style, even if it irks you. lenge Carmack’s dominance, and since Fighting battles over something as per- Obviously, there is a difference Cash and I work on separate subsys- sonal as this simply is not worth the between that theory and the harsh tems, our work is complementary effort — make some compromises and realities of creating a product that has 12 instead of competitive in nature. The move on. to ship to real people on a real calen- lines of code ownership are clearly Other coding style issues, however, dar. Libraries are written by program- defined and are something with which are worth specifying at the outset of a mers, and programmers are human, we’re all very comfortable — and we product’s development. Standard- and humans make mistakes. Many respect each other enough that we ization and consistency are very impor- times, these programmers will even don’t feel any urge to edit someone tant when working on large projects. have a different set of priorities than else’s code. This lets us work in a real Files, data structures, APIs, and vari- your own. team atmosphere, and we manage to ables should have a clean, consistent, This is the crux of the problem. The avoid the whole “Who’s The Man?” and intuitive naming convention so software component that you pur- jockeying that is so common among that there is little room for confusion chased might look great on paper, but computer programmers. when looking at someone else’s code. when you drop it into your program One problem that team program- Static and global variables should be and then spend a week looking for a ming presents is source control. As tagged as such, be it by a prefix, suffix, bug that turns out to be a part of your ashamed as I am to admit it, id software or some other convention. Parameter new magic software IC, well, you tend does not use source code control. Right ordering should be consistent: Is a des- to snap out of your dream world pretty now, this discrepancy is largely the tination address the first or last para- quickly. Anyone who has wanted to result of expediency. We recognize the meter? Are prefixes used in struct mem- firebomb Redmond, Washington, after need for proper source control, but we bers? Where are global variables using Microsoft’s DirectX knows what have enough of a working system that declared and under what conditions? I’m talking about. And when a fix for until source control becomes a crisis, Are globals stuffed into a single global that bug isn’t going to arrive in a time- we won’t address the problem — espe- structure or just tossed out into the ly fashion, you’re suddenly in the posi- cially when we’re this close to shipping global namespace? How are manifest tion of hacking around broken code, a a product. Our next generation soft- constants differentiated from const dec- process pleasantly known as “coming ware hopefully will be developed com- larations? How are directory structures up with a workaround.” Deal with pletely within the framework of a large- organized? enough “workarounds,” and you’ll scale source control system. Personally, eventually reach a cross-over point where you realize that you may have NIH been better off if you’d just written the code yourself. or quite some time (over a And bugs aren’t the only problem F decade now), computer scien- you’ll encounter — there are perfor- tists have been talking about mod- mance issues to contend with also. ular software, component soft- With WINQUAKE, GLQUAKE, and QUAKE ware, or “software ICs.” The 2, we had to work around some pretty theory is that programmers should serious performance problems in be able to purchase a thoroughly Microsoft’s DirectSound. DirectSound debugged and optimized prepack- works the way it’s supposed to, but it’s aged software library (who are we slow enough that you get all teary-eyed kidding?) from some third-party remembering the days of Sound Blaster development house and just drop 16 programming under DOS. it into a program — voila, instant Finally, not only do you have to new features and functionality. contend with bugs and performance

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com GRAPHIC CONTENT

the most effective use of our resources, large that understanding all of it is but it leaves our destiny in our hands, nearly impossible. Any given chunk of which has a certain warm and fuzzy C++ code, assuming it uses even a appeal to it. small portion of the language, can gen- erate seemingly random assembly code. While you can pick up a book Programming Languages such as Bjarne Stroustrup’s Design and Evolution of C++ to help you under- s technology-oriented as id soft- stand why C++ is such a screwed up A ware is perceived, we’re actually language, it still doesn’t address the knuckle-dragging primates when it issue that C++ is a screwed up lan- comes to our programming language guage. It’s constantly evolving, getting of choice. We use good old ANSI C for bigger and uglier, and pretty soon it’s the majority of our development. going to implode under its own Objective-C, a version of C with weight. object-oriented extensions, was the Seven years ago, I bought Borland language of choice for tool develop- Turbo C++ 1.00 the day it was ment back when id was using released (yes, I’m that big a geek), and NextStep. However, during the subse- over the course of the ensuing five or 14 issues, but there’s always the specter quent move to Windows NT, id was six years I used C++ as my only pro- of flexibility. That nifty new library forced to abandon Objective-C in gramming language. In that time, I might do everything you need now, favor of ANSI C for these tasks. We’re learned most of its weird intricacies, but when you’re six months into currently evaluating the performance adjusted to them, and accepted them using that library, and you must have and robustness of OpenStep for as necessary evils, the price I had to a couple new features implemented, Windows NT, and if it turns out that it pay for object-oriented programming. and the library owner isn’t amenable doesn’t suck, we may switch back to When I started working at 3Dfx to adding those features… well, you’re using Objective-C and OpenStep for Interactive, I had to start using ANSI in trouble. You now have the option tool development. C again because I was developing a of undoing months of work and id software still uses ANSI C for its programming library, Glide, that rewriting everything from scratch, at core development; we have several needed to be used by a lot of develop- which point you’ve tossed away compelling reasons why. We stress ers, many of whom would not be months of effort, or you forego the portability, and ANSI C is about as familiar with C++. extra functionality, which may not be portable as a language can get — it’s The amazing thing to me was that a feasible alternative. And, of course, available across a wide range of plat- when I switched back to ANSI C, I was if you want to port to a development forms, and most ANSI C compilers are actually happier — I discovered a new- platform or operating system on extremely stable. ANSI C is no longer found appreciation for ANSI C’s sim- which the library is not available, evolving at a frantic pace, so it’s stable plicity (at least compared to C++). you’re in deep trouble. You can in terms of syntax, feature set, and Sure, I lost some nice syntactic sugar, address many of these problems by behavior. Mechanisms for interfacing and I ended up missing classes and vir- licensing the source code to whatever ANSI C with other languages, such as tual functions a bit, but I was willing library you’re using, but at that point assembler, are well-defined and pre- to eschew these niceties in return for you’re in the position of actually dictable. Compilers and development simplicity. By using ANSI C, I never learning someone else’s code, not to tools support ANSI C more than any had to crack open a reference book, mention maintaining, extending, and other language. Finally, ANSI C is debugging it. At some point, you may a pretty WYSIWYG language — find that you’d have been better off when you look at a chunk of C, writing everything yourself from you can be reasonably certain scratch. what kind of machine code will Don’t get me wrong — I’m not say- be generated. ing that using externally developed C++, on the other hand, does libraries is absolutely a bad thing, but not share these wonderful fea- some tradeoffs are definitely involved. tures. C++ is stuck on top of C We have a hard enough time dealing using the programming language with bugs in our compiler, the Win32 equivalent of duct tape and API, Microsoft DirectX, and hardware twine. It’s still evolving at a dis- drivers without adding someone else’s turbing rate. It’s being designed code to the mix. So the unofficial poli- by a committee. Compilers and cy at id is that we engineer all of our tools that support C++ are con- own code unless we absolutely have no stantly missing features or incor- choice, such as the necessity of rectly implementing them, and depending on DirectX. It may not be the language, as a whole, is so

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com GRAPHIC CONTENT

will be little to no assem- flat color. This routine only would be bly code in post-QUAKE 2 called if the game had texture mapping products from id software. disabled. Optimizing that clear routine There are several reasons probably wasn’t time well spent. for this, the primary one It’s easy to get sidetracked into opti- being that hand coding mizing a chunk of code that you’re for advanced processors working on while you’re still thinking such as the Intel Pentium about it, then tossing away all of that Pro and Pentium II is effort when you change your algo- often a lost cause. At any rithms yet again. Until your overall given time, a Pentium Pro design is set in stone, it’s wise to avoid can have a large amount doing any optimization at all. I had a of non-deterministic chunk of code that I was pretty confi- internal state that radical- dent wouldn’t need to be changed ly affects the efficiency of again — it was responsible for trans- hand-coded assembly lan- forming the points within an Alias guage. With these model — but as luck would have it, two advanced, superscalar, months after I optimized that routine, and superpipelined we ended up needing a new feature 16 processors that support that required editing the optimized features such as specula- source. Luckily, this wasn’t overly trau- tive, out-of-order execu- matic, but if it had been even a bit tion and branch predic- more complex, it would have con- tion, it makes far more sumed far more time than if I had just sense to use CPU-friendly done all the optimization closer to the algorithms as opposed to end of QUAKE 2’s development. CPU-optimized code. Premature optimization also has another, more sinister, side effect — it and I rarely had to work around lan- makes you reluctant to make major guage quirks. Since then, I’ve done Optimization changes to your overall design if it very little serious C++ programming, means rendering your previous opti- and the last time I looked at the spec, ur optimization rules are quite mization work irrelevant. A similar it was a completely different language. O simple: make sure that what adage exists in the world of creative The language has mutated so much you’re optimizing makes a difference, writing — don’t keep a bad paragraph over time that it’s become the don’t optimize before you’re done just because it has a great sentence. The Highlander 2 of programming lan- implementing features, and learn to onset of this mentality can often be guages — you can see similar themes optimize up to the point of diminish- very subtle as you start unconsciously and names, but somehow the new ver- ing returns but no further. It’s amazing weighing the benefits of a potentially sion screws up so badly that it sullies how badly our intuition can deceive us better design against the hassle of the name of its parent. when it comes to finding execution hot rewriting your cherished code. id’s use of assembly language has spots. You’ll often look at a program Finally, make sure that you aren’t varied over the years. DOOM had very and intuitively label certain areas as spending more time optimizing a spe- little assembly language in it, but it definite bottlenecks only to find out, cific chunk of code than is truly neces- was primarily targeted at 486-class after analytical profiling, that some sary. In my experience, the biggest processors, where scheduling, pipelin- other heretofore-unknown hot spot is gains during optimization come within ing, and memory bandwidth issues actually consuming all of your execu- the first 25% or so of the time spent — were not nearly as relevant as on later tion time. Before diving into “prob- after that the increases are only incre- generations of processors. QUAKE, on lem” routines, use a profiler the other hand, was targeted at Intel such as Intel VTune, Pentium-class processors, and as a Tracepoint HiProf, or result, there was significant room for Rational Visual Quantify hand-coded assembly optimization. It (skip the one in Microsoft also helped that Michael Abrash, Mr. Visual C++, it's pretty much Assembly Optimization Dude, was useless) to make sure that working at id then, and could devote you are, in fact, going to large chunks of time to tweaking edit code that makes a dif- inner loops. ference in your program’s QUAKE 2 is also targeted at the overall execution time. Pentium, and thus benefits from QUAKE had a hand-opti- assembly coding. However, there is a mized routine responsible very significant chance that there for clearing the screen to a

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com GRAPHIC CONTENT

OpenGL, software render- and CPUs. We had a divide-by-zero bug ing, window system man- that only generated an exception on agement, input handling, the DEC Alpha processor, and it would sound output, and OS-spe- have been a very long time before this cific utility routines, such as bug was detected in our code under an time routines). By doing Intel x86 processor. abstractions at this level, we However, there are some pretty can greatly minimize the solid business reasons not to port a number of conditional com- game to multiple platforms. With pilation directives in our QUAKE 2 we plan on supporting main code body. As a matter Win32 (x86), Win32 (DEC Alpha), of fact, the statement #ifdef Linux (various CPUs), SGI Irix (MIPS), WIN32 only occurs twice in all and Rhapsody (x86 and PowerPC). of our OpenGL code, and it Our publisher will likely receive a dis- doesn’t occur at all in the proportionately higher number of mental. There’s a cross-over point software rendering subsystem. support calls for the non-Intel/non- where the extra effort spent optimizing We always keep up-to-date C-only Win32 versions of QUAKE 2 if we a piece of code is not reaping commen- versions of our assembly code, both to release these versions on the QUAKE 2 surate increases in performance. Our assist in porting and also because it CD. Couple this with the fact that 18 blanket policy is that we wait until the makes debugging the assembly code ports will probably account for less final stretch — all features implement- extremely easy. It’s really easy to forget than 3% of our overall revenue, and ed — before doing serious “no retreat, to maintain your C-only paths, but it the argument for supporting a pletho- no surrender” optimization work — does pay off the moment you try to get ra of system architectures becomes stuff that requires lots of work and that things up and running on another pretty flimsy. will end up being wasted time if we operating system or CPU. We do it anyway, though, because change higher-level algorithms and It’s easy to get sucked into compiler it’s cool. data structures. and operating system dependencies — In the end, porting to alternate for example, utilizing a compiler’s architectures simply doesn’t make very #pragma directives, or maybe an operat- good business sense for most game Portability ing system’s message box or memory companies. We do our ports for only management functions. Unfortunately, three simple reasons: it’s easy to do, we ne of the nice benefits of using #pragma directives are extremely useful like seeing our games played by as O ANSI C is that our product porta- for a lot of reasons, and it’s easy to for- many people as possible, and we gain bility is limited only by our coding dis- get to bracket them with the appropri- the intangible benefit of having cipline. Throughout the development ate preprocessor directives. The easiest extremely loyal consumers on systems of QUAKE 2 a lot of thought was put way to avoid operating system depen- with poor mainstream support. into the issue of portability, and by dencies in your main body of code is to adhering to some general rules, we make sure that you’re not including make our lives a lot simpler when per- any OS-specific header files (for exam- Stay Tuned forming a port: segregate OS-specific ple, WINDOWS.H) — the compiler code from the rest of the code base, should complain when you start mak- ecause the story is just so darn always maintain a C-only version of ing calls that it doesn’t recognize, such B big, I’ve had to save some for your code, avoid compiler and operat- as MessageBox or VirtualAlloc. later. Tune in to this space next month ing system dependencies, and watch Bugs related to CPU endianess can be for more on QUAKE 2. I’ll be explaining for endianess assumptions. pretty hard to find, so the best way to the tool choices that we made, compli- The first step in writing portable prevent them is to recognize code menting some vendors, and denigrat- code is recognizing appropriate levels that’s doing bad things — for example, ing a few more. ■ of abstraction and managing your code casting between different size appropriately. The bulk of our software types. A beneficial side effect of rendering and sound code only oper- porting to many platforms is ates on memory addresses — the con- that it also forces you to write cepts of DIB sections, DirectDraw, wave much cleaner and more robust sound, and DirectSound aren’t known code, since hidden bugs in your to the actual graphics and sound-gen- code may only manifest them- eration code, and are instead handled selves on another compiler, by abstracted glue code. All OS-specific operating system, or CPU. You code is sequestered into a set of well derive a feeling of confidence defined files — porting QUAKE 2 to an from knowing that your code new platform involves touching less has compiled and run success- than a dozen files, each dealing with fully across a wide range of some OS-specific subsystem (CD audio, operating systems, compilers,

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com by Josh White ARTIST’S VIEW

Part 1: Real-time 3D Art Tools Need Help!

all me cranky, but I have something to say: we artists, especially low- polygon modelers, have tools that are holding us back... and they aren’t going to get better without our help. In a way, that’s to be expected; the C job title “real-time 3D artist” (RT3D) is only a couple of years old, so of course there isn’t an array of perfect dinate systems), composition of the consider my set of feature synonyms a tools out there yet. point from the coordinates of several small “core functionality” improve- 21 The future is what scares me. Even others (“X from point B, but YZ from ment that would take significant devel- when tool makers listen, we artists point C”), or completely custom func- opment effort, and it’d get delayed aren’t talking. Our tools aren’t going to tions via the built-in macro language. endlessly. get any better unless professional Most technical 3D modeling soft- Of course, these multiple interface artists explain their needs in a way that ware (SDRC I-DEAS, AutoCAD, paths to the same database edit start tool makers can understand. I’m only PATRAN) lets the user choose a symbol making developers’ flow charts look one artist in the industry. Tool makers to represent a point: a cross, a dot, a like spider webs. This flexibility is need to hear from other artists (or else box, or a text label. This is unusual in where the underlying architecture of we’ll get a Josh-centric tool — or more 3D art tools; we get only one choice for the software shows. If the software was- likely, the brush-off). So, RT3D artists, tell me what’s wrong with your tools Artists have a reputation of being indepen- ([email protected]), and I’ll publi- cize the gist of it. I’ll start with my dent (if not downright weird) and that’s part- main issues. 3D ART TOOLS AREN’T VERSATILE ENOUGH. ly what makes great art. We need tools with Artists have a reputation as being inde- pendent (if not downright weird), and large ‘vocabulary’ to express it. that’s critical to art. RT3D artists’ tools are forcing us all to work in very simi- vertex viewing. (Nitpicky? On-screen n’t well designed and cleanly coded, lar patterns. That’s wrong. Artists need image matters a lot to artists. For exam- it’s very difficult for the tool maker to many different ways of doing the same ple, little “+” signs can easily draw over avoid bugs when implementing this thing — especially the small variations short edges, obscuring subtle detail in type of new feature. on the same basic idea. In writing, it’s the mesh.) Even Windows 95 offers It’s damned hard to present the user obviously critical; imagine how lame Control-S, Alt-F-S, mouse clicks, and with a ton of different methods with- writing would be if an author could combinations of menu shortcut key out overwhelming an already-compli- only use “good” instead of great, won- presses and mouse clicks. If you love cated UI, and I think most tool devel- derful, terrific, excellent, amazing, mouse and toolbar approaches, you opers are overly focused on “easy to superb, awesome, or stunning. should have those options. use” — they’re assuming artists won’t I’m talking about synonyms of fea- Clearly, tool developers face a major bother to learn their tool if they add tures — multiple similar features. “Rich challenge. But they would be wise to too many features. Unfortunately, 3D feature set” refers to a variety of fea- address a few specific problems. For art tools often take the worst of the tures; that’s not what I mean. For instance, developers have long lists of Windows UI and then strip out the example, AutoCAD’s hardly a world- planned improvements to their prod- versatility that makes it valuable. In standard for art tool excellence, but ucts, and sexy, major features make for Microsoft Word, darn near every func- when AutoCAD users pick a point, more impressive advertising copy (or tion in the whole program is accessi- their options are plentiful. They can so they think). I suspect they would ble via the keyboard, either through use over a dozen object snaps, includ- ing weird ones such as “tangent” and Josh White runs Vector Graphics, a real-time 3D art production company. He wrote “perpendicular,” grid snaps, constraint Designing 3D Graphics (Wiley Computer Publishing, 1996), he has spoken at the to an axis or plane, offset from an CGDC and cofounded the CGA, an open association of computer game artists. You existing point (in polar or planar coor- can reach him at [email protected]. http://www.gdmag.com JANUARY 1998 GAME DEVELOPER ARTIST’S VIEW

menu shortcuts or with customizable you’re using, remember to keep an ware for aerospace, training simula- shortcut keys. For example, there’s no open mind about new tools. One prac- tion, mechanical engineering, GIS, direct keyboard shortcut to change tical way to do this is by keeping a wish medical, and other specialized indus- the font of a style, but you can use the list. Whenever you find yourself gnash- tries. Skim off the few great ideas. We’ll menu shortcuts (Alt-O,S,M,O,F). This ing your teeth about some 3D model- thank you for it. sequence is hardly intuitive, but if you ing problem, pop up Notepad and jot COMPATIBILITY. There are two forms of forget it, you can look at the menus down the annoyance. compatibility I think about: data trans- for a reminder. If you’re a fast typist, Then tell people who care. Attend at fer and backwards-compatibility (also six keystrokes are much faster and least one trade show and when the sales called legacy issues). The first is critical, more reliable than six mouse point people attack you, attack right back not very sexy, and very difficult (no and clicks. with the wish list. You may not find the wonder so few tools do a good job of it), but without a robust way to get When paying customers need their product to data in and out of a modeling tool, it’s useless. Tool makers need to improve work differently, tool makers listen closely. this by agreeing on a common file for- mat (for example, VRML for RT3D) and In most 3D art software UIs, the perfect tool, but by asking for specific writing really solid input/output func- majority of the powerful editing com- features, you’re giving feedback to the tions for it. If you make it a plug-in, mands are only accessible through tool makers... and before long, you’ll distribute source code so that develop- 22 mouse-clicked toolbars. This requires find yourself confronted with a dozen ers can understand what you did. accurate, repetitious mouse move- different paradigms for 3D modeling. After a few years of gradual improve- ment as you navigate through roll- BORROW FEATURES. I want tool makers to ments, 3D art tools are often rebuilt ups and drop-down lists. Witness the incorporate (and improve on) competi- entirely, retaining only the name of lame “keyboard input” windows tors’ good ideas shamelessly. The same the last product. The transition is where you can type in coordinates, applies for 3D modeling in other indus- tough, both for tool makers (who risk but you have to mouse over and click tries. Take a look at custom 3D soft- their user base) and users (who feel exactly on the “+” roll-up button use it. It’s better than no keyboard input at all, but it’s hardly an alternative to mouse movement. Research & Development: IT’S MY WORKSPACE — LET ME ARRANGE IT! The hundreds of buttons packed onto Break Down the Wall the screen are impressive at trade shows, and for new users, they’re con- he top-down structure of large balanced professionals who are extreme venient reminders of a function’s exis- software companies operates team players, but don’t ever get to create tence. For experienced users, however, on the architect/contractor their own designs. If you’ve ever met the they waste desktop space. Who uses T model. The product architect staff of a really successful project, you toolbar buttons for Cut/Copy/Paste? assembles customer surveys into a clean know why I find this upsetting — they’re Naturally, you want to remove them to new product design, which is then thrown talented and organized, but not calm, and save space (as well as declutter your over the wall to a complacent, obedient they definitely build their own designs. work area), but in most mainstream 3D programming department that never sees It’s true that feature creep hurts timely art software with nonstandard toolbars, the actual customer (or even knows how production, but the alternatives are this is impossible. to use the product it constructs). worse. Complacent, user-ignorant pro- To me, an easy-to-learn but inflexible The defending argument goes, “half- grammers turn out bland, bloated prod- interface shows that the tool maker finished ‘good ideas’ aren’t going to help ucts that don’t meet the needs of their doubts its users’ commitment to its a project this size.” The only true gods users. The teams are missing that intense tool. The tool is hard-wired to be E-Z, are the schedule and the specifications. focus, that deep desire that motivates in which means it’s meant only for users These companies don’t want freewheel- a way money never can. who aren’t going to use it for long — a ing cowboy coders who actually have To fix this, we don’t need a revolution, self-fulfilling prophecy. used the product and can form their own but we do need change. One way is get INNOVATE! Incremental improvements opinions. A plague of feature creep (the face-to-face with users. For example, cele- are good, but tool makers also need to development of weird, sometimes bril- brate beta ship dates with field trips to go out on a limb, design-wise. There’s liant, new features that weren’t in the customer sites. Regularly sit down with no really smooth, easy-to-use interface spec) will curse their clean environments users and watch them work, offering sug- for 3D modeling — until one exists, and incite revolution among the other gestions and getting input. Key developers any convergence in software is prema- coders. The feeling is mutual: Creative can adopt a client and work onsite once a ture (and dangerous to market leaders, developers are scared away because month. If the wall between Research and since it makes space for upstarts to developing other people’s design is not a Development falls, then tool programmers stage revolutions). Artists need to be a creative job. will understand their users, and the soft- part of this design process. Unless This leaves behind a group of calm, ware will improve mightily. you’re 100% happy with the tools

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com abandoned). Still, I’m impressed with and tell them what you think. E-mail Part II: Low-polygon Character tool makers who have the guts to them, call them, visit trade shows and throw away old code — it makes for tell them in person. If you’re doing Modeling better software. Ideally, tool architec- something new such as RT3D, the ture allows sections to be rebuilt with- squeaky wheel gets the grease — and f you’ve joined us from last month out disturbing the remaining parts. we seriously need some grease here. Iwhere we designed a RT3D charac- As a user, I can digest an incremental OK, flame off. Let’s actually build that ter, you’ll know that we’ve got 500 tex- improvement (that is, tools created human character we started last time. tured triangles with which to make our from a section-by-section rebuild) much more easily than a complete rev- olution every year, but this incremen- tal approach usually introduces new bugs galore. Once old code is thrown away, I think most tool makers do a good job of compromising between new functionality and old working methods. ENGINEERS, USE YOUR OWN TOOLS. If you’re a professional full-time tool program- mer, your company should be begging 23 you to use your tool as the customer would. I’m always amazed to meet tool developers who don’t. Lots of program- mers grumpily call this “marketing” and think it’s not their problem. I say it’s the “R” in R&D, and it’s critical to making killer tools. See “Research & Development: Break Down the Wall.” ADVICE TO ARTISTS. Artists, tool makers need your help. We artists are too quiet. We aren’t asking for better than what we have. This is bad because pro- fessional tool makers will never be truly clued in to our needs. Without our input, they will assume they’re doing fine, and we’ll keep getting mediocre tools. Though you probably can’t guess it from this column, I’m very grateful to tool makers for providing me any- thing that makes my job easier. My way of thanking them is to tell them all the problems the tool has. Rude? Actually, that input (and, of course, payment for the tool) is the most valuable thing a user can offer a tool maker. When paying customers need their product to work differently, tool makers listen closely. If you do RT3D modeling with gen- eral-purpose 3D tools, tool makers need to know how you use their soft- ware — they probably think you render movies with it. Even tool makers who are specialized in their attempts to make tools for RT3D need input badly — a lot of their previous customers were building from blueprints, not pencil sketches. If you use 3D software regularly, you FIGURE 1. Character design sketch. should write the people who make it http://www.gdmag.com JANUARY 1998 GAME DEVELOPER ARTIST’S VIEW

plete model. faces. Now we’ll mush this geometry After that, we’ll around until it looks like a face. get into animation That’s easier said than done. Start by and revisions. looking at the source art carefully and We’ll link the forming a profile along the edge of parts into a hierar- the sphere in the Left view, as shown chy, place pivots, in Figure 3. We do this by moving and adjust joint vertices, dividing a few edges as nec- designs as neces- essary to get the unique features of sary. Finally, we’ll the profile. Next, we rotate the view show our work in and keep moving vertices, turning the application and dividing edges to define major and do revisions features. Push a few vertices in for an until the model is eye socket, which also forms a bridge approved and for the nose (Figure 4). From there, completed. work the cheekbones a bit and form FIRST-PASS MODEL- the chin. For the chin we can change ING. Though we the lowest height-line of vertices to a FIGURE 2. Basic sphere for head modeling. usually start with semi-diagonal edge of the chin. That 24 existing geometry looks better, but it leaves the under- character come alive. We also have a and modify it, if we have to create chin/neck area hurting. We’ll fix it by clearly defined character, shown in geometry from thin air, we start with dividing a couple of edges, which cre- Figure 1, and enough specifics about low-polygon primitives and move ver- ates new vertices in approximately our environment that we can actually tices, divide edges, and weld vertices in the right area. Move those new ver- build a model. an iterative loop. Note that the illustra- tices to define the jaw/neck intersec- Last month, we decided on our tions here show complete heads, but tion, turning any edges that connect approach (including mapping meth- we usually erase half of the geometry directly below the chin so those ver- ods and face counts on a per-part before we start rough modeling, then tices define the corner in profile (Left basis), identified important areas, and mirror the existing geometry occasion- view). It should now look something divided up our budgets accordingly. ally to see how it really looks. After like Figure 5. So our task at hand is building a tex- we’ve taken a look, we erase the mir- HEAD COVERAGE. As we look at the sketch, tured 3D model from our sketch and rored half and keep working. Once we run into a typical situation: we for- within our face count budget. Here’s we’re done, we mirror the geometry got to plan for accessories. How should how we’ll tackle it: one last time and weld up unnecessary we handle the hat in the sketch? Being • Create the rough geometry. We’ll vertices at the centerline. conscientious artists, we stop model- walk through building the head step Start with a simple sphere with the ing and get back into planning mode by step. approximately correct face count, as for a minute. If we build the hat as • Tune the 3D model to perfection. shown in Figure 2. In a top view, this part of the head (as long as the charac- • Paint textures on each part. one has 12 pie slices and four height- ter doesn’t ever need to bare his head), • Map the parts together into a com- lines between the poles, using 96 we’ll have better performance and less

FIGURE 3. Head profile defined in Left view. FIGURE 4. Eye socket formed.

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com ARTIST’S VIEW

FIGURE 5. Chin, cheeks, and nose formed. FIGURE 6. Rough model completed. 26 work. After consulting with the art decisions still make sense (and change This phase is the pleasant pause after director and game designer, our deci- our minds as appropriate). For exam- the mad thrashing. Calmly and careful- sion is to model the hair and hat as ple, you’ll notice that we don’t have ly, we hone the model into a fine work part of the head. any geometry for the mouth opening of art. Often, artists will create texture To build the hat, we grab the top of — that’s because it will look fine as a maps before doing this second pass on the head’s vertices, move them so they texture map. The eye sockets, on the the 3D model. It’s a personal thing — form a diagonal line in the Left view, other hand, need some 3D depth to either way works, but since we haven’t and scale them a little larger. Then we look good. even addressed material boundaries select a row of four edges near the hair- We also need to remember to keep yet, this example will do second-pass line and extrude them out to form the material boundaries represented in modeling before texturing. bill of the cap. Note that these edges geometry. Though it’s not an issue for At this point, we need to take a aren’t perfectly horizontal; they curve this example, we often need to show more critical look at the overall pro- around the face somewhat. This is expressions on our character. This is portions, adjusting features to more clearly visible in the side view where commonly done by swapping facial closely match the sketch. For exam- we see that the profile of the bill is textures at run-time. In that case, we’d ple, this is a good time to scale the somewhat bulky. This gives us a nice do two things: width of the head down a bit since thick-looking bill, even though we 1) Separate the hat and hair textures heads aren’t usually as sphere-shaped didn’t spend faces modeling the thick- from the facial texture. Why? So as our model. We’ll also move vertices ness of the bill. we don’t waste texture memory in the mouth area so that it looks Once we’ve got the head roughed duplicating the hat and hair more like that of an old man; right out (Figure 6), we mirror it, stand back, images in each and compare it to our thumb just like facial expres- real artists. Close one eye and make sion texture. sure the model doesn’t look like your 2) Make edges thumb. After you’ve taken a look, erase between the that mirrored half — we’re not ready animating for that yet. facial area and MEANWHILE, BACK IN YOUR MIND.... the rest of the Throughout this mushy geometry head. Since editing, we’ll constantly be revisiting each polygon our design decisions. Specifically, can have only we’ll need to review which details one texture need to be 3D geometry, and which map, we need can be shown in textures. This is a separate faces basic decision that was effectively to map the made early on when we sketched the facial anima- wireframe outline over the pencil tion area onto. sketch; everything not represented by SECOND-PASS MODEL- a vertex is assumed to be in the tex- ING: TWEAKING. Now ture. Now that we have the actual it’s time to tune FIGURE 7. Modeling completed. model, we’ll want to make sure those the rough model.

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com ARTIST’S VIEW

now the chin and cheeks look too that aren’t defining critical detail. Let’s revisit the design and see if taut and young. For example, the base of the neck has we’re on track. Specific steps during We also need to fix the face count far too many vertices, especially second-pass modeling are simply itera- — we’ll compensate for some of the since it will be hidden inside the tions of the same types of commands faces that we added with all those torso. We’ll get rid of about half of we used in rough modeling, except edge divisions by removing faces them now. that the changes are more subtle. Instead of stomping an eye socket out a smooth sphere, we’ll be slightly adjust- ing the depth of the socket. The fin- Simple Characters: How Low ished geometry should look something like Figure 7. TEXTURE MAP CREATION. Creating textures Can You Go? from the pencil sketch is relatively straightforward 2D artwork — essen- eet Scared Sam, the artist Scale the top vertices around their local tially, we want to paint full-color, who builds 100,000-face axis about 120%. Create five new faces detailed versions of the pencil sketch. human models for TV that cap the bottom end. Collapse one of There aren’t many technical issues that Mcommercials. Sam the lower edges, creating a four-sided are unique to character texture cre- believes that it’s impossible to build any bottom connected to a five-sided top. The ation, but let’s go through the process. 28 kind of human model with only 500 long edge that was formed by the col- We could paint the entire front faces. “Hah!” we reply, puffing out our lapse is the nape of the neck. Now build a view in a single texture just like the chests. “We could build a human in only five-sided pyramid to cap the top of the sketch, but this wastes precious tex- 100 faces! Yes, that’s right, a mere 100 pentagon. Divide the edge in the middle ture memory in white space around faces. Granted, it will kind of suck, but it of the forehead. Move this new vertex the arms. So we’ll create one texture will be a recognizable human figure.” and the pyramid peak vertex until the for each body part. This approach also “No way.” says Sam. “Prove it, brag- head is a little rounder looking. allows us to use unique (nonsymmet- gart.” And so we do. Scared Sam is impressed. We used 20 rical) texture for the torso, yet re-use First, we use triangular cross-sections faces in this head model, which means we the arm and leg textures on the left for the arms and legs. That means we’ll have a 103-face human. Yeah, it’s ugly as and right sides. have six triangles per straight section. sin, but it’s also surprisingly useful. How Good lighting is critical to good tex- The face counts will be: else would you make a 50-person angry- tures. Keep in mind, however, that two sections mob scene? And And why spend any more creating lights in the textures before (forearm and biceps) 12 faces faces than necessary on a six-pixel-tall we have the environment can be a cap the end of the limb 1 face LOD model? dangerous step to take. If you photo- joints 4 faces graph a red cotton shirt under spot- per limb: 17 faces lights and then paste it over a dimly Total, 4 limbs: 68 faces lit room, the shirt will look like shiny That leaves us a luxurious 32 faces to red plastic because the white high- build a head and torso. lights in the photo won’t match the The concept for the torso is simple. room’s lighting. This is especially true Start with the connection triangles where when the image is so tiny that you the four limbs connect and join them with can’t see the threads in the cloth. as few faces as possible. We may notice Often, the easiest and most versatile that the connection triangle’s shape has solution is to avoid hot spots (bright changed some from the one on the limb. or white reflections) on non-shiny This keeps the torso’s shape reasonable. materials — skin, denim, cotton, and This kind of flexing is what sketching is the like should be pretty uniformly lit. for; we shouldn’t feel bound by our previ- ous sketches if they constrain the rest of Contributors the model horribly. This torso design uses 15 faces. With Lisa Washburn is the lead RT3D the limbs, we’ve now used 83 faces, leav- artist at Vector Graphics. With her ing a paltry 17 faces for the head. That’s background in fine art, she uses not enough — we’ll have to go over our sculpturing skills as well as her 3D polygon budget a bit. modeling abilities to do her magic. The hardest part is the head. Here’s a Lynell Jinks is a professional artist for synopsis of how to built it: Start with an Vector Graphics. He created the pencil uncapped extruded pentagon shape. sketches and textures shown in this col- Twist the shape so that the top and bot- umn. His talent in 2D character artwork tom pairs of five vertices aren’t aligned. spans natural media as well as Photoshop texture and image creation.

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com essentially means that it should be somewhere near an average color. Enough preaching to the choir on how to draw tex- tures. I’m sure you’ve already concluded that we should establish lighting levels and methods, and plan on trying out a few different highlight/contrast schemes until we get good-looking cloth and skin. Creating cylindrical textures from scratch is difficult because it’s harder to imagine how the texture will look on the object. Placing highlights isn’t as intuitive. It’s much easier to work from existing textures, espe- cially for alignment of faces. If you can find a Cyberware scan of somebody’s head, this is a great starting point for painting cylindrical maps of faces (Figure 8).

The Rest FIGURE 8. Head texture. e’ll build the rest of the body next month, 29 W then we’ll assemble the parts into a hierar- Related to lighting, but not the same, is the ambient chy, place pivots, and adjust joint designs as necessary. light level. It sounds obvious that the basic color of the We’ll also prepare simple hand-keyframed animations, textures should be established and consistent, but it’s and walk through steps of applying motion capture data easy to get wrong. One technique for preventing confu- onto the model. sion is to agree on a single RGB value as a background Feedback is always welcome. E-mail [email protected] color. The textures should be visible against it, which and let me know what you thought. ■ MOTION CAPTURE WORKING WITH MOTION CAPTURE FILE FORMATS 30 BY JEFF LANDER

oy am I glad that 3D acceleration hardware is here to stay. I’m

sure you all feel as liberated as I do by not having to write

all that basic polygon stuff. Clipping, sorting, and draw-

ing pixel-by-pixel is about as dull as 3D programming

gets. Now I have all this great hardware to do the mind-

numbingly dull texture mapping and Z-buffering for me. I

also have the render speed and horsepower to do some

really interesting stuff. What am I going to do with all

this spare time? Really cool real-time 3D characters!

Sure, we’ve all seen real-time 3D characters. We’ve even

seen real-time 3D characters with a restricted use of ani-

mation. However, there have been so many limitations,

Jeff Lander is a Digital Evolutionist at Darwin 3D, where he crafts technology for the future of gaming, entertainment, and network communication. He can be reached at [email protected]. BGAMEB DEVELOPER JANUARY 1998 http://www.gdmag.com http://www.gdmag.com JANUARY 1998 GAME DEVELOPER MOTION CAPTURE

the techniques needed for son captured. It’s possible, but tricky, programmers to apply to scale this motion to other body motion capture data to real- types and sizes. However, I would rec- time characters work equally ommend getting all your data from well with any type of anima- one session with one capture artist. tion data, be it keyframed, This will make your life much easier motion captured, or animat- in the long run. ed through procedural Still, as an experienced production dynamics. company, you won’t be burdened with these details because your pro- ducers have budgeted the motion cap- The Need ture session correctly. Now you need to decide how you want this data to et’s imagine a scenario in come to you. Other formats exist, but L which your brilliant pro- the Biovision (.BVA/.BVH) formats ducers have assigned you, and the Acclaim Motion format are the programmer, to develop the big ones, and all the service a real-time 3D character- bureaus and animation packages sup- and we all want so much more. We based game. They have charged you port these. 32 want realism, but how do we go about with the tasks of designing the game Your file format decision depends on fulfilling these sick desires? The engine and creating the production your application and engine needs. answer: motion capture. pathway. For a variety of design, bud- You can bring these formats into a getary, and staffing reasons, you’ve commercial animation package and decided to use motion capture to sup- export the data from there, but the for- Motion Capture ply the bulk of your animation data. mats are very compact and easy to use Your first task is to decide where with your own tool set. et’s face it, motion capture is hot. you’re going to get this data. It does- L In the last couple of years, motion n’t really matter whether you have capture has spread everywhere — from your own capture setup or a service Definition of Terms movies to television commercials, bureau is doing it for you — plan on from sports titles to action games, plenty of cleanup time. Motion cap- ’ll refer to the character that you even to click-and-explore adventures. ture is not simple. The data needs I apply motion capture data to as a Publishers are climbing all over each quite a bit of massaging to get it ready skeleton. The skeleton is made up of other trying to get the words “Motion- for the game, and you can get in trou- bones. To create the character’s look, Captured 3D Characters” on their ble by underestimating the amount of you attach geometry or weighted boxes. A lot of hype has been loaded post-production work the data needs. mesh vertices to these bones. The onto those words, often to the player’s You also need to be aware that motion attributes that describe the position, disappointment. As usual, our expecta- capture data is specific to the hierar- orientation, and scale of a bone will tions exceed what the technology can chy and body dimensions of the per- be referred to as channels. By varying truly deliver. But we’re getting so much closer; we have new ripping hardware and the experience from LISTING 1. Sample Biovision .BVA file. past-generation motion capture down- falls. Yet the desire for more keeps Segment: Hips increasing. Frames: 29 The hype has gotten so over-the-top Frame Time: 0.033333 that for the last couple of years, I’ve XTRAN YTRAN ZTRAN XROT YROT ZROT XSCALE YSCALE ZSCALE INCHES INCHES INCHES DEGREES DEGREES DEGREES INCHES INCHES INCHES been threatening to put out VIRTUA 0.000000 34.519684 0.000000 -14.988039 -12.240604 -3.481155 ... HANGMAN as a demo at . I can just see it, these realistic real-time 3D char- 0.102748 34.078739 3.159979 -15.337654 -14.320413 -3.983407 ... acters marching up to the gallows as 0.260680 33.836613 6.487895 -16.308723 -15.090799 -3.861260 ... you relentlessly guess letters. If we ... REPEATS FOR A TOTAL OF 29 FRAMES want to be cliché, we could even have Segment: Chest a 3D character turning the letters. Frames: 29 Now that would be an excessive use of Frame Time: 0.033333 technology. XTRAN YTRAN ZTRAN XROT YROT ZROT XSCALE YSCALE ZSCALE While I wouldn’t consider using INCHES INCHES INCHES DEGREES DEGREES DEGREES INCHES INCHES INCHES motion capture for characters better 0.272156 38.993561 -1.199981 -4.022753 -0.411088 1.354611 ... suited to traditional keyframing, 0.413597 38.542671 1.932666 -4.371263 -0.591130 1.100887 ... motion capture technology clearly has 0.560568 38.279800 5.184929 -5.020082 -0.657020 0.768863 ... a place in game development. Luckily, ...FOR THE REST OF THE SEGMENTS

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com the value in a channel over time, you Figure 1 shows the hierar- get animation. These channels are chy of a sample .BVA file. combined into an animation stream. In Listing 1, we see that These streams can have a variable Hips as the first bone number of channels within them. described. There are 29 Each slice of time is called a frame. In frames of animation in the most applications, animation data has Hips. The frame time is 30 frames per second, though that’s described as 0.03333 seconds not always the case. (per frame), which corre- BIOVISION’S .BVA FORMAT. This is probably sponds to 30 frames per sec- the easiest file format to handle. It’s ond. Next comes a descrip- directly supported by most of the 3D tion of the channels and animation packages. Let’s take a look at units used, then the actual a piece of a .BVA file (Listing 1). channel data. There are 29 This is as simple as animation data lines of nine values, fol- FIGURE 1. .BVA file FIGURE 2. .BVH file gets. For each bone in the skeleton (or lowed by a segment block hierarchy. hierarchy. what Biovision calls Segments), there that describes the next bone, are nine channels of animation. These and so on, continuing to the represent the translation, rotation, and end of the file. That’s all there is to it. Still, it’s an easy-to-read ASCII format scale values for each bone for each BIOVISION’S .BVH FORMAT. This format is that can be useful for importing and 33 frame. You’ll also notice that there is similar to the .BVA format in many storing animation data. Obtaining data no hierarchy definition. That’s because respects. In practice, I know of no off- in this format should be easy because each bone is described in its actual the-shelf way to import this file format the format is supported by many position (translation, rotation, and into Alias|Wavefront or Softimage, motion capture devices and service scale) for each frame. This can lead to although Biovision’s plug-in, Motion bureaus. problems, but it sure is easy to use. Manager for 3D Studio MAX, reads it. The .BVH format differs from the .BVA format in several key areas, the most significant of which is that .BVH LISTING 2. Sample Biovision .BVH file. can store motion for a hierarchical HIERARCHY skeleton. This means that the motion ROOT Hips of the child bone is directly dependent { on the motion of the parent bone. OFFSET 0.00 0.00 0.00 Figure 2 shows a sample .BVH format CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation hierarchy. JOINT LeftHip In this sample, the bone Hips is the { root of the skeleton. All other bones OFFSET 3.430000 0.000000 0.000000 are children of the Hips. The rotation of CHANNELS 3 Zrotation Xrotation Yrotation the LeftHip is added to the rotation and JOINT LeftKnee translation of the Hips, and so on. { This hierarchy will certainly compli- OFFSET 0.000000 -18.469999 0.000000 cate the ’s render loop. CHANNELS 3 Zrotation Xrotation Yrotation Why would you want to bother? You JOINT LeftAnkle can do many more interesting things if { your motion is in a hierarchy. Let’s OFFSET 0.000000 -17.950001 0.000000 take the example of wanting to com- CHANNELS 3 Zrotation Xrotation Yrotation bine a “walk” motion with a “wave” End Site motion. In the .BVA format, there is no { relationship between the LeftUpArm and OFFSET 0.000000 -3.119999 0.000000 the Hips. If we were to apply a different } motion to the different bones, nothing } would stop them from separating. A } motion hierarchy allows you to com- } bine such motions fairly easily. Also, ... should we ever want to add inverse } kinematics or dynamics to the game MOTION engine, a hierarchy would make this Frames: 20 possible. Frame Time: 0.033333 Listing 2 shows a fragment of a .BVH 0.00 39.68 0.00 0.65 ... file. The word HIERARCHY in the first line ... signifies the start of the skeleton defini- tion section. The first bone that is http://www.gdmag.com JANUARY 1998 GAME DEVELOPER MOTION CAPTURE

defined is the ROOT. This bone is the par- Following the HIERARCHY section is the which describes the actual skeleton and ent to all other bones in the hierarchy. MOTION section. This section actually its hierarchy, and the .AMC file, which Each bone in this hierarchy is defined as describes the animation of each bone contains the motion data. The separa- a JOINT. Braces contain the root and each over time. As in the .BVA format, the tion of these two files has a nice benefit. joint. All joints within a set of braces are first two lines of this section describe In a single motion capture session, you the children of that parent joint. the number of frames and the time can have one .ASF file that describes the Within each braced block is the for each frame. However, unlike the skeleton and multiple .AMC motion OFFSET and CHANNELS definition for that .BVA format, the next lines describe files. The Acclaim format is such a tech- bone (or JOINT). The OFFSET describes dis- the animation for all the bones at nical and complex file format that this placement of the root of the bone from once. In each line in the rest of the overview may not provide all the need- its parent. This (x,y,z) coordinate is the MOTION section, there is a value for ed information. Documents describing world coordinate offset from the par- every CHANNEL described in the HIERARCHY the format in greater detail are available ent bone. In the example, the Hips bone section. For example, if the HIERARCHY on the Game Developer web site is located at offset (0,0,0) and the section describes 56 channels, there (http://www.gdmag.com). LeftHip is 3.43 world units away from The .ASF file is the Hips in the x axis. similar to the The CHANNELS line defines which HIERARCHY section bone parameters will be animating in of the .BVH file the file. The first parameter is the in many ways. 34 number of channels animated for Both files this bone. Next is a data type for each describe the of these channels. The possible types joints and the are: Xposition, Yposition, Zposition, hierarchy, but Xrotation, Yrotation, and Zrotation. Note the .ASF file that the scale channels have been extends this a dropped in the .BVH format. bit. Listing 3 dis- Normally, only the root bone has any plays a portion position data — the rest of the bones of an Acclaim have only rotational data and rely on .ASF file. the root and the hierarchy for their In this file for- position. The CHANNELS can be in any mat, lines begin- order. This order defines the ning with a sequence in which the operations pound sign (#) need to be processed in the playback. are ignored. The For example, in the LeftAnkle joint, .ASF file is divid- the order of channels is Zrotation ed into sections. Xrotation Yrotation, meaning that the Each section bone is first rotated around the z starts with a key- axis, then the x axis, and finally the y word preceded axis. This becomes important when by a colon. The we try to display the data. section contin- The branch of the hierarchy ends ues until anoth- with the End Site joint. This joint is off- er keyword is set is only useful in determining the reached. The length of the last bone. :version, :name, and :documentation will be 56 values on each line of section are self-explanatory. The :units the MOTION section. That continues section describes a definition for all for the total number of frames in values and units of measure used. the animation. The :root section describes the parent That’s it for the .BVH format. of the hierarchy. The axis and order ele- While it’s a bit more complex, it ments describe the order of operations gives the programmer designing the for the initial offset and root node engine greater flexibility. transformation. The position element ACCLAIM SKELETON FORMAT. This is the describes the root translation of the most complicated of the three file skeleton and the orientation element formats. It’s also the most compre- defines the rotation. hensive, and supported by most of The :bonedata keyword starts a block the 3D animation packages. An that describes all of the remaining Acclaim motion capture file is actual- bones in the hierarchy. Each bone is ly made up of two files; the .ASF, delimited by begin and end statements.

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com LISTING 3. Sample Acclaim .ASF file. LISTING 4. Sample .AMC file.

:version 1.10 :FULLY-SPECIFIED :name BioSkeleton :DEGREES :units 1 mass 1.0 root -1.244205 36.710186 7.591899 0.958161 4.190043 -18.282991 length 1.0 hips 0.000000 0.000000 0.000000 angle deg chest 15.511776 -2.804996 -0.725314 :documentation neck 48.559605 0.000000 0.014236 Data translated and provided by head -38.332661 1.462782 -1.753684 BioVision Motion Capture Studios leftcollar 0.000000 15.958783 0.921166 :root leftuparm -10.319685 -15.040003 63.091194 axis XYZ leftlowarm -27.769176 -15.856658 8.187016 order TX TY TZ RZ RY RX lefthand 2.601753 -0.217064 -5.543770 position 0.0 0.0 0.0 rightcollar 0.000000 -8.470076 2.895008 orientation 0.0 0.0 0.0 rightuparm 6.496142 9.551583 -57.854118 :bonedata rightlowarm -26.983490 11.338276 -5.716377 begin righthand -6.387745 -1.258509 5.876069 id 1 leftupleg 23.412262 -5.325913 12.099395 name hips leftlowleg -6.933442 -6.276054 -1.363996 35 direction 0.000000 1.000000 0.000000 leftfoot -1.877641 4.455667 -6.275022 length 0.000000 rightupleg 20.698696 3.189690 -8.377244 axis 0.00000 0.00000 0.00000 XYZ rightlowleg 3.445840 -6.717122 2.046032 dof rx ry rz rightfoot -8.162314 0.687809 9.000264 limits (-180.0 180.0) 2 (-180.0 180.0) root -4.232432 36.723934 9.596100 -7.051147 1.678117 -7.711937 (-180.0 180.0) hips 0.000000 0.000000 0.000000 end chest 31.863499 -19.017111 6.490547 begin ... id 2 name hips1 tx, ty, tz, rx, ry, rz, and l. The first of frame number. Next is the bone anima- ... these six define freedom to translate tion data, which is comprised of the end and rotate around the three axes. The bone name and data for each channel :hierarchy last dof defines the bone’s ability to defined for that bone. This information begin stretch in length over time. Each of was defined in the dof section of each root body_root1 these tokens represents a channel that bone in the .ASF file. The frame sections body_root1 hips will be present in the .AMC file in that in the file continue until the end of the hips hips1 hips2 hips3 order. The order of these channel file. After the complexity of the .ASF file, ... tokens also describes the order of opera- the .AMC looks pretty simple. end tions in the transformation of the bone. The limits element is very interesting. It describes the limits of the degrees of This bone description section is what freedom. It consists of value pairs of makes the Acclaim format very useful. either floats or the keyword inf, mean- The id and name elements describe ing infinite. This information can be the bone by number or string. The ini- useful for setting up an inverse kine- tial rest position of the bone is matic or dynamic 3D character. described by the direction vector, and The next section in the .ASF file is the length describes the physical length :hierarchy. Just as it sounds, it describes of the bone. The axis parameter the hierarchy of the bones declared in describes the global orientation via an the :bonedata section. It’s a begin…end axis vector, and the token letters xyz block in which each line is the parent describe the order of rotations. Not bone followed by its children. From included in the sample are two option- this information, the bones should be al elements: bodymass, which defines the connected together in the proper hier- mass of the bone, and cofmass which archy. Figure 3 displays the hierarchy pinpoints the center of mass via a dis- in the sample .ASF file. tance along the bone. The .AMC file defines the actual chan- The dof element describes the degrees nel animation. Listing 4 contains a sam- of freedom possible in the bone. This is ple .AMC fragment. Each frame of ani- FIGURE 3. .ASF file hierarchy. a list of tokens. The possible values are mation starts with a line declaring the http://www.gdmag.com JANUARY 1998 GAME DEVELOPER MOTION CAPTURE

Pipeline,” Casey stream IDs that describe the order of Muratori, Game channels in each stream. Developer, Listing 5 shows the stream types that February/March 1997, I’ve needed. These are not all the possi- pp.38-41). The order in bilities, but they are the ones that I’ve which you perform found useful. By creating separate these operations is criti- stream types for single operations such cal to getting the as STREAM_TYPE_TRANS and STREAM_TYPE_RXYZ, I expected result. decrease stream size while animating. Because I wanted my This operation isn’t as important when motion capture viewer the animation can fit in RAM, but it to support several differ- becomes critical when you have to ent file formats, it was stream animation off of a CD-ROM or important to take opera- the Internet. tion order into account. Next, I created a data structure to FIGURE 4. A sample animation in OGLView. I created a series of represent a bone (Listing 6). I chose to store the transformation information You should be aware of one impor- as separate scale, translation, and tant aspect of the Acclaim and .BVH rotation vectors instead of a global 36 formats. While both formats can store transformation matrix. This made it rotations in arbitrary order, both much easier to handle the different Softimage and Alias|Wavefront expect channel types. I also find the rotation the order of rotations to be tx, ty, tz, rx, values, called Euler angles, easy to ry, rz. This is important if you plan on understand while debugging. going back and forth between the game Conversion to and from quaternions engine and one of these packages. for animation or a transformation matrix can also be done easily. Once the data format for a game engine is Working with Data set, this can be optimized. Looking at the primStreamType, nce you have your data in a for- primStream, and primFrameCount fields, it O mat that you’re happy with, it’s seems curious that I would want to time to start working on it. I’ve created have a motion stream for each bone. an application that loads motion cap- It would certainly be easier to have ture files of different formats and one animation stream that contains allows the user to play them back. You all the data for all the bones in the can download it from the Game skeleton. However, this method allows Developer web site. When full produc- the flexibility to have different stream tion kicks in, such tools are very useful types per bone. This can be useful for file conversion and formatting. because it allows me to attach com- Also, it serves as a good test application pletely different motions to the indi- to try out new ideas and benchmark vidual bones. Imagine a character in a code. walk cycle. The legs and hips are I decided to create the motion cap- ture viewer as a MFC OpenGL applica- LISTING 5. STREAM definitions from Skeleton.H. tion — I find it very quick and easy to create tools this way. If you’re careful /// STREAM Definitions /////////////////////////////////////////////////////// about how you design the tool, much #define STREAM_TYPE_NONE 0 // NO STREAM APPLIED of the code can be used directly in the #define STREAM_TYPE_SRT 1 // SCALE ROTATION AND TRANSLATION game engine itself. Figure 4 shows a #define STREAM_TYPE_TRANS 2 // STREAM HAS TRANSLATION (X Y Z) ORDER sample animation that has been loaded #define STREAM_TYPE_RXYZ 4 // ROTATION (RX RY RZ) ORDER into the application. #define STREAM_TYPE_RZXY 8 // ROTATION (RZ RX RY) ORDER DATA REPRESENTATION. As we saw from #define STREAM_TYPE_RYZX 16 // ROTATION (RY RZ RX) ORDER the different file formats, there are #define STREAM_TYPE_RZYX 32 // ROTATION (RZ RY RX) ORDER several ways to store the animation #define STREAM_TYPE_RXZY 64 // ROTATION (RX RZ RY) ORDER data from a motion capture session. #define STREAM_TYPE_RYXZ 128 // ROTATION (RY RX RZ) ORDER The most important data is the order #define STREAM_TYPE_S 256 // SCALE ONLY of rotations in each stream. You may #define STREAM_TYPE_T 512 // TRANSLATION ONLY (X Y Z) ORDER remember from 3D matrix math that #define STREAM_TYPE_INTERLEAVED 1024 // THIS DATA STREAM HAS MULTIPLE STREAMS matrix multiplication is noncommu- /////////////////////////////////////////////////////////////////////////////// tative (see “Inspecting the 3D

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com affected by the walk stream. Suppose I LISTING 6. Structure definition from Skeleton.h. then attach a wave stream to the right arm. Now I have a walking and wav- struct t_Bone ing character. We can also begin to { plan for the possibility of blending long id; // BONE ID animations together to create dynam- char name[80]; // BONE NAME ic motions on the fly. // HIERARCHY INFO DISPLAY METHODS. Now that I have all t_Bone *parent; // POINTER TO PARENT BONE this data loaded, I have to display it in a way that provides the most infor- int childCnt; // COUNT OF CHILD BONES mation possible. In my tool, I chose t_Bone *children; // POINTER TO CHILDREN to represent each bone of the skeleton // TRANSFORMATION INFO as an axis. The axes are colored red tVector b_scale; // BASE SCALE FACTORS for x, green for y, and blue for z. An tVector b_rot; // BASE ROTATION FACTORS arrow indicates the positive direction tVector b_trans; // BASE TRANSLATION FACTORS in each axis. Since I was using tVector scale; // CURRENT SCALE FACTORS OpenGL to create my motion capture tVector rot; // CURRENT ROTATION FACTORS tool, this seemed like a good opportu- tVector trans; // CURRENT TRANSLATION FACTORS nity to use display lists. Display lists // ANIMATION INFO are a method that OpenGL uses to 37 DWORD primStreamType; // WHAT TYPE OF PRIMARY STREAM IS ATTACHED optimize sequences of commands. float *primStream; // POINTER TO PRIMARY STREAM OF ANIMATION Listing 7 contains the OpenGL com- mands that I used to create a simple float primFrameCount; // FRAMES IN PRIMARY STREAM colored axis. float primCurFrame; // CURRENT FRAME NUMBER IN STREAM I also created a hierarchy browser ... using the CTreeCtl class in MFC. This // REST OF STRUCTURE DECLARATION gives a nice visual representation of }; how the skeleton is laid out. From there, it’s easy to add dialog boxes to edit bone settings, a more proper ani- LISTING 7. Display list code from OGLView.CPP mation control window, andso on. The animation is all handled via a // CREATE THE DISPLAY LIST FOR AN AXIS WITH ARROWS POINTING IN Windows timer event. This isn’t the // THE POSITIVE DIRECTION Red = X, Green = Y, Blue = Z fastest way to animate a Windows application, but it’s plenty fast for this glNewList(OGL_AXIS_DLIST,GL_COMPILE); demonstration. There’s a very good dis- glBegin(GL_LINES); cussion on animating OpenGL glColor3f(1.0f, 0.0f, 0.0f); // X AXIS STARTS - COLOR RED Windows applications in Ron Fosner’s glVertex3f(-0.2f, 0.0f, 0.0f); book, OpenGL Programming for Windows glVertex3f( 0.2f, 0.0f, 0.0f); 95 and Windows NT. I recommend this glVertex3f( 0.2f, 0.0f, 0.0f); // TOP PIECE OF ARROWHEAD book and the OpenGL Super Bible by glVertex3f( 0.15f, 0.04f, 0.0f); Wright and Sweet to any Windows glVertex3f( 0.2f, 0.0f, 0.0f); // BOTTOM PIECE OF ARROWHEAD OpenGL programmer. glVertex3f( 0.15f, -0.04f, 0.0f); The source code and executable for glColor3f(0.0f, 1.0f, 0.0f); // Y AXIS STARTS - COLOR GREEN this application, along with sample glVertex3f( 0.0f, 0.2f, 0.0f); motion files and two documents describ- glVertex3f( 0.0f, -0.2f, 0.0f); ing the Acclaim file format can be found on the Game Developer web site. ■ glVertex3f( 0.0f, 0.2f, 0.0f); // TOP PIECE OF ARROWHEAD glVertex3f( 0.04f, 0.15f, 0.0f); glVertex3f( 0.0f, 0.2f, 0.0f); // BOTTOM PIECE OF ARROWHEAD glVertex3f( -0.04f, 0.15f, 0.0f); Acknowledgements glColor3f(0.0f, 0.0f, 1.0f); // Z AXIS STARTS - COLOR BLUE I wish to give a special thanks to those glVertex3f( 0.0f, 0.0f, 0.2f); who contributed necessary information glVertex3f( 0.0f, 0.0f, -0.2f); and assets: House of Moves glVertex3f( 0.0f, 0.0f, 0.2f); // TOP PIECE OF ARROWHEAD (www.moves.com) and Biovision glVertex3f( 0.0f, 0.04f, 0.15f); (www.biovision.com) for sample motion files; and Richard Hince of Probe and glVertex3f( 0.0f, 0.0f, 0.2f); // BOTTOM PIECE OF ARROWHEAD Richard Barfield of Oxford Metrics Limited glVertex3f( 0.0f, -0.04f, 0.15f); for information on the Acclaim Motion file glEnd(); format. glEndList(); http://www.gdmag.com JANUARY 1998 GAME DEVELOPER

GAME AI

Addig Plaig Caabiliie o Yo Game AI by Bryan Stout

any complaints about artificial intelli-

gence (AI) in games can be attributed to 39 a single cause: the AI doesn’t under-

stand what it’s doing. Actions are deter-

mined by a combination of mechanistic

rules and internal dice rolls, but often

there is no explicit means of represent-

ing the reasons for particular actions. cle will explore research results in the AI be used for a game AI. Those who want We need to define these reasons and subfield of planning. This research has to explore the subject further should represent them in a way that the com- been going on for over 30 years (a very check out the references at the end of puterMM can manipulate. If we can do so, long time in computer research terms), this article. While the techniques that I then the game’s agents — that is, the and its goal has been to develop rou- present won’t give your game’s AI the autonomous entities, be they simple tines for agents to achieve goals in an reasoning skills of a human, they will monsters, NPCs, military units, or com- environment that the agents themselves help you understand how reasoning puter-controlled players — can demon- can change. Over time, this field has can translate into action. strate several intelligent capabilities. explored the representation of actions • They can act in terms of goals. and goals, the reasoning about time and • They can carry out long-term plans. causality, and methods for dealing with What’s in a Plan? • They can adapt their behavior to situ- unknown and dynamic environments. ations not planned for by the game Such a large field can only be he parts that go into a representa- developers. touched upon briefly. The aim of this T tion of a plan or action become Fortunately, there are means to article is fairly modest: to explore how apparent after some careful analysis. improve AI along these lines. This arti- some of the basic ideas of planning can Think about the plans that you make on a regular basis. Where should I go Bryan Stout has worked professionally both in applied artificial intelligence and in for lunch? Which errands do I have to computer game development. He has lectured on game AI at several conferences, do on the way home from work? How including the Computer Game Developers’ Conference, and has been working on a should I schedule the development of book about game AI. After a hiatus of a few months, he is pleased to announce that my game? Most plans share common he has signed a contract with Morgan Kaufmann, and his book, tentatively titled traits. Adding Intelligence to Computer Games, will appear in 1999. • A plan has a purpose — a goal to reach. Perhaps there are several goals,

http://www.gdmag.com JANUARY 1998 GAME DEVELOPER © 1997 Vadim Vahrameev - All rights reserved. GAME AI

LISTING 1. Sample rules for a plan to get past a monster and locked door to a Production rules can be hard-coded treasure. or stored in explicit data structures that are defined either in a code module or If not sufficiently armed to fight the monster, in an external file. Listing 1 shows then look for weapons. some rules (in outline form) that could If do not have the key to the treasure room door, represent a plan to get a treasure that is then look for the key. protected by a guardian monster and a If significantly wounded, locked door. then heal self. One problem that rule systems must If sufficiently armed and healed, deal with is how to choose between then attack the monster. multiple rules that are supposed to fire If fighting the monster and seriously wounded at the same time. A way to solve this and the monster is not seriously wounded, problem is to assign a priority to each then flee. rule or to the different conditions that If the monster is dead or gone and have the treasure door key, can appear in rules. then unlock the treasure room door key and unlock the door. Another problem is that if a rule sys- If the treasure room door is open tem gets too large, it’s inefficient to test then get the treasure. all of the rules’ conditions every cycle. Fortunately, there are ways to speed up 40 and a meta-goal to achieve them effi- the code — the goals result from the this process. One way is to index all the ciently, but each plan has a purpose. interplay between different parts of the rules by the clauses in their LHSs. • A series of subgoals must be achieved code — or perhaps global variables or Then, for example, if a monster is in order to accomplish a plan. objects will keep track of goals that wounded, the inference engine can fig- Additionally, subgoals may in turn have yet to be fulfilled and the progress ure out what the monster should do by have their own subgoals. towards them. It’s tempting to hard accessing only those rules whose con- • A variety of steps must be be taken in code this functionality into the game, ditions depend on the monster’s order to carry out a plan. since it doesn’t require designing spe- health. • Some steps have prerequisites, or con- cial data structures. This solution is FINITE STATE MACHINES. Another useful ditions, that must be true before they perhaps the most difficult to maintain, way to represent a plan is the finite can be taken. however, because any changes to the state machine (FSM), which consists • The steps are taken in order to achieve AI require modifying and recompiling of nodes (representing states) and the some part of a goal, or a prerequisite the code. It would be better arcs between them (represent- of some other step. if we could separate ing the transitions from • The steps in a plan have an order. the knowledge one state to another). Some orderings are necessary because from the reason- A node or a state in of prerequisites; other orderings are ing; we need to a FSM can stand arbitrary. put the plans for a particular • The steps often use a certain amount in data struc- stage in the plan, of resources — including items such as tures that the and an action raw materials, money, manpower, planning rou- associated with fuel, or time — whose presence must tines can use. the node would be be accounted for in order for a plan PRODUCTION RULES. the action to be car- to succeed. Production rules are ried out. The transi- • Some plans have conditional steps, condition/action rules, tions occur when an action which cause branches in the steps which have often been used in is completed, or some event taken depending on some other out- expert systems and other traditional AI interacts with the process of the plan; comes. applications. A production-rule system conditions on those transitions can loops through all the rules, takes note of indicate what the next state should which ones apply (that is, which have be. Figure 1 shows a simple transition Implementing the Plans conditions that are true), and chooses diagram for the same scenario as one of them to fire (invoke). The basic Listing 1. f course, the basic elements listed condition/ action rule is a very flexible EXPLICIT GOAL, PLAN, AND ACTION STRUCTURES. O previously can be represented in tool and can be adapted to many situa- A representation of plans will be more many ways, from simple to robust. tions. For planning, the action, or right- powerful and robust if you can explicit- HARD-CODING PLANS. The simplest way to hand-side (RHS), of the rule would be ly represent and reason about these represent a plan is to write the plan- the action to take. The condition, or left- aspects of plans, rather than get at ning directly into the source code. The hand-side (LHS), would be the prerequi- them through indirect means. This quality of the plan being followed sites of the action. The regular rules can requires that you represent plans, depends on the thoroughness of the be supplemented with variables that goals, and actions in some explicit way. code as it relates to various incidental keep track of the desired goals and the There are many ways to do this, and situations. The plans can be implicit in status of the plans to realize them. since the needs of different games can

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com vary widely (even within the same The fields for an action class could defined constants used for the goals, genre), I won’t advocate one particular include: for easy comparison. representation. • The action name and other strings. • The resources the actions consume, The following are possible fields that • A defined constant representing the whether raw materials, fuel, money, you might include in a structure for a action in a form the program can or something else. The resources goal class: recognize. could simply be be part of the prereq- • A text string in which to store the • Slots that represent the subject and uisites (for instance, “x tons of iron name of the goal, such as “Occupy object(s) of the action, such as the are needed to build the ship”), or City.” You may need text strings for agent doing the attacking, the agent they could be represented as a sepa- other needs too, such as comments. being attacked, allies, and so on. rate type of field. The resources con- • A defined constant representing the goal • Parameters for the action. For exam- sumed also count among the changes in a form the program can recognize. ple, an action to purchase fuel would made to the world. • A set of slots that stand for the para- need to know how much fuel to pur- • The time it takes to perform the action, meters of the goal, such as the city to chase. The slots and parameters could if that’s important. The time could occupy in a war strategy game. be represented in the same way. just be another resource, or it could be • The bindings of the slots. A generic • Bindings for the slots and values for considered separately, since time has goal type will have a slot for the city the parameters. These would be for its own attributes (everyone has the to occupy. A specific instantiation of the instantiations, not for the action same amount, it can’t be traded, and the goal will state to which city it’s templates. once gone it can’t be taken back). referring. The binding could be a • A pointer to a function that actually • The preference associated with the 41 pointer, an index to an array, a carries out the action (for instance, action. A function that evaluates defined constant, and so on. “monster attacks player”). which action to invoke can judge • A pointer to a function that can deter- • The prerequisites for the action. If the based on the various attributes, but an mine whether the goal is satisfied. program is building a plan from extra field can capture information not • A pointer to a function that evaluates scratch, the prerequisites give it addi- directly represented, or provide a short- how close one is to satisfying the tional subgoals for which to plan. cut past the whole evaluation process. goal, which measures progress. This (For instance, needing a key to The fields for a plan class could and the preceding could be the same unlock a door makes obtaining the include: function, with 100% representing full key a subgoal.) While executing a • The goal of the plan, such as “capture satisfaction, or they could be differ- plan, prerequisites provide a test location x.” While a plan is being ent, since progress measurement and whose failure is a reason to abort the executed, the goal can be checked so satisfaction tests may be more effi- action and perhaps the whole plan that the plan can be halted if or when ciently represented separately. (such as the key that is lost or the goal is fulfilled, whether deliber- • A priority for the goal, to help decide destroyed before you can use it). ately or serendipitously. If a plan is which goals to work on first. • The changes the action makes to the being built, the goal needs an explicit As mentioned earlier, there are differ- game world (for instance, “the chest representation, as explained previous- ences between the goal class structure, is now unlocked,” or “the city is now ly, so that the builder can plan for it. general goal templates, and instantiat- occupied”). If the program builds • The steps that comprise the plan. ed goals. The goal class structure is plans, this field is used to look for Depending on the needs of the game, defined at compile time within the actions that fulfill goals or precondi- these may include subgoals as well as code. General goals all use this same tions. While executing plans, this low-level actions. It’s no coincidence class but represent different specific field can be used to see if the action’s that the fields for goals and actions goals. Thus, the fields would have dif- changes have already happened, in explained previously have many simi- ferent values, such as “defend location” which case the action is skipped (for lar fields. Thus, a class implementation or “attack unit.” These goals would example, there is no need to unlock could define planstep as a superclass of probably be created during develop- an unlocked door). The changes the goal and action classes, for use in ment and saved in a file, to be read in should be represented using the same the plan’s step field and other places. at run time and allocated as goal tem- plates. Instantiated goals are goals FIGURE 1. Sample FSM for a plan to get past a monster and locked door to a assigned to a specific circumstance. treasure. They are like copies of the generic goals with slots bound to specific objects Get Weapons Get Key Heal Self (such as “defend Paris” instead of “defend location”). These two types of goals are probably best represented by having different classes for each, Flee whereby the instantiated goal class would have a pointer to the appropri- ate generic goal class as well as the slot Get Treasure Unlock Door Attack Monster bindings. These same principles apply to action and plan classes as well. http://www.gdmag.com JANUARY 1998 GAME DEVELOPER GAME AI

LISTING 2. Sample plans for a simple dungeon explorer. both AI and for humans. Most plan- making and following that people do is Goals: based on the adaptation of previous StayAlive [100] plans to new situations; similarly, we’ll GetExperience [50] assume that you’ll define plans for your game during development and Plans: save them to a file for the program to if BadlyWounded do GetHealing to StayAlive [80] manipulate. if BadCombatSituation do RunAway to StayAlive [90] Listing 2 shows the sorts of plans do GetTreasure to GetExperience [30] one can build for an autonomous dun- do KillMonsters to GetExperience [40] geon explorer. The number after the if IsHealingSource(x) do (GoTo(x), Use(x)) to GetHealing [78] goals and plans show an assigned pri- if IsTreasure(x) do PickUpTreasure(x) to GetTreasure [25] ority. As the explorer moves about, it if IsMonster(x) do AttackMonster(x) to KillMonsters [37] acts upon the goals and plans that have do ExploreDungeon to GetTreasure [15] the highest priority — thus, if it’s in a do ExploreDungeon to KillMonsters [15] life-threatening situation, the plans for if not Explored(x) do GoTo(x) to ExploreDungeon [12] self preservation will be invoked and if DoorClosed(x) do OpenDoor(x) to GoThroughDoor(x) [12] followed, but if not, then the lower-pri- if DoorLocked(x) do (FindKey(y), UnlockDoor(y,x)) to OpenDoor(x) [10] ority goals of monster slaying and 42 exploration are pursued. • The changes the plan makes to the and gradually adding functionality. A Note that there are several levels of world. This is a composite of the simple representation of a plan would plans, incorporating different subgoals changes that individual actions have be a linear list of steps, assumed to that can be used. The plans here are made which aren’t unmade by other occur in their listed order. very simple, only one or two actions actions. Changes made to the world You may have noticed that goals and long, but longer plans can be devel- are important to know because actions actions possess a lot of similarities. This oped. The balance between the number may have side effects that cause one is not a coincidence, since either type of subgoals, the number of plans, and plan to be chosen over another. can be used as a step in a plan. You the length of the plans depends on the • The order in which the steps are might want to make both classes descen- needs of the game’s intelligence and taken. The order can be strict (for dants of a common ancestor class. the efficiency needed for dealing with example, “do A, then B, then C, then The explicit representations all the plans. A well-defined set of D”) or it can be a partial order (for explained previously offer the most plans can meet the needs of several example, “do A before D, and B direct means of applying the planning genres of games and achieve many AI before C”). Partial orders are more algorithms, which I will discuss short- goals. powerful and flexible, but they are ly. The explicit plan structure contains • Simple agents in an can more complicated to track. several lists: the steps in the plan be given a sense of operating under a • The causal links in the plan’s steps. (including their order), the causal set of goals. If their plans are com- For example, the action OpenDoor is links, and the variable bindings that plete enough, they will act in a rea- fired to fulfill the Opened(Door) prerequi- refer to the list of steps. The normal sonable way regardless of the situa- site to the Remove(Chest,Room) subgoal. trade-offs in data structure construc- tion in which they find themselves. These links are useful during plan tion occur at this point — you must • In role-playing games, one may construction to make sure that noth- take into account the typical size and assign nonplayer characters a set of ing affects the action’s result before range of size of the list, its usage, and goals to work from, such as earning the goal is fulfilled (for example, so on. Usually, lists are constructed as extra money, seeking adventure, get- “make sure nothing shuts the door arrays with their references represented ting revenge on enemies, and so on, before the agent can take the chest by array indices, or built as linked lists which makes them seem more like out of the room”). and pointers. real people with separate lives. • Control flow information. An advanced • War games can structure their strate- planner can include loops and condi- gic and tactical thinking around tional branches such as those found in Oh, The Plans You’ll Build plans. Objectives can be defined and programming languages (for example, then attacked or defended according “if the city is found vacated, occupy it; aving examined ways of repre- to how they achieve some higher goal otherwise surround and attack the H senting plans, let’s look at run- in the conflict. forces there”). time methods for selecting plans, • Strategy games can manage resources • The time and resources used by the implementing plans, and recovering with plans as well. Plans can manage plan as a whole. from failed plans. We won’t cover the the economic infrastructure, military • A preference rating. topic of building plans, even though buildup, R&D, and so on, according Of course, not all of these fields need this was one of the first efforts in plan- to the player’s current goals. to be used. When you’re developing a ning research. Building a new plan • In both action and strategy games, plan-building or plan-execution sys- from scratch (that is, from only primi- plans can be used for group move- tem, you’re better off starting simply tive actions), is time consuming for ment as well as individual action. For

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com example, an ambush or a flanking LISTING 3. Simple algorithm for plan execution. maneuver can be coordinated by using either an overall plan run by a repeat virtual commander who tells the get the next action in the plan individual agents what to do, or by perform the action until it is finished separate plans that tell each agent until the plan is empty what to do when certain other agents have done their parts. goodness of the candidate plan. In down into further steps, and so on short, the score for a plan will consist until actual actions are decided upon. of its “value” minus its “cost.” Value A bottom-up approach works in the Plan A, B, or C? can be measured in terms of the fulfill- reverse direction: It looks at the current ment of goals, the value and quantity situation and decides which actions ssuming that our game has several of goods received, the importance of can be done at the time, sees how these A plans built, the next issue to deal land occupied, the value of good rela- actions might work toward achieving with is how to choose which plan to tionships established, and so on. The goals or preconditions for other follow in a given situation. This issue cost could include resources consumed, actions, and then builds up plans from can be considered from several angles, time expended, estimated damage there. A combined opportunistic leaving a wide range of approaches to taken or lives lost, the number of units approach is often useful, too, involving take. committed that could also be used else- either top-down or bottom-up plan- For instance, should you choose a where, or some other method of mea- ning as is appropriate. For instance, in 43 plan based on optimized or simply sat- surement. Both the value and cost a war game, a commander could build isfied conditions? In other words, estimates should factor in an a top-down plan to drive through a cer- should the game look for the estimate of the certainty tain part of the enemy’s line. If the best plan of all or a plan that that valuable things will enemy responded by bringing in troops is simply good enough? A be gained or lost if that from another sector, and thereby leav- satisfying approach would plan is chosen. ing that sector too weakly defended, a take the first plan which Another issue in bottom-up planner should notice the meets some minimal the plan selection weakness and plan to send a force to standard — the first to process is whether to puncture the line at that point. score over a given mini- use an agent- or Finally, you must decide whether mum, or perhaps the goal-based system. complete plans, a partial plan, or only first that looks as if it In an agent-based specific goals will satisfy your AI. If a will work. This approach system, an agent tries situation under consideration is fairly can be helped by exam- to decide what to do predictable, and the plan takes only a ining candidate plans in a next, including which short amount of time, then making a particular order, such as goals to work for as well complete plan is useful, and the from simple to complex, or as which plans to follow emphasis is on plan selection. But the cheap to costly. For example, and which actions to take. more dynamic and unpredictable the in order to capture a city in a war The agent is the center of the environment, the less useful it is to lay game, the player can first try march- focus — individual plans or goals out complete plans. In such cases it ing into it (if it’s empty of enemy may be dropped or modified. In a goal- may be useful to plan in detail only the troops), then can try a simple attack based system, the focus of attention is next few actions and leave other sub- followed by an advance, and finally the goal, and agents are used in order to goals for later. In extremely dynamic can attempt more involved and pro- achieve the goal, rather than vice-versa. environments, your action selection longed attacks. The goal-based system is a more natural process is concerned with the very next An optimizing approach would approach when there are many small action. You can plan this in several dif- examine several plans and choose the agents at the disposal of an overall ferent ways. In a top-down approach, best one based upon its score. deciding entity — it is frequently used you choose the best high-level plan for Fortunately, not every possible plan in war games and strategy games. For the desired goal, then choose the best needs to be examined (because the instance, if the virtual general in a war subgoal within that plan, and so on same plan can have many instantia- game wants to capture a location, that recursively until an action is selected. tions with different variables or slot goal will look for units to use in that In a bottom-up approach, the action is bindings, such an optimizing approach effort. The units themselves aren’t con- selected that best fits the current situa- can involve huge numbers of plans). sidered to have individual goals and tion and seems to advance toward The number of plans can be held down exist only to follow orders. desirable subgoals and goals. Yet further by limiting the search to a cer- Another decision you must make is another approach is to look at several tain number of plans or a certain whether to use a top-down or bottom- possible plans for the current goals and amount of time spent searching for the up goal selection process. In the top- choose the action that fits the greatest best plan. down approach, a high-level goal may number of plans — in other words, the When I refer to a plan’s “score,” I be fulfilled by achieving a few subgoals. one that leaves the most flexibility for mean some function that evaluates the These subgoals will have to be broken future actions. http://www.gdmag.com JANUARY 1998 GAME DEVELOPER GAME AI

LISTING 4. Algorithm for plan execution with action monitoring. action’s purpose or preconditions.) Action monitoring is fairly robust, repeat but it’s not perfect. It will detect prob- get the next action in the plan lems with the current action, but it if the action’s purpose or changes have already happened won’t detect problems with future continue actions. For example, if an AI-con- if the action’s preconditions are false trolled general starts assembling forces abort the plan to take a city, action monitoring won’t do notice if the enemy abandons the city perform the action until the whole force is assembled and until the action is finished or time runs out is actually at the point of carrying out if the action’s changes are false the assault. For another example, con- abort the plan sider an AI-driven character that found until the plan is empty a locked chest and went off to look for the key. If the character noticed some open. An action monitor performs imp running off with the chest, the Acting upon a Plan three types of tests: character wouldn’t do anything about 1. It tests the action’s intended it until he returned to the scene with a ur game AI knows how to repre- changes. If they’re already true, the key. Handling such problems requires a 44 O sent plans, our agent has chosen a action is skipped since it would be more robust form of testing called plan plan that advances toward a goal, and superfluous. monitoring. now the agent must act upon that deci- 2. It tests the action’s prerequisites. If Plan monitors perform tests similar to sion. How should this be done? The any of them are false, the action can- action monitors, but on a global level. simple, straightforward approach is not occur, and the plan is aborted. First, they test to see if any upcoming shown in Listing 3. The agent repeated- (Note that this may also be put in the action (or subgoal, if it’s not broken ly looks up the next action in the plan, search for the next action when using down to actions yet) has a violated pre- and then does it, until all the actions in partial ordering: Find an unexecuted condition. This test only applies to pre- the plan are done. This is good enough action with no unexecuted predeces- conditions whose causally-linked action for linear plans in a static environment. sors, whose prerequisites are true.) has already been executed. If such a pre- If the plans aren’t linear — that is, if 3. It monitors the action’s execution, condition is found, the plan has failed. the steps are listed in a partial order not only to stop the action when the Second, plan monitors test to see if rather than in a complete order — then desired changes are true, but also to there are steps that can be skipped. A getting the next action is a bit more know when to stop trying. It may plan monitor checks all unexecuted complex than just reading the next step quit the action if the preconditions parts of the plan to see if their desired of the plan. In this case, one needs to are violated during execution, or if a changes have already occurred. If so, look at all the unexecuted actions that certain amount of time has passed or then their preconditions’ causal links have no unexecuted predecessors and certain number of attempts have are followed back and marked as being choose one of them to do. You could been tried. (The time-out test can skipable. When looking for an action to choose the first such action found, or easily be added to the simple loop of perform afterwards, if all its changes are look at several of them and choose the Listing 3 without any reference to an marked skipable (in other words, every best one according to some game-spe- cific criterion, or choose the one with the highest priority rating (which could LISTING 5. Algorithm for plan execution with plan monitoring. be attached to an action or to a produc- tion rule if rules are used). repeat Not all situations are static or pre- if there is a precondition for an unexecuted action dictable, however, and this can affect whose value is false which plan is chosen. These dynamic and whose causal action has already been executed situations often crop up in games, abort the plan where there are usually multiple from the final goal and working backward agents, each with its own agenda. As I if the goal’s or action’s changes are already true stated in my discussion of actions and for each precondition of the goal or action plans, you can monitor the plan during mark the action that causes the precondition as skipable execution and adjust to violated expec- get the next action in the plan with a needed change tations. The first level of monitoring is [ie. with a change not marked skipable] action monitoring (an example of do which is shown in Listing 4), so called perform the action because it runs the tests at the action until the action is finished or time runs out level and it helps avoid invoking stupid if the action’s changes are false actions such as trying to open a pad- abort the plan locked chest or a chest that is already until the plan is empty

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com plan that might have needed this action However, if one is working with and their impact. For instance, if a no longer needs it), then the action is plans in a hierarchical fashion — plans party of dungeon crawlers splits up, it skipped. If the final goal is found ful- that have have subplans and so on — might be important for each person to filled, you might want to add a special then the replanning can be fairly effi- carry a weapon, not because they’re condition to exit the plan, rather than cient. This is because you only have to likely to run into a monster, but marking all remaining actions as replan at a low level, leaving the high- because it would be fatal to encounter skipable. level plans intact. If a situation gets a monster while unarmed. Once a plan is instantiated, it may be really messed up, then plans will fail at ABANDON OR POSTPONE THE GOAL. This is a a good time to go through and anno- higher levels, which may necessitate simple solution to the problem — give tate all of the preconditions to be test- replanning at the higher levels. up and do something else. It may be ed before any actions are taken. This REINSTANTIATE. One of the simplest ways that circumstances within the game avoids having to do it each time an to salvage a broken plan is to find will change and the goal will become action occurs. Since these tests are another way to instantiate the achievable later. more time consuming than action variables or slots of the old All of these approaches need not be monitoring, you need to test plan. For example, if you mutually exclusive. A routine for deal- carefully to see if plan monitor- planned to go down a ing with plan problems may consider ing is worth the effort. You road that is blocked, you several of them — reinstantiation, fix- may prefer to do only one of might look for a differ- ing the problem, using alternative these tests in addition to the ent road. Or, if one plans, and dropping the goal — and action monitoring, or to do agent is too damaged choose the option with the best 45 none at all. If the plan is or otherwise involved cost/benefit trade-off. linear, using a full order and cannot attack, This coverage of AI planning should rather than a partial order, then attack with give you several ideas to play around then it is much easier to do another unit. with — some of them should be applic- the tests, since it’s easy to FIX THE PROBLEM. able to your particular game situations. determine which are the Another approach to Good luck! ■ following or preceding recovering from a actions. You can just go up failed plan is to make or down the list, rather than the violated precondi- F U R T H E R R E A D I N G following causal links around. tion true again. That is, Listing 5 shows how the basic make the condition a new This overview has been necessarily algorithm for plan monitoring goal, and find a plan to general. Here are some books which are might work. make it true. For instance, if very useful for further reading: the road you wanted to travel Allen, James, James Hendler and Austin down is blocked, find some way to Tate. Readings in Planning. (Morgan The Best Laid Plans of Mice and Men remove the barrier. Kaufmann, 1990.) A very good collection TRY ALTERNATIVE PLANS. You may switch Go Oft Awry of important historical papers covering from one plan to another. For instance, various aspects of planning. r, as Von Moltke put it, “No bat- if the dungeon crawler’s key doesn’t O tle plan ever survives contact unlock the door, she may set off in Shapiro, Stuart C. Encyclopedia of Artificial with the enemy.” However you say it, search for another key, or she may Intelligence. (Wiley Inter-Science, 1990.) the truth is that plans often don’t work decide to try destroying the door with Good article on planning (and many out as they should. Whether from a her axe! other good articles). changing world, an independent USE CONDITIONAL PLANS. The original plan Russell, Stuart and Peter Norvig. Artificial agents’ actions, or deliberate sabotage, can have conditional tests meant to Intelligence: A Modern Approach. (Prentice things happen that make plans obso- handle contingencies, thereby avoid- Hall, 1995.) This has the best discussion lete. Discovering this condition was ing the cost of determining what to do on planning of current AI texts. In fact, I the subject of the last section; knowing when a problem arises. For instance, regard it as the best of all current AI what to do about it is the focus of this the dungeon crawler may decide to texts, period, both in general and for one. There is a variety of different bring along all her keys, her axe, and a computer game developers. It has the responses an agent can make to recover gunpowder bomb to deal with possible widest selection of topics, the most from foiled plans. problems. The drawbacks to this recent research, and uses agents as its REPLAN. The simplest act one can per- approach are that you can’t anticipate organizing paradigm – rather than pre- form is to completely scrap the old all possible problems, you can’t prepare senting the different fields of AI in a plan and find a new one to instantiate for all the problems that you can antic- loosely-related manner, it treats all of and follow. It’s the easiest to program, ipate, and anticipating many problems them from the viewpoint of software enti- and in simple situations, it’s sufficient. simply may not be worth the time to ties that are trying to perceive their envi- In other situations, though, it may be think about them or the resources to ronment, make decisions, and act — just inefficient — replanning means redo- deal with them. When deciding which the things that games are full of. ing much of the work that went into problems to anticipate, it might be use- the old plan. ful to consider both their probability http://www.gdmag.com JANUARY 1998 GAME DEVELOPER 3D AUDIO

Aoidig a DiecSod3D Diae by Rich Warwick

D audio can have a tremendous effect on a

gamer’s experience. Unfortunately, if a game 46 doesn’t use the DirectSound3D API correctly, the

effect can vary between little or no 3D audio

positioning to even more serious problems,

such as accidental system overloading. While

the methods for implementing 3D positional audio

via DirectSound3D can be found in reality, 3D positional audio, virtualiza- ing from an area that is much wider various books as well as in Microsoft’s tion, and spatialization are three differ- than the actual speakers. The general own documentation, knowing how not ent concepts, and their differences must perception of spatialization is that it to write to33 this API is just as critical to a be understood before they can be prop- makes a stereo stream sound much successful implementation in your erly applied to games or applications. richer to the average listener. game. Spatialization, sometimes called Virtualization uses signal processing stereo expansion, uses signal process- to fool the listener into thinking that ing to expand the perceived location of there are other speakers present that Defining the Vocabulary speakers. It is a nonlocalizing effect, aren’t really there. For example, a system meaning that it doesn’t localize a could use only two front speakers or efore diving into how and how not sound or a channel to a specific loca- headphones and virtualize rear or sur- Bto use 3D audio, let’s clear up some tion. In fact, it does the opposite. round sound speakers for a home theater of the confusion associated with the Spatialization disperses the perceived effect. Virtualization localizes a specific technology. Often the terms “3D location of the sound so that the listen- channel of audio (such as left rear) to a audio,” “positional audio,” “spatializa- er can no longer determine the exact specific location, as opposed to localiz- tion,” “virtualization,” and “stereo location of the speakers. It makes the ing a specific sound to an exact location expansion” are used interchagably. In listener believe that the sound is com- (which is what occurs in 3D positional audio). Virtualization is only used when Rich Warwick’s experience in the PC industry spans chip, gate array, and board level the source media has more than two hardware design, as well as DSP software development. Rich joined Crystal channels of audio — its usefulness for Semiconductor Corporation in 1995 as a software development manager. He was positioning interactive sound sources responsible for the software development for Crystal's CS4610 PCI audio accelerator. (such as those found in action games) is He is currently the Manager of DSP Software Technology, leading the development of limited. Examples of multichannel software for Cirrus Logic's "Sound Fusion" line of PCI audio accelerators. source media are Dolby Prologic

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com Surround or Dolby Digital audio a much wider sound field than the jump from the front speakers to the streams. In this article, when I refer to actual speakers, which in this case are rear (depending on the player’s 3D audio, I mean 3D positional audio. very close together. actions), but cannot due to prior encod- 3D positional audio uses signal pro- Care must be taken never to apply ing on a specific channel. However, cessing to localize a single sound to a this effect to an audio stream that has multichannel audio and the virtualiza- specific location in three-dimensional already been processed by a 3D posi- tion of these channels are very effective space around the listener. 3D positional tional algorithm, because spatialization for noninteractive game intro scenes. audio is the most common effect used alters the phase of the signal and can Virtualization is typically used to in interactive games, because a sound destroy the 3D positional effect. play back Dolby AC-3 or Dolby Pro effect, such as the sound of an oppo- However, such conflicts are the con- Logic audio streams on a system that nent’s automobile, can be localized to a only has two speakers. For example, specific position. This position, DVD movies can have a 5.1 channel for instance, could be behind Dolby AC-3 audio track encoded the listener and quickly on the DVD. (The 5.1 chan- moving around the left nels are actually left front, side while all the other right front, center, left sounds are posi- rear, right rear, and a tioned separately. subwoofer. The sub-

47

woofer 3D posi- is referred tional audio is to as the “.1” also referred to as channel of the 5.1.) HRTF-based 3D 3D positional audio audio. HRTF stands for techniques are used to “head-related transfer position a front center function,” a method by channel as well as right and which sounds are processed to left rear channels at their virtual localize them in space around the locations. Virtualization simulates the player. Although this technique is additional speakers that aren’t typically acceptable for 3D positioning, it present on a computer. Virtualizing rear requires a large amount of processing cern of the audio system designers, not speakers is an example of using 3D power. This is the reason 3D audio the developer of game or application. positional audio for a noninteractive hardware accelerators are becoming so APPLICATIONS FOR VIRTUALIZATION. Virtual- application, because the virtual speaker common in PCs. For an explanation of ization is an effect that gives the listen- locations aren’t moving or responding the mechanics of 3D audio and HRTF er the impression of a home theater to the listener. processing, see “Exploiting Surround environment even when only two APPLICATIONS FOR 3D POSITIONAL AUDIO. One Sound using DirectSound3D” in the speakers or headphones are present, of the reasons that 3D positional audio December/ January 1997 issue of Game which is typically the case with multi- is so popular in action games is because Developer. media PCs. However, to use this effect, it can be interactive. Sounds don’t have APPLICATIONS FOR SPATIALIZATION. Spatial- multichannel audio must be available, to be preprocessed during the game’s ization is an effect for processing and the sounds to be played back on development to position the sound. As music, such as an audio CD or a stereo the virtualized rear speakers must be the listener changes location in a virtu- music soundtrack in a game. This effect encoded onto those tracks during pro- al world, all the sound objects can is especially useful for PC speakers that duction. This makes this solution less maintain their correct location speed are built into the monitor because it than ideal for the action portion of and path of motion around the listener makes the sound appear to come from games, in which sounds might have to as the action unfolds. http://www.gdmag.com JANUARY 1998 GAME DEVELOPER 3D AUDIO

This is different from applications necessary. This is a common mistake able frequency) will assign a sample rate that encode the audio into a certain because it’s the default in some of the conversion application to the audio channel (such as a rear or surround DirectSound SDK examples. To make stream. This consumes additional pro- channel) during development. best use of a hardware DirectSound cessing resources either on the host Encoding the location of a sound into accelerator, pay attention to the flags processor or on the audio hardware a particular channel of a multichannel specified in the lpcDSBufferDesc.dwFlags accelerator. If the host PC contains a stream is an example of noninteractive parameter, which are passed to multitasking audio hardware accelerator audio placement. Multichannel audio IDirectSound::CreateSoundBuffer(). Some of with dynamic resource management, is typically used in an environment these flags are straightforward — for the resources consumed by these sample where the listener doesn’t have control example, DSBCAPS_LOCHARDWARE asks for a rate conversion applications could have over the sounds — such as when you hardware-accelerated buffer and been used to accelerate more 3D audio watch a movie in a home theater. DSBCAPS_CTRL3D asks for DirectSound3D channels. As you can see, blindly creat- control. Other flags have implications ing all streams as variable frequency for hardware accelerators that aren't so streams will slow down the host proces- Implementing 3D Audio Today straightforward. The worst offender is sor and/or prevent 3D audio streams DSBCAPS_CTRLFREQUENCY, which specifies that from being accelerated. he use of 3D audio in PC games ini- you need to be able to adjust the buffer's 2. NEVER USE 3D WHEN 2D WILL SUFFICE. Only T tially wasn’t widespread, mostly due playback frequency after the buffer has create 3D sound buffers when necessary. to poor 3D audio support in the been allocated. There are circumstances Many games have created all of their 48 Microsoft DirectSound3D 3.0 API. The where this is a useful capability (some audio streams as 3D streams, but this first iteration of this API didn’t allow racing games use it to adjust the pitch of practice results in a poor listening expe- specialized 3D audio hardware to process an engine, for example), but most of the rience. An accelerated system will quick- the 3D streams, and as a result, game time it's not required. ly run out of resources, and the result developers couldn’t be certain that 3D You also need to be aware that will be a complete lack of accelerated 3D sound objects would sound satisfactory Microsoft's default lpcDSBufferDesc.dwFlags audio. After all the hardware accelerator and have the desired effect — even if a value, DSBCAPS_CTRLDEFAULT, includes the resources are consumed, the host will world-class 3D audio accelerator was pre- DSBCAPS_CTRLFREQUENCY flag (in addition to apply its 3D audio algorithm to the sent in the PC. So there wasn’t much DSBCAPS_CTRLVOLUME and DSBCAPS_CTRLPAN), so remaining streams. These streams will incentive for game developers to incor- you're not safe from this potential per- consume much more processing power porate 3D audio into their games early formance-draining trap if you supply than 2D streams, and further burden last year. However, when Direct- Microsoft's default flag value. the system. The bottom line is that it’s Sound3D 5 started shipping in August Every buffer that is created with very wasteful to play every stream as 3D 1997, the situation changed. That API DSBCAPS_CTRLFREQUENCY (that is, set for vari- when it isn’t necessary. supports specialized 3D audio accelera- tors for processing 3D audio streams. TABLE 1. Games that currently support 3D positional audio or will do so in coming months. Using the DirectSound3D API Company Game hile there are a number of Acclaim TUROK: DINOSAUR HUNTER; FORSAKEN W sources for information about Activision HEAVY GEAR using the DirectSound3D API, it’s Crack dot Com GOLGOTHA equally important to know how not to Eidos THE DARK PROJECT use it. At last year’s Computer Game Electronic Arts MOTO RACER Developers’ Conference, a number of GT Interactive TIGERSHARK; MAGESLAYER; BUG RIDERS programmers working on 3D positional Interactive Magic Online WARBIRDS audio for games explained problems Interplay STARFLEET ACADEMY that they had encountered and the LucasArts OUTLAWS, JEDI KNIGHT lessons that they had learned during Maxis SIMCOPTER; STREETS OF SIMCITY; SIMCITY 3000 development. Their problems resulted Microprose MECHWARRIOR III in poor performance in their games and n-Space TIGERSHARK; BUG RIDERS little or no apparent 3D effect, even on Probe FORSAKEN the sounds the developers most wanted Raven Software MAGESLAYER to position in 3D space. I’ve boiled their Reality Bytes DARK VENGEANCE comments down to four rules that you Ripcord Games SPACE BUNNIES MUST DIE should follow when implementing 3D Sculptured Software TUROK: DINOSAUR HUNTER positional audio in your own title. SegaSoft ROCKET JOCKEY ANARUS 1. NEVER USE VARIABLE FREQUENCY BUFFERS Sony Interactive Studios T RIME ITIES PEED HRILL IRTUA OMMAND UNLESS THEY’RE ACTUALLY REQUIRED. It’s Techland Software C C ; S T ; V C ; important not to request variable fre- CRUSHER; SPEEDWAY MANAGER 3D quency sound buffers when they’re not Source: http://www.aureal.com/tech/A3Ddevs.html

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com 3. AVOID USING THE DuplicateSoundBuffer CALL. A in DirectSound 5 cannot take over. channels are already consumed, or there common mistake that game developers This is because DirectSound 5 doesn’t was no accelerator in the system, the make is not checking for the failure of a have access to the parameters that host 3D algorithm in DirectSound 5 DuplicateSoundBuffer call. Failure to check you’re requesting to duplicate. These takes over and processes the stream on for a bad return code from this call can parameters only reside in the hardware the host. This process is invisible to the lead to audio streams or sound effects accelerator. Therefore, the game or application. The steams that are being completely lost. The reason an DuplicateSoundBuffer will fail, and relegated to the host won’t be posi- application developer would use the DirectSound 5 won’t play the buffer on tioned very well and will use more host DuplicateSoundBuffer call instead of using the host. At this point, the buffer is lost processing power than 2D streams. CreateSoundBuffer is strictly a matter of and the sound will never be heard. This convenience. Instead of providing all the isn’t a problem if the game or applica- necessary parameters for each 3D buffer, tion checks for the failure and then Follow the Rules you can just reference, or duplicate the reinitiates the call using CreateSoundBuffer parameters of a previously created instead. However, the best approach is lways create the most critical 3D buffer. This practice is acceptable only if not to use the DuplicateSoundBuffer call. A sound buffers first. That way, if you understand what happens when a Only use CreateSoundBuffer, and this there is an accelerator in the system, it call fails and can take corrective action. problem can be avoided. will be used for the sounds that will Here’s the problem: If a new 3D 4. ALWAYS CREATE THE MOST IMPORTANT 3D have the most impact on the listener. sound buffer is created using SOUNDS FIRST. To maximize the 3D It’s no secret that 3D audio can be an CreateSoundBuffer, the buffer will be creat- impact on the listener, it’s important to immersive experience for game players. 49 ed on the hardware accelerator if there create the most important sound buffers However, if you’re going to adopt this is a free 3D channel. If no hardware 3D first. Each time a 3D sound buffer is cre- technology, make sure that you avoid channels are available, the software 3D ated using CreateSoundBuffer, the buffer the common pitfalls associated with emulation in DirectSound 5 will auto- will be created on the 3D audio hard- DirectSound3D. When followed, these matically take over. However, if the ware accelerator — if one is present in four rules will maximize the impact of new 3D sound buffer is created using the system and has a 3D channel avail- your audio and reduce unintended DuplicateSoundBuffer, the host emulation able. If all the hardware accelerated audio processing. ■ PROJECT MANAGEMENT

isten to this and see if it sounds familiar. You want to create

a new game. You think your game is going to be a hit, the

next big thing. You’ve assembled a team of talented people,

who have lots of great ideas and have created some fancy

technology. All that you need is time and

money. You present your idea. It’s well-received.

And, you can have your money if… you can ship your 51 game by Christmas 1998. You glance at your notes and your LL impressive-looking Gantt charts, and then confidently say, “No problem.” If only that were true. If you’re developing a new, innovative game, you’re going to have problems. You’ll make mistakes. You’ll struggle to A Chao find solutions. You’ll design and redesign through the process of trial and error. You’ll be forced to make trade-offs. Your plans will change. The unexpected will happen. You’ll be faced with crisis. You’ll have to divert at least one disaster. Theo When your goals are ambitious, chaos and crisis are the norm, and anxiety is a constant companion. Creating a new game can be nerve-wracking, even perilous (financially, by Martin Streicher physically, and emotionally). But taking risks also provides you and your development team with challenge, excite- ment, and enrichment — perhaps even fame and fortune. In my September 1997 Game Developer article, “The Game of Risk,” I presented some techniques to identify and man- age risk in your development projects. In this article, I pre- sent some techniques for encouraging, embracing, and leveraging risk and chaos in product development.

Martin Streicher is an Executive Producer at Berkeley Systems, Inc. in Berkeley, CA. He graduated from Purdue University in 1986 with a Master’s degree in Computer Science, and has been a software development manager since 1989. Most recently Martin produced YOU DON’T KNOW JACK MOVIES and YOU DON’T KNOW JACK VOLUME 3. Martin is currently the executive producer, producer, and director of a new CD-ROM game show that he also created. Please send comments or questions about this article to [email protected]. http://www.gdmag.com JANUARY 1998 GAME DEVELOPER PROJECT MANAGEMENT

Misery Loves Game Companies hardware, software, storytelling, adapt your current practices and invent game play, art — are so diverse and new ones. ame development schedules are often revolutionary. A new game You’ll certainly face situations and G notoriously volatile. Why? Because makes the unreal real — certainly the problems that you’ve never faced creating great games is an art. And while stuff of art. before, and you’ll be called upon to that comparison may be overused and Additionally, the process of creating make decisions for which you’re unpre- cliche, I think it’s apropos. a game — its design, execution, and pared. You’ll make mistakes, but that’s The people that create games — implementation — is not a science. normal. Game development has no for- game designers, developers, artists, Each software development “model” mulas to follow, nor physical laws to animators, modelers, musicians, and has advantages and disadvantages, and obey. Development has no rules. There writers — are all artisans who have development methodologies vary are no good nor bad decisions per se — mastered a specialized craft. Like greatly. Great games challenge the lim- it’s up to you to decide what works and other craftspeople, the people that its of technology — you should expect what does not work. create games require skill, insight, that creating great games will likewise All of this uncertainty can be terrify- direction, materials, and time to pro- challenge your status quo and the lim- ing, but it can also be compelling. Each duce great work. I would argue that its of your own abilities. If your goals open issue provides you with the game developers face even greater are ambitious, then you should expect opportunity to excel, create, invent, challenges since their materials — things to change. You should expect to and imagine. If you’re a smart develop- ment manager, you’ll recognize the 52 chaos, relate to the anxiety it can cause, and at the same time, harness its PEZ energy. Trial and error is good chaos. It shows that you’re seeing faults in your Things to accomplish: design and trying to address them. • Ship PEZ by Christmas 1998 (sound familiar?) Tweaking performance is good chaos. • Stay within budget Building several game prototypes is • Develop a strong team of writers good chaos. Developing more than one • Create a supportive and collaborative culture for content development backstory is good chaos. Juggling prior- • Develop techniques for content testing and refinement ities is good chaos. Finding additional Critical dates: funding to continue development is • 6 October - PEZ funding presentation great chaos. Even if you try and fail • 1 December - End of feature testing; finish all refinements and complete game play several times, your final solution ulti- specification mately improves your game. • 7 January 1998 - End preproduction phase; start production phase So how do you do encourage risk- • July, August 1998 - External prereleases taking, and embrace chaos and uncer- • September 1998 - Product ships tainty without derailing your develop- People required: ment project? Good question. To leverage chaos during a project, • 3 full-time artists/animators/modelers you must budget it and then manage it • 1 part-time artist — just as you budget and manage • 3 software developers, a production coordinator money. • Myself (acting as producer and director) • A Software Quality Assurance (SQA) lead and several SQA engineers • A composer and musicians • A sound engineer Budgeting Chaos • An editor-in-chief ow do you budget chaos? You • 2 full-time writers establish limits for chaos and • Several part-time writers H then decide how much chaos each part Equipment required: of your project can afford. Tasks that 3 • A ⁄4” tape deck you want to control closely are “allo- • A video capture board cated” little or no chaos. Tasks that • A dedicated image scanning system require trial and error to perfect are • A recording booth usually afforded more chaos. • A Web-based database server For example, you may choose to Project risks: “allocate” a good portion of your chaos • Developing a writing staff and creating content budget on a task such as level design. • Developing and implementing an effective content test plan However, a critical task such as 3D • Time (time is always a risk; and if you are independent game developer and not a engine development might be afforded developer/publisher, money is also always a risk) less chaos since it’s critical to your • Creation of the marketing plan title’s game play and look-and-feel. To create a chaos budget, you must first

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com identify everything that’s critical to the You are developing a new game sched- ates a process in which you and your success of your project. Specifying uled for a Christmas 1998 release. team analyze, estimate, debate, design, what is critical sets limits and ensures Shortly after you begin development, review, and ratify a development plan. that you don’t spend so foolishly that you learn that your company is run- Once your team has completed the it endangers your project. ning out of cash and that your ship process of creating a project schedule, At a minimum, your list of critical date for the game is being moved up to the schedule is useless. items should include: Summer 1998. Given this new informa- A development schedule, no matter • A thorough and detailed description tion, you and your team have to review how detailed, is not a substitute for of the new product’s features and revise all of your project goals and your leadership. All of your infrastruc- • A list of critical dates (this list includes your chaos budgets. You may decide to ture — Gantt charts, spreadsheets, sta- your ship date and other milestones cut features, expand the staff, and tus reports, e-mail, code reviews, design such as “feature complete,” “external accelerate development of certain key reviews, staffing, and meetings — are prerelease,” and other) technologies. You may decide to take only a means to an end. • A definitive list of things that you more risk (spend more chaos) in engi- want to accomplish in the project neering to match the accelerated • A list of risks to the project scheduled. Or, you may decide to Managing Chaos • A list of dedicated resources that are severely cut your chaos budget by required to execute the project plan greatly restricting the kinds of deci- o manage chaos, you have to earn (resources include money, people, sions each part of the T it, invest in it, keep track of your information, and equipment) team can make investment, invest more when it’s need- 53 • A list of the expectations that you independently. ed, and know when it’s time to cut your have for each person on the develop- losses. And, to continue the analogy, ment team you cannot manage your investment For example, the sidebar shows the effectively and safely without doing critical items that I identified for a your research. As the project leader, it is development project that my team just your primary responsibility to measure started (the product is code-named progress, assess risk, prevent and antici- “PEZ”). pate problems, and adapt the project As you can see, my list of crucial whenever a critical item is threatened. items includes the goals of the project, It’s your responsibility to lead, partici- a description of the product that I want pate, communicate with, and listen to to build, critical dates in the schedule, your team. In fact, accommodating and the resources required to be suc- chaos and encouraging risk-taking puts cessful. Armed with this list, I’m happy an even greater onus on you to interact to let chaos reign free (or in my analo- with everyone on your development gy, be spent freely) until it conflicts team. Here’s how I recommend you with or threatens anything crucial to Budgeting chaos is oddly similar to manage your project portfolio. the project. how the Federal Reserve Board controls ENGAGE AND PARTICIPATE. As the project My lists are admittedly very broad in interest rates. If risk is costing the team leader you must establish and then scope; they define limits, but are too too much time, effort, and money, cut protect the autonomy and indepen- general for day-to-day chaos manage- back on how much chaos is available. dence of your development team. To ment. To complete a chaos budget, If your project needs or wants more establish autonomy, you must estab- your team’s lead programmer, lead experimentation, then make chaos lish a creative, collaborative environ- artist, and marketing manager should more readily available. ment that fosters innovation, risk-tak- compile their own lists of crucial ele- You may be wondering why my ing, and experimentation. Enable all of ments. When all of your lists are com- detailed PEZ development schedule your team members to make as many bined, the entire team can operate wasn’t included in my list of project independent decisions as possible. independently within well-defined parameters. In a chaotic environment, Once you have autonomy, do not treat boundaries. In fact, reviewing all of the I don’t necessarily care when or how it as an entitlement. You have to work critical items and individual “chaos things happen as long as the team is as a team to protect it. For example, budgets” is an excellent way to manage achieving its stated goals. Am I advo- during the development of YOU DON’T the entire project. cating anarchy? No. Process and infra- KNOW JACK MOVIES, the art team found As project requirements change — structure are required for any large- itself five calendar days behind sched- and we know that they will — redefine scale project. You still need design ule. Rather than ask for additional per- your critical items and reallocate chaos documents, schedules, reporting struc- sonnel or time to complete the work, as if you were shifting money between tures, and milestones. Ultimately, how- the art team decided to work two week- investments. Audit how people are ever, a development schedule is only ends in a row to make up the time. The spending their chaos. Work together to an estimate of how and when work will art team devised its own solution, exer- manage chaos as if it were money. be done. A pro forma schedule (such as cised its autonomy, and simultaneous- Consider an extreme example (but those usually created in Microsoft ly increased the entire team’s cachet of not necessarily an uncommon one): Project) is useful only because it initi- credibility. The more credible your http://www.gdmag.com JANUARY 1998 GAME DEVELOPER PROJECT MANAGEMENT

team is, the more autonomous it will with everyone on the team also allows Set a deadline, broadcast it to your become. me to coordinate the team. When you team, and then focus the entire team on Work with your development team are managing chaos, this is perhaps the integrating all completed work. Take first to find solutions to problems, and most important task to perform. If you your art and process it with your tools. try to solve your problems without ask- don’t communicate and coordinate, Take the data from that step and drop it ing for additional resources (money, you won’t be able to measure just how into your graphics engine. Attach AI to people, time). However, if you do need chaotic your project really is. As the the characters in the game and enable help, by all means ask for it. Asking for project leader, you have to simultane- the user interface. Take the output from assistance doesn’t discredit your team ously envision the “big picture” and your level editor and drop that into — in fact a team that asks for help scrutinize the finest level of detail. Do your engine, too. Start the game and see when it needs it actually reinforces its you remember my critical items for PEZ what happens. Some things will work, credibility. development? That’s my big picture. others won’t. Look at the game closely. If you’ve established a collaborative, The lists that the leads created are their Audit your team’s progress. Has the independent environment, your team big pictures, yet provide me with game improved since the last incremen- should be able to disagree, debate, and another level of detail. By talking to tal build? Why? Why not? Did the team reach consensus on its own. I encour- everyone on the team, I assemble both make the right design decisions? Is any- age you to foster debates to find the a panoramic and microscopic view of thing missing? What adjustments need best possible solutions. Let your soft- the project. And that’s how I manage to be made? In staff? In assignments? In ware developers argue about imple- chaos in my projects — I always know priorities? Is the project too chaotic? 54 mentations — you’ll get better results where to invest or Incremental builds are excellent indica- if each developer has to present and divest chaos. tors of how your project is proceeding. defend his or her design. If your team Incremental builds as are like mile cannot agree on an issue, it’s extreme- markers along a highway — each incre- ly important for you to settle your dif- mental build gives you an indication of ferences within the team. If neces- your project’s speed and location. sary, study There are no rules for game develop- the facts, ment, no physical laws to obey. The gather excitement and challenge of game opinions, development is to solve novel, hard, and then insert yourself as an and critical problems with limited time, arbitrator. In the worst case, and money, and people. At the start of your if all else fails, make the final deci- project, identify what is crucial to your sion. Settle the conflict and rally the success. If you remain true to your orig- team to support the decision. REVIEW. Ultimately, your job as the pro- inal intentions and manage with your COMMUNICATE. As the project leader, it’s ject leader is to control chaos and end-result in mind, how you ultimately your responsibility to defend your ensure that the goals of the project are accomplish your goals is arbitrary. development team’s priorities, opin- being accomplished. You need to Manage time, people, and tasks with ions, and decisions. And to best repre- spend a good deal of time collecting your goals in mind. Otherwise, let sent your team, you must be intimately information, and once you have it, you chaos reign. ■ familiar with every aspect of the pro- need to analyze it and react. Review ject. Personal contact and interaction and answer these questions every day: F U R T H E R R E A D I N G with every member of your team is the What worked today? How can that be most valuable technique for gathering leveraged? What didn’t work? How can I highly recommend the following and disseminating information. we better solve or prevent the problem books if you are interested in improving Without information, no team mem- in the future? Is each team member your ability to create and manage a ber, including you, can make effective focused on his or her critical list? Did chaotic environment. and appropriate decisions. Make sure the parameters of the project change? Maguire, Steve. Debugging the Development to communicate regularly with every Process. Redmond, WA: Microsoft Press, team member. 1994. For example, I prefer short, one-on- Reining in Chaos one ad hoc discussions instead of large McCarthy, Jim. Dynamics of Software meetings. I use these quick, frequent egular communication with every- Development. Redmond, WA: Microsoft Press, 1995. meetings to ask and answer questions, R one on your team provides you gauge status, offer advice, change prior- with qualitative results — information Peters, Tom. The Tom Peters Seminar: Crazy ities, and assess risk. Talking to every- such as status, plans, design decisions, Times Call for Crazy Organizations. New one on the team is time consuming, and risks. To get quantitative results, you York, NY: Vintage Books, 1994. but it’s extremely easy to do. For me, have to analyze your progress against its it’s one of the most satisfying parts of stated goals. The best way to rein in Yourdon, Edward. Rise and Resurrection of my job. I socialize, learn, discuss, and chaos and yield an accurate appraisal of the American Programmer. Upper Saddle teach every day. your progress is to try to build a run- River, NJ: Prentice Hall, 1996. COORDINATE. Regular communication ning, playable version of your game.

GAME DEVELOPER JANUARY 1998 http://www.gdmag.com POSTMORTEM STAR WARS: SHADOWS OF THE EMPIRE by Mark Haigh-Hutchinson

hadows of the Empire is an action

game originally developed for the

56 64 . It

formed part of a multimedia Star

Wars event consisting of a novel,

soundtrack, toy line, comic books, SStrading cards, and other related merchan- dising. The Nintendo 64 version was

released in December of 1996, and has

proven to be very popular with over one

million copies shipped to date. The IBM

PC version was released in early September

of 1997, and has enhanced cut scenes, Red

Book audio (both music and voice), and

high-resolution graphics. It requires the Dinner in Kyoto, Japan, August 1996. (Left to right: Don James, Hiro Yamada, Mark Haigh-Hutchinson, , Kenji Miki.) use of a 3D accelerator card.

GAME DEVELOPER JANUARY 1997 http://www.gdmag.com Images courtesy of LucasArts Entertainment Company LLC, © 1997. 24-bit graphics. Eventually, we would have to change our programmers’ com- puters to INDYs (still powerful machines) to install the Nintendo 64 development systems. In addition, we were fortunate that LucasArts allowed us to obtain a Silicon Graphics ONYX supercomputer. This impressive and somewhat expensive refrigerator-sized computer boasted Reality Engine 2 graphics hardware, four the INDY. This later became known as Why Shadows? R4000 CPUs, and 256MB of RAM. It the Revision 1 board, but on inspection became an essential part of our develop- it was extremely “clean” — no wire ack in the summer of 1994, ment equipment, as it was the only wraps or other temporary items in B LucasArts was exploring the pos- hardware available that could possibly sight. Within three days, technical lead sibility of developing a new 3D title for emulate how the final Nintendo 64 Eric Johnston and second programmer one of the emerging “next-generation” hardware would perform. Indeed, Mark Blattel had ported the game to platforms. After some discussion, the Nintendo and SGI supplied us with soft- the actual hardware. It was an awe- Nintendo 64 was decided upon as the ware that emulated most of the features inspiring moment when we first saw platform of choice, even though there that the real hardware would support. the Battle of Hoth running on the 57 was no hardware available at the time. In late September, the programmers “real” machine. The first revision of Due to our close relationship with took a trip down to Silicon Graphics to the hardware was very close to the orig- Lucasfilm, we were aware that discuss the Nintendo 64 hardware inal specifications supplied by SGI. Lucasfilm Licensing was planning the design with its chief architect, Tim Van Other than the RCP (Reality Shadows of the Empire event. Jon Hook. The SGI engineers were rightly CoProcessor) not running at quite the Knoles, the lead artist and designer on proud of their design, and promised final speed, and one of the special the Nintendo 64 game, took an active that they would deliver hardware video “dither modes” not being avail- part in deciding the timeline of matching the ambitious specifications. able, it performed extremely well. Shadows. He suggested that it take Nine months later, we learned that they Over the next few weeks, we would place between The Empire Strikes Back had indeed met those specifications. receive an additional two boards, so and Return of the Jedi. By Christmas of 1994, we had the that all the programmers were devel- The Shadows story line deals mainly basis of the first level of the game, The oping in a similar fashion. Three with the criminal underworld of the Battle of Hoth, running quite nicely on months later, we would receive Galaxy, and the new period allowed us the ONYX — “quite nicely” being in Revision 2 boards, which brought the to explore some of the things that high resolution (1280×1024), 32-bit RCP up to full speed as well as fixing a weren’t explained in Return of the Jedi. color, and at 60 frames a second. By this few minor bugs. Another pleasant sur- It also opened up some new characters point, we had also received a very early prise was the doubling of the amount that were not bound to the original prototype of the Nintendo 64 con- of RAM to 4MB. story, which gave us more creative free- troller. This consisted of a modified A further development was the hard- dom than using established figures. A Super Nintendo controller with a primi- ware “dither modes” that perform sev- bonus was that it allowed us to make tive analogue joystick and Z trigger. Due eral different kinds of functions at the use of everyone’s favorite bounty to our strict nondisclosure agreement, video back end — mostly to reduce the hunter, Boba Fett. we were unable to discuss the hardware effect of Mach banding, which is com- Since we were developing one of the or the project with anyone outside the mon when using 16-bit color. premier titles for an entirely new game core team. Consequently, we would machine, there was a conscious deci- furtively hide the prototype controller sion to attempt to stretch out and cover in a cardboard box while we used it. In Technology a number of different game-play styles. answer to the inevitable questions about We wanted to ensure that the player what we were doing, we replied jokingly ince Eric Johnston and Mark would have as much variety as possible, that it was a new type of controller — a S Blattel had extensive experience yet still enjoy a satisfying experience. bowl of liquid that absorbed your with the SGI platform, we undertook to thoughts through your fingertips. Of prototype the game using the course, you had to think in Japanese…. Performer 3D API. This is an OpenGL- A Reality Engine for $200? In July of 1995, we received our first based system that is very flexible. actual hardware as a plug-in board for Eventually, we would write our own y early September 1994, we had B received our Silicon Graphics Mark Haigh-Hutchinson is a Project Leader and Senior Programmer at LucasArts workstations and the core team was Entertainment Company. He has been developing computer and video games as a working. Initially the three program- hobby since 1979, and professionally since 1984. Cutting his teeth on numerous 8-bit mers were using Indigo 2 Extremes, computers such as the Sinclair ZX Spectrum, he has contributed to 32 published with 200mhz CPUs, 64MB of RAM, and games, 16 as sole programmer. He may be reached at [email protected].

http://www.gdmag.com JANUARY 1997 GAME DEVELOPER POSTMORTEM

(effectively as RGBA values) However, the first problem that we caused the scene to appear came across was hardware incompati- as purely pastel colors. bilities between the MIDI keyboards used by our musicians and the Silicon Graphics computers used to develop Motion Capture the game. The theory was that the compositions could be previewed n the spring of 1995, we directly on the Nintendo 64 hardware Idecided to experiment as a musician played them on a key- with the use of motion cap- board. Naturally, this would provide ture to control the anima- the best possible feedback to the musi- tions of the main character cian. Unfortunately, for some Jon Knoles directs actor Amos Glick who recoils as well as enemies such as unknown reason(s), note on/off pairs from an imaginary shot. Mark Haigh-Hutchinson Stormtroopers. Fortunately were lost, causing chords to sound as wrangles the cables and provides a supporting for us, our sister company, one note. Additionally, note releases hand. Industrial Light & Magic were sometimes missed completely. (ILM), had a capture system Before long, other unwelcome behav- subset of Performer’s functionality on available for use. It was a tethered sys- iors surfaced. We worked around these the Nintendo 64. This allowed us to tem, using a magnetic field to deter- mysteries by having the musicians cap- 58 move the game from a $140,000 SGI mine the position of each of the sen- ture the sample set and play it solely ONYX to a $200 Nintendo 64 in a mat- sors. The sensors were attached to the on their keyboards. ter of just three days. actor at 11 locations using a combina- After some experimentation, though, Level designers used the tool set from tion of a climbing harness, sports joint we felt that the MIDI music was good, DARK FORCES to construct the first-per- supports, bandages, and Velcro strips. but didn’t capture the essence of the son levels for the game. This allowed a The nature of the system presented John Williams orchestral soundtrack crude form of preview using the actual several problems. First, the actor had to that is so closely associated with Star DARK FORCES engine on an IBM PC. This perform on a raised wooden platform, Wars. Furthermore, each additional worked fairly well, although later in the since the metal construction supports instrument channel would require more project we were able to have a single in the concrete floor would affect the CPU time than we wanted to allocate. SGI for dedicated use by the level capture system. Secondly, since the At this point, we tried an experiment designers. The PC solution, however, actor was on a platform as well as teth- using uncompressed digital samples of was also useful because the level design- ered, we couldn’t obtain a “clean” run the Star Wars main theme. The quality ers were already familiar with the cycle. Some of our more ambitious was extremely good, even after subse- processes involved. Unfortunately, motions also proved problematic. On quent compression with the ADPCM since the game engine wasn’t running the positive side, once the system was encoder provided by Nintendo. After a on the PC at that point, the develop- calibrated, we were able to capture over little persuasion, Nintendo generously ment cycle was somewhat slow. 100 motions in a single day, each with agreed to increase the amount of car- Additionally, the ONYX calculated two or three different “takes.” We tridge space from 8MB to 12MB. This the preculling visibility tree for each of viewed the motions in real time on a allowed us to include approximately 15 these levels. The way it works is quite SGI Indigo 2 Extreme computer run- minutes of 16-bit, 11khz, mono music elegant, thanks to Eric and Mark. The ning Alias PowerAnimator. This that sounded surprisingly good. world is subdivided into “sectors” — allowed us to quickly ensure that every Considering that most users would lis- that is, polygonal regions defined by capture was “clean” before continuing ten to the music through their televi- either geometry or some other criteria. with the next action. sions (rather than a sophisticated audio These sectors control collision detec- Unfortunately, we were to discover system), the results were close to that tion, have properties relating to game that after analysis, the motion data of an audio CD, thereby justifying the play, and perform several other related proved to be unusable. This was mainly extra cartridge space required. functions. The visibility program tra- because the angle information for the verses the world rendering the scene joints wasn’t consistent on its represen- from the center of every sector in a 360- tation of the direction around each Art Path degree arc as well as three elevations. axis. Consequently, all the animation For every polygon to be rendered in the for the characters was redone by hand, continuing problem throughout scene from a particular sector, an identi- a somewhat time-consuming task. A the development of SHADOWS was fying 32-bit value, rather than texture the inability to import and export data information, fills the appropriate pixels between the various 3D packages we in the frame buffer. It’s then a simple MIDI Music were using. Eventually, we managed to matter of reading the frame buffer to circumvent these problems with a determine which sectors are visible from ur initial approach to music for number of translation utilities as well that location. This process became O the game was similar to that as by using Alias Power Animator as known as “pastelization” because the taken on some of our PC titles — our central “hub” format. However, identifiers written into the frame buffer namely, a MIDI-based solution. there were still issues with scale, model

GAME DEVELOPER JANUARY 1997 http://www.gdmag.com hierarchies, and animation data. It was also meant an almost Herculean pro- core game players. A variety of game sometimes difficult for the artists to see gramming task in trying to write and play was important for a game that, for what their artwork really looked like debug what amounted to five different many players, would be one of their first until it had been through the hands of game engines. These consisted of low experiences in a fully 3D environment. our polygon wrangler (thanks Tom!). flight over terrain, gunnery action in Initially, it was difficult for our texture space, first/third person on foot or with artist to visualize the restrictions on jet pack (including a moving train Hardware Performance texture size required by the hardware, sequence), high-speed chases on a as well as color reduction issues. speeder bike, and full 360-degree space s mentioned before, for the first flight. Nonetheless, the result was that A nine months of SHADOWS, we had most players’ experiences with the game no real hardware with which to gauge New Hardware were always interesting, at the expense the performance of the game — other of displeasing some of the more hard- than a rather nice Silicon Graphics here were a number of other issues T that we had to deal with in devel- oping the game, not the least of which was that for the first nine months of The Core Team the project, we didn’t have any real The core team developing SHADOWS from inception to completion consisted of hardware on which to run the game. mainly six people, although twenty people contributed to the game for varying This deficiency wasn’t insurmountable lengths of time, and to varying degrees. Nonetheless, everyone played a vital role 59 by any means, but it restricted our in the production of the game. choices in certain ways, especially in Game Designer/Lead Artist - Jon Knoles 3D/Background Artist - Bill Stoneham level design. We were forced to make Project Leader/Senior Programmer - Storyboard Artist - Paul Topolos some assumptions, especially regarding Mark Haigh-Hutchinson Music Editor - Peter McConnell to performance. Fortunately, this was- Technical Lead - Eric Johnston Sound Designers - Larry the O and Clint n’t quite the bugbear that we anticipat- Programmer/Lycanthrope - Mark Blattel Bajakian ed. Still, as is well known, those on the Polygon Wrangler - Tom Harper Lead Tester - Darren Johnson. bleeding edge of technology are often Level Designer - Jim Current Production Manager - Brett Tosti sacrificed upon it. Level Designers - Matthew Tateishi and Extra thanks go to Don James, Henry Ingar Shu Sterchi, Hiro Yamada, Kensuke Tanabe, 3D Artists - Paul Zinnes, Andrew and Shigeru Miyamoto. Special thanks Other Issues Holdun, and Garry M. Gaber as always go to the staff at LucasArts, 3D Animator - Eric Ingerson and particularly to George Lucas for his here was considerable pressure to Texture Artist - Chris Hockabout gift of the Star Wars universe. T finish the game in time for the Christmas 1996 deadline. This reality meant many, many late nights, with some team members regularly working over 100 hours every week for the best part of a year. Hopefully, this sort of workload can be avoided in future pro- jects. Time pressure is, of course, a com- mon thing in the computer games industry — and we were certainly no strangers to the phenomenon. However, since we had to release our game shortly after launch of the machine, we were under more pressure than might usually have been encountered. Game testing also became an issue because there were very few machines with which to actu- ally test the game.

Game Play Variety Back Row (left to right): Steve Dauterman, Peter McConnell, Jon Knoles, Andrew Holdun, Paul Topolos, Mr. B. Fett; Middle Row (left to right): Jim e were able to include a very Current, Matthew Tateishi, Bill Stoneham, Brett Tosti, Ingar Shu, Tom Harper, W wide variety of game play styles Chris Hockabout; Front Row (left to right): Garry Gaber, Mark Blattel, Eric in SHADOWS. In retrospect, this meant Johnston, Mark Haigh-Hutchinson; Not shown: Paul Zinnes, Larry the O, Clint that we couldn’t tune each type of game Bajakian, Eric Ingerson, and Darren Johnson. play as much as we would have liked. It http://www.gdmag.com JANUARY 1997 GAME DEVELOPER POSTMORTEM

vary considerably depending upon scene complexity, as well as the simple fact that we didn’t have any real hardware from which to measure performance characteristics. Essentially, the program keeps track of the absolute time between each update of the game. This value, which we called delta time, became a multiplicand for any movement or other time-based quantity. By this method, the game runs independent of the video ONYX. Nonetheless, when we finally refresh rate, with all objects moving and we had to compress everything in the received the real hardware, we were responding at the correct frequency. game to fit it into the cartridge space pleased to find that the performance The other issue had to do with the available. This included the thin operat- estimates given to us by SGI proved to “letterbox” effect that is common to ing system that SGI provides as part of be very accurate. In fact, in large part many NTSC to PAL conversions. In most the development system. Therefore, due to the parallel nature of the graph- cases, there is no extra rendering or upon machine reset, it’s necessary to ics hardware, we were able to use float- increase in the vertical frame buffer size, decompress this OS to run the game. To ing-point mathematics throughout leaving unsightly black bands above and perform this decompression, we wrote a 60 SHADOWS with no significant impact below the visible game area. Since the small bootstrap program, which intro- upon performance. vertical resolution is now greater than duced a small amount of time between Additionally, SHADOWS was pro- the original NTSC display, the aspect the hardware being initialized and the grammed entirely using the C language ratio will also change, causing the graph- OS starting. This lag introduced a one- — it wasn’t necessary for us to use ics to appear stretched horizontally. time glitch on the screen as the video assembler (a first as far as I was con- While I wasn’t willing to accept this, I hardware started. Not very noticeable, cerned, and a pleasant surprise even had presumed that I couldn’t afford the except to me. After many late nights, I though I’m a long-time hardcore extra CPU time necessary to render a discovered a way to remove the glitch assembler fan). Since our scene com- larger frame buffer, even with the extra by directly accessing the Nintendo 64 plexity was relatively high (usually time available due to the 50hz video video hardware registers. kept to around 3,000 polygons or so, refresh rate. There was also a question of but variable according to the level type the additional RAM usage required by and design), the graphics task took our triple buffering of the frame buffer. Bad Idea longer to execute than the program My first attempt, therefore, was simply code (that is, we were graphics-bound). to change both the field of view and e then discovered that because Consequently, optimizations to the aspect ratios of the 3D engine. This sim- W we had accessed the hardware program code didn’t significantly ple fix solved the “stretching” problem directly, it caused an infrequent bug. improve overall performance. quite nicely, although the display Rarely (1 out of 50 times) the Nintendo remained letter-boxed, of course. 64 would crash if the reset button were Unfortunately, it also meant that any pressed at a particular point in the NTSC to PAL Conversion 2D-overlay status information remained game. Not only that, I couldn’t repeat “stretched.” There was the potential that the bug on my hardware (I hate it fter completing the American and game play could be affected because the when that happens). A Japanese versions of the game, it field of view, by definition, would affect After a number of very late nights was my task to convert the game so that the player’s perception of the 3D world. (over the Christmas holiday), with the it could run on the European PAL televi- Again, this just wasn’t good enough. help of Nintendo of America’s techni- sion standard. Being British, I had a vest- What I needed was a solution that did- cal staff (thanks Mark and Jim), we ed interest in making sure that the con- n’t require extra rendering, yet would finally resolved the problem: first, by version was a good one. This meant two fix the aspect ratio problems. After a lit- removing the code that directly things: first, that the game used the tle bit of research, I realized that I had accessed the video registers, and sec- whole of the vertical resolution of the discovered earlier that it was possible to ond, by restoring the registers control- PAL display (625 lines vs. 525 lines of change the size of the final visible dis- ling the scaling of the output in the NTSC); second, I wanted to ensure that play area on the output stage of the dis- vertical axis upon reset. Sometimes, the the speed of the PAL game was the same play hardware. In reality, it’s possible to simplest solution is the best. as the NTSC one, even though the PAL shrink or enlarge the display both hori- refresh rate is 50hz rather than 60hz. zontally and vertically. To compensate Fortunately, when we started work on for the letterboxing, all I had to do was Support from SGI and Nintendo SHADOWS, we realized that one of the change the vertical display size by a fac- most important things to consider was tor of 625/525 or 1.19. Once I did this, I e were very lucky to receive that it had to be a time-based game, immediately had a full-screen PAL ver- W excellent support from both SGI rather than a frame-based one. This sion. Or so I thought…. and Nintendo during the production of would allow for update rates that could One of things about SHADOWS is that the game. The SGI engineers (thanks in

GAME DEVELOPER JANUARY 1997 http://www.gdmag.com particular to “Acorn”) were very helpful a major problem (that continued n’t have to build all new tools, and would normally have an answer to throughout the duration of the pro- although a large number of data our questions within a day, sometimes ject) was the inability of various 3D conversion utilities were necessary. within the hour. I would like to thank packages to import and export data. In addition, by reusing familiar Nintendo for their assistance in the pro- Although we were able, for the most tools, our level designers could be duction of the game. Nintendo of part, to write our own conversion more productive earlier in the pro- America’s technical support and QA utilities, it still proved to be a stum- ject than otherwise might have been departments also proved invaluable. In bling block and prevented us from expected. addition, three of Nintendo of Japan’s having an efficient art path. 3) Our decision to use digitized music staff spent some time working directly Fortunately, the companies supply- proved to be a crucial one. Because with us at our offices. ing these tools now recognize the most users would listen to the music I was also fortunate enough to visit need for importing and exporting through their televisions, the quality Nintendo’s head quarters in Kyoto, data to other packages, and are tak- approximated that of an audio CD as Japan, to discuss SHADOWS with Shigeru ing steps to remedy the situation — far as many customers were con- Miyamoto, creator of MARIO 64. His VRML, for example, is proving to be cerned. This alone justified the extra insights were both fascinating and a useful format. cartridge space required and sur- extremely relevant. He is simply a 4) Time was the biggest enemy of all in prised many players who didn’t genius with an instinctive understand- producing the game. This is nothing expect that level of quality from a ing of video games. new, but was exacerbated by the fact cartridge game. that we were working on a non-exis- 4) The conversion of the game for the 61 tent machine for nine months. PAL television standard went Of Wampas and Men Nonetheless, even though this was, extremely well and was much appre- for the most part, out of our control, ciated by customers in those coun- hen developing a project on we were still able to produce a quali- tries. It would be fair to say that W the scale of SHADOWS, there will ty game. SHADOWS has set the standard in that always be some things that didn’t 5) With hindsight, probably the most it runs both full screen and full progress as smoothly as they could important lesson to be learned from speed. There is no reason why all have… the game’s development is that of games from this point on shouldn’t 1) The motion capture process proved focus. Do one or two things and do run just as well on PAL systems as to be a red herring for us. While them extremely well. Although our they do on NTSC. originally promising a much more ambitions were well placed in trying 5) Given that we were working on realistic animation solution, in our to provide the player with as much completely new hardware and for case the data proved unusable. variety as possible, we effectively the most part had to discover every- However, I still believe that it has had to write five different game thing that we needed to know by great potential and deserves further engines. Additionally, we could have ourselves, the support from both SGI investigation, even though we didn’t also used a fourth programmer dedi- and Nintendo was invaluable to us get to the point of dealing with the cated to all aspects of the front-end throughout the project. potential problems matching the of the game; that is, level selection, motions to the character’s environ- controller options, and so forth. This ment and so forth. Caveat emptor. would have taken some of the pres- Varying Shadows 2) Attempting to use a MIDI-based sure away from the main program- music solution also proved incorrect mers towards the end of the project. ven though we were not able to for this game. While it promised to E spend as much time as we would be an efficient solution in terms of have liked tuning the game, SHADOWS memory (an important considera- Out of the Shadows… does succeed in supplying the player tion for a cartridge-based game), it with a variety of game-play styles. Its simply wasn’t suitable for an orches- hanks to the talent, dedication, popularity is a testament to the creativ- tral soundtrack such as Star Wars. T and experience of the SHADOWS ity and talent of the team of which I 3) When we started work on SHADOWS, team, many things went well during was fortunate enough to be a part. ■ the development process. 1) By using the powerful SGI comput- ers (fairly uncommon in the games industry in 1994) to prototype, com- bined with our programmers’ knowl- edge of 3D technology, we were able to develop the game rapidly, yet remain flexible in terms of perfor- mance requirements. 2) Our ability to reuse tools from our earlier DARK FORCES title saved us time and resources because we did-

GAME DEVELOPER JANUARY 1997 http://www.gdmag.com SOAPBOX by Ron Fosner

Why I Don’t Hate Direct3D

t was with some amusement that I read Chris because they were scared of Microsoft (and they needed to hedge their bets in Hecker’s “An Open Letter to Microsoft” in the case Direct3D took off), and they sup- ported OpenGL because GLQUAKE April/May 1997 issue of Game Developer. I design proved that OpenGL was a viable gam- ing API (and they needed to hedge 3D graphics software for a living, and frankly, my their bets in case Direct3D flopped). I The result of all this is that it suddenly experiences with DirectX in general differently. The 3D graphics industry appears that you really will be able to 64 and Direct3D Immediate Mode in par- in general, and game developers in par- program for either OpenGL or ticular have been less than favorable. ticular, were shouting loudly. Very Direct3D, whichever API you like — When Direct3D made its initial appear- loudly. All was in a glorious state of although because Microsoft has cut ance, my first thought was something turmoil. Now, is this really a bad IHVs off at the knees by dropping MCD akin to, “What planet are these guys thing? driver support for Windows 95, a lot of from?” I’ve been programming Stop and think for a minute. If you the video card makers are scrambling OpenGL on PCs since it first debuted went to the Computer Game around trying to pick up the pieces. on Windows NT 3.5, so I didn’t under- Developers’ Conference or SIGGRAPH “Yeah,” you might be saying, stand why Microsoft would feel the or E3 or Win-HEC last year, you “there’s been a lot of frenetic activity need to provide another 3D API. I like couldn’t help but notice all the video in the past year or so.” And you’d prob- OpenGL, I wrote a book on program- card makers demoing both OpenGL ably agree with me that Microsoft insti- ming OpenGL, and I’m happy with it. and Direct3D software. They were gated the whole thing by bringing out It’s easy to understand, robust, and falling over themselves to show you a premature implementation of there’s plenty of other folks to ask this stuff. They supported Direct3D Continued on page 63. questions of, plenty of good books on it, and plenty of pro- gramming examples. Direct3D has none of that. Microsoft never did provide anything resembling a programming guide, the exam- ples required an Ouija board to understand, and they kept changing the damn interface. All valid reasons to hate it, all acknowledged by Microsoft. But after I read Chris’s article I reflected back upon what a tem- pest in a teapot it all was. The OpenGL programmers derided

Direct3D. Let’s face it, the first Illustration by Rick Eberly. release of Direct3D was abysmal. The game programmers who started (or were stuck) with Direct3D managed to get some reasonable results in spite of Direct3D’s shortcomings, and they, in turn, taunted the OpenGL folks about lack of dri- Contrary to what you may think, Ron isn't a Microsoft employee. He's the author of OpenGL ver support. Hardware vendors Programming for Windows 95 and Windows NT published by Addison-Wesley, so his were annoyed because Microsoft heart is in the right place. Ron is the chief mechanic at Data Visualization, an OpenGL and was telling them one thing, DirectX custom software/driver house. You can reach him at ron@.com. while John Carmack was proving

GAME DEVELOPER JNAUARY 1998 http://www.gdmag.com tion of letting up the pace. If the cost of getting 3D accelerators They recently gutted their on PCs everywhere by 1999 is that I OpenGL graphics group have to live with Direct3D, then I can and merged them into the live with it. While I personally feel that DirectX group (a shotgun Microsoft was stupid to bring out wedding, no doubt). What Direct3D while they had OpenGL, if this means is that they’re going to support both of them, Direct3D is going to con- then I can live with having two APIs to tinue to get better, putting choose from. I’m not too happy with more pressure on the the active lack of support for OpenGL OpenGL side of things to that Microsoft has demonstrated in the increase the pace as well. last few months. I think that this is a Continued from page 64. So while I agree that last mistake that will do them more harm Direct3D and touting it as being “The year, Chris raised some excellent than they estimate. only 3D gaming API you’ll ever need.” points in his article in the OpenGL vs. OpenGL on PCs has too much indus- So ask yourself what effect this had on Direct3D debate, I take the stance that try support to get killed from lack of the 3D community. It started the API while Microsoft did a bad thing with attention by Microsoft. Time will tell. wars — an endless stream of vitriolic Direct3D, it did provide a rude wake- Meanwhile, I’m just going to bask in Usenet postings, a flurry of examples up call of the 3D community. Two the radiant glow of 3D, giggle when I and counter examples. It stirred up years ago, most game programmers get a new 3D board to test, play some 63 every video card maker and even a few didn’t have a clue what a BSP tree was, 3D games and admire those nice multi- PC makers. Hell, I don’t know about what the “A” in RGBA stood for, or pass rendering tricks, write some code you, but I had a great time! how a Z-buffer worked. that does some effects from Chris Since Microsoft made that big boast Now I see video card makers pon- Hecker’s physics articles, and sleep and then tried for two years to deliver dering trilinear and anisotropic tex- soundly at night knowing that next on it, there has been a veritable renais- ture filters, while Microsoft and year, even better 3D features will be sance of activity in 3D graphics. I used Hewlett-Packard are introducing APIs around for me to take advantage of. If I to worry that the adoption of 3D with automatic level-of-detail geome- have to blame Direct3D for causing would be slow, that to write a great 3D try functionality. These are features most of this, then so be it. ■ game would require, unreasonably, that I previously saw only that the user have a 3D graphics accel- in ultra–high-end sys- erator. Hah! That’s one worry that I can tems, that I never would put to rest. This Christmas, practically have thought would make every PC made came with a 3D acceler- it to the PC before the ator. There were an estimated 40 mil- next century. While I still lion 3D accelerator chips sold in 1997. have no love for That’s a heck of a target market. Just as Direct3D, I admire you no longer have to special order a Microsoft for listening CD-ROM or a fast Windows video card (somewhat) to the criti- when you get a PC, 3D chips are replac- cisms of Direct3D and ing the 2D-only systems. addressing them. Now, why has this happened? Well, I think it’s safe to “blame” Microsoft again. If they hadn’t stirred things up as they did, and if the normally sedate Editor-at-Large Chris Hecker Responds: 3D graphics community hadn’t reacted so strongly, then we might still be hile I agree with slowed down adoption of 3D hardware, looking toward a slow adoption of 3D Ron's point that the while early standardization on OpenGL as a standard feature. Direct3D certain- past year has been would not have had this problem ly has lit a fire under the normally W fun in the roller- (although I do agree the ARB moves sedentary OpenGL ARB. The frenetic coaster sense of the word, I disagree much faster these days). However, hind- pace at which Microsoft is revving the that Microsoft and Direct3D can take sight is a wonderful thing. For now — Direct3D API is forcing OpenGL to credit for the quick adoption of 3D hard- and looking towards the future — I only move at a faster pace. This is good — it ware. The truth is, it's simply time for hope Ron is correct when he says, "You used to be that OpenGL was the feature 3D on the PC, and IHVs were already really will be able to program for either leader. Now, with DirectX 5, we have well on their way to making it common- OpenGL or Direct3D." I'm not so confi- hardware-optimized texture support (in place by the time Direct3D was even dent, and I think it will take eternal vigi- the form of optimized surfaces). That’s conceived, let alone shipping. I believe lance from game developers to ensure a feature that’s scheduled for the a coherent argument can be made that we have a viable choice of 3D APIs from release of OpenGL 1.2 sometime later Direct3D's machinations have actually here on out. this year. And Microsoft has no inten- http://www.gdmag.com JANUARY 1998 GAME DEVELOPER