1 / 23

Game Programming :Programming Lab 2

Game Programming :Programming Lab 2. 2008/9/24 Kim, HyungSeok. Part I: Framework 1. Windows creation 2. Renderer 3. Lights and Objects/Model loading 4. GUI design/Input system/Sound. Part II: Simulation 5. Math libs 6. Collision detection 7. Basic scripting 8. Model animation

jerica
Télécharger la présentation

Game Programming :Programming Lab 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Game Programming:Programming Lab 2 2008/9/24 Kim, HyungSeok

  2. Part I: Framework 1. Windows creation 2. Renderer 3. Lights and Objects/Model loading 4. GUI design/Input system/Sound Part II: Simulation 5. Math libs 6. Collision detection 7. Basic scripting 8. Model animation Part III: Advanced rendering 9. Special effects 10. Textures Part IV: Final 11. Game final Programming Labs HyungSeok Kim, Konkuk University

  3. Game Engine • Rendering • Video • Audio • Haptic, … • Simulation • AI • Math calculation • User interface • Input • Scene graph HyungSeok Kim, Konkuk University

  4. What we have done in Lab #1 • Create a frame for an engine • Game Engine • Main loop • Class Renderer • Class Simulator • … HyungSeok Kim, Konkuk University

  5. Lab #2 • Create a basic scene graph structures • Which object to create? • Which structure to hold? • Create a basic renderer • How to put renderer into the framework? • Which functionality the renderer will have? HyungSeok Kim, Konkuk University

  6. Scene Definition • Task 1: Following the last Homework • Create a scene database • How? • Requirement analysis • Specification • Implementation HyungSeok Kim, Konkuk University

  7. Scene Definition • Common properties of objects • Position • Orientation • Transform matrix • Shape • Mesh • … and more HyungSeok Kim, Konkuk University

  8. Scene Definition • Scene structure • Why? • How? • Array? • Tree? • Any others? • Your proposition • Pros and cons HyungSeok Kim, Konkuk University

  9. Scene Definition • Scene Graph • Tree-like approach HyungSeok Kim, Konkuk University

  10. Scene Definition • 1. Class hierarchy definition • 2. Data definition • Position/Orientation? • Shape? HyungSeok Kim, Konkuk University

  11. Transform Matrix • Transform Matrix • Matrix for specifying position and orientation • Translation • Rotation • Matrix concatenation and storage HyungSeok Kim, Konkuk University

  12. Hierarchical Transform • Hierarchical transform • World matrix stack • Why stack? HyungSeok Kim, Konkuk University

  13. Exemplar Code in D3D ID3DXMatrixStack* pMatrixStack; D3DXCreateMatrixStack(0,&pMatrixStack); pMatrixStack->LoadMatrix(<Hand matrix>); <Draw Hand> For childrens • pMatrixStack->Push(); • pMatrixStack->MultMatrix(<Finger 1 matrix>); • <Draw Finger 1> • For childrens if any • … • pMatrixStack->Pop(); HyungSeok Kim, Konkuk University

  14. Exemplar Code in OpenGL glLoadMatrix(<Hand matrix>); <Draw Hand> For childrens • glPushMatrix(); • glMultMatrix(<Finger 1 matrix>); • <Draw Finger 1> • For childrens if any • … • glPopMatrix(); HyungSeok Kim, Konkuk University

  15. What to Store? • Matrix • Translation (x,y,z) • Rotation • How? • Quaternion HyungSeok Kim, Konkuk University

  16. D3D functions • Mesh • Container for a shape • Shape-wise representation: an object • Use a container instead of separated elements • Easy representation and control of multiple shapes • Store/load of a shape • OpenGL: vertex array, index array, … • D3D: class ID3DXMesh; HyungSeok Kim, Konkuk University

  17. Displaying a Mesh • D3D • HRESULT ID3DXBaseMesh::DrawSubset(DWORD AttribId ); • Subset • A group of triangles which has the same material and states • OpenGL • glDrawPrimitives, glDrawElements, … HyungSeok Kim, Konkuk University

  18. Scene Definition • class Scene { … }; • Singleton • Access scene definition • Array case: able to get array • Tree case: able to get tree root • … HyungSeok Kim, Konkuk University

  19. Lab #2 – Task 1 • Create Box or Sphere and add it to your scene • OpenGL • GLUquadricObj* gluNewQuadric( void ); • void gluSphere( GLUquadricObj *qobj,GLdouble radius,GLint slices,GLint stacks); • D3D • HRESULT D3DXCreateBox(LPDIRECT3DDEVICE9 pDevice, FLOAT width, FLOAT height, FLOAT depth, LPD3DXMESH *ppMesh, LPD3DXBUFFER *ppAdjacency); • Draw HyungSeok Kim, Konkuk University

  20. Renderer • Render scene periodically • Should be called in main loop • Event-based update vs. Continuous update HyungSeok Kim, Konkuk University

  21. Renderer • Functions • Traverse scene database • Scene graph • Scene array? • … • Render each object • Optimization HyungSeok Kim, Konkuk University

  22. Lab #2 – Task 2 • Add another box or sphere to the scene graph • Render all HyungSeok Kim, Konkuk University

  23. Conclusion HyungSeok Kim, Konkuk University

More Related