Index

Symbols

∗ operator, 63

+ operator, 64

= operator, 469

== operator, 469

− operator, 62

Numbers

2D coordinate systems, 151

2D graphics, 1415

drawing, 1921

filtering analog sticks, 267269

implementing, 1821

Initialize function, 19

scrolling backgrounds, 5153

Shutdown function, 19

sprites, 42

animating, 4850

drawing, 4448

2D transformations

rotation matrix, 157158

scale matrix, 157

translation matrices, 158159

3D

Actor transform, 184, 189190

BasicMesh shader, 203204

calculating view-projection matrix, 200

Euler angles, 185186

lighting. See lighting

MeshComponent, 204206

quaternions, 186187

in code, 188189

combining rotations, 187

quaternion-to-rotation matrix, 188

rotating vectors, 188

spherical linear interpolation (Slerp), 188

transform matrices, 184185

transforming clip space

projection matrix, 197200

view matrix, 196197

updating vertex attributes, 193194

z-buffering, 201203

3D AABB, 308

3D coordinate system, 184

3D meshes, drawing, 195196

3D models

choosing formats, 191193

loading, 190

vertex and index buffers, 133138

3D positional audio, 233234

setting up listeners, 234236

4x4 matrices, 184185

A

A*, 106, 111113

optimizing, 113

AABB (axis-aligned bounding box), 303306

AABB contains point tests, 308

AABB versus AABB test, 311312

acceleration, 79

Actor transform, 3D, 184, 189190

Actor::LoadProperties, 436437

actors

adding to world transforms, 159161

associating with sound events, AudioComponent, 237238

jumping, 248251

loading in level files, 435439

saving in level files, 446448

Actor::SaveProperties, 446447

adaptive refresh rate, 18

AddButton, 349

adding

an aiming reticule, 352354

flipY option to UIScreen::DrawTexture, 406

pitch to first-person cameras, 278280

point lights, 418

PointLightComponent class, 419

positional functionality to SoundEvent, 236237

radar, 354358

shaders to games, 146

springs to follow cameras, 283285

text maps, 359361

world transforms, to actors, 159161

AddInt, 444

addition, vector addition, 6364

AddSprite, 46

AddTarget, 352

adjacency lists, 99

admissible, heuristics, 104

adversarial, 116

AI (artificial intelligence), 91

designing state machines, 9293

game trees, 116118

alpha-beta pruning, 121124

incomplete game trees, 120121

minimax, 118119

graphs, 98100

BFS (breadth-first search), 100103

implementing state machines, 9395

pathfinding 98

Dijkstra’s Algorithm, 113114

following paths, 114115

heuristics, 104105

navigation meshes, 115116

path nodes, 115

state machine behaviors, 92

states, as classes, 9598

AIComponent class, 9395

AIComponent::Update function, 94, 96

AIDeath state, 97

aiming reticule, adding, 352354

AIPatrol class, 97

AIState, 95

Alarm state, 93

Alert state, 93

alpha, 121

alpha blending, 178180

alpha values, 1415

alpha-beta pruning, 121124

AlphaBetaDecide, 121122

AlphaBetaMax, 122123

AlphaBetaMin, 123

ambient light, 207208

loading global properties, 434435

analog sticks, 264267

filtering, 267269

anchors, 361

angle summation, 309

angles

converting from forward vectors, 6768

converting to forward vectors, 6667

determining between two vectors, dot product, 6870

animating sprites, 4850

animation, skeletal animation. See skeletal animation

Animation class, 381382

animation data, 371372

loading for skeletal animation, 380385

animations, updating, 386389

AnimSpriteComponent, 49, 50, 5354

anisotropic filtering, 399400

API (application programming interface), 3

Apple macOS, setting up development environments, 2

application programming interface (API), 3

architecture, InputSystem, 251253

arctangent, 6768

arrays, 460461, 462

artificial intelligence. See AI (artificial intelligence)

ASCII, 358359

AStarScratch, 111

Asteroid constructor, 7475

Asteroids, 8486

atan2 function, 67

Attack state, 93

attenuates, 233

attributes

OpenGL, 129

skinning vertex attributes, drawing with, 374378

vertex attributes, updating, 193194, 206

audio

3D positional audio, 233234

setting up listeners, 234236

audio systems, creating, 224226

AudioComponent, creating to associate actors with sound events, 237238

banks, loading/unloading, 227229

bootstrapping, 222

buses, 242243

Doppler effect, 240241

effects, 241242

equalization, 242

FMOD, 222223

banks and events, 226227

event instances, 229230

installing, 223224

listeners, in third-person games, 239240

mixing, 241242

occlusion, 243244

positional functionality, adding to SoundEvent, 236237

reverb, 242

snapshots, 243

SoundEvent class, 230233

audio systems, creating, 224226

AudioComponent, creating to associate actors with sound events, 237238

AudioComponent::PlayEvent, 238

AudioComponent::StopAllEvents, 238

AudioComponent::Update, 238

AudioSystem::PlayEvent Implementation with Event IDs, 230231

AudioSystem::SetListener, 235236

AudioSystem::UnloadAllBanks, 228

AudioSystem::Update, 231

auto, 475476

axis, filters, 265

axis-aligned bounding box. See AABB (axis-aligned bounding box)

B

back buffer, 17

backgrounds, scrolling backgrounds, 5153

ball collisions

with SegmentCast, 327328

testing in PhysWorld, 329331

BallActor, 328

balls

drawing, 2023

updating position of, 2830

banks

FMOD, 226227

loading/unloading, 227229

basic input processing, 1113

Basic.frag file, 141

BasicMesh shader, 203204

BasicMesh.vert shader, 421

Basic.vert file, writing basic shaders, 139140

beta, 121

BFS (breadth-first search), 100103

BGSpriteComponent, 51

BGTexture, 51

bidirectional light, 214

bidirectional reflectance distribution function (BRDF), 209

Big-O notation, 470471

bilinear filtering, 169, 394, 395397, 400

bilinear interpolation, 396

binary data, 448449

binary mesh files, loading, 452454

saving, binary mesh files, 449452

binary mesh files

loading, 452454

saving, 449452

bind pose, 368

Feline Swordsman, 378

blank windows, creating, 1011

Blended, 339

blitting, 131

bone hierarchy, 367368

Bone struct, 370

bones, 366

BoneTransform, 369, 371372

bootstrapping, audio, 222

bounding spheres, 303

bounding volume tests, 310

AABB versus AABB test, 311312

capsule versus capsule test, 313314

sphere versus AABB test, 312313

sphere versus sphere tests, 311

bounding volumes, 302303

AABB (axis-aligned bounding box), 303306

capsules, 306307

convex polygons, 307

OBB (oriented bounding box), 306

spheres, 303

BoxComponent class, 324325

BRDF (bidirectional reflectance distribution function), 209

breadth-first search (BFS), 100103

broadphase techniques, 331

buses, 242243

Button class, 346350

buttons

controllers, 262264

mouse input, 256258

user interfaces, 346350

Button::SetName, 347

C

C++ Standard Library, 3

calculating

lighting, 407408

normal vectors, 7072

points on line segments, 298

view-projection matrix, 200

weighted averages, in bilinear filtering, 396

world transform matrix, 189

camera position, computing, 282

CameraComponent, 277278

cameras, 34

first-person camera, 276

adding pitch, 278280

cameras without pitch, 277278

first-person models, 280281

movement, 276277

follow cameras, 281283

adding springs, 283285

orbit cameras, 286288

spline cameras, 289292

unprojection, 292294

without pitch, 277278

capsule contains point tests, 309

capsule versus capsule test, 313314

capsules, 306307

Catmull-Rom spline, 289

CCD (continuous collision detection), 321

ChangeState function, 94, 96, 98

channels, 15, 222

character.jump(), 249

characters, jumping, 248251

choosing 3D model formats, 191193

CircleComponent subclass, creating, 8384

circle-versus-circle intersection, 82

class hierarchies, game objects, 3436

classes, 464465

dynamic allocation of, 465

states as, 9598

clip space, transforming

with projection matrix (3D), 197200

with view matrix (3D), 196197

from world space, 161163

closed set, GBFS (greedy best-first search), 106

collections, 470

collision detection, 81

ball collisions

with SegmentCast, 327328

testing in PhysWorld, 329331

bounding volumes, 302303

AABB (axis-aligned bounding box), 303306

capsules, 306307

convex polygons, 307

OBB (oriented bounding box), 306

spheres, 303

BoxComponent class, 324325

CircleComponent subclass, creating, 8384

circle-versus-circle intersection, 82

dynamic objects, 321323

geometric types, 298

line segments, 298301

planes, 301302

intersection tests. See intersection tests

line segment tests

line segment versus AABB test, 318320

line segment versus plane test, 314315

line segment versus sphere test, 315317

PhysWorld class, 325327

player collision, against walls, 331333

CollisionInfo, 326

color buffer, 1516

color depth, 15

column vectors, 155, 156

combining

equations, 154

rotation, for 3D, 187

transformations, 152153, 159

vectors, 6364

compatibility profiles, OpenGL, 129

CompileShader, 142143

Complete transition, Alarm state, 93

Component class, 440

component declaration, 3940

component-based game object model, 3638

ComponentFunc, 442

components

game objects, 3638

as hierarchy, 3840

loading, in level files, 439444

saving, in level files, 446448

composite, 248

ComputeGlobalInvBindPose, 379

ComputeMatrixPalette, 384, 389

computing

camera position, 282

positions, with Euler integration, 80

const, 464465

contains point tests, 308

AABB contains point tests, 308

capsule contains point tests, 309

convex polygon contains point (2D) tests, 309310

sphere contains point tests, 308

ContainsPoint, 347

context, OpenGL, 130

continuous collision detection (CCD), 321

controller input, 261

buttons, 262264

disabling controllers, 262

enabling single controllers, 261262

multiple controllers, 269270

ControllerState, 263, 267

converting

from angles to forward vectors, 6667

forward vectors, to angles, 6768

convex polygon contains point (2D) tests, 309310

convex polygons, 307

coordinate systems

3D coordinate system, 184

left-handed coordinate system, 184

UV coordinates, 395

coordinates, NDC (normalized device coordinates), 132133

copy constructor, 467468

core profile, OpenGL, 129

Create, 410

CreateMirrorTarget, 404

CreateMirrorTexture, 402

CreateRotationZ, 160

CreateScale, 160

CreateTranslation, 160

CreateWorldTransform, 160

cross product, 7072

crosshair texture, drawing, 353

cross-platform libraries, 3

D

dead zones, 265

Death state transition, 92

debug logging, initializing, 225

Debug_Initialize, 225

deferred shading, 407408, 424425

G-buffer

creating, 408411

writing to, 412414

global lighting, 414418

point lights, 418419

drawing, 421424

deleting, dynamically allocated arrays, 463

delta time, 2428

dependency injection, 39

depth buffer, 201

depth buffering. See z-buffering

designing, state machines, AI (artificial intelligence), 9293

Destroy, 411

destructors, 466467

development environments, setting up, 2

Apple macOS, 2

Microsoft Windows, 2

dialog boxes, 349352

diamond inheritance, 36

DiffuseColor, 421

digital signal processing (DSP), 241

Dijkstra’s Algorithm, 113114

directed, 98

directed edges, 100

directional light, 208

loading global properties, 434435

directions, vectors, 6566

disabling controllers, 262

distance, vectors, 6465

Doppler effect, 240241

Dot function, 70

dot product, 6870

double buffering, 1618

Draw function, 52

Draw3DScene, 404405, 413

DrawComponent, 36

DrawFromGBuffer, 416417

drawing

2D graphics, 1921

3D meshes, 195196

balls, 2023

crosshair texture, 353

mirror texture, in HUD, 406407

paddles, 2023

point lights, 421424

radar, 357

with skinning vertex attributes, 374378

sprites, 4448

textures, 47

triangles, 146148

transformations, 148149

walls, 2023

DrawScreen, 348

DSP (digital signal processing), 241

dynamic memory allocation, 462463

dynamic memory allocation of classes, 465

dynamic objects, collision detection, 321323

DynamicArray, 466, 467

E

edges, 98

effects, audio, 241242

encapsulating buttons, 346

endianness, 451

equalization, 242

equations, combining, 154

ES profiles, OpenGL, 129

Escape key, 256

Euclidean distance heuristic, 105

Euler angles, 185186

Euler integration, 80

event instances, FMOD, 229230

event processing, 1112

EventInstances, 229230

events, 11

FMOD, 226227

input devices, 251

exchange formats, 191

extensions

.frag extension, 139

.vert extension, 139

F

falloff function, 233

falloff radius, 208

FBO (framebuffer objects)

creating, 402404

rendering, 404405

Feline Swordsman, bind pose, 378

FIFO (first-in, first out), 473

Filter1D, 265267

Filter2D, 268269

filtering, 400

analog sticks, 267269

anisotropic filtering, 399400

bilinear filtering, 394, 395397, 400

nearest-neighbor filtering, 395

trilinear filtering, 398, 399, 400

filters, for axis, 265

first-in, first-out (FIFO), 473

first-person camera, 276

adding pitch, 278280

cameras without pitch, 277278

first-person models, 280281

movement, 276277

first-person models, 280281

first-person movement, 276277

FixCollisions, 332333

flat shading, 211

flipY option, adding to UIScreen::DrawTexture, 406

FMOD, 222223

audio systems, creating, 224226

banks and events, 226227

event instances, 229230

installing, 223224

occlusion, 244

positional audio, 234

snapshots, 243

FMOD Studio, 223

buses, 242243

DSP (digital signal processing), 242

FMOD_VECTOR, 234235

FMOD_ErrorString, 225

follow cameras, 281283

adding springs, 283285

FollowCamera, 282

FollowCamera::Update, 283, 284285

following paths, AI (artificial intelligence), 114115

font rendering, 338340

Font::Load, 338339

Font::RenderText, 339, 340, 359

For loops, 475476

force, 7980

force feedback, 5

formats, 3D model formats, choosing, 191193

forward rendering, 407408

forward vectors

converting from angles, 6667

converting to angles, 6768

FPS (frames per second), 4

FPS angular speed, 277

FPSActor::FixCollisions, 332333

FPSCamera, 278

FPSCamera::Update, 279

.frag extension, 139

fragment shaders, 139, 412

frame buffer, 201

frame limiting, 2526

frame rate, 4

framebuffer, 15

framebuffer objects

creating, 402404

rendering, 404405

frames, 46

rendering, in OpenGL, 131

frames per second (FPS), 4

front buffer, 17

G

game classes

main function, 1011

skeleton game class, 67

Initialize function, 79

RunLoop function, 910

Shutdown function, 9

Game Declaration, skeleton game class, 7

game loops, 4

frames, 46

integrating game objects into, 4042

single-threaded game loop, 5

game object models, 40

game objects as class hierarchies, 3436

game objects as hierarchy with components, 3840

game objects with components, 3638

game objects, 34

as class hierarchies, 3436

with components, 3638

as hierarchy with components, 3840

integrating, into game loops, 4042

types of, 34

game projects

3D graphics, 216

Asteroids, 8486

audio, 244245

cameras, 295

collision detection, 333334

convertingAstroids game to OpenGL, 180

intermediate graphics, 425

level files and binary data, 454455

moving spaceships, 271272

skeletal animation, 389390

sprites, 5355

tower defense game, 124

user interfaces, 362

game time, 24

game trees, 116118

AI (artificial intelligence)

alpha-beta pruning, 121124

incomplete game trees, 120121

minimax, 118119

Game::GenerateOutput function, 147

Game::LoadData, 430

Game::LoadShaders, 166

games

adding shaders to, 146

Asteroids, 8486

Pac-Man game, pseudocode, 6

Pong. See Pong

tic-tac-toe, game trees, 116117

tower defense game, 124

updating, 23

delta time, 2428

game time, 24

real time, 24

GameState, 120

gamut, 14

GBFS (greedy best-first search), 105111

G-buffer, 408

creating, 408411

writing to, 412414

GBuffer class, creating, 408411

GBuffer::Create, 410

GBufferGlobal.frag shader, 415416, 418

GBufferPointLight.frag shader, 419421

GBufferWrite.frag, 412

geometric types, 298

line segments, 298301

planes, 301302

GetCircle function, 84

GetComponentOfType, 441

GetEventInstance, 232

GetFont, 339

GetGlobalPoseAtTime, 382383, 387388

GetInt, JsonHelper, 433

GetKeyState, 254, 255

GetKeyValue, 254, 255

GetLeftTrigger(), 267

GetMesh, 195

GetName function, 95

GetNextPoint function, 115

GetPossibleMoves, 120

GetRightTrigger(), 267, 276

GetScore function, 118, 120

GetType, 441

GetVector3, 434

GL_ARRAY_BUFFER, 136

GL_ELEMENT_ARRAY_BUFFER, 136

GL_LINEAR, 399

GL_RGB, 402

GL_RGB16F, 411

GL_RGB32F, 410411

GL_STATIC_DRAW, 136

GL_TEXTURE_2D, 171

glAttachShader, 145

glBindBuffer, 136

glBindFramebuffer, 402, 404

glBindTexture, 173

glBlendFunc, 179

glBufferData, 174

glCheckFrameBuffer, 403, 404

glClear, 131, 202

glCreateProgram, 145

glDrawBuffers, 403

glDrawElements, 146147

glEnable, 179

GLEW, initializing, 130131

glFramebufferTexture, 403

glGenerateMipmap, 399

glGenFrameBuffers, 402

glGenTextures, 171

glGetError, 130

glGetShaderiv, 144

global lighting, 414418

properties, loading, 430431

global pose, 368

global properties

loading, 430434

saving, 446

globally unique IDs (GUIDs), 229

GLSL, 138

Basic.frag file, 141

Basic.vert file, 139140

glTexImage2D, 171

glVertexAttribIPointer, 376

glVertexAttribPointer, 376

goal nodes, 100

Gouraud shading, 211

gpmesh files, loading, 194195

graphics

2D graphics. See 2D graphics

intermediate graphics. See intermediate graphics

graphics debuggers, 414

GraphNode, 100

graphs, AI (artificial intelligence), 98100

BFS (breadth-first search), 100103

Grassmann product, 187

greedy best-first search), 105111

GUIDs (globally unique IDs), 229

H

HandleKeyPress, 344

hash maps, 475

heads-up display. See HUD (heads-up display)

heuristics, 104105

A*, 111113

GBFS (greedy best-first search), 105111

hierarchies, game objects with components, 3840

high-quality reflections, 401

homogenous coordinates, 158

horizontal field of view (FOV), 199

hot swapping, 261, 270

HUD (heads-up display), 337

drawing, mirror texture, 406407

UI screen stack, 342344

UI screens, 340342

HUD elements, 352

adding

an aiming reticule, 352354

radar, 354358

HUD::Draw, 353

HUD::UpdateCrosshair, 353

HUD::UpdateRadar, 356357

I

IDE (integrated development environment), 2

image files, loading, 4344

IMG_Load, 43

implementing

2D graphics, 1821

lighting, 212216

skeletal animation, 373374

drawing with skinning vertex attributes, 374378

skeleton game class, 67

Initialize function, 79

RunLoop function, 910

Shutdown function, 9

state machines, AI (artificial intelligence), 9395

improving texture quality, 394

inadmissible, heuristics, 104

incomplete game trees, 120121

index buffers, 133138

inheritance, diamond inheritance, 36

Initialize function

2D graphics, 19

skeleton game class, 79

initializing

debug logging, 225

GLEW, 130131

OpenGL, 128

input devices, 248

analog sticks, 264267

controller input, 261

analog sticks. See analog sticks

buttons, 262264

enabling single controllers, 261262

multiple controllers, 269270

events, 251

keyboards, 253256

mouse, 256

buttons and position, 256258

relative motion, 258259

scroll wheels, 260261

polling, 248

positive and negative edges, 248251

triggers, 264

input mappings, 270271

InputComponent class, creating, 7679

InputSystem, architecture, 251253

InputSystem::Filter2D, 268269

InputSystem::Initialize, 263

installing

FMOD, 223224

Xcode, 2

instantaneous tests, 321

integrated development environment (IDE), 2

integrating game objects into game loops, 4042

intermediate graphics

anisotropic filtering, 399400

deferred shading, 407408

drawing mirror texture in HUD, 406407

global lighting, 414418

improving texture quality, 394

mipmapping, 397399

rendering to textures, 400401

creating framebuffer objects, 402404

creating textures, 401402

texture sampling, 395397

interpolate, 186

Intersect function, 83, 315, 319320

intersection, circle-versus-circle intersection, 82

intersection tests, 307

bounding volume tests, 310

AABB versus AABB test, 311312

capsule versus capsule test, 313314

sphere versus AABB test, 312313

sphere versus sphere tests, 311

contains point tests, 308

AABB contains point tests, 308

capsule contains point tests, 309

convex polygon contains point (2D) tests, 309310

sphere contains point tests, 308

inverse bind pose matrix, 371

IsCompiled, 143144

IsTerminal, 120

IsValidProgram, 145

iterative deepening, 124

iterators, 475476

J

joints, 366

JSON (JavaScript Object Notation), 191, 448449

level files

loading actors, 435439

loading components, 439444

loading global properties, 430434

saving, 444446

saving actors and components, 446448

saving global properties, 446

JsonHelper, 433, 444

JsonHelper::GetInt, 433

jumping characters, spacebar, 248251

K

keyboards, 248

input, 253256

KeyboardState, 254

L

last-in, first-out (LIFO), 474

left-handed coordinate system, 184

length, vectors, 6465

Length () function, 65

LengthSquared() function, 65

level files

loading, 430

actors, 435439

components, 439444

global properties, 430434

saving, 444446

actors, 446448

components, 446448

global properties, 446

LevelLoader, 437

LevelLoader class, 431

LevelLoader::LoadActors, 438439

LevelLoader::LoadComponents, 443444

LevelLoader::LoadGlobalProperties, 434435

LevelLoader::LoadJSON, 431433

LevelLoader::SaveActors, 447448

LevelLoader:SaveLevel, 445

LevelLoader::SaveLevel, 445

libraries

3D positional audio library, 234235

C++ Standard Library, 3

OpenGL. See OpenGL

SDL (Simple DirectMedia Layer) library, 4

SDL TTF library, 338

LIFO (last-in, first-out), 474

lighting, 206

ambient light, 207208

loading global properties, 434435

bidirectional light, 214

deferred shading. See deferred shading

directional light, 208

global lighting, 414418

implementing, 212216

Phong reflection model, 209211

point lights, 208

adding, 418419

drawing, 421424

spotlight, 209

vertex attributes, 206207

lighting calculations, 407408

line segment tests, 314

line segment versus AABB test, 318320

line segment versus plane test, 314315

line segment versus sphere test, 315317

line segment versus AABB test, 318320

line segment versus plane test, 314315

line segment versus sphere test, 315317

line segments, 298301

linear mechanics, 7980

LineSegment::MinDistSq, 300301, 309

linked lists, 472

listeners, 233

setting up for 3D positional audio, 234236

in third-person games, 239240

listings

AABB::Rotate Implementation, 305306

Abbreviated Render Declaration, 195196

Actor Declaration, 3839

Actor::ComputeWorldTransform Implementation, 161

Actor::LoadProperties Function, 436437

Actor::RotateToNewForward, 327328

Actors with Components in JSON (Excerpt from the Full File), 440

Actor::SaveProperties Implementation, 447

Adding a flipY Option to UIScreen::DrawTexture, 406

AIComponent::ChangeState Implementation, 96

AlphaBetaDecide Implementation, 122

AlphaBetaMin Implementation, 123

AlphaBetaMax Implementation, 123

Animation Declaration, 381382

AnimSpriteComponent Declaration, 49

AnimSpriteComponent::Update Implementation, 50

Asteroid Constructor, 7475

AudioComponent Declaration, 237

AudioSystem::LoadBank Implementation, 227228

AudioSystem::PlayEvent Implementation with Event IDs, 230231

AudioSystem::SetListener Implementation, 235236

AudioSystem::Update Implementation with Event IDs, 231

Basic InputSystem Declarations, 252

Basic.frag Code, 141

Basic.vert Code, 140

The Beginning of a Skeleton Data, 370

The Beginning of an Animation Data, 380381

BGSpriteComponent Declaration, 51

BoxComponent Declaration, 324

BoxComponent::OnUpdateWorldTransform Implementation, 325

Breadth-First Search, 102

Button Declaration, 346

Circle Class with const Member, 464

CircleComponent Declaration, 83

CircleComponent Intersection, 83

Component Declaration, 3940

ComputeGlobalInvBindPose, 379380

ComputeMatrixPalette, 384

Constructing a Plane from Three Points, 301

ConvexPolygon::Contains Implementation, 310

Creating a Texture for Rendering, 401402

Creating the Mirror Framebuffer, 403404

Cube.gpmesh, 192

Current Implementation of SpriteComponent::Draw, 166167

Declaring Vertex Attributes in the VertexArray Constructor, 375376

directional light, loading global properties, 434435

Drawing MeshComponents in Renderer::Draw, 205

Drawing Point Lights in Renderer::DrawFromGBuffer, 422

English.gptext Text Map File, 359

Filter1D Implementation, 266

Final Version of GetGlobalPoseAtTime, 387388

First Version of GetGlobalPoseAtTime, 382383

FollowCamera::Update Implementation (with Spring), 284285

Font Declaration, 338

Font::Load Implementation, 339

Font::RenderText Implementation, 340

FPS Angular Speed Calculation from the Mouse, 277

FPSActor::FixCollisions, 332333

FPSCamera::Update Implementation (with Pitch Added), 279

FPSCamera::Update Implementation (Without Pitch), 278

Game Declaration, 7

Game::GenerateOutput Attempting to Draw Sprites, 147

Game::ProcessInput Implementation, 13

Game::UpdateGame Implementation, 26

Game::UpdateGame Updating Actors, 4142

GBuffer Declaration, 409

GBuffer::Create Implementation, 410

GBufferGlobal.frag Shader, 415416

GBufferPointLight.frag Main Function, 420421

GBufferWrite.frag shader, 412

Greedy Best-First Search, 110111

HUD::UpdateCrosshair, 353

HUD::UpdateRadar Implementation, 356357

Initial AudioSystem Declaration, 224

Initial ControllerState, 263

Initial MouseState Declaration, 258

Initial Shader Declaration, 142

Initial UIScreen Declaration, 341342

InputComponent Declaration, 77

InputComponent::ProcessInput Implementation, 7778

InputSystem::Filter2D, 268269

InputSystem::ProcessEvent Implementation for the Scroll Wheel, 260

JsonHelper::GetInt Implementation, 433

KeyboardState Declaration, 254

KeyboardState::GetKeyState, 255

Level with Actors (Level1.gplevel), 435436

Level with Global Lighting Properties, 430431

LevelLoader::LoadActors Implementation, 438439

LevelLoader::LoadComponents Implementation, 443444

LevelLoader::LoadGlobalProperties, 434435

LevelLoader::LoadJSON, 432

LevelLoader::SaveActors Implementation, 447448

LevelLoader:SaveLevel Implementation, 445

Line Segment Versus AABB Helper Function, 319

Line Segment Versus AABB Intersection, 320

Line Segment Versus Plane Intersection, 315

Line Segment Versus Sphere Intersection, 317

LineSegment::MinDistSq Implementation, 300301

Loading the G-buffer Global Lighting Shader, 416

Loop over the Adjacent Nodes in an A* Search, 112113

main Implementation, 10

MaxPlayer and MinPlayer Functions, 118119

MaxPlayerLimit Implementation, 120

Mesh Declaration, 194

MeshBinHeader Struct, 449450

MeshComponent Declaration, 204

MeshComponent::Draw Implementation, 205

MeshComponent::LoadProperties Implementation, 442

Mesh::LoadBinary Outline, 452453

Mesh::SaveBinary Implementation, 450451

MoveComponent Declaration, 73

MoveComponent::Update Implementation, 74

MoveComponent::Update Implementation with Quaternions, 190

OrbitCamera::Update Implementation, 287288

Pac-Man Game Loop Pseudocode, 6

Phong.frag Lighting Uniforms, 212

Phong.frag Main Function, 215

Phong.vert Main Function, 214

PhysWorld::SegmentCast, 326327

PhysWorld::TestPairWise, 329

PhysWorld::TestSweepAndPrune, 330331

PointLightComponent Declaration, 419

PointLightComponent::Draw Implementation, 423424

Quaternion Functions of Note, 189

Renderer::Draw Updated to Render Both Mirror and Default Passes, 405

Renderer::Draw3DScene Helper Function, 404405

Renderer::DrawFromGBuffer Implementation, 417

Renderer::GetScreenDirection Implementation, 294

Renderer::Unproject Implementation, 293

Requesting OpenGL Attributes, 129

Shader::CompileShader Implementation, 143

Shader::IsCompiled Implementation, 144

Shader::Load Implementation, 144145

Shader::SetMatrixUniform, 165

Ship Declaration, 54

SkeletalMeshComponent Declaration, 377

Skeleton Declaration, 378379

Skeleton PhysWorld Declaration, 325326

Skinned.vert Main Function, 385386

SoundEvent Declaration, 232

SoundEvent's Is3D and Set3DAttributes Implementation, 236237

SplineCamera::Update, 291292

Spline::Compute Implementation, 290

SpriteComponent Declaration, 4546

SpriteComponent::Draw Implementation, 48

Sprite.frag Implementation, 177

Sprite.vert Implementation, 176

Swept-Sphere Intersection, 323

Texture Declaration, 170171

Texture::Load Implementation, 172173

Transform.vert Vertex Shader, 164

UIScreen::ProcessInput, 348349

Updating Position and Rotation of the First-Person Model, 280

Using SegmentCast for Ball Movement, 328

VertexArray Declaration, 135

Z-Buffering Pseudocode, 202

Load function, 144145, 338339, 379

LoadActors, 438

LoadBank, 227228

LoadBinary, 452453

LoadComponents, 443444

LoadData function, 44

LoadGlobalProperties, 434

loading

3D models, 190

animation data, skeletal animation, 380385

banks, 227229

binary mesh files, 452454

G-buffer global lighting shader, 416

global properties, 430434

gpmesh files, 194195

image files, 4344

level files, 430

actors, 435439

components, 439444

global properties, 430434

shaders

adding shaders to games, 146

CompileShader, 142143

IsCompiled, 143144

IsValidProgram, 145

Load, 144145

OpenGL, 141142

SetActive, 145

Unload, 146

skeletons, 378380

textures, 170173

LoadJSON, 431433

LoadLevel function, 431

LoadProperties, 436, 441

LoadShaders, 146, 415

LoadText, 359

local lighting model, 209

local pose, 368

localization, 358, 361

text maps, adding, 359361

Unicode, 358359

look-at matrix, 196

low-pass filter, occlusion, 243

low-quality reflections, 401

M

Mac, installing FMOD, 223

macros

offsetof macro, 175

SDL_BUTTON macro, 257

main function, 1011

Manhattan distance heuristics, 104105

maps, 474475

hash maps, 475

mass, 7980

Math::Clamp, 266

Math::Cos, 67

Math.h library

Dot function, 70

Normalize(), 66

Math::Max, 313

Math::NearZero function, 7374

Math::Sin, 67

Math::ToDegrees, 47

matrices

inverse bind pose matrix, 371

look-at matrix, 196

transformations, matrix multiplication, 154155

transformations and, 154

transforming points, 155157

view matrix (3D), 196197

view-projection matrix, calculating, 200

matrix multiplication, 154155, 156

matrix palettes, 385

max players, 116

maxAngularSpeed, 277

maxMouseSpeed, 277

MaxPlayer, 119

MaxPlayerLimit function, 120

mCurrFrame, 50

membership tests, 106

memory allocation, 462463

memory usage, reducing, 375

Mesh, 194195

MeshBinHeader, 449450

MeshBinHeader*, 451

MeshComponent, 439

3D, 204206

MeshComponent::GetType, 441

MeshComponent::LoadProperties, 442

meshes, drawing 3D meshes, 195196

Mesh::Load, 195, 452

Mesh::LoadBinary, 452453

Mesh::SaveBinary, 450451

Microsoft Visual Studio Community 2017, 2

Microsoft Windows

API (application programming interface), 3

setting up development environments, 2

min players, 116

MinDistSq, 300301, 313

minimax, 118119

MinimaxDecide, 119

mirror framebuffer, creating, 403404

mirror texture, drawing in HUD, 406407

MirrorCamera, 405

mirrors, rendering framebuffer objects, 404405

mixing audio, 241242

monolithic hierarchy, 36

mouse, 256

buttons and position, 256258

FPS angular speed, 277

relative motion, 258259

scroll wheels, 260261

MouseState, 257258

MoveComponent, 190, 276

creating, 7375

movement, 270

first-person camera, 276277

InputComponent class, creating, 7679

MoveComponent class, creating, 7375

multiple controllers, 269270

multiplying vectors, 6263

N

narrowphase techniques, 331

nav mesh, 115116

NavComponent, 114

navigation meshes, 115116

NDC (normalized device coordinates), 132133

nearest-neighbor filtering, 395

nearest-neighbor mipmapping, 398

negative edges, 248251

Newtonian physics, 79

linear mechanics, 7980

node adoption, 111

nodes, 98

goal nodes, 100

parent nodes, 100

path nodes, 115

start nodes, 100

NodeToPointerMap, 101

non-player characters (NPCs), 115

normal vectors, calculating, 7072

normalization, unit vectors, 6566

Normalize(), 66

normalized device coordinates (NDC), 132133

NPCs (non-player characters), 115

numeric integration, 8081

O

OBB (oriented bounding box), 306

object space, 149150

occlusion, 243244

offsetof macro, 175

OnClick, 347, 349

OnEnter, 95

OnExit, 95

OnUpdateWorldTransform, 324325

open set, GBFS (greedy best-first search), 106

OpenGL

alpha blending, 178180

anisotropic filtering, 399

context, 130

initializing, 128

loading shaders, 141142

adding shaders to games, 146

CompileShader, 142143

IsCompiled, 143144

IsValidProgram, 145

Load, 144145

SetActive, 145

Unload, 146

mipmapping, 399

rendering frames, 131

requesting attributes, 129

setting up OpenGL window, 128129

texture mapping, 167170

updating vertex format, 173175

UBOs (uniform buffer objects), 165

vertex array object, 134135

writing basic shaders, 139141

operator overloading, 468470

operator+, 469

optimizing A*, 113

orbit cameras, 286288

OrbitCamera class, 287

OrbitCamera::Update, 287288

oriented bounding box (OBB), 306

orthographic projection, 197

outMap, 101

overdraw, 200

overloading operators, 468470

P

Pac-Man game

partial class hierarchy, 36

pseudocode, 6

state machine behaviors, 92

paddles

drawing, 2023

updating position of, 2628

painter’s algorithm, issues with in 3D, 200201

parallax effect, 53

parameters, sound events, 223

parent nodes, 100

pass by value, 459

path nodes, 115

path-cost component, 111

pathfinding, AI (artificial intelligence), 98

BFS (breadth-first search), 100103

Dijkstra’s Algorithm, 113114

following paths, 114115

heuristics, 104105

navigation meshes, 115116

path nodes, 115

Patrol state, 92, 9495

pause menu, 344345

perspective divide, 199

perspective projection, 197

phantom inputs, 265

Phong reflection model, 209211

Phong shading, 211

physics, Newtonian physics, 79

linear mechanics, 7980

PhysWorld class, 325327

testing ball collisions, 329331

PhysWorld::TestPairWise, 329

pitch, 185

pixels, 14

PlaneActor, 331, 333

planes, 301302

platform specific libraries, 3

player collision, against walls, 331333

PlayEvent, 229, 230, 238

playing event instances, 229230

PNG files, 43

point light fragment shaders, 419421

point lights, 208

adding, 418419

drawing, 421424

pointers, 459460

PointLightComponent class, adding, 419

PointLightComponent::Draw, 423424

points, transforming, with matrices, 155157

polling, 248

polygons, 131132

Pong

drawing walls, balls, and paddles, 2023

updating

ball’s position, 2830

paddle’s position, 2628

poses, skeletons and, 367370

position of

balls, updating, 2830

mouse, 256258

paddles, updating, 2628

positional functionality, adding to SoundEvent, 236237

positions, computing with Euler integration, 80

positive edges, 248251

PosNormTex format, 191192

PrepareForUpdate, 255, 264

printf function, 8

processing, basic input processing, 1113

ProcessInput, 1112, 13, 251, 343

InputComponent class, 76

ProcessKeyboard function, 54

projection matrix (3D), transforming, clip space, 197200

properties, loading global properties, 430434

Q

quality, improving texture quality, 394

quaternions, 186187

in code, 188189

combining, rotations, 187

MoveComponent, 190

quaternion-to-rotation matrix, 188

rotating vectors, 188

spherical linear interpolation (Slerp), 188

quaternion-to-rotation matrix, 188

queues, 473474

quit dialog box, 351

R

radar

adding, 354358

drawing, 357

Random function, 75

range-based For loops, 475476

RapidJSON, 194, 430, 449

saving level files, 444446

raster graphics, 14

real time, 24

red, green, blue (RGB), 14

reducing memory usage, 375

references, 458459, 464465

reflections, 401

refresh rate, 16

RegisterState function, 96

relative motion, mouse input, 258259

RemoteTarget, 352

RemoveActor, 41

Renderer, abbreviated declaration, 195196

renderer, 19

Renderer::Draw, 343, 377, 405

Renderer::DrawFromGBuffer, 417

Renderer::GetScreenDirection, 294

Renderer::Initialize, 404, 411

Renderer::Shutdown, 404, 411

rendering

framebuffer objects, 404405

frames, OpenGL, 131

to textures, 400401

creating framebuffer objects, 402404

creating textures, 401402

RenderText, 338, 340, 347

repositories, 3

requesting OpenGL, attributes, 129

resolution, 14

supporting multiple resolutions, 361362

reticule, adding, aiming reticule, 352354

reverb, 242

RGB (red, green, and blue), 14

RGBA, 1415

roll, 185

RotateToNewForward, 327328

rotating vectors, quaternions, 188

rotation, 152

combining for 3D, 187

Euler angles, 3D, 185186

quaternions, 3D, 186187

quaternion-to-rotation matrix, 188

rotation matrix, 157158

row vectors, 155

RunLoop function, 910

S

sample data, 226227

SaveActors, 447448

SaveBinary, 450451

SaveComponents, 448

SaveLevel, 445, 446

saving

binary mesh files, 449452

level files, 444446

actors, 446448

components, 446448

global properties, 446

scalar multiplication, 6263

scale, 151152

scale matrix, 157

scaling vectors, 6263

screen tearing, 1617

scroll wheels, mouse input, 260261

scrolling backgrounds, 5153

SDL (Simple DirectMedia Layer) library, 4

input devices, 251

SDL 2D coordinate system, mouse position, 257

SDL controller axis constants, 264

SDL Image, 43

SDL image file formats, 43

SDL subsystem flags, 8

SDL TTF library, 338

SDL_BUTTON macro, 257

SDL_CreateRenderer, 19

SDL_CreateTextureFromSurface, 43

SDL_CreateWindow function, 8, 128

SDL_DestroyRenderer, 19

SDL_Event, 12

SDL_GameControllerAddMappingsFromFile, 262

SDL_GameControllerGetAxis, 267

SDL_GameControllerGetButton, 264

SDL_GameControllerOpen, 261

SDL_GetKeyboardState, 13, 248, 253

SDL_GetMouseState, 256258

SDL_GetRelativeMouseState, 259, 277

SDL_GetTicks, 25

SDL_INIT_AUDIO, 8

SDL_INIT_GAMECONTROLLER, 8

SDL_INIT_HAPTIC, 8

SDL_INIT_VIDEO, 8

SDL_Log function, 8

SDL_PollEvent function, 1112

SDL_QueryTexture, 46

SDL_QUIT, 12

SDL_Rect, 21

SDL_RenderClear, 20

SDL_RenderCopy, 47

SDL_RenderCopyEx, 47

SDL_Renderer, 128

SDL_RenderFillRect, 20, 22

SDL_RenderPresent, 20

SDL_SCANCODE, 13

SDL_SetRenderDrawColor, 20

SDL_ShowCursor, 256

SDL_Surface, 43, 339

SDL_Texture, 44

SDL_WINDOW_FULLSCREEN, 9

SDL_WINDOW_FULLSCREEN_DESKTOP, 9

SDL_WINDOW_OPENGL, 9

SDL_WINDOW_RESIZABLE, 9

SegmentCast, 326

ball collisions, 327328

Set3DAttributes, 236237

set3DSettings, 241

SetActive, 137, 145, 416

SetAnimTextures function, 50

SetIntUniform, 415416

SetListener, 235, 236

SetMatrixUniform, 164, 165, 386

setMatrixUniform, 415416

SetName, 347

SetTexture function, 46

SetTexturesActive, 416417

setting up

development environments, 2

Apple macOS, 2

Microsoft Windows, 2

listeners, for 3D positional audio, 234236

OpenGL window, 128129

SetViewMatrix, 277278

SetVolume, 242

shader programs, 145

shaders, 138

adding shaders to games, 146

BasicMesh shader, 203204

BasicMesh.vert shader, 421

fragment shaders, 139

loading, 141142

CompileShader, 142143

IsCompiled, 143144

IsValidProgram, 145

Load, 144145

SetActive, 145

Unload, 146

point light fragment shaders, 419421

skinning vertex shaders, 385387

updating, 175176

Sprite.frag shader, 176178

to use transform matrices, 163167

vertex shaders, 138139

writing basic shaders, 139

Basic.frag file, 141

Basic.vert file, 139140

Ship::UpdateActor function, 54

Shutdown function, 2D graphics, 19

Shutdown function, 9

Simple DirectMedia Layer. See SDL

Simple OpenGL Image Library (SOIL), 170

SimpleViewProjection matrix, 163

single controllers, enabling, 261262

single-threaded game loop, 5

skeletal animation, 365367

animation data, 371372

drawing with skinning vertex attributes, 374378

implementing, 373374

inverse bind pose matrix, 371

loading animation data, 380385

loading skeletons, 378380

skeletons and poses, 367370

skinning, 372373

skinning vertex shader, 385387

updating, 386389

skeletal hierarchy, 367368

SkeletalMeshComponent, 376377, 380, 383384, 441

SkeletalMeshComponent::Draw, 386

SkeletalMeshComponent::Update, 388389

skeleton game class, 67

Initialize function, 79

RunLoop function, 910

Shutdown function, 9

skeletons

loading, 378380

poses and, 367370

skinned animation. See skeletal animation

Skinned.vert, 374, 385386

skinning, 372373

skinning vertex attributes, drawing with, 374378

skinning vertex shaders, 385387

Slerp (spherical linear interpolation), 188

smoothstep function, 421

SnapToIdeal, 285

SOIL (Simple OpenGL Image Library), 170, 172

sound effects, third-person games, 239240

sound events, 223

sound occlusion, 243244

SoundEvent class, 230233

adding positional functionality to, 236237

SoundEvent::IsValid, 233

sounds. See audio

source code, 3

source control systems, 3

space

clip space. See clip space, 161163

object space, 149150

world space, 150

transforming, 150151

sphere contains point tests, 308

sphere versus AABB test, 312313

sphere versus sphere tests, 311

spheres, 303

spherical linear interpolation (Slerp), 188

spline cameras, 289292

SplineCamera class, 290

SplineCamera::Update, 291292

Spline::Compute, 290

splines, Catmull-Rom spline, 289

spotlight, 209

springs, adding to follow cameras, 283285

SpriteComponent, 4546, 166

SpriteComponent::Draw, 4748, 166167, 173

Sprite.frag shader, 176178

sprites, 42, 148

animating, 4850

drawing, 4448

texture-mapped sprites, 178

Sprite.vert shader, 175176

stacks, 474

start nodes, 100

state machine behaviors, AI (artificial intelligence), 92

state machines

designing, 9293

implementing, 9395

transitions, 94

states, as classes, 9598

static objects, 34

std::function, 346, 437, 442

std::map, 475

std::pair, 476

std::queue, 474

std::string, 359, 437

std::unordered_map, 475

std::vector, 319, 370

strafe speed, 276

streaming data, 226227

subtraction, vectors, 6162

supporting multiple resolutions, 361362

surround sound, 234

Swap, 462

sweep-and-prune, 331

swept-sphere intersection, 323

swizzle, 213214

T

TargetActor, 435

TargetComponent, 353, 354

testing ball collisions in PhysWorld, 329331

TestPairWise, 329

tests

contains point tests. See contains point tests

instantaneous tests, 321

intersection tests. See intersection tests

line segment tests. See line segment tests

TestSweepAndPrune, 330331

texel density, 394

texels, 394

text, localization, 361

text maps, adding, 359361

texture coordinates, 168, 395

texture mapping, 167170

updating, vertex format, 173175

texture quality, improving, 394

texture sampling, 395397

Texture::Load, 172173

texture-mapped sprites, 178

textures

drawing, 47

loading, 170173

rendering to, 400401

creating framebuffer objects, 402404

creating textures, 401402

Texture::SetActive, 173

Texture::Unload, 173

third-person games, listeners, 239240

tic-tac-toe, game trees, 116117

ToMatrix, 369

tower defense game, 124

tracking

event instances, 230

loaded banks and events, 227

tracks, 380

transform matrices

3D, 184185

updating shaders, 163167

transformation matrix, 155

transformations, 148149

combining, 152153, 159

matrices, 154

matrix multiplication, 154155

TransformComponent, 3738

transforming

clip space

projection matrix (3D), 197200

view matrix (3D), 196197

points, with matrices, 155157

from world space, to clip space, 161163

world space, 150151, 157

rotation, 152

rotation matrix, 157158

scale, 151152

scale matrix, 157

translation, 151

translation matrices, 158159

Transform.vert, 163

TransformWithPerspDiv, 293

transitions, 92

state machines, 94

translation, 151

translation matrices, 158159

triangles, 131132

drawing, 146148

transformations, 148149

fragment shaders, 139

normalized device coordinates (NDC), 132133

texture mapping, 167170

vertex and index buffers, 133138

vertex shaders, 138139

triggers, 34, 264

trilinear filtering, 398, 399, 400

TTF_OpenFont, 338

TTF_Quit, 338

TTF_RenderText_Blended, 339

turning on anisotropic filtering, 400

TurnTo function, 114

types of game objects, 34

U

UBOs (uniform buffer objects), 165

UI screen stack, 342344

UI screens, 340342

UIScreen, 340342

UIScreen::DrawScreen, 348

UIScreen::DrawTexture, 406

UIScreen::ProcessInput, 348349

undirected, 98

Unicode, 358359

uniform buffer objects (UBOs), 165

uniform cost search, 114

unit quaternions, 186

unit vectors, 6566

Unload function, 146

unloading banks, 227229

Unproject, 294

unprojection, 292294

unweighted graphs, 9899

Update function, 39, 50, 388389

UpdateActor, 39

UpdateComponents, 39

UpdateCrosshair, 353

UpdateGame, 25, 26, 4142

UpdateMinMax, 304, 305

updating

animations, skeletal animation, 386389

balls, position of, 2830

games, 23

delta time, 2428

game time, 24

real time, 24

paddles, position of, 2628

shaders

Sprite.frag shader, 176178

Sprite.vert shader, 175176

to use transform matrices, 163167

vertex attributes, 193194

vertex format, 173175

user interfaces (UI)

buttons, 346350

dialog boxes, 349352

font rendering, 338340

localization, 358, 361

text maps, 359361

Unicode, 358359

pause menu, 344345

supporting multiple resolutions, 361362

UI screen stack, 342344

UI screens, 340342

UTF-8, 358

UV coordinates, 395

V

VAO (vertex array object), 150

variable time steps, 8081

VecToFMOD, 234235

vector addition, 6364

vector subtraction, 6162

vectors, 5961, 471472

column vectors, 155, 156

combining, 6364

converting forward vectors to angles, 6768

converting from angles to forward vectors, 6667

determining angles between, dot product, 6870

determining directions, 6566

determining distance, length, 6465

normal vectors, calculating, 7072

rotating, with quaternions, 188

row vectors, 155

scaling, 6263

velocity, 7980

.vert extension, 139

vertex array object (VAO), 150

vertex, creating, 163

vertex attributes

lighting, 206207

updating, 193194

vertex buffers, 133138

vertex format, updating, 173175

vertex normal, 206

vertex shaders, 138139

VertexArray class, 135, 452

VertexArray constructor, 375376

vertical synchronization (vsync), 17

vertices, 98

view matrix (3D), transforming, clip space, 196197

view-projection matrix, 162

calculating, 200

Visual Studio, 2

vsync (vertical synchronization), 17

W

walls

drawing, 2023

player collision against, 331333

waypoint graphs, 115

weighted graphs, 99

weights, edges, 9899

Window Creation flags, 9

Windows, FMOD, installing, 223

windows, creating blank windows, 1011

world space, 150

combining transformations, 152153

transforming, 150151, 157

to clip space, 161163

rotation, 152

rotation matrix, 157158

scale, 151152

scale matrix, 157

translation, 151

translation matrices, 158159

world transform matrix, calculating, 189

world transforms, adding to actors, 159161

writing

basic shaders, 139

Basic.frag file, 141

Basic.vert file, 139140

to G-buffer, 412414

X

Xcode, installing, 2

.xyz syntax, 213214

Y

yaw, 185

Z

z-buffer, 201

z-buffering, 201203

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.229.143