Advanced Animation with Directx.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Table of Contents Advanced Animation with DirectX..................................................................................................................1 Introduction.........................................................................................................................................................4 Part One: Preparations.....................................................................................................................................7 Chapter 1: Preparing for the Book..................................................................................................................8 Overview.................................................................................................................................................8 Installing the DirectX SDK.....................................................................................................................8 Choosing the Debug or Retail Libraries...............................................................................................10 Configuring Your Compiler..................................................................................................................11 Setting the DirectX SDK Directories.............................................................................................11 Linking to the DirectX Libraries....................................................................................................12 Setting the Default char State.........................................................................................................14 Using the Book's Helper Code..............................................................................................................15 Using the Helper Objects...............................................................................................................15 Checking Out the Helper Functions...............................................................................................21 Moving On with the Book....................................................................................................................34 Part Two: Animation Basics...........................................................................................................................36 Chapter 2: Timing in Animation and Movement.........................................................................................37 Using Time−Based Motion...................................................................................................................37 Reading Time in Windows...................................................................................................................37 Animating with Time............................................................................................................................38 Moving with Time................................................................................................................................41 Moving along Paths........................................................................................................................41 Creating an .X Path Parser.............................................................................................................48 Creating In−Game Cinematic Sequences.......................................................................................53 Check Out the Demos...........................................................................................................................54 TimedAnim....................................................................................................................................54 TimedMovement............................................................................................................................55 Route..............................................................................................................................................55 Cinematic........................................................................................................................................56 Chapter 3: Using the .X File Format..............................................................................................................58 Working with .X Templates and Data Objects.....................................................................................58 Defining Templates........................................................................................................................61 Creating Data Objects from Templates..........................................................................................63 Embedding Data Objects and Template Restrictions.....................................................................64 Working with the DirectX Standard Templates.............................................................................65 Accessing .X Files................................................................................................................................66 Registering Custom and Standard Templates................................................................................66 Opening an .X File.........................................................................................................................67 Enumerating Data Objects..............................................................................................................68 Retrieving Data from a Data Object...............................................................................................72 Constructing an .X Parser Class.....................................................................................................75 Loading Meshes from .X......................................................................................................................79 Loading Meshes Using D3DX.......................................................................................................79 Loading Meshes with Your .X Parser............................................................................................82 i Table of Contents Chapter 3: Using the .X File Format Loading Skinned Meshes...............................................................................................................83 Loading Frame Hierarchies from .X.....................................................................................................84 Loading Animations from .X................................................................................................................86 Loading Custom Data from .X..............................................................................................................86 Check Out the Demos...........................................................................................................................88 ParseFrame.....................................................................................................................................88 ParseMesh......................................................................................................................................88 Part Three: Skeletal Animation......................................................................................................................90 Chapter 4: Working with Skeletal Animation..............................................................................................91 Overview...............................................................................................................................................91 Taking on Skeletal Animation..............................................................................................................91 Using Skeletal Structures and Bone Hierarchies..................................................................................92 Loading Hierarchies from .X..........................................................................................................93 Modifying Bone Orientation..........................................................................................................95 Updating the Hierarchy..................................................................................................................96 Working with Skinned Meshes.............................................................................................................97 Loading Skinned Meshes from .X................................................................................................100 Creating a Secondary Mesh Container.........................................................................................101 Mapping Bones to Frames............................................................................................................102 Manipulating the Skinned Mesh...................................................................................................103 Updating the Skinned Mesh.........................................................................................................104 Rendering the Skinned Mesh.......................................................................................................106 Check Out the Demo...........................................................................................................................106 Chapter 5: Using Key−Framed Skeletal Animation...................................................................................108 Using Key−Framed Skeletal Animation Sets.....................................................................................108