When I got my first game console in 1979—a way-cool Intellivision system by Mattel—the term “game engine” did not exist. Back then, video and arcade games were considered by most adults to be nothing more than toys, and the software that made them tick was highly specialized to both the game in question and the hardware on which it ran. Today, games are a multi-billion-dollar mainstream industry rivaling Hollywood in size and popularity. And the software that drives these now-ubiquitous three-dimensional worlds—game engines like Epic Games’ Unreal Engine 4, Valve’s Source engine and, Crytek’s CRYENGINE® 3, Electronic Arts DICE’s Frostbite™ engine, and the Unity game engine—have become fully featured reusable software development kits that can be licensed and used to build almost any game imaginable.
1979 年,当我得到第一台游戏机(Mattel 推出的一款非常酷的 Intellivision 系统)时,“游戏引擎”这个术语还不存在。当时,视频和街机游戏被大多数成年人认为只不过是玩具,而让它们发挥作用的软件对于相关游戏及其运行的硬件来说都是高度专业化的。如今,游戏已成为价值数十亿美元的主流产业,其规模和受欢迎程度可与好莱坞相媲美。驱动这些现在无处不在的三维世界的软件——游戏引擎,如 Epic Games 的 Unreal Engine 4、Valve 的 Source 引擎和 Crytek 的 CRYENGINE® 3、Electronic Arts DICE 的 Frostbite™ 引擎和 Unity 游戏引擎——已经完全成为现实。特色可重复使用的软件开发工具包,可以授权并用于构建几乎任何可以想象到的游戏。
While game engines vary widely in the details of their architecture and implementation, recognizable coarse-grained patterns have emerged across both publicly licensed game engines and their proprietary in-house counterparts. Virtually all game engines contain a familiar set of core components, including the rendering engine, the collision and physics engine, the animation system, the audio system, the game world object model, the artificial intelligence system and so on. Within each of these components, a relatively small number of semi-standard design alternatives are also beginning to emerge.
虽然游戏引擎在架构和实现的细节上差异很大,但在公共许可的游戏引擎和专有的内部引擎中都出现了可识别的粗粒度模式。几乎所有的游戏引擎都包含一组熟悉的核心组件,包括渲染引擎、碰撞和物理引擎、动画系统、音频系统、游戏世界对象模型、人工智能系统等。在每个组件中,相对少量的半标准设计替代方案也开始出现。
There are a great many books that cover individual game engine subsystems, such as three-dimensional graphics, in exhaustive detail. Other books cobble together valuable tips and tricks across a wide variety of game technology areas. However, I have been unable to find a book that provides its reader with a reasonably complete picture of the entire gamut of components that make up a modern game engine. The goal of this book, then, is to take the reader on a guided hands-on tour of the vast and complex landscape of game engine architecture.
有很多书籍详细介绍了各个游戏引擎子系统,例如三维图形。其他书籍汇集了各种游戏技术领域的宝贵提示和技巧。然而,我一直无法找到一本书为读者提供构成现代游戏引擎的整个组件的相当完整的图片。因此,本书的目标是带领读者亲身体验游戏引擎架构的广阔而复杂的景观。
In this book you will learn:
在本书中你将学到:
We’ll also get a first-hand glimpse into the inner workings of some popular game engines, such as Quake, Unreal and Unity, and some well-known middleware packages, such as the Havok Physics library, the OGRE rendering engine and Rad Game Tools’ Granny 3D animation and geometry management toolkit. And we’ll explore a number of proprietary game engines that I’ve had the pleasure to work with, including the engine Naughty Dog developed for its Uncharted and The Last of Us game series.
我们还将第一手了解一些流行游戏引擎的内部工作原理,例如 Quake、Unreal 和 Unity,以及一些著名的中间件包,例如 Havok 物理库、OGRE 渲染引擎和 Rad Game Tools 的 Granny 3D 动画和几何管理工具包。我们将探索一些我有幸使用过的专有游戏引擎,包括 Naughty Dog 为其《神秘海域》和《最后生还者》游戏系列开发的引擎。
Before we get started, we’ll review some techniques and tools for large-scale software engineering in a game engine context, including:
在开始之前,我们将回顾一些在游戏引擎环境中进行大规模软件工程的技术和工具,包括:
In this book I assume that you have a solid understanding of C++ (the language of choice among most modern game developers) and that you understand basic software engineering principles. I also assume you have some exposure to linear algebra, three-dimensional vector and matrix math and trigonometry (although we’ll review the core concepts in Chapter 5). Ideally, you should have some prior exposure to the basic concepts of real time and event-driven programming. But never fear—I will review these topics briefly, and I’ll also point you in the right direction if you feel you need to hone your skills further before we embark.
在本书中,我假设您对 C++(大多数现代游戏开发人员选择的语言)有深入的了解,并且了解基本的软件工程原理。我还假设您对线性代数、三维向量和矩阵数学以及三角学有一定的了解(尽管我们将在第 5 章中回顾核心概念)。理想情况下,您应该事先了解实时和事件驱动编程的基本概念。但不要害怕——我将简要回顾这些主题,如果您觉得在我们开始之前需要进一步磨练您的技能,我也会为您指出正确的方向。
Before we delve into the structure of a typical game engine, let’s first take a brief look at the structure of a typical game development team. Game studios are usually composed of five basic disciplines: engineers, artists, game designers, producers and other management and support staff (marketing, legal, information technology/technical support, administrative, etc.). Each discipline can be divided into various subdisciplines. We’ll take a brief look at each below.
在深入研究典型游戏引擎的结构之前,我们首先简单了解一下典型游戏开发团队的结构。游戏工作室通常由五个基本学科组成:工程师、美术师、游戏设计师、制作人和其他管理和支持人员(营销、法律、信息技术/技术支持、行政等)。每个学科又可以分为不同的子学科。我们将在下面简要介绍每一项。
The engineers design and implement the software that makes the game, and the tools, work. Engineers are often categorized into two basic groups: runtime programmers (who work on the engine and the game itself) and tools programmers (who work on the offline tools that allow the rest of the development team to work effectively). On both sides of the runtime/tools line, engineers have various specialties. Some engineers focus their careers on a single engine system, such as rendering, artificial intelligence, audio or collision and physics. Some focus on gameplay programming and scripting, while others prefer to work at the systems level and not get too involved in how the game actually plays. Some engineers are generalists—jacks of all trades who can jump around and tackle whatever problems might arise during development.
工程师设计并实现使游戏和工具正常运行的软件。工程师通常分为两个基本组:运行时程序员(负责引擎和游戏本身)和工具程序员(负责离线工具,使开发团队的其他成员能够有效工作)。在运行时/工具线的两边,工程师都有不同的专业。一些工程师将他们的职业生涯集中在单一引擎系统上,例如渲染、人工智能、音频或碰撞和物理。有些人专注于游戏编程和脚本编写,而另一些人则喜欢在系统级别工作,而不过多参与游戏的实际玩法。有些工程师是多面手——各行各业的杰作,他们可以跳来跳去解决开发过程中可能出现的任何问题。
Senior engineers are sometimes asked to take on a technical leadership role. Lead engineers usually still design and write code, but they also help to manage the team’s schedule, make decisions regarding the overall technical direction of the project, and sometimes also directly manage people from a human resources perspective.
高级工程师有时会被要求承担技术领导角色。首席工程师通常仍然设计和编写代码,但他们也帮助管理团队的日程安排,就项目的整体技术方向做出决策,有时还从人力资源的角度直接管理人员。
Some companies also have one or more technical directors (TD), whose job it is to oversee one or more projects from a high level, ensuring that the teams are aware of potential technical challenges, upcoming industry developments, new technologies and so on. The highest engineering-related position at a game studio is the chief technical officer (CTO), if the studio has one. The CTO’s job is to serve as a sort of technical director for the entire studio, as well as serving a key executive role in the company.
一些公司还设有一名或多名技术总监(TD),其工作是从高层监督一个或多个项目,确保团队了解潜在的技术挑战、即将到来的行业发展、新技术等。游戏工作室中与工程相关的最高职位是首席技术官 (CTO)(如果工作室有的话)。 CTO 的工作是充当整个工作室的技术总监,并在公司中担任关键的执行角色。
As we say in the game industry, “Content is king.” The artists produce all of the visual and audio content in the game, and the quality of their work can literally make or break a game. Artists come in all sorts of flavors:
正如我们在游戏行业所说的那样,“内容为王”。美术师制作了游戏中的所有视觉和音频内容,他们的工作质量确实可以决定游戏的成败。艺术家有各种各样的风格:
As with engineers, senior artists are often called upon to be team leaders. Some game teams have one or more art directors—very senior artists who manage the look of the entire game and ensure consistency across the work of all team members.
与工程师一样,资深美术师经常被任命为团队领导者。一些游戏团队有一名或多名艺术总监 - 非常资深的艺术家,他们管理整个游戏的外观并确保所有团队成员工作的一致性。
The game designers’ job is to design the interactive portion of the player’s experience, typically known as gameplay. Different kinds of designers work at different levels of detail. Some (usually senior) game designers work at the macro level, determining the story arc, the overall sequence of chapters or levels, and the high-level goals and objectives of the player. Other designers work on individual levels or geographical areas within the virtual game world, laying out the static background geometry, determining where and when enemies will emerge, placing supplies like weapons and health packs, designing puzzle elements and so on. Still other designers operate at a highly technical level, working closely with gameplay engineers and/or writing code (often in a high-level scripting language). Some game designers are ex-engineers, who decided they wanted to play a more active role in determining how the game will play.
游戏设计师的工作是设计玩家体验的交互部分,通常称为游戏玩法。不同类型的设计师在不同的细节层次上工作。一些(通常是高级)游戏设计师在宏观层面上工作,确定故事情节、章节或关卡的总体顺序以及玩家的高级目标和目的。其他设计师则致力于虚拟游戏世界中的各个关卡或地理区域,布置静态背景几何形状,确定敌人出现的地点和时间,放置武器和医疗包等补给品,设计谜题元素等。还有一些设计师在高技术水平上运作,与游戏工程师密切合作和/或编写代码(通常使用高级脚本语言)。一些游戏设计师曾经是工程师,他们决定在决定游戏的玩法方面发挥更积极的作用。
Some game teams employ one or more writers. A game writer’s job can range from collaborating with the senior game designers to construct the story arc of the entire game, to writing individual lines of dialogue.
一些游戏团队雇用一名或多名编剧。游戏编剧的工作范围很广,从与高级游戏设计师合作构建整个游戏的故事情节,到编写单独的对话台词。
As with other disciplines, some senior designers play management roles. Many game teams have a game director, whose job it is to oversee all aspects of a game’s design, help manage schedules, and ensure that the work of individual designers is consistent across the entire product. Senior designers also sometimes evolve into producers.
与其他学科一样,一些高级设计师扮演着管理角色。许多游戏团队都有一名游戏总监,其工作是监督游戏设计的各个方面,帮助管理时间表,并确保各个设计师的工作在整个产品中保持一致。高级设计师有时也会演变成制作人。
The role of producer is defined differently by different studios. In some game companies, the producer’s job is to manage the schedule and serve as a human resources manager. In other companies, producers serve in a senior game design capacity. Still other studios ask their producers to serve as liaisons between the development team and the business unit of the company (finance, legal, marketing, etc.). Some smaller studios don’t have producers at all. For example, at Naughty Dog, literally everyone in the company, including the two co-presidents, plays a direct role in constructing the game; team management and business duties are shared between the senior members of the studio.
不同的工作室对制片人的角色有不同的定义。在一些游戏公司,制作人的工作是管理日程并担任人力资源经理。在其他公司,制作人担任高级游戏设计职务。还有一些工作室要求他们的制作人充当开发团队和公司业务部门(财务、法律、营销等)之间的联络人。一些较小的工作室根本没有制片人。例如,在顽皮狗,公司的每个人,包括两位联合总裁,都在游戏的构建中发挥着直接作用;团队管理和业务职责由工作室的高级成员共同承担。
The team of people who directly construct the game is typically supported by a crucial team of support staff. This includes the studio’s executive management team, the marketing department (or a team that liaises with an external marketing group), administrative staff and the IT department, whose job is to purchase, install and configure hardware and software for the team and to provide technical support.
直接构建游戏的团队通常得到关键支持人员团队的支持。这包括工作室的执行管理团队、营销部门(或与外部营销团队联络的团队)、行政人员和 IT 部门,其工作是为团队购买、安装和配置硬件和软件,并提供技术支持。支持。
The marketing, manufacture and distribution of a game title are usually handled by a publisher, not by the game studio itself. A publisher is typically a large corporation, like Electronic Arts, THQ, Vivendi, Sony, Nintendo, etc. Many game studios are not affiliated with a particular publisher. They sell each game that they produce to whichever publisher strikes the best deal with them. Other studios work exclusively with a single publisher, either via a long-term publishing contract or as a fully owned subsidiary of the publishing company. For example, THQ’s game studios are independently managed, but they are owned and ultimately controlled by THQ. Electronic Arts takes this relationship one step further, by directly managing its studios. First-party developers are game studios owned directly by the console manufacturers (Sony, Nintendo and Microsoft). For example, Naughty Dog is a first-party Sony developer. These studios produce games exclusively for the gaming hardware manufactured by their parent company.
游戏的营销、制作和发行通常由发行商负责,而不是由游戏工作室本身负责。发行商通常是一家大公司,例如艺电、THQ、维旺迪、索尼、任天堂等。许多游戏工作室并不隶属于特定发行商。他们将自己制作的每款游戏出售给与他们达成最优惠交易的发行商。其他工作室通过长期出版合同或作为出版公司的全资子公司与单一出版商独家合作。例如,THQ的游戏工作室是独立管理的,但它们的所有权和最终控制权归THQ所有。艺电通过直接管理其工作室,将这种关系更进一步。第一方开发商是游戏机制造商(索尼、任天堂和微软)直接拥有的游戏工作室。例如,顽皮狗是索尼第一方开发商。这些工作室专门为其母公司制造的游戏硬件制作游戏。
We probably all have a pretty good intuitive notion of what a game is. The general term “game” encompasses board games like chess and Monopoly, card games like poker and blackjack, casino games like roulette and slot machines, military war games, computer games, various kinds of play among children, and the list goes on. In academia we sometimes speak of game theory, in which multiple agents select strategies and tactics in order to maximize their gains within the framework of a well-defined set of game rules. When used in the context of console or computer-based entertainment, the word “game” usually conjures images of a three-dimensional virtual world featuring a humanoid, animal or vehicle as the main character under player control. (Or for the old geezers among us, perhaps it brings to mind images of two-dimensional classics like Pong, Pac-Man, or Donkey Kong.) In his excellent book, A Theory of Fun for Game Design, Raph Koster defines a game to be an interactive experience that provides the player with an increasingly challenging sequence of patterns which he or she learns and eventually masters [30]. Koster’s assertion is that the activities of learning and mastering are at the heart of what we call “fun,” just as a joke becomes funny at the moment we “get it” by recognizing the pattern.
我们可能都对游戏是什么有一个非常直观的概念。一般术语“游戏”包括国际象棋和大富翁等棋盘游戏、扑克和二十一点等纸牌游戏、轮盘赌和老虎机等赌场游戏、军事战争游戏、电脑游戏、儿童的各种游戏等等。在学术界,我们有时会谈论博弈论,其中多个智能体选择策略和战术,以便在一组明确定义的游戏规则的框架内最大化他们的收益。当在控制台或基于计算机的娱乐环境中使用时,“游戏”一词通常会让人联想到三维虚拟世界的图像,其中以人形、动物或车辆为主角,由玩家控制。 (或者对于我们这些老家伙来说,也许它会让人想起《乒乓球》、《吃豆人》或《大金刚》等二维经典游戏的图像。)在 Raph Koster 的优秀著作《游戏设计的乐趣理论》中,他定义了游戏成为一种交互式体验,为玩家提供越来越具有挑战性的模式序列,他或她可以学习并最终掌握这些模式[30]。科斯特认为,学习和掌握的活动是我们所说的“乐趣”的核心,就像当我们通过识别模式“明白”时,一个笑话变得有趣一样。
For the purposes of this book, we’ll focus on the subset of games that comprise two- and three-dimensional virtual worlds with a small number of players (between one and 16 or thereabouts). Much of what we’ll learn can also be applied to HTML5/JavaScript games on the Internet, pure puzzle games like Tetris, or massively multiplayer online games (MMOG). But our primary focus will be on game engines capable of producing first-person shooters, third-person action/platform games, racing games, fighting games and the like.
出于本书的目的,我们将重点关注包含少量玩家(1 到 16 人左右)的二维和三维虚拟世界的游戏子集。我们将学到的大部分内容也可以应用于互联网上的 HTML5/JavaScript 游戏、俄罗斯方块等纯益智游戏或大型多人在线游戏 (MMOG)。但我们的主要关注点将是能够制作第一人称射击游戏、第三人称动作/平台游戏、赛车游戏、格斗游戏等的游戏引擎。
Most two- and three-dimensional video games are examples of what computer scientists would call soft real-time interactive agent-based computer simulations. Let’s break this phrase down in order to better understand what it means.
大多数二维和三维视频游戏都是计算机科学家所谓的基于软实时交互代理的计算机模拟的例子。让我们分解一下这句话,以便更好地理解它的含义。
In most video games, some subset of the real world—or an imaginary world—is modeled mathematically so that it can be manipulated by a computer. The model is an approximation to and a simplification of reality (even if it’s an imaginary reality), because it is clearly impractical to include every detail down to the level of atoms or quarks. Hence, the mathematical model is a simulation of the real or imagined game world. Approximation and simplification are two of the game developer’s most powerful tools. When used skillfully, even a greatly simplified model can sometimes be almost indistinguishable from reality—and a lot more fun.
在大多数视频游戏中,现实世界或想象世界的某些子集都经过数学建模,以便可以由计算机操纵。该模型是现实的近似和简化(即使它是想象的现实),因为将每个细节都包含到原子或夸克的水平显然是不切实际的。因此,数学模型是对真实或想象的游戏世界的模拟。近似和简化是游戏开发者最强大的两个工具。如果使用得当,即使是大大简化的模型有时也几乎与现实没有区别,而且会更有趣。
An agent-based simulation is one in which a number of distinct entities known as “agents” interact. This fits the description of most three-dimensional computer games very well, where the agents are vehicles, characters, fireballs, power dots and so on. Given the agent-based nature of most games, it should come as no surprise that most games nowadays are implemented in an object-oriented, or at least loosely object-based, programming language.
基于代理的模拟是一种由许多称为“代理”的不同实体进行交互的模拟。这非常符合大多数三维电脑游戏的描述,其中的代理是车辆、角色、火球、能量点等等。考虑到大多数游戏基于代理的性质,当今大多数游戏都是用面向对象或至少松散地基于对象的编程语言实现的,这一点也就不足为奇了。
All interactive video games are temporal simulations, meaning that the virtual game world model is dynamic—the state of the game world changes over time as the game’s events and story unfold. A video game must also respond to unpredictable inputs from its human player(s)—thus interactive temporal simulations. Finally, most video games present their stories and respond to player input in real time, making them interactive real-time simulations. One notable exception is in the category of turn-based games like computerized chess or turn-based strategy games. But even these types of games usually provide the user with some form of real-time graphical user interface. So for the purposes of this book, we’ll assume that all video games have at least some real-time constraints.
所有交互式视频游戏都是时间模拟,这意味着虚拟游戏世界模型是动态的——游戏世界的状态随着游戏事件和故事的展开而随着时间的推移而变化。视频游戏还必须响应人类玩家不可预测的输入,从而实现交互式时间模拟。最后,大多数视频游戏都会实时呈现故事并响应玩家输入,从而使它们成为交互式实时模拟。一个值得注意的例外是回合制游戏,例如计算机国际象棋或回合制策略游戏。但即使是这些类型的游戏通常也会为用户提供某种形式的实时图形用户界面。因此,就本书而言,我们假设所有视频游戏都至少有一些实时限制。
At the core of every real-time system is the concept of a deadline. An obvious example in video games is the requirement that the screen be updated at least 24 times per second in order to provide the illusion of motion. (Most games render the screen at 30 or 60 frames per second because these are multiples of an NTSC monitor’s refresh rate.) Of course, there are many other kinds of deadlines in video games as well. A physics simulation may need to be updated 120 times per second in order to remain stable. A character’s artificial intelligence system may need to “think” at least once every second to prevent the appearance of stupidity. The audio library may need to be called at least once every 1/60 second in order to keep the audio buffers filled and prevent audible glitches.
每个实时系统的核心都是截止日期的概念。视频游戏中一个明显的例子是要求屏幕每秒至少更新 24 次才能提供运动的错觉。 (大多数游戏以每秒 30 或 60 帧的速度渲染屏幕,因为这些是 NTSC 显示器刷新率的倍数。)当然,视频游戏中还有许多其他类型的截止时间。物理模拟可能需要每秒更新 120 次才能保持稳定。角色的人工智能系统可能需要每秒至少“思考”一次,以防止出现愚蠢的情况。音频库可能需要至少每 1/60 秒调用一次,以保持音频缓冲区填充并防止可听故障。
A “soft” real-time system is one in which missed deadlines are not catastrophic. Hence, all video games are soft real-time systems—if the frame rate dies, the human player generally doesn’t! Contrast this with a hard real-time system, in which a missed deadline could mean severe injury to or even the death of a human operator. The avionics system in a helicopter or the control-rod system in a nuclear power plant are examples of hard real-time systems.
“软”实时系统是一种错过最后期限不会造成灾难性后果的系统。因此,所有视频游戏都是软实时系统——如果帧速率消失,人类玩家通常不会!与此形成对比的是硬实时系统,在硬实时系统中,错过最后期限可能意味着操作员的严重受伤甚至死亡。直升机中的航空电子系统或核电站中的控制杆系统都是硬实时系统的例子。
Mathematical models can be analytic or numerical. For example, the analytic (closed-form) mathematical model of a rigid body falling under the influence of constant acceleration due to gravity is typically written as follows:
数学模型可以是解析的或数值的。例如,在重力恒定加速度影响下下落的刚体的解析(封闭式)数学模型通常写如下:
An analytic model can be evaluated for any value of its independent variables, such as the time t in the above equation, given only the initial conditions v0 and y0 and the constant g. Such models are very convenient when they can be found. However, many problems in mathematics have no closed-form solution. And in video games, where the user’s input is unpredictable, we cannot hope to model the entire game analytically.
可以评估解析模型的自变量的任何值,例如上式中的时间 t,仅给出初始条件 v 0 和 y 0 以及常数 g 。当找到这样的模型时,它们非常方便。然而,数学中的许多问题没有封闭式解。在视频游戏中,用户的输入是不可预测的,我们不能希望对整个游戏进行分析建模。
A numerical model of the same rigid body under gravity can be expressed as follows:
同一刚体在重力作用下的数值模型可表示为:
That is, the height of the rigid body at some future time (t + Δt) can be found as a function of the height and its first, second, and possibly higher-order time derivatives at the current time t. Numerical simulations are typically implemented by running calculations repeatedly, in order to determine the state of the system at each discrete time step. Games work in the same way. A main “game loop” runs repeatedly, and during each iteration of the loop, various game systems such as artificial intelligence, game logic, physics simulations and so on are given a chance to calculate or update their state for the next discrete time step. The results are then “rendered” by displaying graphics, emitting sound and possibly producing other outputs such as force-feedback on the joypad.
也就是说,可以将刚体在未来某个时间 (t + Δt) 的高度作为当前时间 t 的高度及其一阶、二阶和可能的高阶时间导数的函数来求得。数值模拟通常通过重复运行计算来实现,以确定系统在每个离散时间步长的状态。游戏也以同样的方式运作。主“游戏循环”重复运行,在循环的每次迭代期间,人工智能、游戏逻辑、物理模拟等各种游戏系统都有机会计算或更新下一个离散时间步的状态。然后通过显示图形、发出声音以及可能产生其他输出(例如手柄上的力反馈)来“渲染”结果。
The term “game engine” arose in the mid-1990s in reference to first-person shooter (FPS) games like the insanely popular Doom by id Software. Doom was architected with a reasonably well-defined separation between its core software components (such as the three-dimensional graphics rendering system, the collision detection system or the audio system) and the art assets, game worlds and rules of play that comprised the player’s gaming experience. The value of this separation became evident as developers began licensing games and retooling them into new products by creating new art, world layouts, weapons, characters, vehicles and game rules with only minimal changes to the “engine” software. This marked the birth of the “mod community”—a group of individual gamers and small independent studios that built new games by modifying existing games, using free toolkits provided by the original developers.
“游戏引擎”一词出现于 20 世纪 90 年代中期,指的是第一人称射击 (FPS) 游戏,例如 id Software 出品的极受欢迎的《Doom》。 《毁灭战士》的架构在其核心软件组件(例如三维图形渲染系统、碰撞检测系统或音频系统)与艺术资产、游戏世界和包含玩家的游戏规则之间进行了相当明确的分离。游戏体验。随着开发商开始授权游戏并通过创建新的艺术、世界布局、武器、角色、车辆和游戏规则将其重组为新产品,并且只对“引擎”软件进行最小的更改,这种分离的价值变得显而易见。这标志着“模组社区”的诞生——一群个人游戏玩家和小型独立工作室,他们使用原始开发者提供的免费工具包,通过修改现有游戏来构建新游戏。
Towards the end of the 1990s, some games like Quake III Arena and Unreal were designed with reuse and “modding” in mind. Engines were made highly customizable via scripting languages like id’s Quake C, and engine licensing began to be a viable secondary revenue stream for the developers who created them. Today, game developers can license a game engine and reuse significant portions of its key software components in order to build games. While this practice still involves considerable investment in custom software engineering, it can be much more economical than developing all of the core engine components in-house.
到 20 世纪 90 年代末,一些游戏(例如 Quake III Arena 和 Unreal)在设计时就考虑到了重用和“改装”。引擎通过 id 的 Quake C 等脚本语言实现了高度可定制,并且引擎许可开始成为创建它们的开发人员的可行的第二收入来源。如今,游戏开发人员可以许可游戏引擎并重用其关键软件组件的重要部分来构建游戏。虽然这种做法仍然需要对定制软件工程进行大量投资,但它比内部开发所有核心引擎组件要经济得多。
The line between a game and its engine is often blurry. Some engines make a reasonably clear distinction, while others make almost no attempt to separate the two. In one game, the rendering code might “know” specifically how to draw an orc. In another game, the rendering engine might provide generalpurpose material and shading facilities, and “orc-ness” might be defined entirely in data. No studio makes a perfectly clear separation between the game and the engine, which is understandable considering that the definitions of these two components often shift as the game’s design solidifies.
游戏与其引擎之间的界限通常是模糊的。有些引擎做出了相当清晰的区分,而另一些引擎几乎没有尝试将两者分开。在一款游戏中,渲染代码可能“知道”具体如何绘制兽人。在另一个游戏中,渲染引擎可能提供通用材质和着色设施,并且“兽人”可能完全在数据中定义。没有哪个工作室能够将游戏和引擎完全清晰地分开,考虑到这两个组件的定义经常随着游戏设计的巩固而发生变化,这是可以理解的。
Arguably a data-driven architecture is what differentiates a game engine from a piece of software that is a game but not an engine. When a game contains hard-coded logic or game rules, or employs special-case code to render specific types of game objects, it becomes difficult or impossible to reuse that software to make a different game. We should probably reserve the term “game engine” for software that is extensible and can be used as the foundation for many different games without major modification.
可以说,数据驱动的架构是游戏引擎与游戏而非引擎的软件的区别所在。当游戏包含硬编码逻辑或游戏规则,或采用特殊情况代码来呈现特定类型的游戏对象时,重用该软件来制作不同的游戏就变得困难或不可能。我们或许应该为可扩展的软件保留术语“游戏引擎”,并且可以将其用作许多不同游戏的基础而无需进行重大修改。
Clearly this is not a black-and-white distinction. We can think of a gamut of reusability onto which every engine falls. Figure 1.1 takes a stab at the locations of some well-known games/engines along this gamut.
显然,这不是非黑即白的区分。我们可以想到每个引擎都属于的可重用性范围。图 1.1 尝试了该领域中一些知名游戏/引擎的位置。
One would think that a game engine could be something akin to Apple QuickTime or Microsoft Windows Media Player—a general-purpose piece of software capable of playing virtually any game content imaginable. However, this ideal has not yet been achieved (and may never be). Most game engines are carefully crafted and fine-tuned to run a particular game on a particular hardware platform. And even the most general-purpose multiplatform engines are really only suitable for building games in one particular genre, such as first-person shooters or racing games. It’s safe to say that the more generalpurpose a game engine or middleware component is, the less optimal it is for running a particular game on a particular platform.
人们可能会认为游戏引擎可能类似于 Apple QuickTime 或 Microsoft Windows Media Player——一种通用软件,能够播放几乎任何可以想象到的游戏内容。然而,这个理想尚未实现(而且可能永远不会实现)。大多数游戏引擎都经过精心设计和微调,可以在特定的硬件平台上运行特定的游戏。即使是最通用的多平台引擎也实际上只适合构建一种特定类型的游戏,例如第一人称射击游戏或赛车游戏。可以肯定地说,游戏引擎或中间件组件的通用性越强,在特定平台上运行特定游戏的最佳性就越差。
This phenomenon occurs because designing any efficient piece of software invariably entails making trade-offs, and those trade-offs are based on assumptions about how the software will be used and/or about the target hardware on which it will run. For example, a rendering engine that was designed to handle intimate indoor environments probably won’t be very good at rendering vast outdoor environments. The indoor engine might use a binary space partitioning (BSP) tree or portal system to ensure that no geometry is drawn that is being occluded by walls or objects that are closer to the camera. The outdoor engine, on the other hand, might use a less-exact occlusion mechanism, or none at all, but it probably makes aggressive use of level-of-detail (LOD) techniques to ensure that distant objects are rendered with a minimum number of triangles, while using high-resolution triangle meshes for geometry that is close to the camera.
出现这种现象的原因是,设计任何高效的软件都不可避免地需要进行权衡,而这些权衡是基于有关软件将如何使用和/或软件将运行的目标硬件的假设。例如,设计用于处理亲密的室内环境的渲染引擎可能不太擅长渲染广阔的室外环境。室内引擎可能使用二元空间分区 (BSP) 树或门户系统来确保不会绘制被墙壁或更靠近相机的物体遮挡的几何图形。另一方面,室外引擎可能使用不太精确的遮挡机制,或者根本不使用,但它可能会积极使用细节级别 (LOD) 技术来确保以最少的数量渲染远处的物体三角形,同时对靠近相机的几何体使用高分辨率三角形网格。
The advent of ever-faster computer hardware and specialized graphics cards, along with ever-more-efficient rendering algorithms and data structures, is beginning to soften the differences between the graphics engines of different genres. It is now possible to use a first-person shooter engine to build a strategy game, for example. However, the trade-off between generality and optimality still exists. A game can always be made more impressive by fine-tuning the engine to the specific requirements and constraints of a particular game and/or hardware platform.
更快的计算机硬件和专用显卡的出现,以及更高效的渲染算法和数据结构,正在开始软化不同类型的图形引擎之间的差异。例如,现在可以使用第一人称射击引擎来构建策略游戏。然而,通用性和最优性之间的权衡仍然存在。通过根据特定游戏和/或硬件平台的特定要求和限制对引擎进行微调,总是可以使游戏更加令人印象深刻。
Game engines are typically somewhat genre specific. An engine designed for a two-person fighting game in a boxing ring will be very different from a massively multiplayer online game (MMOG) engine or a first-person shooter (FPS) engine or a real-time strategy (RTS) engine. However, there is also a great deal of overlap—all 3D games, regardless of genre, require some form of low-level user input from the joypad, keyboard and/or mouse, some form of 3D mesh rendering, some form of heads-up display (HUD) including text rendering in a variety of fonts, a powerful audio system, and the list goes on. So while the Unreal Engine, for example, was designed for first-person shooter games, it has been used successfully to construct games in a number of other genres as well, including the wildly popular third-person shooter franchise Gears of War by Epic Games, the hit action-adventure games in the Batman: Arkham series by Rocksteady Studios, the well-known fighting game Tekken 7 by Bandai Namco Studios, and the first three role-playing third-person shooter games in the Mass Effect series by BioWare.
游戏引擎通常是特定类型的。为拳击场上的两人格斗游戏设计的引擎与大型多人在线游戏(MMOG)引擎或第一人称射击游戏(FPS)引擎或实时策略(RTS)引擎有很大不同。然而,也存在大量重叠——所有 3D 游戏,无论类型如何,都需要来自游戏手柄、键盘和/或鼠标的某种形式的低级用户输入、某种形式的 3D 网格渲染、某种形式的头部——向上显示(HUD),包括各种字体的文本渲染、强大的音频系统,等等。例如,虽然虚幻引擎是为第一人称射击游戏设计的,但它也已成功用于构建许多其他类型的游戏,包括 Epic Games 广受欢迎的第三人称射击游戏《战争机器》 、Rocksteady Studios 出品的热门动作冒险游戏《蝙蝠侠:阿卡姆》系列、Bandai Namco Studios 出品的知名格斗游戏《铁拳 7》以及 BioWare 出品的《质量效应》系列中的前三款角色扮演第三人称射击游戏。
Let’s take a look at some of the most common game genres and explore some examples of the technology requirements particular to each.
让我们看一下一些最常见的游戏类型,并探讨每种游戏类型特有的技术要求的一些示例。
The first-person shooter (FPS) genre is typified by games like Quake, Unreal Tournament, Half-Life, Battlefield, Destiny, Titanfall and Overwatch (see Figure 1.2). These games have historically involved relatively slow on-foot roaming of a potentially large but primarily corridor-based world. However, modern first-person shooters can take place in a wide variety of virtual environments including vast open outdoor areas and confined indoor areas. Modern FPS traversal mechanics can include on-foot locomotion, rail-confined or free-roaming ground vehicles, hovercraft, boats and aircraft. For an overview of this genre, see http://en.wikipedia.org/wiki/First-person_shooter.
第一人称射击游戏 (FPS) 类型的代表游戏有《雷神之锤》、《虚幻竞技场》、《半条命》、《战地》、《命运》、《泰坦陨落》和《守望先锋》(见图 1.2)。从历史上看,这些游戏涉及在一个可能很大但主要基于走廊的世界中相对缓慢的步行漫游。然而,现代第一人称射击游戏可以在各种虚拟环境中进行,包括广阔的开放室外区域和有限的室内区域。现代 FPS 穿越机制可以包括步行运动、轨道限制或自由漫游的地面车辆、气垫船、船只和飞机。有关此类型的概述,请参阅 http://en.wikipedia.org/wiki/First-person_shooter。
First-person games are typically some of the most technologically challenging to build, probably rivaled in complexity only by third-person shooters, action-platformer games, and massively multiplayer games. This is because first-person shooters aim to provide their players with the illusion of being immersed in a detailed, hyperrealistic world. It is not surprising that many of the game industry’s big technological innovations arose out of the games in this genre.
第一人称游戏通常是技术上最具挑战性的游戏,在复杂性上可能只有第三人称射击游戏、动作平台游戏和大型多人游戏可以与之媲美。这是因为第一人称射击游戏旨在为玩家提供沉浸在详细、超现实世界中的错觉。游戏行业的许多重大技术创新都源于此类游戏,这并不奇怪。
First-person shooters typically focus on technologies such as: • efficient rendering of large 3D virtual worlds;
第一人称射击游戏通常关注以下技术: • 大型 3D 虚拟世界的高效渲染;
The rendering technology employed by first-person shooters is almost always highly optimized and carefully tuned to the particular type of environment being rendered. For example, indoor “dungeon crawl” games often employ binary space partitioning trees or portal-based rendering systems. Outdoor FPS games use other kinds of rendering optimizations such as occlusion culling, or an offline sectorization of the game world with manual or automated specification of which target sectors are visible from each source sector.
第一人称射击游戏所采用的渲染技术几乎总是经过高度优化,并根据渲染的特定类型环境进行仔细调整。例如,室内“地下城爬行”游戏通常采用二元空间分区树或基于门户的渲染系统。户外 FPS 游戏使用其他类型的渲染优化,例如遮挡剔除,或通过手动或自动指定哪些目标扇区从每个源扇区可见的方式对游戏世界进行离线扇区化。
Of course, immersing a player in a hyperrealistic game world requires much more than just optimized high-quality graphics technology. The character animations, audio and music, rigid body physics, in-game cinematics and myriad other technologies must all be cutting-edge in a first-person shooter. So this genre has some of the most stringent and broad technology requirements in the industry.
当然,让玩家沉浸在超现实的游戏世界中需要的不仅仅是优化的高质量图形技术。角色动画、音频和音乐、刚体物理、游戏内动画和无数其他技术都必须是第一人称射击游戏的尖端技术。因此,这种类型具有业内最严格、最广泛的技术要求。
“Platformer” is the term applied to third-person character-based action games where jumping from platform to platform is the primary gameplay mechanic. Typical games from the 2D era include Space Panic, Donkey Kong, Pitfall! and Super Mario Brothers. The 3D era includes platformers like Super Mario 64, Crash Bandicoot, Rayman 2, Sonic the Hedgehog, the Jak and Daxter series (Figure 1.3), the Ratchet & Clank series and Super Mario Galaxy. See http://en.wikipedia.org/wiki/Platformer for an in-depth discussion of this genre.
“平台玩家”这个术语适用于基于第三人称角色的动作游戏,其中从一个平台跳转到另一个平台是主要的游戏机制。 2D时代的典型游戏有《Space Panic》、《Donkey Kong》、《Pitfall!》等。和超级马里奥兄弟。 3D 时代包括《超级马里奥 64》、《古惑狼》、《雷曼 2》、《刺猬索尼克》、《杰克与达斯特》系列(图 1.3)、《瑞奇与叮当》系列和《超级马里奥银河》等平台游戏。有关此类型的深入讨论,请参阅 http://en.wikipedia.org/wiki/Platformer。
In terms of their technological requirements, platformers can usually be lumped together with third-person shooters and third-person action/adventure games like Just Cause 2, Gears of War 4 (Figure 1.4), the Uncharted series, the Resident Evil series, the The Last of Us series, Red Dead Redemption 2, and the list goes on.
就技术要求而言,平台游戏通常可以与第三人称射击游戏和第三人称动作/冒险游戏混为一谈,例如《正义事业 2》、《战争机器 4》(图 1.4)、《神秘海域》系列、《生化危机》系列、 《最后生还者》系列、《荒野大镖客:救赎 2》等等。
Third-person character-based games have a lot in common with first-person shooters, but a great deal more emphasis is placed on the main character’s abilities and locomotion modes. In addition, high-fidelity full-body character animations are required for the player’s avatar, as opposed to the somewhat less-taxing animation requirements of the “floating arms” in a typical FPS game. It’s important to note here that almost all first-person shooters have an online multiplayer component, so a full-body player avatar must be rendered in addition to the first-person arms. However, the fidelity of these FPS player avatars is usually not comparable to the fidelity of the non-player characters in these same games; nor can it be compared to the fidelity of the player avatar in a third-person game.
基于第三人称角色的游戏与第一人称射击游戏有很多共同点,但更注重主角的能力和运动模式。此外,玩家的头像需要高保真全身角色动画,这与典型 FPS 游戏中“浮动手臂”的动画要求相对宽松。这里需要注意的是,几乎所有第一人称射击游戏都有在线多人游戏组件,因此除了第一人称手臂之外还必须渲染全身玩家头像。然而,这些 FPS 玩家化身的保真度通常无法与这些相同游戏中的非玩家角色的保真度相媲美;它也无法与第三人称游戏中玩家头像的保真度相比。
In a platformer, the main character is often cartoon-like and not particularly realistic or high-resolution. However, third-person shooters often feature a highly realistic humanoid player character. In both cases, the player character typically has a very rich set of actions and animations.
在平台游戏中,主角通常是卡通人物,并不是特别现实或高分辨率。然而,第三人称射击游戏通常具有高度逼真的人形玩家角色。在这两种情况下,玩家角色通常具有非常丰富的动作和动画集。
Some of the technologies specifically focused on by games in this genre include:
该类型游戏特别关注的一些技术包括:
Fighting games are typically two-player games involving humanoid characters pummeling each other in a ring of some sort. The genre is typified by games like Soul Calibur and Tekken 3 (see Figure 1.5). The Wikipedia page http://en.wikipedia.org/wiki/Fighting_game provides an overview of this genre.
格斗游戏通常是两人游戏,涉及类人角色在某种形式的环中互相殴打。该类型的典型代表是《灵魂能力》和《铁拳 3》等游戏(见图 1.5)。维基百科页面 http://en.wikipedia.org/wiki/Fighting_game 提供了该类型的概述。
Traditionally games in the fighting genre have focused their technology efforts on:
传统上,格斗类型游戏的技术重点集中在:
Since the 3D world in these games is small and the camera is centered on the action at all times, historically these games have had little or no need for world subdivision or occlusion culling. They would likewise not be expected to employ advanced three-dimensional audio propagation models, for example.
由于这些游戏中的 3D 世界很小,并且摄像机始终以动作为中心,因此从历史上看,这些游戏很少或根本不需要世界细分或遮挡剔除。例如,他们同样不会被期望采用先进的三维音频传播模型。
Modern fighting games like EA’s Fight Night Round 4 and NetherRealm Studios’ Injustice 2 (Figure 1.6) have upped the technological ante with features like:
现代格斗游戏,如 EA 的 Fight Night Round 4 和 NetherRealm Studios 的 Injustice 2(图 1.6),已经提高了技术赌注,具有以下功能:
It’s important to note that some fighting games like Ninja Theory’s Heavenly Sword and For Honor by Ubisoft Montreal take place in a large-scale virtual world, not a confined arena. In fact, many people consider this to be a separate genre, sometimes called a brawler. This kind of fighting game can have technical requirements more akin to those of a third-person shooter or a strategy game.
值得注意的是,一些格斗游戏,例如《忍者理论》的《倚天剑》和育碧蒙特利尔公司的《荣耀战魂》,是在大型虚拟世界中进行的,而不是在封闭的竞技场中。事实上,许多人认为这是一个独立的类型,有时被称为格斗游戏。这种格斗游戏的技术要求可能更类似于第三人称射击游戏或策略游戏。
The racing genre encompasses all games whose primary task is driving a car or other vehicle on some kind of track. The genre has many subcategories. Simulation-focused racing games (“sims”) aim to provide a driving experience that is as realistic as possible (e.g., Gran Turismo). Arcade racers favor over-the-top fun over realism (e.g., San Francisco Rush, Cruis’n USA, Hydro Thunder). One subgenre explores the subculture of street racing with tricked out consumer vehicles (e.g., Need for Speed, Juiced). Kart racing is a subcategory in which popular characters from platformer games or cartoon characters from TV are re-cast as the drivers of whacky vehicles (e.g., Mario Kart, Jak X, Freaky Flyers). Racing games need not always involve time-based competition. Some kart racing games, for example, offer modes in which players shoot at one another, collect loot or engage in a variety of other timed and untimed tasks. For a discussion of this genre, see http://en.wikipedia.org/wiki/Racing_game.
赛车类型涵盖所有主要任务是在某种赛道上驾驶汽车或其他车辆的游戏。该类型有许多子类别。以模拟为中心的赛车游戏(“sims”)旨在提供尽可能真实的驾驶体验(例如 Gran Turismo)。街机赛车手更喜欢过度的乐趣而不是现实主义(例如,San Francisco Rush、Cruis’n USA、Hydro Thunder)。其中一个子类型探索了街头赛车的亚文化,其中包括改装过的消费类车辆(例如《极品飞车》、《果汁》)。卡丁车赛车是一个子类别,平台游戏中的流行角色或电视中的卡通人物被重新塑造为古怪车辆的驾驶员(例如马里奥卡丁车、Jak X、Freaky Flyers)。赛车游戏不一定总是涉及基于时间的竞争。例如,一些卡丁车赛车游戏提供玩家互相射击、收集战利品或参与各种其他定时和不定时任务的模式。有关此类型的讨论,请参阅 http://en.wikipedia.org/wiki/Racing_game。
A racing game is often very linear, much like older FPS games. However, travel speed is generally much faster than in an FPS. Therefore, more focus is placed on very long corridor-based tracks, or looped tracks, sometimes with various alternate routes and secret short-cuts. Racing games usually focus all their graphic detail on the vehicles, track and immediate surroundings. As an example of this, Figure 1.7 shows a screenshot from the latest installment in the well-known Gran Turismo racing game series, Gran Turismo Sport, developed by Polyphony Digital and published by Sony Interactive Entertainment. However, kart racers also devote significant rendering and animation bandwidth to the characters driving the vehicles.
赛车游戏通常非常线性,就像旧的 FPS 游戏一样。然而,行进速度通常比 FPS 快得多。因此,更多的注意力集中在非常长的走廊轨道或环形轨道上,有时有各种替代路线和秘密捷径。赛车游戏通常将所有图形细节集中在车辆、赛道和周围环境上。作为一个例子,图 1.7 显示了著名的 Gran Turismo 赛车游戏系列 Gran Turismo Sport 的最新版本的屏幕截图,该游戏由 Polyphony Digital 开发并由 Sony Interactive Entertainment 发行。然而,卡丁车赛车手也为驾驶车辆的角色投入了大量的渲染和动画带宽。
Some of the technological properties of a typical racing game include the following techniques:
典型赛车游戏的一些技术特性包括以下技术:
The modern strategy game genre was arguably defined by Dune II: The Building of a Dynasty (1992). Other games in this genre include Warcraft, Command & Conquer, Age of Empires and Starcraft. In this genre, the player deploys the battle units in his or her arsenal strategically across a large playing field in an attempt to overwhelm his or her opponent. The game world is typically displayed at an oblique top-down viewing angle. A distinction is often made between turn-based strategy games and real-time strategy (RTS). For a discussion of this genre, see https://en.wikipedia.org/wiki/Strategy_video_game.
现代策略游戏类型可以说是由《沙丘 II:王朝建设》(1992 年)定义的。该类型的其他游戏包括《魔兽争霸》、《命令与征服》、《帝国时代》和《星际争霸》。在这种类型中,玩家在广阔的比赛场地上战略性地部署他或她的武器库中的战斗单位,试图压倒他或她的对手。游戏世界通常以倾斜的自上而下的视角显示。回合制策略游戏和实时策略 (RTS) 之间通常存在区别。有关此类型的讨论,请参阅 https://en.wikipedia.org/wiki/Strategy_video_game。
The strategy game player is usually prevented from significantly changing the viewing angle in order to see across large distances. This restriction permits developers to employ various optimizations in the rendering engine of a strategy game.
通常阻止策略游戏玩家显着改变视角以观察远距离。此限制允许开发人员在策略游戏的渲染引擎中采用各种优化。
Older games in the genre employed a grid-based (cell-based) world construction, and an orthographic projection was used to greatly simplify the renderer. For example, Figure 1.8 shows a screenshot from the classic strategy game Age of Empires.
该类型的较早游戏采用基于网格(基于单元)的世界构建,并使用正交投影来大大简化渲染器。例如,图 1.8 显示了经典策略游戏帝国时代的屏幕截图。
Modern strategy games sometimes use perspective projection and a true 3D world, but they may still employ a grid layout system to ensure that units and background elements, such as buildings, align with one another properly. A popular example, Total War: Warhammer 2, is shown in Figure 1.9.
现代策略游戏有时会使用透视投影和真正的 3D 世界,但它们仍可能采用网格布局系统来确保单位和背景元素(例如建筑物)彼此正确对齐。一个流行的例子是《全面战争:战锤 2》,如图 1.9 所示。
Some other common practices in strategy games include the following techniques:
策略游戏中的其他一些常见做法包括以下技术:
The massively multiplayer online game (MMOG or just MMO) genre is typified by games like Guild Wars 2 (AreaNet/NCsoft), EverQuest (989 Studios/SOE), World of Warcraft (Blizzard) and Star Wars Galaxies (SOE/Lucas Arts), to name a few. An MMO is defined as any game that supports huge numbers of simultaneous players (from thousands to hundreds of thousands), usually all playing in one very large, persistent virtual world (i.e., a world whose internal state persists for very long periods of time, far beyond that of any one player’s gameplay session). Otherwise, the gameplay experience of an MMO is often similar to that of their small-scale multiplayer counterparts. Subcategories of this genre include MMO role-playing games (MMORPG), MMO realtime strategy games (MMORTS) and MMO first-person shooters (MMOFPS). For a discussion of this genre, see http://en.wikipedia.org/wiki/MMOG. Figure 1.10 shows a screenshot from the hugely popular MMORPG World of Warcraft.
大型多人在线游戏(MMOG 或 MMO)类型的代表游戏有《激战 2》(AreaNet/NCsoft)、《无尽的任务》(989 Studios/SOE)、《魔兽世界》(暴雪)和《星球大战星系》(SOE/Lucas Arts) ,仅举几例。 MMO 被定义为任何支持大量同时玩家(从数千到数十万)的游戏,通常都在一个非常大的、持久的虚拟世界中玩(即,一个内部状态持续很长一段时间的世界,远远超出任何一个玩家的游戏会话)。除此之外,MMO 的游戏体验通常与小型多人游戏类似。该类型的子类别包括 MMO 角色扮演游戏 (MMORPG)、MMO 即时策略游戏 (MMORTS) 和 MMO 第一人称射击游戏 (MMOFPS)。有关此类型的讨论,请参阅 http://en.wikipedia.org/wiki/MMOG。图 1.10 显示了广受欢迎的 MMORPG 魔兽世界的屏幕截图。
At the heart of all MMOGs is a very powerful battery of servers. These servers maintain the authoritative state of the game world, manage users signing in and out of the game, provide inter-user chat or voice-over-IP (VoIP) services and more. Almost all MMOGs require users to pay some kind of regular subscription fee in order to play, and they may offer micro-transactions within the game world or out-of-game as well. Hence, perhaps the most important role of the central server is to handle the billing and micro-transactions which serve as the game developer’s primary source of revenue.
所有 MMOG 的核心都是一组非常强大的服务器。这些服务器维护游戏世界的权威状态、管理用户登录和退出游戏、提供用户间聊天或 IP 语音 (VoIP) 服务等。几乎所有 MMOG 都要求用户支付某种定期订阅费才能玩游戏,并且它们可能会在游戏世界内或游戏外提供微交易。因此,中央服务器最重要的作用也许是处理计费和微交易,这是游戏开发商的主要收入来源。
Graphics fidelity in an MMO is almost always lower than its non-massively multiplayer counterparts, as a result of the huge world sizes and extremely large numbers of users supported by these kinds of games.
MMO 中的图形保真度几乎总是低于非大型多人在线游戏,因为此类游戏支持巨大的世界规模和极大量的用户。
Figure 1.11 shows a screen from Bungie’s latest FPS game, Destiny 2. This game has been called an MMOFPS because it incorporates some aspects of the MMO genre. However, Bungie prefers to call it a “shared world” game because unlike a traditional MMO, in which a player can see and interact with literally any other player on a particular server, Destiny provides “on-the-fly match-making.” This permits the player to interact only with the other players with whom they have been matched by the server; this matchmaking system has been significantly improved for Destiny 2. Also unlike a traditional MMO, the graphics fidelity in Destiny 2 is on par with first- and third-person shooters.
图 1.11 显示了 Bungie 最新的 FPS 游戏《命运 2》的屏幕。这款游戏被称为 MMOFPS,因为它融合了 MMO 类型的某些方面。然而,Bungie 更愿意将其称为“共享世界”游戏,因为与传统的 MMO 不同,在传统的 MMO 中,玩家可以看到特定服务器上的任何其他玩家并与之互动,而《命运》提供了“即时匹配”。这允许玩家仅与服务器匹配的其他玩家进行交互; 《命运 2》的匹配系统得到了显着改进。与传统 MMO 不同的是,《命运 2》的图形保真度与第一人称和第三人称射击游戏不相上下。
We should note here that the game Player Unknown’s Battlegrounds (PUBG) has recently popularized a subgenre known as battle royale. This type of game blurs the line between regular multiplayer shooters and massively multiplayer online games, because they typically pit on the order of 100 players against each other in an online world, employing a survival-based “last man standing” gameplay style.
这里我们应该注意到,《绝地求生》(PUBG)游戏最近流行了一个被称为大逃杀的子类型。此类游戏模糊了常规多人射击游戏和大型多人在线游戏之间的界限,因为它们通常在在线世界中让 100 名左右的玩家相互对战,采用基于生存的“最后一人站立”游戏风格。
As social media takes off, games are becoming more and more collaborative in nature. A recent trend in game design is toward player-authored content. For example, Media Molecule’s LittleBigPlanet,™ LittleBigPlanet™ 2 (Figure 1.12) and LittleBigPlanet™ 3: The Journey Home are technically puzzle platformers, but their most notable and unique feature is that they encourage players to create, publish and share their own game worlds. Media Molecule’s latest installment in this engaging genre is Dreams for the PlayStation 4 (Figure 1.13).
随着社交媒体的兴起,游戏本质上变得越来越协作。游戏设计的最新趋势是玩家创作的内容。例如,Media Molecule 的《LittleBigPlanet》、《LittleBigPlanet™ 2》(图 1.12)和《LittleBigPlanet™ 3:The Journey Home》在技术上都是益智平台游戏,但它们最显着和最独特的功能是鼓励玩家创建、发布和分享自己的游戏世界。 Media Molecule 在这一引人入胜的类型中的最新作品是《Dreams for the PlayStation 4》(图 1.13)。
Perhaps the most popular game today in the player-created content genre is Minecraft (Figure 1.14). The brilliance of this game lies in its simplicity: Minecraft game worlds are constructed from simple cubic voxel-like elements mapped with low-resolution textures to mimic various materials. Blocks can be solid, or they can contain items such as torches, anvils, signs, fences and panes of glass. The game world is populated with one or more player characters, animals such as chickens and pigs, and various “mobs”—good guys like villagers and bad guys like zombies and the ubiquitous creepers who sneak up on unsuspecting players and explode (only scant moments after warning the player with the “hiss” of a burning fuse).
也许当今玩家创建的内容类型中最受欢迎的游戏是《我的世界》(图 1.14)。这款游戏的亮点在于它的简单性:《我的世界》游戏世界是由简单的立方体素类元素构建而成,这些元素映射有低分辨率纹理以模仿各种材质。方块可以是实心的,也可以包含火把、铁砧、标志、栅栏和玻璃板等物品。游戏世界中充满了一个或多个玩家角色、鸡和猪等动物以及各种“暴民”——好人如村民,坏人如僵尸,以及无处不在的爬行动物,它们偷偷靠近毫无戒心的玩家并爆炸(只有很短的时间)在用保险丝燃烧的“嘶嘶声”警告玩家之后)。
Players can create a randomized world in Minecraft and then dig into the generated terrain to create tunnels and caverns. They can also construct their own structures, ranging from simple terrain and foliage to vast and complex buildings and machinery. Perhaps the biggest stroke of genius in Minecraft is redstone. This material serves as “wiring,” allowing players to lay down circuitry that controls pistons, hoppers, mine carts and other dynamic elements in the game. As a result, players can create virtually anything they can imagine, and then share their worlds with their friends by hosting a server and inviting them to play online.
玩家可以在《我的世界》中创建一个随机世界,然后挖掘生成的地形来创建隧道和洞穴。他们还可以建造自己的结构,从简单的地形和树叶到巨大而复杂的建筑物和机械。也许《我的世界》中最大的天才之举就是红石。这种材料充当“线路”,允许玩家铺设控制活塞、料斗、矿车和游戏中其他动态元素的电路。因此,玩家几乎可以创造任何他们能想象到的东西,然后通过托管服务器并邀请他们在线玩游戏来与他们的朋友分享他们的世界。
Virtual, augmented and mixed reality are exciting new technologies that aim to immerse the viewer in a 3D world that is either entirely generated by a computer, or is augmented by computer-generated imagery. These technologies have many applications outside the game industry, but they have also become viable platforms for a wide range of gaming content.
虚拟现实、增强现实和混合现实是令人兴奋的新技术,旨在让观众沉浸在完全由计算机生成或由计算机生成图像增强的 3D 世界中。这些技术在游戏行业之外有许多应用,但它们也成为各种游戏内容的可行平台。
Virtual reality (VR) can be defined as an immersive multimedia or computer-simulated reality that simulates the user’s presence in an environment that is either a place in the real world or in an imaginary world. Computer-generated VR (CG VR) is a subset of this technology in which the virtual world is exclusively generated via computer graphics. The user views this virtual environment by donning a headset such as HTC Vive, Oculus Rift, Sony PlayStation VR, Samsung Gear VR or Google Daydream View. The headset displays the content directly in front of the user’s eyes; the system also tracks the movement of the headset in the real world, so that the virtual camera’s movements can be perfectly matched to those of the person wearing the headset. The user typically holds devices in his or her hands which allow the system to track the movements of each hand. This allows the user to interact in the virtual world: Objects can be pushed, picked up or thrown, for example.
虚拟现实 (VR) 可以定义为沉浸式多媒体或计算机模拟现实,模拟用户在现实世界或想象世界中的环境。计算机生成的 VR(CG VR)是该技术的一个子集,其中虚拟世界完全通过计算机图形生成。用户通过佩戴 HTC Vive、Oculus Rift、Sony PlayStation VR、Samsung Gear VR 或 Google Daydream View 等耳机来查看该虚拟环境。耳机将内容直接显示在用户眼前;该系统还跟踪耳机在现实世界中的运动,以便虚拟摄像机的运动可以与佩戴耳机的人的运动完美匹配。用户通常将设备握在手中,使系统能够跟踪每只手的运动。这允许用户在虚拟世界中进行交互:例如,可以推动、拾取或投掷物体。
The terms augmented reality (AR) and mixed reality (MR) are often confused or used interchangeably. Both technologies present the user with a view of the real world, but with computer graphics used to enhance the experience. In both technologies, a viewing device like a smart phone, tablet or tech-enhanced pair of glasses displays a real-time or static view of a real-world scene, and computer graphics are overlaid on top of this image. In real-time AR and MR systems, accelerometers in the viewing device permit the virtual camera’s movements to track the movements of the device, producing the illusion that the device is simply a window through which we are viewing the actual world, and hence giving the overlaid computer graphics a strong sense of realism.
增强现实(AR)和混合现实(MR)这两个术语经常被混淆或互换使用。这两种技术都向用户展示了现实世界的视图,但都使用计算机图形来增强体验。在这两种技术中,智能手机、平板电脑或技术增强型眼镜等查看设备都会显示现实世界场景的实时或静态视图,并将计算机图形叠加在该图像之上。在实时 AR 和 MR 系统中,观看设备中的加速计允许虚拟相机的运动跟踪设备的运动,产生设备只是我们观看现实世界的窗口的错觉,从而提供计算机图形叠加了强烈的写实感。
Some people make a distinction between these two technologies by using the term “augmented reality” to describe technologies in which computer graphics are overlaid on a live, direct or indirect view of the real world, but are not anchored to it. The term “mixed reality,” on the other hand, is more often applied to the use of computer graphics to render imaginary objects which are anchored to the real world and appear to exist within it. However, this distinction is by no means universally accepted.
有些人通过使用术语“增强现实”来描述计算机图形叠加在现实世界的实时、直接或间接视图上但不锚定于现实世界的技术来区分这两种技术。另一方面,术语“混合现实”更常应用于使用计算机图形来渲染锚定于现实世界并似乎存在于其中的想象对象。然而,这种区别决没有被普遍接受。
Here are a few examples of AR technology in action:
以下是 AR 技术的一些实际应用示例:
And here are a few examples of MR:
以下是 MR 的一些示例:
The game industry is currently experimenting with VR and AR/MR technologies, and is trying to find its footing within these new media. Some traditional 3D games have been “ported” to VR, yielding very interesting, if not particularly innovative, experiences. But perhaps more exciting, entirely new game genres are starting to emerge, offering gameplay experiences that could not be achieved without VR or AR/MR.
游戏行业目前正在尝试 VR 和 AR/MR 技术,并试图在这些新媒体中找到自己的立足点。一些传统的 3D 游戏已经被“移植”到 VR 上,产生了非常有趣(即使不是特别创新)的体验。但也许更令人兴奋的全新游戏类型正在开始出现,提供没有 VR 或 AR/MR 就无法实现的游戏体验。
For example, Job Simulator by Owlchemy Labs plunges the user into a virtual job museum run by robots, and asks them to perform tongue-in-cheek approximations of various real-world jobs, making use of game mechanics that simply wouldn’t work on a non-VR platform. Owlchemy’s next installment, Vacation Simulator, applies the same whimsical sense of humour and art style to a world in which the robots of Job Simulator invite the player to relax and perform various tasks. Figure 1.15 shows a screenshot from another innovative (and somewhat disturbing!) game for HTC Vive called Accounting, from the creators of “Rick & Morty” and The Stanley Parable.
例如,Owlchemy Labs 的工作模拟器将用户带入由机器人运行的虚拟工作博物馆,并要求他们玩笑地近似各种现实世界的工作,利用根本无法工作的游戏机制非 VR 平台。 Owlchemy 的下一部作品《假期模拟器》将同样异想天开的幽默感和艺术风格应用到了《工作模拟器》的机器人邀请玩家放松并执行各种任务的世界中。图 1.15 显示了 HTC Vive 的另一款创新游戏(有点令人不安!)的屏幕截图,名为 Accounting,由《Rick & Morty》和《斯坦利寓言》的创作者制作。
VR game engines are technologically similar in many respects to first-person shooter engines, and in fact many FPS-capable engines such as Unity and Unreal Engine support VR “out of the box.” However, VR games differ from FPS games in a number of significant ways:
VR 游戏引擎在许多方面与第一人称射击游戏引擎在技术上相似,事实上,许多支持 FPS 的引擎(例如 Unity 和 Unreal Engine)都支持“开箱即用”的 VR。然而,VR 游戏在许多方面与 FPS 游戏不同:
Of course, VR makes up for these limitations somewhat by enabling new user interaction paradigms that aren’t possible in traditional video games. For example,
当然,VR 通过启用传统视频游戏中不可能实现的新用户交互模式,在一定程度上弥补了这些限制。例如,
Games like Pokémon Go neither overlay graphics onto an image of the real world, nor do they generate a completely immersive virtual world. However, the user’s view of the computer-generated world of Pokémon Go does react to movements of the user’s phone or tablet, much like a 360-degree video. And the game is aware of your actual location in the real world, prompting you to go searching for Pokémon in nearby parks, malls and restaurants. This kind of game can’t really be called AR/MR, but neither does it fall into the VR category. Such a game might be better described as a form of location-based entertainment, although some people do use the AR moniker for these kinds of games.
像 Pokémon Go 这样的游戏既不会将图形叠加到现实世界的图像上,也不会生成完全身临其境的虚拟世界。然而,用户对 Pokémon Go 计算机生成世界的看法确实会对用户手机或平板电脑的移动做出反应,就像 360 度视频一样。游戏会知道你在现实世界中的实际位置,提示你去附近的公园、商场和餐馆寻找神奇宝贝。这种游戏确实不能称为AR/MR,但也不属于VR范畴。这种游戏可能更适合描述为一种基于位置的娱乐形式,尽管有些人确实使用 AR 绰号来形容此类游戏。
There are of course many other game genres which we won’t cover in depth here. Some examples include:
当然还有许多其他游戏类型,我们在这里不会深入介绍。一些例子包括:
and the list goes on.
而这样的例子不胜枚举。
We have seen that each game genre has its own particular technological requirements. This explains why game engines have traditionally differed quite a bit from genre to genre. However, there is also a great deal of technological overlap between genres, especially within the context of a single hardware platform. With the advent of more and more powerful hardware, differences between genres that arose because of optimization concerns are beginning to evaporate. It is therefore becoming increasingly possible to reuse the same engine technology across disparate genres, and even across disparate hardware platforms.
我们已经看到,每种游戏类型都有其特定的技术要求。这解释了为什么传统上游戏引擎在不同类型之间存在很大差异。然而,不同类型之间也存在大量技术重叠,特别是在单一硬件平台的背景下。随着越来越强大的硬件的出现,由于优化问题而产生的流派之间的差异开始消失。因此,在不同的类型、甚至不同的硬件平台上重复使用相同的引擎技术变得越来越可能。
The first 3D first-person shooter (FPS) game is generally accepted to be Castle Wolfenstein 3D (1992). Written by id Software of Texas for the PC platform, this game led the game industry in a new and exciting direction. id Software went on to create Doom, Quake, Quake II and Quake III. All of these engines are very similar in architecture, and I will refer to them as the Quake family of engines. Quake technology has been used to create many other games and even other engines. For example, the lineage of Medal of Honor for the PC platform goes something like this:
人们普遍认为第一款 3D 第一人称射击游戏 (FPS) 是《德军总部 3D》(Castle Wolfenstein 3D)(1992 年)。这款游戏由德克萨斯州的 id Software 为 PC 平台编写,引领游戏行业走向一个令人兴奋的新方向。 id Software 随后创建了《Doom》、《Quake》、《Quake II》和《Quake III》。所有这些引擎在架构上都非常相似,我将它们称为 Quake 系列引擎。 Quake 技术已被用于创建许多其他游戏,甚至其他引擎。例如,PC 平台的《荣誉勋章》的血统是这样的:
Many other games based on Quake technology follow equally circuitous paths through many different games and studios. In fact, Valve’s Source engine (used to create the Half-Life games) also has distant roots in Quake technology.
许多其他基于 Quake 技术的游戏也遵循同样迂回的路径,穿过许多不同的游戏和工作室。事实上,Valve 的 Source 引擎(用于创建《半条命》游戏)也与 Quake 技术有着悠久的渊源。
The Quake and Quake II source code is freely available, and the original Quake engines are reasonably well architected and “clean” (although they are of course a bit outdated and written entirely in C). These code bases serve as great examples of how industrial-strength game engines are built. The full source code to Quake and Quake II is available at https://github.com/id-Software/Quake-2.
Quake 和 Quake II 源代码是免费提供的,并且原始 Quake 引擎的架构相当良好并且“干净”(尽管它们当然有点过时并且完全用 C 编写)。这些代码库是如何构建工业级游戏引擎的绝佳示例。 Quake 和 Quake II 的完整源代码可在 https://github.com/id-Software/Quake-2 上获取。
If you own the Quake and/or Quake II games, you can actually build the code using Microsoft Visual Studio and run the game under the debugger using the real game assets from the disk. This can be incredibly instructive. You can set breakpoints, run the game and then analyze how the engine actually works by stepping through the code. I highly recommend downloading one or both of these engines and analyzing the source code in this manner.
如果您拥有 Quake 和/或 Quake II 游戏,您实际上可以使用 Microsoft Visual Studio 构建代码,并使用磁盘上的真实游戏资源在调试器下运行游戏。这非常有启发性。您可以设置断点,运行游戏,然后通过单步执行代码来分析引擎的实际工作原理。我强烈建议下载其中一个或两个引擎并以这种方式分析源代码。
Epic Games, Inc. burst onto the FPS scene in 1998 with its legendary game Unreal. Since then, the Unreal Engine has become a major competitor to Quake technology in the FPS space. Unreal Engine 2 (UE2) is the basis for Unreal Tournament 2004 (UT2004) and has been used for countless “mods,” university projects and commercial games. Unreal Engine 4 (UE4) is the latest evolutionary step, boasting some of the best tools and richest engine feature sets in the industry, including a convenient and powerful graphical user interface for creating shaders and a graphical user interface for game logic programming called Blueprints (previously known as Kismet).
Epic Games, Inc. 于 1998 年凭借其传奇游戏 Unreal 闯入 FPS 领域。从那时起,虚幻引擎就成为了 FPS 领域 Quake 技术的主要竞争对手。虚幻引擎 2 (UE2) 是《虚幻竞技场 2004》(UT2004) 的基础,并已用于无数“模组”、大学项目和商业游戏。虚幻引擎 4 (UE4) 是最新的进化步骤,拥有业界最好的工具和最丰富的引擎功能集,包括用于创建着色器的方便而强大的图形用户界面以及用于称为蓝图的游戏逻辑编程的图形用户界面(以前称为 Kismet)。
The Unreal Engine has become known for its extensive feature set and cohesive, easy-to-use tools. The Unreal Engine is not perfect, and most developers modify it in various ways to run their game optimally on a particular hardware platform. However, Unreal is an incredibly powerful prototyping tool and commercial game development platform, and it can be used to build virtually any 3D first-person or third-person game (not to mention games in other genres as well). Many exciting games in all sorts of genres have been developed with UE4, including Rime by Tequila Works, Genesis: Alpha One by Radiation Blue, A Way Out by Hazelight Studios, and Crackdown 3 by Microsoft Studios.
虚幻引擎以其广泛的功能集和内聚且易于使用的工具而闻名。虚幻引擎并不完美,大多数开发人员都会以各种方式对其进行修改,以便在特定的硬件平台上以最佳方式运行他们的游戏。然而,Unreal 是一个非常强大的原型设计工具和商业游戏开发平台,它几乎可以用来构建任何 3D 第一人称或第三人称游戏(更不用说其他类型的游戏)。许多令人兴奋的各种类型的游戏都是用 UE4 开发的,包括 Tequila Works 的 Rime、Radiation Blue 的 Genesis: Alpha One、Hazelight Studios 的 A Way Out 和 Microsoft Studios 的 Crackdown 3。
The Unreal Developer Network (UDN) provides a rich set of documentation and other information about all released versions of the Unreal Engine (see http://udn.epicgames.com/Main/WebHome.html). Some documentation is freely available. However, access to the full documentation for the latest version of the Unreal Engine is generally restricted to licensees of the engine. There are plenty of other useful websites and wikis that cover the Unreal Engine. One popular one is http://www.beyondunreal.com.
虚幻开发者网络 (UDN) 提供了有关虚幻引擎所有已发布版本的丰富文档和其他信息(请参阅 http://udn.epicgames.com/Main/WebHome.html)。一些文档是免费提供的。然而,访问最新版本虚幻引擎的完整文档通常仅限于该引擎的许可持有者。还有许多其他有用的网站和 wiki 涵盖了虚幻引擎。一种流行的方法是 http://www.beyondunreal.com。
Thankfully, Epic now offers full access to Unreal Engine 4, source code and all, for a low monthly subscription fee plus a cut of your game’s profits if it ships. This makes UE4 a viable choice for small independent game studios.
值得庆幸的是,Epic 现在提供对虚幻引擎 4、源代码和所有内容的完全访问,只需支付较低的月订阅费,再加上游戏发行后的利润分成。这使得 UE4 成为小型独立游戏工作室的可行选择。
Source is the game engine that drives the well-known Half-Life 2 and its sequels HL2: Episode One and HL2: Episode Two, Team Fortress 2 and Portal (shipped together under the title The Orange Box). Source is a high-quality engine, rivaling Unreal Engine 4 in terms of graphics capabilities and tool set.
Source 是驱动著名的《半条命 2》及其续集《HL2:第一集》和《HL2:第二集》、《军团要塞 2》和《传送门》(以 The Orange Box 为标题一起发行)的游戏引擎。 Source 是一款高质量引擎,在图形功能和工具集方面可与虚幻引擎 4 相媲美。
The Frostbite engine grew out of DICE’s efforts to create a game engine for Battlefield Bad Company in 2006. Since then, the Frostbite engine has become the most widely adopted engine within Electronic Arts (EA); it is used by many of EA’s key franchises including Mass Effect, Battlefield, Need for Speed, Dragon Age, and Star Wars Battlefront II. Frostbite boasts a powerful unified asset creation tool called FrostEd, a powerful tools pipeline known as Backend Services, and a powerful runtime game engine. It is a proprietary engine, so it’s unfortunately unavailable for use by developers outside EA.
Frostbite 引擎源于 DICE 在 2006 年为 Battlefield Bad Company 创建游戏引擎的努力。从那时起,Frostbite 引擎已成为 Electronic Arts (EA) 内采用最广泛的引擎; EA 的许多主要系列游戏都使用它,包括《质量效应》、《战地》、《极品飞车》、《龙腾世纪》和《星球大战:前线 II》。 Frostbite 拥有一个名为 FrostEd 的强大统一资产创建工具、一个名为后端服务的强大工具管道以及一个强大的运行时游戏引擎。它是一个专有引擎,因此不幸的是 EA 之外的开发人员无法使用它。
RAGE is the engine that drives the insanely popular Grand Theft Auto V. Developed by RAGE Technology Group, a division of Rockstar Games’ Rockstar San Diego studio, RAGE has been used by Rockstar Games’ internal studios to develop games for PlayStation 4, Xbox One, PlayStation 3, Xbox 360, Wii, Windows, and MacOS. Other games developed on this proprietary engine include Grand Theft Auto IV, Red Dead Redemption and Max Payne 3.
RAGE 是驱动极受欢迎的 Grand Theft Auto V 的引擎。由 RAGE Technology Group(Rockstar Games 的 Rockstar San Diego 工作室的一个部门)开发,RAGE 已被 Rockstar Games 的内部工作室用来开发 PlayStation 4、Xbox One 的游戏、PlayStation 3、Xbox 360、Wii、Windows 和 MacOS。使用该专有引擎开发的其他游戏包括 Grand Theft Auto IV、Red Dead Redemption 和 Max Payne 3。
Crytek originally developed their powerful game engine known as CRYENGINE as a tech demo for NVIDIA. When the potential of the technology was recognized, Crytek turned the demo into a complete game and Far Cry was born. Since then, many games have been made with CRYENGINE including Crysis, Codename Kingdoms, Ryse: Son of Rome, and Everyone’s Gone to the Rapture. Over the years the engine has evolved into what is now Crytek’s latest offering, CRYENGINE V. This powerful game development platform offers a powerful suite of asset-creation tools and a feature-rich runtime engine featuring high-quality real-time graphics. CRYENGINE can be used to make games targeting a wide range of platforms including Xbox One, Xbox 360, PlayStation 4, PlayStation 3, Wii U, Linux, iOS and Android.
Crytek 最初开发了名为 CRYENGINE 的强大游戏引擎,作为 NVIDIA 的技术演示。当这项技术的潜力得到认可后,Crytek 将演示版变成了一款完整的游戏,《孤岛惊魂》由此诞生。从那时起,许多游戏都是用 CRYENGINE 制作的,包括《孤岛危机》、《代号王国》、《崛起:罗马之子》和《Everybody’s Gone to the Rapture》。多年来,该引擎已发展成为 Crytek 的最新产品 CRYENGINE V。这个强大的游戏开发平台提供了一套强大的资产创建工具和功能丰富的运行时引擎,具有高质量的实时图形。 CRYENGINE 可用于制作针对多种平台的游戏,包括 Xbox One、Xbox 360、PlayStation 4、PlayStation 3、Wii U、Linux、iOS 和 Android。
In an effort to make developing games for Sony’s PlayStation 3 platform more accessible, Sony introduced PhyreEngine at the Game Developer’s Conference (GDC) in 2008. As of 2013, PhyreEngine has evolved into a powerful and full-featured game engine, supporting an impressive array of features including advanced lighting and deferred rendering. It has been used by many studios to build over 90 published titles, including thatgamecompany’s hits flOw, Flower and Journey, and Coldwood Interactive’s Unravel. PhyreEngine now supports Sony’s PlayStation 4, PlayStation 3, PlayStation 2, PlayStation Vita and PSP platforms. PhyreEngine gives developers access to the power of the highly parallel Cell architecture on PS3 and the advanced compute capabilities of the PS4, along with a streamlined new world editor and other powerful game development tools. It is available free of charge to any licensed Sony developer as part of the PlayStation SDK.
为了让索尼 PlayStation 3 平台的游戏开发变得更容易,索尼在 2008 年的游戏开发者大会 (GDC) 上推出了 PhyreEngine。截至 2013 年,PhyreEngine 已发展成为一个强大且功能齐全的游戏引擎,支持令人印象深刻的阵列功能包括高级照明和延迟渲染。它已被许多工作室用来制作超过 90 款已发行的游戏,包括 thatgamecompany 的热门游戏《flOw》、《Flower and Journey》以及 Coldwood Interactive 的《Unravel》。 PhyreEngine 现在支持索尼的 PlayStation 4、PlayStation 3、PlayStation 2、PlayStation Vita 和 PSP 平台。 PhyreEngine 使开发人员能够利用 PS3 上高度并行 Cell 架构的强大功能和 PS4 的高级计算功能,以及简化的新世界编辑器和其他强大的游戏开发工具。作为 PlayStation SDK 的一部分,任何获得许可的索尼开发者都可以免费使用它。
Microsoft’s XNA Game Studio is an easy-to-use and highly accessible game development platform based on the C# language and the Common Language Runtime (CLR), and aimed at encouraging players to create their own games and share them with the online gaming community, much as YouTube encourages the creation and sharing of home-made videos.
微软的XNA Game Studio是一个易于使用且高度可访问的游戏开发平台,基于C#语言和公共语言运行时(CLR),旨在鼓励玩家创建自己的游戏并与在线游戏社区分享,就像 YouTube 鼓励创作和分享自制视频一样。
For better or worse, Microsoft officially retired XNA in 2014. However, developers can port their XNA games to iOS, Android, Mac OS X, Linux and Windows 8 Metro via an open-source implementation of XNA called MonoGame. For more details, see https://www.windowscentral.com/xnadead-long-live-xna.
无论好坏,微软于 2014 年正式退役了 XNA。不过,开发人员可以通过名为 MonoGame 的 XNA 开源实现将他们的 XNA 游戏移植到 iOS、Android、Mac OS X、Linux 和 Windows 8 Metro。有关更多详细信息,请参阅 https://www.windowscentral.com/xnadead-long-live-xna。
Unity is a powerful cross-platform game development environment and runtime engine supporting a wide range of platforms. Using Unity, developers can deploy their games on mobile platforms (e.g., Apple iOS, Google Android), consoles (Microsoft Xbox 360 and Xbox One, Sony PlayStation 3 and PlayStation 4, and Nintendo Wii, Wii U), handheld gaming platforms (e.g., Playstation Vita, Nintendo Switch), desktop computers (Microsoft Windows, Apple Macintosh and Linux), TV boxes (e.g., Android TV and tvOS) and virtual reality (VR) systems (e.g., Oculus Rift, Steam VR, Gear VR).
Unity是一个强大的跨平台游戏开发环境和运行时引擎,支持广泛的平台。使用 Unity,开发人员可以在移动平台(例如 Apple iOS、Google Android)、游戏机(Microsoft Xbox 360 和 Xbox One、Sony PlayStation 3 和 PlayStation 4、Nintendo Wii、Wii U)、手持游戏平台(例如、Playstation Vita、Nintendo Switch)、台式电脑(Microsoft Windows、Apple Macintosh 和 Linux)、电视盒(例如 Android TV 和 tvOS)和虚拟现实 (VR) 系统(例如 Oculus Rift、Steam VR、Gear VR)。
Unity’s primary design goals are ease of development and cross-platform game deployment. As such, Unity provides an easy-to-use integrated editor environment, in which you can create and manipulate the assets and entities that make up your game world and quickly preview your game in action right there in the editor, or directly on your target hardware. Unity also provides a powerful suite of tools for analyzing and optimizing your game on each target platform, a comprehensive asset conditioning pipeline, and the ability to manage the performance-quality trade-off uniquely on each deployment platform. Unity supports scripting in JavaScript, C# or Boo; a powerful animation system supporting animation retargeting (the ability to play an animation authored for one character on a totally different character); and support for networked multiplayer games.
Unity 的主要设计目标是易于开发和跨平台游戏部署。因此,Unity 提供了一个易于使用的集成编辑器环境,您可以在其中创建和操作构成游戏世界的资产和实体,并在编辑器中或直接在目标上快速预览游戏的运行情况硬件。 Unity 还提供了一套强大的工具来分析和优化每个目标平台上的游戏、全面的资产调节管道以及在每个部署平台上独特地管理性能质量权衡的能力。 Unity 支持 JavaScript、C# 或 Boo 脚本编写;强大的动画系统,支持动画重定向(能够在完全不同的角色上播放为一个角色创作的动画);并支持网络多人游戏。
Unity has been used to create a wide variety of published games, including Deus Ex: The Fall by N-Fusion/Eidos Montreal, Hollow Knight by Team Cherry, and the subversive retro-style Cuphead by StudioMDHR. The Webby Award winning short film Adam was rendered in real time using Unity.
Unity 已被用于创建各种已发行的游戏,包括 N-Fusion/Eidos Montréal 的《Deus Ex: The Fall》、Team Cherry 的《Hollow Knight》以及 StudioMDHR 的颠覆性复古风格 Cuphead。威比奖获奖短片 Adam 是使用 Unity 实时渲染的。
There are lots of other commercial game engines out there. Although indie developers may not have the budget to purchase an engine, many of these products have great online documentation and/or wikis that can serve as a great source of information about game engines and game programming in general. For example, check out the Tombstone engine (http://tombstoneengine.com/) by Terathon Software, the LeadWerks engine (https://www.leadwerks.com/), and HeroEngine by Idea Fabrik, PLC (http://www.heroengine.com/).
还有许多其他商业游戏引擎。尽管独立开发人员可能没有购买引擎的预算,但其中许多产品都有出色的在线文档和/或维基,可以作为有关游戏引擎和游戏编程的重要信息来源。例如,查看 Terathon Software 的 Tombstone 引擎 (http://tombstoneengine.com/)、LeadWerks 引擎 (https://www.leadwerks.com/) 以及 Idea Fabrik, PLC 的 HeroEngine (http:// www.heroengine.com/)。
Many companies build and maintain proprietary in-house game engines. Electronic Arts built many of its RTS games on a proprietary engine called Sage, developed at Westwood Studios. Naughty Dog’s Crash Bandicoot and Jak and Daxter franchises were built on a proprietary engine custom tailored to the PlayStation and PlayStation 2. For the Uncharted series, Naughty Dog developed a brand new engine custom tailored to the PlayStation 3 hardware. This engine evolved and was ultimately used to create Naughty Dog’s The Last of Us series on the PlayStation 3 and PlayStation 4, as well as its most recent releases, Uncharted 4: A Thief’s End and Uncharted: The Lost Legacy. And of course, most commercially licensed game engines like Quake, Source, Unreal Engine 4 and CRYENGINE all started out as proprietary in-house engines.
许多公司构建并维护专有的内部游戏引擎。 Electronic Arts 在 Westwood Studios 开发的名为 Sage 的专有引擎上构建了许多 RTS 游戏。 Naughty Dog 的 Crash Bandicoot 和 Jak and Daxter 系列是建立在专为 PlayStation 和 PlayStation 2 定制的专有引擎之上的。对于《神秘海域》系列,Naughty Dog 开发了专为 PlayStation 3 硬件定制的全新引擎。该引擎不断发展,最终被用于在 PlayStation 3 和 PlayStation 4 上制作 Naughty Dog 的《最后生还者》系列,以及最新发行的《神秘海域 4:盗贼末路》和《神秘海域:失落的遗产》。当然,大多数商业授权的游戏引擎,如 Quake、Source、Unreal Engine 4 和 CRYENGINE 都是从专有的内部引擎开始的。
Open source 3D game engines are engines built by amateur and professional game developers and provided online for free. The term “open source” typically implies that source code is freely available and that a somewhat open development model is employed, meaning almost anyone can contribute code. Licensing, if it exists at all, is often provided under the Gnu Public License (GPL) or Lesser Gnu Public License (LGPL). The former permits code to be freely used by anyone, as long as their code is also freely available; the latter allows the code to be used even in proprietary for-profit applications. Lots of other free and semi-free licensing schemes are also available for open source projects.
开源 3D 游戏引擎是由业余和专业游戏开发人员构建并免费在线提供的引擎。 “开源”一词通常意味着源代码可以免费获得,并且采用某种程度开放的开发模型,这意味着几乎任何人都可以贡献代码。许可(如果存在)通常是根据 Gnu 公共许可证 (GPL) 或 Lesser Gnu 公共许可证 (LGPL) 提供的。前者允许任何人自由使用代码,只要他们的代码也是免费可用的;后者甚至允许在专有的营利性应用程序中使用代码。许多其他免费和半免费许可方案也可用于开源项目。
There are a staggering number of open source engines available on the web. Some are quite good, some are mediocre and some are just plain awful! The list of game engines provided online at http://en.wikipedia.org/wiki/List_of_game_engines will give you a feel for the sheer number of engines that are out there. (The list at http://www.worldofleveldesign.com/categories/level_design_tutorials/recommended-game-engines.php is a bit more digestible.) Both of these lists include both open-source and commercial game engines.
网络上有数量惊人的开源引擎。有些非常好,有些很平庸,有些简直太糟糕了! http://en.wikipedia.org/wiki/List_of_game_engines 在线提供的游戏引擎列表将让您感受到现有引擎的绝对数量。 (http://www.worldofleveldesign.com/categories/level_design_tutorials/recommished-game-engines.php 上的列表更容易理解。)这两个列表都包含开源和商业游戏引擎。
OGRE is a well-architected, easy-to-learn and easy-to-use 3D rendering engine. It boasts a fully featured 3D renderer including advanced lighting and shadows, a good skeletal character animation system, a two-dimensional overlay system for heads-up displays and graphical user interfaces, and a post-processing system for full-screen effects like bloom. OGRE is, by its authors’ own admission, not a full game engine, but it does provide many of the foundational components required by pretty much any game engine.
OGRE是一个架构良好、易学易用的3D渲染引擎。它拥有功能齐全的 3D 渲染器,包括先进的光照和阴影、良好的骨骼角色动画系统、用于平视显示器和图形用户界面的二维叠加系统,以及用于全屏效果(如绽放)的后处理系统。作者自己承认,OGRE 并不是一个完整的游戏引擎,但它确实提供了几乎所有游戏引擎所需的许多基础组件。
Some other well-known open source engines are listed here:
这里列出了其他一些知名的开源引擎:
Two-dimensional games have become incredibly popular with the recent explosion of casual web gaming and mobile gaming on platforms like Apple iPhone/iPad and Google Android. A number of popular game/multimedia authoring toolkits have become available, enabling small game studios and independent developers to create 2D games for these platforms. These toolkits emphasize ease of use and allow users to employ a graphical user interface to create a game rather than requiring the use of a programming language. Check out this YouTube video to get a feel for the kinds of games you can create with these toolkits: https://www.youtube.com/watch?v=3Zq1yo0lxOU
随着最近 Apple iPhone/iPad 和 Google Android 等平台上休闲网页游戏和手机游戏的爆炸式增长,二维游戏变得异常受欢迎。许多流行的游戏/多媒体创作工具包已经可用,使小型游戏工作室和独立开发者能够为这些平台创建 2D 游戏。这些工具包强调易用性,允许用户使用图形用户界面来创建游戏,而不需要使用编程语言。观看此 YouTube 视频,了解可以使用这些工具包创建的游戏类型:https://www.youtube.com/watch?v=3Zq1yo0lxOU
A game engine generally consists of a tool suite and a runtime component. We’ll explore the architecture of the runtime piece first and then get into tool architecture in the following section.
游戏引擎通常由工具套件和运行时组件组成。我们将首先探索运行时部分的架构,然后在下一节中讨论工具架构。
Figure 1.16 shows all of the major runtime components that make up a typical 3D game engine. Yeah, it’s big! And this diagram doesn’t even account for all the tools. Game engines are definitely large software systems.
图 1.16 显示了构成典型 3D 游戏引擎的所有主要运行时组件。是的,它很大!这张图甚至没有考虑到所有的工具。游戏引擎绝对是大型软件系统。
Like all software systems, game engines are built in layers. Normally upper layers depend on lower layers, but not vice versa. When a lower layer depends upon a higher layer, we call this a circular dependency. Dependency cycles are to be avoided in any software system, because they lead to undesirable coupling between systems, make the software untestable and inhibit code reuse. This is especially true for a large-scale system like a game engine.
与所有软件系统一样,游戏引擎也是分层构建的。通常上层依赖于下层,但反之则不然。当较低层依赖于较高层时,我们将其称为循环依赖。在任何软件系统中都应该避免依赖循环,因为它们会导致系统之间的不良耦合,使软件无法测试并抑制代码重用。对于像游戏引擎这样的大型系统尤其如此。
What follows is a brief overview of the components shown in the diagram in Figure 1.16. The rest of this book will be spent investigating each of these components in a great deal more depth and learning how these components are usually integrated into a functional whole.
下面是图 1.16 中所示组件的简要概述。本书的其余部分将更深入地研究每个组件,并了解这些组件通常如何集成到一个功能整体中。
The target hardware layer represents the computer system or console on which the game will run. Typical platforms include Microsoft Windows, Linux and MacOS-based PCs; mobile platforms like the Apple iPhone and iPad, Android smart phones and tablets, Sony’s PlayStation Vita and Amazon’s Kindle Fire (among others); and game consoles like Microsoft’s Xbox, Xbox 360 and Xbox One, Sony’s PlayStation, PlayStation 2, PlayStation 3 and PlayStation 4, and Nintendo’s DS, GameCube, Wii, Wii U and Switch. Most of the topics in this book are platform-agnostic, but we’ll also touch on some of the design considerations peculiar to PC or console development, where the distinctions are relevant.
目标硬件层代表游戏将在其上运行的计算机系统或控制台。典型平台包括基于 Microsoft Windows、Linux 和 MacOS 的 PC;移动平台,如 Apple iPhone 和 iPad、Android 智能手机和平板电脑、索尼 PlayStation Vita 和亚马逊 Kindle Fire(等等);以及微软的 Xbox、Xbox 360 和 Xbox One 等游戏机,索尼的 PlayStation、PlayStation 2、PlayStation 3 和 PlayStation 4,以及任天堂的 DS、GameCube、Wii、Wii U 和 Switch。本书中的大多数主题与平台无关,但我们也会涉及一些 PC 或控制台开发特有的设计注意事项,其中的区别是相关的。
Device drivers are low-level software components provided by the operating system or hardware vendor. Drivers manage hardware resources and shield the operating system and upper engine layers from the details of communicating with the myriad variants of hardware devices available.
设备驱动程序是操作系统或硬件供应商提供的低级软件组件。驱动程序管理硬件资源,并保护操作系统和上层引擎层免受与各种可用硬件设备通信的细节的影响。
On a PC, the operating system (OS) is running all the time. It orchestrates the execution of multiple programs on a single computer, one of which is your game. Operating systems like Microsoft Windows employ a time-sliced approach to sharing the hardware with multiple running programs, known as preemptive multitasking. This means that a PC game can never assume it has full control of the hardware—it must “play nice” with other programs in the system.
在 PC 上,操作系统 (OS) 始终运行。它协调在一台计算机上执行多个程序,其中之一就是您的游戏。 Microsoft Windows 等操作系统采用时间切片方法与多个正在运行的程序共享硬件,称为抢占式多任务处理。这意味着 PC 游戏永远不能假设它完全控制硬件——它必须与系统中的其他程序“很好地合作”。
On early consoles, the operating system, if one existed at all, was just a thin library layer that was compiled directly into your game executable. On those early systems, the game “owned” the entire machine while it was running. However, on modern consoles this is no longer the case. The operating system on the Xbox 360, PlayStation 3, Xbox One and PlayStation 4 can interrupt the execution of your game, or take over certain system resources, in order to display online messages, or to allow the player to pause the game and bring up the PS4’s “XMB” user interface or the Xbox One’s dashboard, for example. On the PS4 and Xbox One, the OS is continually running background tasks, such as recording video of your playthrough in case you decide to share it via the PS4’s Share button, or downloading games, patches and DLC, so you can have fun playing a game while you wait. So the gap between console and PC development is gradually closing (for better or for worse).
在早期的游戏机上,操作系统(如果存在的话)只是一个薄的库层,直接编译到游戏可执行文件中。在那些早期的系统上,游戏在运行时“拥有”整个机器。然而,在现代游戏机上,情况已不再如此。 Xbox 360、PlayStation 3、Xbox One 和 PlayStation 4 上的操作系统可以中断游戏的执行,或接管某些系统资源,以便显示在线消息,或允许玩家暂停游戏并调出例如,PS4 的“XMB”用户界面或 Xbox One 的仪表板。在 PS4 和 Xbox One 上,操作系统会持续运行后台任务,例如录制游戏过程的视频,以便您决定通过 PS4 的共享按钮共享它,或者下载游戏、补丁和 DLC,以便您可以享受玩游戏的乐趣。等待时玩游戏。因此,主机和 PC 开发之间的差距正在逐渐缩小(无论好坏)。
Most game engines leverage a number of third-party software development kits (SDKs) and middleware, as shown in Figure 1.17. The functional or class-based interface provided by an SDK is often called an application programming interface (API). We will look at a few examples.
大多数游戏引擎都利用许多第三方软件开发工具包(SDK)和中间件,如图 1.17 所示。 SDK 提供的功能或基于类的接口通常称为应用程序编程接口 (API)。我们将看几个例子。
Like any software system, games depend heavily on container data structures and algorithms to manipulate them. Here are a few examples of third-party libraries that provide these kinds of services:
与任何软件系统一样,游戏在很大程度上依赖于容器数据结构和算法来操纵它们。以下是提供此类服务的第三方库的一些示例:
The C++ standard library also provides many of the same kinds of facilities found in third-party libraries like Boost. The subset of the standard library that implements generic container classes such as std::vector and std::list is often referred to as the standard template library (STL), although this is technically a bit of a misnomer: The standard template library was written by Alexander Stepanov and David Musser in the days before the C++ language was standardized. Much of this library’s functionality was absorbed into what is now the C++ standard library. When we use the term STL in this book, it’s usually in the context of the subset of the C++ standard library that provides generic container classes, not the original STL.
C++ 标准库还提供了许多与 Boost 等第三方库中相同类型的工具。实现通用容器类(例如 std::vector 和 std::list )的标准库子集通常称为标准模板库 (STL),尽管这在技术上有点用词不当:标准模板库是由 Alexander Stepanov 和 David Musser 在 C++ 语言标准化之前编写的。该库的大部分功能都被吸收到了现在的 C++ 标准库中。当我们在本书中使用术语 STL 时,通常是在提供通用容器类的 C++ 标准库子集的上下文中,而不是原始的 STL。
Most game rendering engines are built on top of a hardware interface library, such as the following:
大多数游戏渲染引擎都构建在硬件接口库之上,如下所示:
Collision detection and rigid body dynamics (known simply as “physics” in the game development community) are provided by the following well-known SDKs:
碰撞检测和刚体动力学(在游戏开发社区中简称为“物理”)由以下知名 SDK 提供:
A number of commercial animation packages exist, including but certainly not limited to the following:
存在许多商业动画包,包括但不限于以下内容:
As we mentioned previously, the line between character animation and physics is beginning to blur. Packages like Havok Animation try to marry physics and animation in a traditional manner, with a human animator providing the majority of the motion through a tool like Maya and with physics augmenting that motion at runtime. But a firm called Natural Motion Ltd. has produced a product that attempts to redefine how character motion is handled in games and other forms of digital media.
正如我们之前提到的,角色动画和物理之间的界限开始变得模糊。 Havok Animation 等软件包尝试以传统方式将物理和动画结合起来,由人类动画师通过 Maya 等工具提供大部分运动,并在运行时通过物理增强该运动。但一家名为 Natural Motion Ltd. 的公司生产了一款产品,试图重新定义游戏和其他形式的数字媒体中角色运动的处理方式。
Its first product, Endorphin, is a Maya plug-in that permits animators to run full biomechanical simulations on characters and export the resulting animations as if they had been hand animated. The biomechanical model accounts for center of gravity, the character’s weight distribution, and detailed knowledge of how a real human balances and moves under the influence of gravity and other forces.
它的第一个产品 Endorphin 是一个 Maya 插件,允许动画师对角色运行完整的生物力学模拟,并导出生成的动画,就像它们是手工制作的动画一样。生物力学模型考虑了重心、角色的体重分布,以及真实人类如何在重力和其他力的影响下保持平衡和移动的详细知识。
Its second product, Euphoria, is a real-time version of Endorphin intended to produce physically and biomechanically accurate character motion at runtime under the influence of unpredictable forces.
它的第二个产品 Euphoria 是 Endorphin 的实时版本,旨在在运行时在不可预测的力的影响下产生物理和生物力学上准确的角色运动。
Most game engines are required to be capable of running on more than one hardware platform. Companies like Electronic Arts and ActivisionBlizzard Inc., for example, always target their games at a wide variety of platforms because it exposes their games to the largest possible market. Typically, the only game studios that do not target at least two different platforms per game are first-party studios, like Sony’s Naughty Dog and Insomniac studios. Therefore, most game engines are architected with a platform independence layer, like the one shown in Figure 1.18. This layer sits atop the hardware, drivers, operating system and other third-party software and shields the rest of the engine from the majority of knowledge of the underlying platform by “wrapping” certain interface functions in custom functions over which you, the game developer, will have control on every target platform.
大多数游戏引擎都需要能够在多个硬件平台上运行。例如,Electronic Arts 和 ActivisionBlizzard Inc. 等公司总是将其游戏瞄准各种平台,因为这样可以将其游戏暴露在尽可能大的市场中。通常情况下,唯一不针对每个游戏至少两个不同平台的游戏工作室是第一方工作室,例如索尼的 Naughty Dog 和 Insomniac 工作室。因此,大多数游戏引擎的架构都具有平台独立层,如图 1.18 所示。该层位于硬件、驱动程序、操作系统和其他第三方软件之上,并通过将某些接口函数“包装”在游戏开发人员所使用的自定义函数中,保护引擎的其余部分免受底层平台的大部分知识的影响。 ,将控制每个目标平台。
There are two primary reasons to “wrap” functions as part of your game engine’s platform independence layer like this: First, some application programming interfaces (APIs), like those provided by the operating system, or even some functions in older “standard” libraries like the C standard library, differ significantly from platform to platform; wrapping these functions provides the rest of your engine with a consistent API across all of your targeted platforms. Second, even when using a fully cross-platform library such as Havok, you might want to insulate yourself from future changes, such as transitioning your engine to a different collision/physics library in the future.
将函数“包装”为游戏引擎平台独立层的一部分有两个主要原因:首先,一些应用程序编程接口(API),例如操作系统提供的接口,甚至是旧“标准”库中的某些函数与 C 标准库一样,不同平台之间存在显着差异;包装这些函数可为引擎的其余部分提供跨所有目标平台的一致 API。其次,即使使用完全跨平台的库(例如 Havok),您也可能希望将自己与未来的变化隔离开来,例如将来将引擎转换到不同的碰撞/物理库。
Every game engine, and really every large, complex C++ software application, requires a grab bag of useful software utilities. We’ll categorize these under the label “core systems.” A typical core systems layer is shown in Figure 1.19. Here are a few examples of the facilities the core layer usually provides:
每个游戏引擎,以及实际上每个大型、复杂的 C++ 软件应用程序,都需要大量有用的软件实用程序。我们将把它们分类在“核心系统”标签下。典型的核心系统层如图 1.19 所示。以下是核心层通常提供的一些设施的示例:
A detailed discussion of the most common core engine systems can be found in Part II.
最常见的核心引擎系统的详细讨论可以在第二部分中找到。
Present in every game engine in some form, the resource manager provides a unified interface (or suite of interfaces) for accessing any and all types of game assets and other engine input data. Some engines do this in a highly centralized and consistent manner (e.g., Unreal’s packages, OGRE’s Resource-Manager class). Other engines take an ad hoc approach, often leaving it up to the game programmer to directly access raw files on disk or within compressed archives such as Quake’s PAK files. A typical resource manager layer is depicted in Figure 1.20.
资源管理器以某种形式存在于每个游戏引擎中,提供统一的接口(或接口套件),用于访问任何和所有类型的游戏资产和其他引擎输入数据。一些引擎以高度集中和一致的方式执行此操作(例如,Unreal 的包、OGRE 的 Resource-Manager 类)。其他引擎采用临时方法,通常由游戏程序员直接访问磁盘上的原始文件或压缩档案(例如 Quake 的 PAK 文件)中的原始文件。典型的资源管理器层如图 1.20 所示。
The rendering engine is one of the largest and most complex components of any game engine. Renderers can be architected in many different ways. There is no one accepted way to do it, although as we’ll see, most modern rendering engines share some fundamental design philosophies, driven in large part by the design of the 3D graphics hardware upon which they depend.
渲染引擎是任何游戏引擎中最大、最复杂的组件之一。渲染器可以通过多种不同的方式构建。尽管我们将看到,大多数现代渲染引擎都共享一些基本的设计理念,但在很大程度上是由它们所依赖的 3D 图形硬件的设计驱动的,但没有一种公认的方法可以做到这一点。
One common and effective approach to rendering engine design is to employ a layered architecture as follows.
渲染引擎设计的一种常见且有效的方法是采用如下分层架构。
The low-level renderer, shown in Figure 1.21, encompasses all of the raw rendering facilities of the engine. At this level, the design is focused on rendering a collection of geometric primitives as quickly and richly as possible, without much regard for which portions of a scene may be visible. This component is broken into various subcomponents, which are discussed below.
低级渲染器(如图 1.21 所示)包含引擎的所有原始渲染工具。在这个级别,设计的重点是尽可能快速、丰富地渲染几何图元的集合,而不太考虑场景的哪些部分可能是可见的。该组件分为多个子组件,下面将对此进行讨论。
Graphics SDKs, such as DirectX, OpenGL or Vulkan, require a reasonable amount of code to be written just to enumerate the available graphics devices, initialize them, set up render surfaces (back-buffer, stencil buffer, etc.) and so on. This is typically handled by a component that I’ll call the graphics device interface (although every engine uses its own terminology).
图形 SDK(例如 DirectX、OpenGL 或 Vulkan)需要编写合理数量的代码来枚举可用的图形设备、初始化它们、设置渲染表面(后台缓冲区、模板缓冲区等)等。这通常由我称之为图形设备接口的组件处理(尽管每个引擎都使用自己的术语)。
For a PC game engine, you also need code to integrate your renderer with the Windows message loop. You typically write a “message pump” that services Windows messages when they are pending and otherwise runs your render loop over and over as fast as it can. This ties the game’s keyboard polling loop to the renderer’s screen update loop. This coupling is undesirable, but with some effort it is possible to minimize the dependencies. We’ll explore this topic in more depth later.
对于 PC 游戏引擎,您还需要代码将渲染器与 Windows 消息循环集成。您通常会编写一个“消息泵”,在 Windows 消息待处理时为其提供服务,否则会尽可能快地一遍又一遍地运行渲染循环。这将游戏的键盘轮询循环与渲染器的屏幕更新循环联系起来。这种耦合是不受欢迎的,但通过一些努力,可以最大限度地减少依赖性。稍后我们将更深入地探讨这个主题。
The other components in the low-level renderer cooperate in order to collect submissions of geometric primitives (sometimes called render packets), such as meshes, line lists, point lists, particles, terrain patches, text strings and whatever else you want to draw, and render them as quickly as possible.
低级渲染器中的其他组件进行协作,以收集提交的几何图元(有时称为渲染数据包),例如网格、线列表、点列表、粒子、地形块、文本字符串以及您想要绘制的任何其他内容,并尽快渲染它们。
The low-level renderer usually provides a viewport abstraction with an associated camera-to-world matrix and 3D projection parameters, such as field of view and the location of the near and far clip planes. The low-level renderer also manages the state of the graphics hardware and the game’s shaders via its material system and its dynamic lighting system. Each submitted primitive is associated with a material and is affected by n dynamic lights. The material describes the texture(s) used by the primitive, what device state settings need to be in force, and which vertex and pixel shader to use when rendering the primitive. The lights determine how dynamic lighting calculations will be applied to the primitive. Lighting and shading is a complex topic. We’ll discuss the fundamentals in Chapter 11, but these topics are covered in depth in many excellent books on computer graphics, including [16], [49] and [2].
低级渲染器通常提供视口抽象以及关联的相机到世界矩阵和 3D 投影参数,例如视场以及近剪裁平面和远剪裁平面的位置。低级渲染器还通过其材质系统和动态光照系统来管理图形硬件和游戏着色器的状态。每个提交的图元都与一个材质相关联,并受到 n 个动态灯光的影响。该材质描述了图元使用的纹理、需要生效的设备状态设置以及渲染图元时要使用的顶点和像素着色器。灯光决定动态光照计算如何应用于图元。照明和阴影是一个复杂的话题。我们将在第 11 章中讨论基础知识,但许多优秀的计算机图形学书籍都深入介绍了这些主题,包括 [16]、[49] 和 [2]。
The low-level renderer draws all of the geometry submitted to it, without much regard for whether or not that geometry is actually visible (other than back-face culling and clipping triangles to the camera frustum). A higher-level component is usually needed in order to limit the number of primitives submitted for rendering, based on some form of visibility determination. This layer is shown in Figure 1.22.
低级渲染器绘制提交给它的所有几何图形,而不考虑该几何图形是否实际上可见(除了背面剔除和将三角形裁剪到相机平截头体之外)。通常需要更高级别的组件,以便根据某种形式的可见性确定来限制提交用于渲染的图元数量。该层如图 1.22 所示。
For very small game worlds, a simple frustum cull (i.e., removing objects that the camera cannot “see”) is probably all that is required. For larger game worlds, a more advanced spatial subdivision data structure might be used to improve rendering efficiency by allowing the potentially visible set (PVS) of objects to be determined very quickly. Spatial subdivisions can take many forms, including a binary space partitioning tree, a quadtree, an octree, a kd-tree or a sphere hierarchy. A spatial subdivision is sometimes called a scene graph, although technically the latter is a particular kind of data structure and does not subsume the former. Portals or occlusion culling methods might also be applied in this layer of the rendering engine.
对于非常小的游戏世界,可能只需要简单的截锥体剔除(即删除相机无法“看到”的对象)。对于更大的游戏世界,可以使用更先进的空间细分数据结构,通过允许非常快速地确定对象的潜在可见集(PVS)来提高渲染效率。空间细分可以采用多种形式,包括二元空间划分树、四叉树、八叉树、kd 树或球体层次结构。空间细分有时称为场景图,尽管从技术上讲后者是一种特殊类型的数据结构并且不包含前者。门户或遮挡剔除方法也可以应用于渲染引擎的这一层。
Ideally, the low-level renderer should be completely agnostic to the type of spatial subdivision or scene graph being used. This permits different game teams to reuse the primitive submission code but to craft a PVS determination system that is specific to the needs of each team’s game. The design of the OGRE open source rendering engine (http://www.ogre3d.org) is a great example of this principle in action. OGRE provides a plug-and-play scene graph architecture. Game developers can either select from a number of preimplemented scene graph designs, or they can provide a custom scene graph implementation.
理想情况下,低级渲染器应该完全不知道所使用的空间细分或场景图的类型。这允许不同的游戏团队重用原始提交代码,但可以根据每个团队的游戏需求构建一个 PVS 确定系统。 OGRE 开源渲染引擎 (http://www.ogre3d.org) 的设计是这一原则实际应用的一个很好的例子。 OGRE 提供了即插即用的场景图架构。游戏开发人员可以从许多预先实现的场景图设计中进行选择,也可以提供自定义场景图实现。
Modern game engines support a wide range of visual effects, as shown in Figure 1.23, including:
现代游戏引擎支持多种视觉效果,如图1.23所示,包括:
Some examples of full-screen post effects include:
全屏后期效果的一些示例包括:
It is common for a game engine to have an effects system component that manages the specialized rendering needs of particles, decals and other visual effects. The particle and decal systems are usually distinct components of the rendering engine and act as inputs to the low-level renderer. On the other hand, light mapping, environment mapping and shadows are usually handled internally within the rendering engine proper. Full-screen post effects are either implemented as an integral part of the renderer or as a separate component that operates on the renderer’s output buffers.
游戏引擎通常具有效果系统组件,用于管理粒子、贴花和其他视觉效果的专门渲染需求。粒子和贴花系统通常是渲染引擎的不同组件,并充当低级渲染器的输入。另一方面,光照贴图、环境贴图和阴影通常在渲染引擎内部进行处理。全屏后期效果要么作为渲染器的一个组成部分实现,要么作为在渲染器的输出缓冲区上运行的单独组件实现。
Most games employ some kind of 2D graphics overlaid on the 3D scene for various purposes. These include:
大多数游戏都会出于各种目的而在 3D 场景上叠加某种 2D 图形。这些包括:
This layer is shown in Figure 1.24. Two-dimensional graphics like these are usually implemented by drawing textured quads (pairs of triangles) with an orthographic projection. Or they may be rendered in full 3D, with the quads bill-boarded so they always face the camera.
该层如图 1.24 所示。像这样的二维图形通常是通过使用正交投影绘制纹理四边形(三角形对)来实现的。或者它们可以以全 3D 方式渲染,并将四边形放在广告牌上,以便它们始终面向摄像机。
We’ve also included the full-motion video (FMV) system in this layer. This system is responsible for playing full-screen movies that have been recorded earlier (either rendered with the game’s rendering engine or using another rendering package).
我们还在这一层中加入了全动态视频 (FMV) 系统。该系统负责播放之前录制的全屏电影(使用游戏的渲染引擎渲染或使用其他渲染包渲染)。
A related system is the in-game cinematics (IGC) system. This component typically allows cinematic sequences to be choreographed within the game itself, in full 3D. For example, as the player walks through a city, a conversation between two key characters might be implemented as an in-game cinematic. IGCs may or may not include the player character(s). They may be done as a deliberate cut-away during which the player has no control, or they may be subtly integrated into the game without the human player even realizing that an IGC is taking place. Some games, such as Naughty Dog’s Uncharted 4: A Thief’s End, have moved away from pre-rendered movies entirely, and display all cinematic moments in the game as real-time IGCs.
一个相关的系统是游戏内过场动画(IGC)系统。该组件通常允许在游戏本身中以全 3D 方式编排电影序列。例如,当玩家走过一座城市时,两个关键角色之间的对话可能会被实现为游戏中的过场动画。 IGC 可能包括也可能不包括玩家角色。它们可能是故意的切入,在此期间玩家无法控制,或者它们可能巧妙地融入到游戏中,而人类玩家甚至没有意识到 IGC 正在发生。一些游戏,例如 Naughty Dog 的《神秘海域 4:盗贼末路》,已经完全放弃了预渲染电影,并将游戏中的所有电影时刻显示为实时 IGC。
Games are real-time systems and, as such, game engineers often need to profile the performance of their games in order to optimize performance. In addition, memory resources are usually scarce, so developers make heavy use of memory analysis tools as well. The profiling and debugging layer, shown in Figure 1.25, encompasses these tools and also includes in-game debugging facilities, such as debug drawing, an in-game menu system or console and the ability to record and play back gameplay for testing and debugging purposes.
游戏是实时系统,因此游戏工程师通常需要分析游戏的性能以优化性能。此外,内存资源通常是稀缺的,因此开发人员也大量使用内存分析工具。如图 1.25 所示,分析和调试层包含这些工具,还包括游戏内调试设施,例如调试绘图、游戏内菜单系统或控制台以及出于测试和调试目的记录和回放游戏玩法的能力。
There are plenty of good general-purpose software profiling tools available, including:
有许多优秀的通用软件分析工具可用,包括:
However, most game engines also incorporate a suite of custom profiling and debugging tools. For example, they might include one or more of the following:
然而,大多数游戏引擎还包含一套自定义分析和调试工具。例如,它们可能包括以下一项或多项:
The PlayStation 4 provides a powerful core dump facility to aid programmers in debugging crashes. The PlayStation 4 is always recording the last 15 seconds of gameplay video, to allow players to share their experiences via the Share button on the controller. Because of this, the PS4’s core dump facility automatically provides programmers not only with a complete call stack of what the program was doing when it crashed, but also with a screenshot of the moment of the crash and 15 seconds of video footage showing what was happening just prior to the crash. Core dumps can be automatically uploaded to the game developer’s servers whenever the game crashes, even after the game has shipped. These facilities revolutionize the tasks of crash analysis and repair.
PlayStation 4 提供了强大的核心转储工具来帮助程序员调试崩溃。 PlayStation 4 始终录制最后 15 秒的游戏视频,以便玩家通过控制器上的“分享”按钮分享他们的体验。因此,PS4 的核心转储工具不仅会自动为程序员提供程序崩溃时正在执行的操作的完整调用堆栈,还会提供崩溃时刻的屏幕截图以及显示发生情况的 15 秒视频片段就在坠机之前。每当游戏崩溃时,即使游戏已经发布,核心转储也可以自动上传到游戏开发者的服务器。这些设施彻底改变了碰撞分析和修复的任务。
Collision detection is important for every game. Without it, objects would interpenetrate, and it would be impossible to interact with the virtual world in any reasonable way. Some games also include a realistic or semi-realistic dynamics simulation. We call this the “physics system” in the game industry, although the term rigid body dynamics is really more appropriate, because we are usually only concerned with the motion (kinematics) of rigid bodies and the forces and torques (dynamics) that cause this motion to occur. This layer is depicted in Figure 1.26.
碰撞检测对于每个游戏都很重要。没有它,物体就会相互渗透,并且不可能以任何合理的方式与虚拟世界交互。有些游戏还包括真实或半真实的动力学模拟。我们在游戏行业中将其称为“物理系统”,尽管“刚体动力学”这个术语确实更合适,因为我们通常只关心刚体的运动(运动学)以及导致这种情况的力和扭矩(动力学)运动发生。该层如图 1.26 所示。
Collision and physics are usually quite tightly coupled. This is because when collisions are detected, they are almost always resolved as part of the physics integration and constraint satisfaction logic. Nowadays, very few game companies write their own collision/physics engine. Instead, a third-party SDK is typically integrated into the engine.
碰撞和物理通常是紧密耦合的。这是因为当检测到碰撞时,它们几乎总是作为物理集成和约束满足逻辑的一部分来解决。如今,很少有游戏公司编写自己的碰撞/物理引擎。相反,第三方 SDK 通常集成到引擎中。
Open source physics and collision engines are also available. Perhaps the best-known of these is the Open Dynamics Engine (ODE). For more information, see http://www.ode.org. I-Collide, V-Collide and RAPID are other popular non-commercial collision detection engines. All three were developed at the University of North Carolina (UNC). For more information, see http://www.cs.unc.edu/∼geom/I_COLLIDE/index.html and http://www.cs.unc.edu/∼geom/V_COLLIDE/index.html.
还提供开源物理和碰撞引擎。其中最著名的也许是开放动态引擎(ODE)。欲了解更多信息,请访问 http://www.ode.org。 I-Collide、V-Collide 和 RAPID 是其他流行的非商业碰撞检测引擎。这三个项目都是在北卡罗来纳大学 (UNC) 开发的。有关详细信息,请参阅 http://www.cs.unc.edu/∼geom/I_COLLIDE/index.html 和 http://www.cs.unc.edu/∼geom/V_COLLIDE/index.html。
Any game that has organic or semi-organic characters (humans, animals, cartoon characters or even robots) needs an animation system. There are five basic types of animation used in games:
任何具有有机或半有机角色(人类、动物、卡通人物甚至机器人)的游戏都需要动画系统。游戏中使用的动画有五种基本类型:
Skeletal animation permits a detailed 3D character mesh to be posed by an animator using a relatively simple system of bones. As the bones move, the vertices of the 3D mesh move with them. Although morph targets and vertex animation are used in some engines, skeletal animation is the most prevalent animation method in games today; as such, it will be our primary focus in this book. A typical skeletal animation system is shown in Figure 1.27.
骨骼动画允许动画师使用相对简单的骨骼系统来构成详细的 3D 角色网格。当骨骼移动时,3D 网格的顶点也会随之移动。尽管某些引擎中使用了变形目标和顶点动画,但骨骼动画是当今游戏中最流行的动画方法;因此,这将是我们在本书中的主要关注点。典型的骨骼动画系统如图 1.27 所示。
You’ll notice in Figure 1.16 that the skeletal mesh rendering component bridges the gap between the renderer and the animation system. There is a tight cooperation happening here, but the interface is very well defined. The animation system produces a pose for every bone in the skeleton, and then these poses are passed to the rendering engine as a palette of matrices. The renderer transforms each vertex by the matrix or matrices in the palette, in order to generate a final blended vertex position. This process is known as skinning.
您会在图 1.16 中注意到,骨架网格物体渲染组件弥合了渲染器和动画系统之间的差距。这里发生了紧密的合作,但界面定义得非常明确。动画系统为骨架中的每个骨骼生成一个姿势,然后这些姿势作为矩阵调色板传递到渲染引擎。渲染器通过调色板中的一个或多个矩阵变换每个顶点,以生成最终的混合顶点位置。此过程称为剥皮。
There is also a tight coupling between the animation and physics systems when rag dolls are employed. A rag doll is a limp (often dead) animated character, whose bodily motion is simulated by the physics system. The physics system determines the positions and orientations of the various parts of the body by treating them as a constrained system of rigid bodies. The animation system calculates the palette of matrices required by the rendering engine in order to draw the character on-screen.
当使用布娃娃时,动画和物理系统之间也存在紧密的耦合。布娃娃是一个跛行(通常是死亡)的动画角色,其身体运动由物理系统模拟。物理系统通过将身体的各个部分视为刚体的约束系统来确定它们的位置和方向。动画系统计算渲染引擎所需的矩阵调色板,以便在屏幕上绘制角色。
Every game needs to process input from the player, obtained from various human interface devices (HIDs) including:
每个游戏都需要处理玩家的输入,这些输入是从各种人机接口设备 (HID) 获得的,包括:
We sometimes call this component the player I/O component, because we may also provide output to the player through the HID, such as force-feedback/ rumble on a joypad or the audio produced by the Wiimote. A typical HID layer is shown in Figure 1.28.
我们有时将此组件称为播放器 I/O 组件,因为我们还可以通过 HID 向播放器提供输出,例如手柄上的力反馈/隆隆声或 Wiimote 产生的音频。典型的 HID 层如图 1.28 所示。
The HID engine component is sometimes architected to divorce the low-level details of the game controller(s) on a particular hardware platform from the high-level game controls. It massages the raw data coming from the hardware, introducing a dead zone around the center point of each joypad stick, debouncing button-press inputs, detecting button-down and button-up events, interpreting and smoothing accelerometer inputs (e.g., from the PlayStation Dualshock controller) and more. It often provides a mechanism allowing the player to customize the mapping between physical controls and logical game functions. It sometimes also includes a system for detecting chords (multiple buttons pressed together), sequences (buttons pressed in sequence within a certain time limit) and gestures (sequences of inputs from the buttons, sticks, accelerometers, etc.).
HID 引擎组件有时被设计为将特定硬件平台上的游戏控制器的低级细节与高级游戏控制分开。它处理来自硬件的原始数据,在每个手柄杆的中心点周围引入死区,消除按钮按下输入的抖动,检测按钮按下和按钮弹起事件,解释和平滑加速度计输入(例如来自 PlayStation 的加速度计输入) Dualshock 控制器)等。它通常提供一种机制,允许玩家自定义物理控制和逻辑游戏功能之间的映射。有时它还包括一个用于检测和弦(同时按下多个按钮)、序列(在特定时间限制内按顺序按下按钮)和手势(来自按钮、摇杆、加速计等的输入序列)的系统。
Audio is just as important as graphics in any game engine. Unfortunately, audio often gets less attention than rendering, physics, animation, AI and gameplay. Case in point: Programmers often develop their code with their speakers turned off! (In fact, I’ve known quite a few game programmers who didn’t even have speakers or headphones.) Nonetheless, no great game is complete without a stunning audio engine. The audio layer is depicted in Figure 1.29.
在任何游戏引擎中,音频与图形一样重要。不幸的是,音频通常没有渲染、物理、动画、人工智能和游戏玩法受到关注。举个例子:程序员经常在关闭扬声器的情况下开发代码! (事实上,我认识很多游戏程序员,他们甚至没有扬声器或耳机。)尽管如此,如果没有令人惊叹的音频引擎,任何伟大的游戏都是不完整的。音频层如图 1.29 所示。
Audio engines vary greatly in sophistication. Quake’s audio engine is pretty basic, and game teams usually augment it with custom functionality or replace it with an in-house solution. Unreal Engine 4 provides a reasonably robust 3D audio rendering engine (discussed in detail in [45]), although its feature set is limited and many game teams will probably want to augment and customize it to provide advanced game-specific features. For DirectX platforms (PC, Xbox 360, Xbox One), Microsoft provides an excellent runtime audio engine called XAudio2. Electronic Arts has developed an advanced, high-powered audio engine internally called SoundR!OT. In conjunction with first-party studios like Naughty Dog, Sony Interactive Entertainment (SIE) provides a powerful 3D audio engine called Scream, which has been used on a number of PS3 and PS4 titles including Naughty Dog’s Uncharted 4: A Thief’s End and The Last of Us: Remastered. However, even if a game team uses a preexisting audio engine, every game requires a great deal of custom software development, integration work, fine-tuning and attention to detail in order to produce high-quality audio in the final product.
音频引擎的复杂程度差异很大。 Quake 的音频引擎非常基础,游戏团队通常会使用自定义功能来增强它或用内部解决方案替换它。虚幻引擎 4 提供了一个相当强大的 3D 音频渲染引擎(在 [45] 中详细讨论),尽管其功能集有限,并且许多游戏团队可能希望增强和自定义它以提供高级的游戏特定功能。对于 DirectX 平台(PC、Xbox 360、Xbox One),微软提供了一个优秀的运行时音频引擎,称为 XAudio2。 Electronic Arts 开发了一种先进的高性能音频引擎,内部称为 SoundR!OT。索尼互动娱乐 (SIE) 与 Naughty Dog 等第一方工作室合作,提供了名为 Scream 的强大 3D 音频引擎,该引擎已用于多种 PS3 和 PS4 游戏,包括 Naughty Dog 的《神秘海域 4:盗贼末路》和《最后的结局》我们的:重制版。然而,即使游戏团队使用预先存在的音频引擎,每个游戏都需要大量的定制软件开发、集成工作、微调和对细节的关注,以便在最终产品中产生高质量的音频。
Many games permit multiple human players to play within a single virtual world. Multiplayer games come in at least four basic flavors:
许多游戏允许多个人类玩家在一个虚拟世界中玩游戏。多人游戏至少有四种基本风格:
The multiplayer networking layer is shown in Figure 1.30.
多人游戏网络层如图 1.30 所示。
Multiplayer games are quite similar in many ways to their single-player counterparts. However, support for multiple players can have a profound impact on the design of certain game engine components. The game world object model, renderer, human input device system, player control system and animation systems are all affected. Retrofitting multiplayer features into a preexisting single-player engine is certainly not impossible, although it can be a daunting task. Still, many game teams have done it successfully. That said, it is usually better to design multiplayer features from day one, if you have that luxury.
多人游戏在很多方面与单人游戏非常相似。然而,对多个玩家的支持可能会对某些游戏引擎组件的设计产生深远的影响。游戏世界对象模型、渲染器、人类输入设备系统、玩家控制系统和动画系统都会受到影响。将多人游戏功能改造到现有的单人游戏引擎中当然不是不可能的,尽管这可能是一项艰巨的任务。尽管如此,许多游戏团队还是成功做到了这一点。也就是说,如果你有这种奢侈的话,通常最好从一开始就设计多人游戏功能。
It is interesting to note that going the other way—converting a multiplayer game into a single-player game—is typically trivial. In fact, many game engines treat single-player mode as a special case of a multiplayer game, in which there happens to be only one player. The Quake engine is well known for its client-on-top-of-server mode, in which a single executable, running on a single PC, acts both as the client and the server in single-player campaigns.
有趣的是,反之亦然——将多人游戏转换为单人游戏——通常是微不足道的。事实上,许多游戏引擎将单人游戏模式视为多人游戏的一种特殊情况,其中恰好只有一个玩家。 Quake 引擎以其客户端在服务器之上的模式而闻名,在该模式中,在单台 PC 上运行的单个可执行文件在单人游戏中既充当客户端又充当服务器。
The term gameplay refers to the action that takes place in the game, the rules that govern the virtual world in which the game takes place, the abilities of the player character(s) (known as player mechanics) and of the other characters and objects in the world, and the goals and objectives of the player(s). Gameplay is typically implemented either in the native language in which the rest of the engine is written or in a high-level scripting language—or sometimes both. To bridge the gap between the gameplay code and the low-level engine systems that we’ve discussed thus far, most game engines introduce a layer that I’ll call the gameplay foundations layer (for lack of a standardized name). Shown in Figure 1.31, this layer provides a suite of core facilities, upon which game-specific logic can be implemented conveniently.
术语“游戏玩法”是指游戏中发生的动作、游戏发生的虚拟世界的规则、玩家角色(称为玩家机制)以及其他角色和对象的能力世界中的情况,以及玩家的目的和目标。游戏玩法通常使用编写引擎其余部分的本机语言或高级脚本语言来实现,有时也使用两者来实现。为了弥合游戏玩法代码和我们迄今为止讨论的低级引擎系统之间的差距,大多数游戏引擎引入了一个我称之为游戏玩法基础层的层(因为缺乏标准化名称)。如图1.31所示,该层提供了一套核心设施,可以方便地实现游戏特定的逻辑。
The gameplay foundations layer introduces the notion of a game world, containing both static and dynamic elements. The contents of the world are usually modeled in an object-oriented manner (often, but not always, using an object-oriented programming language). In this book, the collection of object types that make up a game is called the game object model. The game object model provides a real-time simulation of a heterogeneous collection of objects in the virtual game world.
游戏基础层引入了游戏世界的概念,包含静态和动态元素。世界的内容通常以面向对象的方式建模(通常但不总是使用面向对象的编程语言)。在本书中,构成游戏的对象类型的集合称为游戏对象模型。游戏对象模型提供了虚拟游戏世界中异构对象集合的实时模拟。
Typical types of game objects include:
游戏对象的典型类型包括:
and the list goes on.
而这样的例子不胜枚举。
The game world model is intimately tied to a software object model, and this model can end up pervading the entire engine. The term software object model refers to the set of language features, policies and conventions used to implement a piece of object-oriented software. In the context of game engines, the software object model answers questions, such as:
游戏世界模型与软件对象模型密切相关,并且该模型最终可能遍及整个引擎。术语“软件对象模型”是指用于实现面向对象软件的一组语言功能、策略和约定。在游戏引擎的背景下,软件对象模型回答以下问题:
We’ll explore software object models and game object models in considerable depth in Section 16.2.
我们将在 16.2 节中深入探讨软件对象模型和游戏对象模型。
Game objects invariably need to communicate with one another. This can be accomplished in all sorts of ways. For example, the object sending the message might simply call a member function of the receiver object. An event-driven architecture, much like what one would find in a typical graphical user interface, is also a common approach to inter-object communication. In an event-driven system, the sender creates a little data structure called an event or message, containing the message’s type and any argument data that are to be sent. The event is passed to the receiver object by calling its event handler function. Events can also be stored in a queue for handling at some future time.
游戏对象总是需要相互通信。这可以通过各种方式来实现。例如,发送消息的对象可能只是调用接收者对象的成员函数。事件驱动架构与典型的图形用户界面非常相似,也是对象间通信的一种常见方法。在事件驱动系统中,发送者创建一个称为事件或消息的小数据结构,其中包含消息的类型和要发送的任何参数数据。通过调用事件处理函数将事件传递给接收者对象。事件还可以存储在队列中以供将来某个时间处理。
Many game engines employ a scripting language in order to make development of game-specific gameplay rules and content easier and more rapid. Without a scripting language, you must recompile and relink your game executable every time a change is made to the logic or data structures used in the engine. But when a scripting language is integrated into your engine, changes to game logic and data can be made by modifying and reloading the script code. Some engines allow script to be reloaded while the game continues to run. Other engines require the game to be shut down prior to script recompilation. But either way, the turnaround time is still much faster than it would be if you had to recompile and relink the game’s executable.
许多游戏引擎采用脚本语言,以便更容易、更快速地开发特定于游戏的游戏规则和内容。如果没有脚本语言,每次对引擎中使用的逻辑或数据结构进行更改时,您都必须重新编译并重新链接游戏可执行文件。但是,当脚本语言集成到您的引擎中时,可以通过修改和重新加载脚本代码来更改游戏逻辑和数据。有些引擎允许在游戏继续运行时重新加载脚本。其他引擎要求在脚本重新编译之前关闭游戏。但无论哪种方式,周转时间仍然比必须重新编译和重新链接游戏可执行文件要快得多。
Traditionally, artificial intelligence has fallen squarely into the realm of game-specific software—it was usually not considered part of the game engine per se. More recently, however, game companies have recognized patterns that arise in almost every AI system, and these foundations are slowly starting to fall under the purview of the engine proper.
传统上,人工智能完全属于游戏专用软件的领域——它通常不被认为是游戏引擎本身的一部分。然而,最近,游戏公司已经认识到几乎每个人工智能系统中都会出现的模式,并且这些基础正慢慢开始落入引擎本身的权限范围内。
For example, a company called Kynogon developed a middleware SDK named Kynapse, which provides much of the low-level technology required to build commercially viable game AI. This technology was purchased by Autodesk and has been superseded by a totally redesigned AI middleware package called Gameware Navigation, designed by the same engineering team that invented Kynapse. This SDK provides low-level AI building blocks such as nav mesh generation, path finding, static and dynamic object avoidance, identification of vulnerabilities within a play space (e.g., an open window from which an ambush could come) and a well-defined interface between AI and animation.
例如,一家名为 Kynogon 的公司开发了一款名为 Kynapse 的中间件 SDK,它提供了构建商业上可行的游戏 AI 所需的大部分低级技术。这项技术被 Autodesk 购买,并被完全重新设计的 AI 中间件包(称为 Gameware Navigation)所取代,该中间件包是由发明 Kynapse 的同一工程团队设计的。该 SDK 提供了低级 AI 构建块,例如导航网格生成、路径查找、静态和动态物体回避、游戏空间内的漏洞识别(例如,伏击可能来自的打开的窗口)以及定义明确的界面介于人工智能和动画之间。
On top of the gameplay foundation layer and the other low-level engine components, gameplay programmers and designers cooperate to implement the features of the game itself. Gameplay systems are usually numerous, highly varied and specific to the game being developed. As shown in Figure 1.32, these systems include, but are certainly not limited to the mechanics of the player character, various in-game camera systems, artificial intelligence for the control of non-player characters, weapon systems, vehicles and the list goes on. If a clear line could be drawn between the engine and the game, it would lie between the game-specific subsystems and the gameplay foundations layer. Practically speaking, this line is never perfectly distinct. At least some game-specific knowledge invariably seeps down through the gameplay foundations layer and sometimes even extends into the core of the engine itself.
在游戏玩法基础层和其他低级引擎组件之上,游戏玩法程序员和设计师合作实现游戏本身的功能。游戏系统通常数量众多、变化很大并且特定于正在开发的游戏。如图 1.32 所示,这些系统包括但当然不限于玩家角色的机制、各种游戏内摄像机系统、用于控制非玩家角色的人工智能、武器系统、车辆等等。 。如果可以在引擎和游戏之间划出一条清晰的界限,那么它就位于游戏特定子系统和游戏玩法基础层之间。实际上,这条线从来都不是完全清晰的。至少一些特定于游戏的知识总是会渗透到游戏玩法基础层,有时甚至延伸到引擎本身的核心。
Any game engine must be fed a great deal of data, in the form of game assets, configuration files, scripts and so on. Figure 1.33 depicts some of the types of game assets typically found in modern game engines. The thicker dark-grey arrows show how data flows from the tools used to create the original source assets all the way through to the game engine itself. The thinner light-grey arrows show how the various types of assets refer to or use other assets.
任何游戏引擎都必须以游戏资产、配置文件、脚本等形式提供大量数据。图 1.33 描述了现代游戏引擎中常见的一些游戏资产类型。较粗的深灰色箭头显示数据如何从用于创建原始源资产的工具一直流到游戏引擎本身。较细的浅灰色箭头显示各种类型的资产如何引用或使用其他资产。
Games are multimedia applications by nature. A game engine’s input data comes in a wide variety of forms, from 3D mesh data to texture bitmaps to animation data to audio files. All of this source data must be created and manipulated by artists. The tools that the artists use are called digital content creation (DCC) applications.
游戏本质上是多媒体应用程序。游戏引擎的输入数据有多种形式,从 3D 网格数据到纹理位图、动画数据到音频文件。所有这些源数据都必须由艺术家创建和操作。艺术家使用的工具称为数字内容创建 (DCC) 应用程序。
A DCC application is usually targeted at the creation of one particular type of data—although some tools can produce multiple data types. For example, Autodesk’s Maya and 3ds Max and Pixologic’s ZBrush are prevalent in the creation of both 3D meshes and animation data. Adobe’s Photoshop and its ilk are aimed at creating and editing bitmaps (textures). SoundForge is a popular tool for creating audio clips. Some types of game data cannot be created using an off-the-shelf DCC app. For example, most game engines provide a custom editor for laying out game worlds. Still, some engines do make use of preexisting tools for game world layout. I’ve seen game teams use 3ds Max or Maya as a world layout tool, with or without custom plug-ins to aid the user. Ask most game developers, and they’ll tell you they can remember a time when they laid out terrain height fields using a simple bitmap editor, or typed world layouts directly into a text file by hand. Tools don’t have to be pretty—game teams will use whatever tools are available and get the job done. That said, tools must be relatively easy to use, and they absolutely must be reliable, if a game team is going to be able to develop a highly polished product in a timely manner.
DCC 应用程序通常旨在创建一种特定类型的数据,尽管某些工具可以生成多种数据类型。例如,Autodesk 的 Maya 和 3ds Max 以及 Pixologic 的 ZBrush 在 3D 网格和动画数据的创建中很流行。 Adobe 的 Photoshop 及其同类产品旨在创建和编辑位图(纹理)。 SoundForge 是一种流行的音频剪辑创建工具。某些类型的游戏数据无法使用现成的 DCC 应用程序创建。例如,大多数游戏引擎都提供自定义编辑器来布局游戏世界。尽管如此,一些引擎确实利用了现有的工具来进行游戏世界布局。我见过游戏团队使用 3ds Max 或 Maya 作为世界布局工具,有或没有自定义插件来帮助用户。询问大多数游戏开发人员,他们会告诉您,他们记得曾经使用简单的位图编辑器布置地形高度字段,或者直接将世界布局手动输入到文本文件中。工具不必非常漂亮——游戏团队将使用任何可用的工具来完成工作。也就是说,如果游戏团队要能够及时开发出高度完善的产品,那么工具必须相对易于使用,并且绝对必须可靠。
The data formats used by digital content creation (DCC) applications are rarely suitable for direct use in-game. There are two primary reasons for this.
数字内容创建 (DCC) 应用程序使用的数据格式很少适合在游戏中直接使用。造成这种情况的主要原因有两个。
Therefore, the data produced by a DCC app is usually exported to a more accessible standardized format, or a custom file format, for use in-game.
因此,DCC 应用程序生成的数据通常会导出为更易于访问的标准化格式或自定义文件格式,以便在游戏中使用。
Once data has been exported from the DCC app, it often must be further processed before being sent to the game engine. And if a game studio is shipping its game on more than one platform, the intermediate files might be processed differently for each target platform. For example, 3D mesh data might be exported to an intermediate format, such as XML, JSON or a simple binary format. Then it might be processed to combine meshes that use the same material, or split up meshes that are too large for the engine to digest. The mesh data might then be organized and packed into a memory image suitable for loading on a specific hardware platform.
从 DCC 应用程序导出数据后,通常必须在发送到游戏引擎之前对其进行进一步处理。如果游戏工作室在多个平台上发布其游戏,则每个目标平台的中间文件处理方式可能会有所不同。例如,3D 网格数据可能会导出为中间格式,例如 XML、JSON 或简单的二进制格式。然后,它可能会被处理以组合使用相同材质的网格,或者分割太大而引擎无法消化的网格。然后,网格数据可以被组织并打包到适合加载到特定硬件平台上的内存映像中。
The pipeline from DCC app to game engine is sometimes called the asset conditioning pipeline (ACP). Every game engine has this in some form.
从 DCC 应用程序到游戏引擎的管道有时称为资产调节管道 (ACP)。每个游戏引擎都以某种形式存在这一点。
The visible geometry you see in a game is typically constructed from triangle meshes. Some older games also make use of volumetric geometry known as brushes. We’ll discuss each type of geometric data briefly below. For an in-depth discussion of the techniques used to describe and render 3D geometry, see Chapter 11.
您在游戏中看到的可见几何体通常是由三角形网格构建的。一些较旧的游戏还使用称为画笔的体积几何形状。我们将在下面简要讨论每种类型的几何数据。有关用于描述和渲染 3D 几何的技术的深入讨论,请参阅第 11 章。
A mesh is a complex shape composed of triangles and vertices. Renderable geometry can also be constructed from quads or higher-order subdivision surfaces. But on today’s graphics hardware, which is almost exclusively geared toward rendering rasterized triangles, all shapes must eventually be translated into triangles prior to rendering.
网格是由三角形和顶点组成的复杂形状。可渲染几何体也可以从四边形或高阶细分曲面构造。但在当今的图形硬件上,几乎专门用于渲染光栅化三角形,所有形状最终都必须在渲染之前转换为三角形。
A mesh typically has one or more materials applied to it in order to define visual surface properties (color, reflectivity, bumpiness, diffuse texture, etc.). In this book, I will use the term “mesh” to refer to a single renderable shape, and “model” to refer to a composite object that may contain multiple meshes, plus animation data and other metadata for use by the game.
网格通常应用一种或多种材质,以定义视觉表面属性(颜色、反射率、凹凸度、漫反射纹理等)。在本书中,我将使用术语“网格”来指代单个可渲染形状,使用“模型”来指代可能包含多个网格以及游戏使用的动画数据和其他元数据的复合对象。
Meshes are typically created in a 3D modeling package such as 3ds Max, Maya or SoftImage. A powerful and popular tool by Pixologic called ZBrush allows ultra high-resolution meshes to be built in a very intuitive way and then down-converted into a lower-resolution model with normal maps to approximate the high-frequency detail.
网格通常在 3D 建模包(例如 3ds Max、Maya 或 SoftImage)中创建。 Pixologic 推出的一款强大而流行的工具 ZBrush 允许以非常直观的方式构建超高分辨率网格,然后将其下转换为带有法线贴图的低分辨率模型,以近似高频细节。
Exporters must be written to extract the data from the digital content creation (DCC) tool (Maya, Max, etc.) and store it on disk in a form that is digestible by the engine. The DCC apps provide a host of standard or semistandard export formats, although none are perfectly suited for game development (with the possible exception of COLLADA). Therefore, game teams often create custom file formats and custom exporters to go with them.
必须编写导出器以从数字内容创建 (DCC) 工具(Maya、Max 等)中提取数据,并将其以引擎可消化的形式存储在磁盘上。 DCC 应用程序提供了大量标准或半标准导出格式,但没有一个完全适合游戏开发(COLLADA 可能除外)。因此,游戏团队经常创建自定义文件格式和自定义导出器来配合它们。
Brush geometry is defined as a collection of convex hulls, each of which is defined by multiple planes. Brushes are typically created and edited directly in the game world editor. This is essentially an “old school” approach to creating renderable geometry, but it is still used in some engines.
笔刷几何体被定义为凸包的集合,每个凸包由多个平面定义。画笔通常直接在游戏世界编辑器中创建和编辑。这本质上是一种创建可渲染几何体的“老派”方法,但它仍在某些引擎中使用。
Pros:
优点:
Cons:
缺点:
A skeletal mesh is a special kind of mesh that is bound to a skeletal hierarchy for the purposes of articulated animation. Such a mesh is sometimes called a skin because it forms the skin that surrounds the invisible underlying skeleton. Each vertex of a skeletal mesh contains a list of indices indicating to which joint(s) in the skeleton it is bound. A vertex usually also includes a set of joint weights, specifying the amount of influence each joint has on the vertex.
骨架网格物体是一种特殊类型的网格物体,为了铰接动画的目的而绑定到骨架层次结构。这种网格有时被称为蒙皮,因为它形成了围绕不可见的底层骨架的蒙皮。骨架网格物体的每个顶点都包含一个索引列表,指示它绑定到骨架中的哪个关节。顶点通常还包括一组关节权重,指定每个关节对顶点的影响量。
In order to render a skeletal mesh, the game engine requires three distinct kinds of data:
为了渲染骨架网格物体,游戏引擎需要三种不同类型的数据:
The mesh and skeleton are often exported from the DCC application as a single data file. However, if multiple meshes are bound to a single skeleton, then it is better to export the skeleton as a distinct file. The animations are usually exported individually, allowing only those animations which are in use to be loaded into memory at any given time. However, some game engines allow a bank of animations to be exported as a single file, and some even lump the mesh, skeleton and animations into one monolithic file.
网格和骨架通常作为单个数据文件从 DCC 应用程序导出。但是,如果多个网格体绑定到单个骨架,则最好将骨架导出为不同的文件。动画通常是单独导出的,只允许在任何给定时间将正在使用的动画加载到内存中。然而,一些游戏引擎允许将一组动画导出为单个文件,有些甚至将网格、骨架和动画合并到一个整体文件中。
An unoptimized skeletal animation is defined by a stream of 4 × 3 matrix samples, taken at a frequency of at least 30 frames per second, for each of the joints in a skeleton (of which there can be 500 or more for a realistic humanoid character). Thus, animation data is inherently memory-intensive. For this reason, animation data is almost always stored in a highly compressed format. Compression schemes vary from engine to engine, and some are proprietary. There is no one standardized format for game-ready animation data.
未优化的骨骼动画由 4 × 3 矩阵样本流定义,对于骨骼中的每个关节(对于真实的人形角色可以有 500 个或更多关节),以每秒至少 30 帧的频率采集)。因此,动画数据本质上是内存密集型的。因此,动画数据几乎总是以高度压缩的格式存储。压缩方案因引擎而异,有些是专有的。游戏就绪的动画数据没有一种标准化格式。
Audio clips are usually exported from Sound Forge or some other audio production tool in a variety of formats and at a number of different data sampling rates. Audio files may be in mono, stereo, 5.1, 7.1 or other multi-channel configurations. Wave files (.wav) are common, but other file formats such as PlayStation ADPCM files (.vag) are also commonplace. Audio clips are often organized into banks for the purposes of organization, easy loading into the engine, and streaming.
音频剪辑通常以多种格式和多种不同的数据采样率从 Sound Forge 或其他一些音频制作工具导出。音频文件可以是单声道、立体声、5.1、7.1 或其他多声道配置。 Wave 文件 (.wav) 很常见,但其他文件格式(例如 PlayStation ADPCM 文件 (.vag))也很常见。音频剪辑通常被组织到库中,以便于组织、轻松加载到引擎中和流式传输。
Modern games make use of complex particle effects. These are authored by artists who specialize in the creation of visual effects. Third-party tools, such as Houdini, permit film-quality effects to be authored; however, most game engines are not capable of rendering the full gamut of effects that can be created with Houdini. For this reason, many game companies create a custom particle effect editing tool, which exposes only the effects that the engine actually supports. A custom tool might also let the artist see the effect exactly as it will appear in-game.
现代游戏利用复杂的粒子效果。这些是由专门从事视觉效果创作的艺术家创作的。第三方工具(例如 Houdini)允许创作电影质量的效果;然而,大多数游戏引擎无法渲染使用 Houdini 创建的全部效果。为此,许多游戏公司创建了自定义粒子效果编辑工具,该工具仅公开引擎实际支持的效果。自定义工具还可以让美工人员看到与游戏中完全相同的效果。
The game world is where everything in a game engine comes together. To my knowledge, there are no commercially available game world editors (i.e., the game world equivalent of Maya or Max). However, a number of commercially available game engines provide good world editors:
游戏世界是游戏引擎中所有内容聚集在一起的地方。据我所知,目前还没有商业化的游戏世界编辑器(即相当于 Maya 或 Max 的游戏世界)。然而,许多商用游戏引擎提供了良好的世界编辑器:
Writing a good world editor is difficult, but it is an extremely important part of any good game engine.
编写一个好的世界编辑器很困难,但它是任何优秀游戏引擎极其重要的一部分。
Game engines deal with a wide range of asset types, from renderable geometry to materials and textures to animation data to audio. These assets are defined in part by the raw data produced by the artists when they use a tool like Maya, Photoshop or SoundForge. However, every asset also carries with it a great deal of metadata. For example, when an animator authors an animation clip in Maya, the metadata provides the asset conditioning pipeline, and ultimately the game engine, with the following information:
游戏引擎处理各种资产类型,从可渲染几何体到材质和纹理,从动画数据到音频。这些资产部分是由艺术家在使用 Maya、Photoshop 或 SoundForge 等工具时生成的原始数据定义的。然而,每项资产还带有大量元数据。例如,当动画师在 Maya 中创作动画剪辑时,元数据会提供资产调节管道,并最终提供游戏引擎,并提供以下信息:
Every game engine requires some kind of database to manage all of the metadata associated with the game’s assets. This database might be implemented using an honest-to-goodness relational database such as MySQL or Oracle, or it might be implemented as a collection of text files, managed by a revision control system such as Subversion, Perforce or Git. We’ll call this metadata the resource database in this book.
每个游戏引擎都需要某种数据库来管理与游戏资产相关的所有元数据。该数据库可以使用 MySQL 或 Oracle 等真正的关系数据库来实现,也可以作为文本文件的集合来实现,由 Subversion、Perforce 或 Git 等修订控制系统管理。在本书中,我们将这种元数据称为资源数据库。
No matter in what format the resource database is stored and managed, some kind of user interface must be provided to allow users to author and edit the data. At Naughty Dog, we wrote a custom GUI in C# called Builder for this purpose. For more information on Builder and a few other resource database user interfaces, see Section 7.2.1.3.
无论资源数据库以什么格式存储和管理,都必须提供某种用户界面以允许用户创作和编辑数据。为此,在 Naughty Dog,我们用 C# 编写了一个名为 Builder 的自定义 GUI。有关 Builder 和其他一些资源数据库用户界面的更多信息,请参阅第 7.2.1.3 节。
A game engine’s tool suite may be architected in any number of ways. Some tools might be stand-alone pieces of software, as shown in Figure 1.34. Some tools may be built on top of some of the lower layers used by the runtime engine, as Figure 1.35 illustrates. Some tools might be built into the game itself. For example, Quake- and Unreal-based games both boast an in-game console that permits developers and “modders” to type debugging and configuration commands while running the game. Finally, web-based user interfaces are becoming more and more popular for certain kinds of tools.
游戏引擎的工具套件可以通过多种方式构建。有些工具可能是独立的软件,如图 1.34 所示。一些工具可能构建在运行时引擎使用的一些较低层之上,如图 1.35 所示。一些工具可能内置于游戏本身中。例如,基于 Quake 和 Unreal 的游戏都拥有游戏内控制台,允许开发人员和“模组制作者”在运行游戏时键入调试和配置命令。最后,对于某些类型的工具来说,基于网络的用户界面变得越来越流行。
As an interesting and unique example, Unreal’s world editor and asset manager, UnrealEd, is built right into the runtime game engine. To run the editor, you run your game with a command-line argument of “editor.” This unique architectural style is depicted in Figure 1.36. It permits the tools to have total access to the full range of data structures used by the engine and avoids a common problem of having to have two representations of every data structure—one for the runtime engine and one for the tools. It also means that running the game from within the editor is very fast (because the game is actually already running). Live in-game editing, a feature that is normally very tricky to implement, can be developed relatively easily when the editor is a part of the game. However, an in-engine editor design like this does have its share of problems. For example, when the engine is crashing, the tools become unusable as well. Hence a tight coupling between engine and asset creation tools can tend to slow down production.
作为一个有趣且独特的示例,Unreal 的世界编辑器和资源管理器 UnrealEd 直接内置于运行时游戏引擎中。要运行编辑器,您可以使用命令行参数“editor”来运行游戏。这种独特的架构风格如图 1.36 所示。它允许工具完全访问引擎使用的所有数据结构,并避免每个数据结构必须有两种表示形式的常见问题——一种用于运行时引擎,另一种用于工具。这也意味着从编辑器中运行游戏非常快(因为游戏实际上已经在运行)。实时游戏编辑是一项通常很难实现的功能,但当编辑器是游戏的一部分时,开发起来相对容易。然而,像这样的引擎内编辑器设计确实存在一些问题。例如,当引擎崩溃时,工具也变得无法使用。因此,引擎和资产创建工具之间的紧密耦合往往会减慢生产速度。
Web-based user interfaces are quickly becoming the norm for certain kinds of game development tools. At Naughty Dog, we use a number of web-based UIs. Naughty Dog’s localization tool serves as the front-end portal into our localization database. Tasker is the web-based interface used by all Naughty Dog employees to create, manage, schedule, communicate and collaborate on game development tasks during production. A web-based interface known as Connector also serves as our window into the various streams of debugging information that are emitted by the game engine at runtime. The game spits out its debug text into various named channels, each associated with a different engine system (animation, rendering, AI, sound, etc.) These data streams are collected by a lightweight Redis database. The browser-based Connector interface allows users to view and filter this information in a convenient way.
基于网络的用户界面正在迅速成为某些类型的游戏开发工具的标准。在 Naughty Dog,我们使用许多基于 Web 的 UI。顽皮狗的本地化工具充当我们本地化数据库的前端门户。 Tasker 是一个基于网络的界面,所有 Naughty Dog 员工都使用它来创建、管理、安排、沟通和协作制作过程中的游戏开发任务。称为 Connector 的基于 Web 的界面也可作为我们查看游戏引擎在运行时发出的各种调试信息流的窗口。游戏将其调试文本吐出到各种命名通道中,每个通道都与不同的引擎系统(动画、渲染、AI、声音等)相关联。这些数据流由轻量级 Redis 数据库收集。基于浏览器的连接器界面允许用户以方便的方式查看和过滤这些信息。
Web-based UIs offer a number of advantages over stand-alone GUI applications. For one thing, web apps are typically easier and faster to develop and maintain than a stand-alone app written in a language like Java, C# or C++. Web apps require no special installation—all the user needs is a compatible web browser. Updates to a web-based interface can be pushed out to the users without the need for an installation step—they need only refresh or restart their browser to receive the update. Web interfaces also force us to design our tools using a client-server architecture. This opens up the possibility of distributing our tools to a wider audience. For example, Naughty Dog’s localization tool is available directly to outsourcing partners around the globe who provide language translation services to us. Stand-alone tools still have their place of course, especially when specialized GUIs such as 3D visualization are required. But if your tool only needs to present the user with editable forms and tabular data, a web-based tool may be your best bet.
与独立的 GUI 应用程序相比,基于 Web 的 UI 具有许多优势。一方面,Web 应用程序通常比用 Java、C# 或 C++ 等语言编写的独立应用程序更容易、更快速地开发和维护。 Web 应用程序不需要特殊安装——用户只需要一个兼容的 Web 浏览器。基于 Web 界面的更新可以推送给用户,无需安装步骤 - 他们只需刷新或重新启动浏览器即可接收更新。 Web 界面还迫使我们使用客户端-服务器架构来设计我们的工具。这为将我们的工具分发给更广泛的受众提供了可能性。例如,顽皮狗的本地化工具可直接向全球为我们提供语言翻译服务的外包合作伙伴使用。当然,独立工具仍然占有一席之地,特别是在需要 3D 可视化等专用 GUI 时。但是,如果您的工具只需要向用户提供可编辑的表单和表格数据,那么基于 Web 的工具可能是您的最佳选择。