Tricks of the 3D Game Programming Gurus 无水印pdf

所需积分/C币:20 2017-09-24 17:55:04 48.23MB PDF

Tricks of the 3D Game Programming Gurus 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
00067231835Cfm05·02·20032:312 M Page ii Tricks of the 3D Game programming gurus Associate publisher Advanced 3D Graphics and Rasterization Michael Stephens Copyright o 2003 by Sams Publishing Acquisitions Editor All rights reserved. No part of this book shall be reproduced, stored in Kim Spilker a retrieval system, or transmitted by any means electronic, mechani cal, photocopying, recording, or otherwise, without written permission Development Editor Mark renfrow from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution laging Editor has bccn taken in the preparation of this book the publisher and Charlotte Clapp author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the informa- Project Editor tion contained herein George E. Nedeff International standard book number: 0-672-31835-0 Copy Editors Library of Congress Catalog Card Nunber: 99-067392 Seth Kerney Printed in the United states of america Mike Henry First Printing: June 200 Indexer 06050403 4321 Erika millen Sams publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, Proofreaders Kevin Ober Case contact Suzanne thomas U.S. Corporate and government sales 1-800-382-3419 chnical editor David franson corpsales@pearsontechgroup co Team Coordinator For sales outside of the U.S., please contact Cindy teeter International sales 1-317581-3793 Multimedia Developer Dan Scherf international@pearsontechgroupcoIn Graphic Designer Trademarks Gary Adair All terms mentioned in this book that are known to be trademarks or Cover llustrator service marks have been appropriately capitalized. Sams Publishing Alex Varanese cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark Warning and disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The infor mation provided is on an"as is"basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the CD or programs accom panying it 000672318350fm05·02·20032:31 PM Page ill Contents at a glance Foreword XIX Introductio Part I Introduction to 3D Game Programming 1 Getting Started with 3D Game Programming 2 A Crash Course in Windows and directX 3 3D Game programming with a virtual Computer 115 Part Il 3D Math and transformation 4 It's a Math, Math, Math World--Trigonometry, Vectors, Matrices, and Quaternions 241 5 Building a Math engine 363 6 Introduction to 3D Graphics 493 7 Rendering wireframe worlds in 3D 621 Part Il Basic 3D Rendering 8 Basic lighting and Solid Modeling 743 9 Interpolative Shading Techniques and Affine Texture Mapping 869 10 Clipping in 3D++ 1005 1 Depth Buffering and visibility 1087 Part Iv Advanced 3D Rendering 12 Advanced Texturing techniques 1147 13 Spatial partitioning and visible algorithms 1307 14 Lighting, Shadows, and Secrets of the id 1439 Part v Advanced animation and physics modeling and optimization 15 Character Animation, Motion and collision detection 1493 16 Optimization Technologies 1549 00067231835Cfm05·02·20032:312 M Page iv Part VI CD-ROM Appendixes a About The CD-rom B Installing DirectX and Using Visual C/C++ c Trigonometry and Vector Reference D C++ primer E Game Programming Resources F ASCII Tables Index 000 000672318350fm05·02·20032:31 PM Page v Table of contents Introduction PartI Introduction to 3D Game Programming 1 Getting Started with 3D Game Programming A Brief introduction The elements of a 2d/3D game Section 1: Initialization Section 2: Enter Game Loop Section 3 Retrieve player Inpu 912222 Section 4 Perform Al and Game logic Section 5: Render next frame 13 Section 6: Synchronize Display 13 Section z: l 13 13 General game programming guidelines 17 sing tools 22 3D Level editors 26 Setting Up to get Down-USing The Compiler 28 A Sample 3D Game: Raiders 3D 32 The event le 61 The Core 3D Game logic 61 3D Projections 63 The star field The laser cannons and collision detection 66 The explosions 67 Playing Raiders 67 Summ 67 2 A Crash Course in windows and directx 69 The Win32 Programming Model The Bare Minimum for a Windows Program 71 It All Begins with WinMain () 71 A Basic windows applicatio The windows class 78 Registering the Windows Class 84 Creating the window 00067231835Cfm05·02·20032:312 M Page vi Tricks of the 3D Game Programming Gurus: Advanced 3D Graphics and Rasterization The event ilandler 87 The Main Event Loop Making a real-Time event Loop QO DirectX and com crash Coursc 101 The hel and hal l03 The directX Foundation Classes in Depth 104 Flash Introduction to COM 106 What Exactly Is a COM Object? 107 Creating and Using DirectX COM interfaces 110 Querying for Interfaces 111 Summary 114 3 3D Game Programming with a Virtual Computer 115 Introduction to the virtual Computer interface Building the virtual computer Interface 118 The Frame Buffer and Video System 118 th color 123 Animating the Display 125 The Complete Virtual Graphics System 128 I/O, Sound, and music 129 The t3dlib game console 130 T3DLIB System Overview 131 The basic game Console 131 The T3DLIB1 Library 139 The directX Graphics Engine architecture 139 Basic definitions Working macros 142 Data t d structures 143 Function Prototypes 147 Global domination 53 The direct draw interface 15 2n Polygon Functions 160 Math and error functions 169 Bitmap functions 8-Bit palette Functions 177 Utility functions 181 The BoB (Blitter object) Engine 183 The T3DLIB2 DirectX Input system 193 The T3DLIB3 Sound and Music Library 201 The header 201 The Type 202 000672318350fm05·02·20032:31 PM Page vil Contents Global domination 203 The DirectSound apI Wrapper 204 The DirectMusic API Rapper 210 Building the Final T3D Game Console 214 Mapping the Real graphics to the Unreal Graphics of the Virtual interface 214 The Final t3dliB game Console 218 mple T3LIB Applicatio 231 Windowed applications 231 Full-Screen Applicati 232 Sound and music 233 Working with Input 234 summary 238 Part ll 3D Math and transformation 4 It's a Math, Math, Math World--Trigonometry, Vectors, Matrices, and Quaternions 241 Mathematical notation 242 2D Coordinate systems 243 2D Cartesian coordinates 243 2D Polar Coordinates 246 3D Coordinate systems 249 3D Cartesian Coordinates 249 3D Cylindrical Coordinates 252 Converting Between 3D Cartesian and polar coordinates 253 3D Spherical coordinates 253 1gonometry 256 The right Triangle 256 Inverse Trigonometric Functions 259 rigonometric Identities 259 Vectors 261 Vector Length 262 Normalization 263 Scalar multiplication 263 Vector Addition 265 265 The inner product, or the "dot product 266 The Cross product 270 The zero vector 272 000672318350fm05·02·20032:31 PM Page viil Tricks of the 3D Game Programming Gurus: Advanced 3D Graphics and Rasterization Position and displacement Vectors 272 Vectors as linear combinations 273 Matrices and Linear algebra 273 The identity matrix .275 Matrix addition 276 Transpose of a Matrix 276 Matrix Multiplication 277 Laws for Matrix Operations 279 Computing the inverse and solving systems 279 Cramer's rule 282 Transformations using matrices 285 Homogeneous Coordinates 286 Applied Matrix Transformations 287 Basic geometric entities 296 Points 297 Lir 297 Lines in 3d Space Planes 302 Using Parametric Equations 307 2D and 3d parametric lines 307 Parametric line segments with Standard Direction Vector v 308 Parametric Line segments with Unit Direction Vector lvI= 1 309 Parametric lines in 3D 311 Introduction to Quaternions 317 Complex Number Theory 318 Hyper-Complex Numbers 325 Applications of Quaternions 333 Basic calculus 337 The concept of Infinity 337 340 Summation and finite series 341 Infinite series 344 Derivatives 345 Integrals ummary 361 5 Building a Math Engine 363 Brief overview of the math engine 364 File Structure of the math Engine 364 Naming convention g S 365 00067231835Cfm05·02·20032:312 M Page ix Contents Error llandli My Final word on c++ 366 Data Structures and Ty 367 Vectors and points 367 Parametric lines 369 3D Planes 371 Matrices 372 376 Angular Coordinate System Support 377 Polar 2D 378 Cylindrical 3d 379 c al 3d Fixed-Point numbers 381 Math Constants 382 Macros and inline functions General utility and conversion 390 Points andⅴ actors 390 Matrices Quaternions 394 Fixed-Point math 395 Prototypes 395 Globals 400 Math Engine apI listing 401 Trigonometric Functions 401 Coordinate system support functions 403 Vector Support Functions 407 Matrix Support Functions 4 2D and 3d parametric line support functions 434 3D Plane support functions 440 Quaternion Support Functions 446 Fixed-Point Math Support Functions 458 Equation Solving Support 464 Floating-Point Unit Math Primer 468 The fpu architecture 469 The fpu stack 470 The fpu instruction set 472 Classical instruction format 475 Memory Instruction Format 475 Register Instruction Format 476 Register pop instruction Format 477 FPU Examples 477


关注 私信 TA的资源