Download - Basic Flight Simulation
![Page 1: Basic Flight Simulation](https://reader030.vdocuments.site/reader030/viewer/2022012800/61bd026661276e740b0e6cd8/html5/thumbnails/1.jpg)
Game Programming
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Basic Flight Simulation
September 12, 2005
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Objectives
Practice in using our camera model and basic terrain rendering
![Page 2: Basic Flight Simulation](https://reader030.vdocuments.site/reader030/viewer/2022012800/61bd026661276e740b0e6cd8/html5/thumbnails/2.jpg)
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Two Cameras
First camera – first person viewbehind an airplane
Second camera – whole viewcorner of the terrain
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Airplane (1)
ID3DXMesh interfacecreating an empty mesh
creating an object and loading the geometric data from X file
HRESULT D3DXLoadMeshFromX (LPCSTR pFilename,DWORD Options,LPDIRECT3DDEVICE9 pDevice,LPD3DXBUFFER* ppAdjacency,LPD3DXBUFFER* ppMaterials,LPD3DXBUFFER* ppEffectInstances,PDWORD pNumMaterials,LPD3DXMESH* ppMesh
);
HRESULT D3DXLoadMeshFromX (LPCSTR pFilename,DWORD Options,LPDIRECT3DDEVICE9 pDevice,LPD3DXBUFFER* ppAdjacency,LPD3DXBUFFER* ppMaterials,LPD3DXBUFFER* ppEffectInstances,PDWORD pNumMaterials,LPD3DXMESH* ppMesh
);
HRESULT ID3DXCreateMeshFVF (DWORD NumFaces,DWORD NumVertices,DWORD Options,DWORD FVF,LPDIRECT3DDEVICE9 pDevice,LPD3DXMESH* ppMesh
);
HRESULT ID3DXCreateMeshFVF (DWORD NumFaces,DWORD NumVertices,DWORD Options,DWORD FVF,LPDIRECT3DDEVICE9 pDevice,LPD3DXMESH* ppMesh
);
![Page 3: Basic Flight Simulation](https://reader030.vdocuments.site/reader030/viewer/2022012800/61bd026661276e740b0e6cd8/html5/thumbnails/3.jpg)
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Airplane (2)
ID3DXMesh interface (cont.)reorganizing the vertices and indices of a mesh to render it more efficiently
drawing the triangles of a particular subset specified
ex) drawing all subsets of a mesh
HRESULT ID3DXMesh::OptimizeInplace (DWORD Flags,CONST DWORD* pAdjacencyIn,DWORD* pAdjacencyOut,DWORD* pFaceRemap,LPD3DXBUFFER* ppVertexRemap
);
HRESULT ID3DXMesh::OptimizeInplace (DWORD Flags,CONST DWORD* pAdjacencyIn,DWORD* pAdjacencyOut,DWORD* pFaceRemap,LPD3DXBUFFER* ppVertexRemap
);
HRESULT ID3DXMesh::DrawSubset(DWORD AttribId);HRESULT ID3DXMesh::DrawSubset(DWORD AttribId);
for(int i=0; i<numSubsets; i++) {Device->SetMaterial( mtrls[i] );Device->SetTexture( 0, textures[i] );Mesh->DrawSubset(i);
}
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Global Variables
![Page 4: Basic Flight Simulation](https://reader030.vdocuments.site/reader030/viewer/2022012800/61bd026661276e740b0e6cd8/html5/thumbnails/4.jpg)
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Setting a Second Camera
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Loading a Mesh from an X File
![Page 5: Basic Flight Simulation](https://reader030.vdocuments.site/reader030/viewer/2022012800/61bd026661276e740b0e6cd8/html5/thumbnails/5.jpg)
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Extracting Material & Texture
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Optimizing a Mesh
![Page 6: Basic Flight Simulation](https://reader030.vdocuments.site/reader030/viewer/2022012800/61bd026661276e740b0e6cd8/html5/thumbnails/6.jpg)
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Computing the Bounding Box
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Setting a Light
![Page 7: Basic Flight Simulation](https://reader030.vdocuments.site/reader030/viewer/2022012800/61bd026661276e740b0e6cd8/html5/thumbnails/7.jpg)
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Cleanup ( )
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Window Procedure
![Page 8: Basic Flight Simulation](https://reader030.vdocuments.site/reader030/viewer/2022012800/61bd026661276e740b0e6cd8/html5/thumbnails/8.jpg)
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Display ( ) – Keyboard
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Display ( ) – Viewing
![Page 9: Basic Flight Simulation](https://reader030.vdocuments.site/reader030/viewer/2022012800/61bd026661276e740b0e6cd8/html5/thumbnails/9.jpg)
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Display ( ) – Drawing a Mesh
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/gp2
Assignment # 1
Flight simulation + shooting game
Defaultsdifferent terrain
two more airplanes
flexible flight simulation
shoot a missile
Optionsfirework – particle system (chapter 14)
picking (chapter 15)
scores, levels of difficulty
etc.