[Summary of "Game Engine Architecture"] (1) What is a game, introduction to game engine architecture


Preface to the series

  "Game Engine Architecture" has always been regarded as the leading work in the direction of game engines. What is commendable is that it is not only informative, but also very readable. Often difficult and obscure knowledge points are explained clearly in a few words, which shows the profound skills of the author and translator. During the reading process, the author feels that the book is all-encompassing, and it is necessary to make a personal summary of it.


what is the game

  Everyone has a very intuitive understanding of what a "game" is. We have been exposed to board games, card games, casino games, military war games, computer games and more. Here are a few classic definitions of games:

  • There is a "game theory" in academics, which refers to multiple agents choosing strategies and tactics under a clear framework of game rules in order to maximize their interests.

  • Ralph Koster defines a game as an interactive experience that provides the player with a series of progressive challenges that the player can eventually learn to master the entire game. Lassler regards learning and mastery as the fun of the game, just as you listen to a joke and feel funny the moment you understand the point of the joke.

  • Among computer scientists, games are called soft real-time interactive agent-based computer simulations . This phrase is really subtle, and it may be the best summary of video games from a scientific perspective. Let's break this phrase down to understand it

    Computer simulation means that in most video games, some subset of the real world is mathematically modeled. But obviously, we can't completely simulate all the details of the world, so these models are only simplified or approximated versions of the real world, " approximation " and " simplification " are the most important tools for game developers.

    Agent refers to the interaction of multiple independent entities in the simulation. Vehicles, characters, fireballs, etc. in the game can all be regarded as agents. From this point of view, the more widely known term is "object".

    Interaction is another important concept in the game world. As the game events and story unfold, the state of the game world changes over time, and the game must also respond to player input, which is inherently unpredictable to the game itself.

    Timing is a central concept in all real-time interactive simulations, typically in video games where the screen updates at least 24 times per second to create the illusion of motion. Of course, video games also have other types of limitations, such as physical models that may need to be updated 120 times per second to maintain stability, so I won’t go into details here.

    Soft real-time systems are systems that miss deadlines without catastrophic consequences. If the number of frames is insufficient, human players will not do well in reality, as opposed to "hard real-time systems" such as helicopter avionics systems.

  Simulating a virtual world often requires mathematical modeling. Mathematical models can be classified as " analytical " or " numerical ". For example, if a rigid body falls with a constant acceleration due to gravity, its analytical formula can be written as:

  For a given initial condition, the value of y(t) can be obtained at any time t, but most mathematical problems do not have this closure type solution. In the game world, user input is unpredictable, so it cannot be expected to be completely analytical for the entire game.
  The numerical model of a rigid body falling by gravity can be written as, that is to say, the height of a rigid body in a period of time in the future can be represented by the current height, the first derivative of the height, the second derivative of the height and the current time t as parameters . In order to achieve numerical simulation, it is usually necessary to repeat calculations to determine the state of the system at each discrete time. The same is true for games, a main loop executes continuously, and at each iteration of the loop, each game system has the opportunity to calculate or update the state of the next discrete step. These results can finally be rendered into graphics display, or output to other devices.


What is a game engine

  The term "game engine" first appeared in the mid-1990s. Related to the famous FPS game "Doom", the software architecture of "Doom" at that time was quite clearly divided into core software components, art assets, game world, and game rules. The value of this division is gradually reflected in the follow-up. After another developer obtains the authorization, he only needs to change a small part to make the game a new product. It also sparked interest in the mod community.

  In the late 1990s, some game developers have consciously considered reusability and mods when designing, such as "Quake". At the same time, the game studio also began to license the engine externally.

  Often, the distinction between games and engines is blurry. If we want to make a distinction, we can probably use " data-driven architecture " to distinguish which part of the software is the engine and which part is the game. If a game contains hard-coded logic, it becomes very difficult to reuse the software to make another game. Therefore, the "game engine" here is worth extensible and reusable software, which can be used as the basis of most games without too many modifications.

  Obviously, such a game engine cannot be turned into a general-purpose software, and most engines are fine-tuned for specific games or specific hardware platforms. The reason for this phenomenon is that designing efficient software always requires trade-offs. For example, an engine designed to render a compact indoor environment cannot render a wide outdoor scene well. With the development of computer technology and hardware, the differences between graphics engines of different game types have narrowed, but there is still a trade-off between versatility and optimality. In fact, some of the more general-purpose game engines are only suitable for making certain types of games.


Runtime Engine Architecture

  A game engine usually consists of two parts: a tool suite and a runtime component. The figure below shows the main runtime components of a typical 3D game engine. It can be seen that the game engine is undoubtedly a very large software system. Like all large software systems, game engines are also layered, usually the upper layer depends on the lower layer, and the lower layer does not depend on the upper layer.

insert image description here

Teacher Wang Xi's Games104 course divides the game engine into tool layer, method layer, resource layer, core layer, platform layer and third-party software package, such a 5+1 architecture. The rest of this article will combine these two statements and briefly introduce each part of the components.

  1. Hardware, drivers and operating systems : The hardware layer represents the computer system or game console used to execute the game. Typical platforms include PlayStation, Windows, etc. The driver is responsible for managing hardware resources and isolating the operating system and the upper engine. The operating system is responsible for coordinating the execution of multiple programs on a hardware device. Most of this series has nothing to do with these three parts.

  2. Third-party software packages : Most game engines will borrow third-party software development kits (SDKs) and middleware (middleware), which provide some function-based or class-based interfaces (APIs). Here are a few examples

    • Data Structures and Algorithms: STL
    • Graphics: OpenGL, DirectX
    • Collision and Physics: Havok
    • Character animation: Granny, Havok Animation
    • Artificial Intelligence: Kynapse
  3. Platform independent layer : Most game engines need to run on multiple platforms, and the platform independent layer wraps some basic APIs to ensure that the wrapped interfaces are consistent on all hardware platforms. The platform independence layer sits on top of the hardware, drivers, operating system, and third-party software, isolating the rest of the engine from the underlying platform.

  4. Core layer : The core layer includes some practical software, including container creation, memory allocation, mathematical calculation, thread management, etc. The core layer provides support for the upper layer.

  5. Resource Layer : Every game engine has some form of resource manager that provides a uniform set of interfaces to access any type of game assets and input data.

  6. Method layer : The method layer provides basic functions such as game drawing and motion. It includes many contents, the most important ones are:

    • Rendering: Rendering is one of the largest and most complex components in any game engine. Although there are many different architectures for modern renderers, most rendering engines have some common design philosophies, such as layered architecture, etc., which are not listed here for the time being, and will be introduced in more detail in subsequent articles.
    • Collision and Physics: Collision and physics systems are closely linked because when collisions occur, collisions are almost always resolved by physics integration and constraint satisfaction logic. Nowadays, few game companies write their own physics engines, instead they use third-party physics SDKs, such as: Havok, PhysX
    • Animation: Skeletal animation is the most popular animation method today, and a typical skeletal animation system is shown in the figure above.
  7. Tool layer : The tool layer refers to a series of development tools that can directly interact with developers. Such as performance and debugging tools, map editor, etc.

  8. Gameplay Basic System : The term gameplay refers to the activities in the game, the rules that govern the game world, the abilities of the player character, the abilities of other characters, the player's long-term and short-term goals, etc. The gameplay system is the source of the fun of video games .


Summarize

Today's article mainly introduces the understanding of games and game engines, as well as the architecture of runtime game engines, which is a beginning for this series. Hope to finish this series from beginning to end.

Guess you like

Origin blog.csdn.net/qq_35595611/article/details/126402857