3D Programming and DirectX API. Content Mathematics Mathematics Prepare to Write a 3D program Prepare to Write a 3D program Program Structure Program.

Slides:



Advertisements
Similar presentations
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Advertisements

Projective Texture Mapping
GAM666 – Introduction To Game Programming ● As of DirectX 8, DirectDraw (2D) and Direct3D (3D) have been combined into DirectX Graphics (still often called.
3D Graphics Rendering and Terrain Modeling
INTRODUCTION. Painting with numbers! Aspects Modeling Rendering Animation.
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics February 26, 2007.
1 Lecture 9 Lighting Light Sources Reflectance Camera Models.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
Surface Rendering With OpenGL CS460 Project by Rui Yu 11/30/03.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Introduction to DirectX Programming Dongho Kim February 12, 2002 Dongho Kim February 12, 2002.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics Introducing DirectX
Antigone Engine Kevin Kassing – Period
CS451 Computer Graphics JYH-MING LIEN DEPARTMENT OF COMPUTER SCIENCE GEORGE MASON UNIVERSITY.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Real-time Graphical Shader Programming with Cg (HLSL)
3D Visualisation of Simulation Data. Informal Seminar 08/03/2004. By Chris Sweet.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Geometric Objects and Transformations. Coordinate systems rial.html.
3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0.
Tennis for Two, 1958, by William Higinbotham, Brookhaven National Lab CSE 380 – Computer Game Programming Graphics Device Management.
OpenGL Shading Language (Advanced Computer Graphics) Ernest Tatum.
Week 2 - Wednesday CS361.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
1 ETC. 2 Sounds FX Sounds FX –WAV audio files –Load into memory and play it »Load »Play »Stop »Pause –2D or 3D »3D should be integrated into scene management.
The Graphics Rendering Pipeline 3D SCENE Collection of 3D primitives IMAGE Array of pixels Primitives: Basic geometric structures (points, lines, triangles,
Computer Graphics Using Direct 3D Introduction. 2 What are we doing here? Simply, learning how to make the computer draw.
CSE 581: Interactive Computer Graphics Spring 2012, UG 4 Tuesday, Thursday – 9:00AM – 10:18AM DL 0317 Raghu Machiraju Slides: Courtesy - Prof. Huamin Wang,
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
The Cg Runtime Cyril Zeller. Cg Pipeline Graphics programs are written in Cg and compiled to low-level assembly code... Cg Runtime API...
1 Contents  Audio  Sprite  Input devices  Game production milestones  Course summary.
Mark Nelson 3d projections Fall 2013
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Development of a Software Renderer for utilizing 3D Contents on a 2D-based Mobile System Sungkwan Kang 1, Joonseub Cha 2, Jimin Lee 1 and Jongan Park 1,
2009 GRAPHICS : PROJECT 1 BASED ON DX9 BASICS. Documented by Dongjoon Kim SNU CS Ph.D Course Student Contact : NOTE.
Computer Graphics IN5I11 Nabil H. Mustafa
Computer Graphics 3 Lecture 6: Other Hardware-Based Extensions Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
GAM666 – Introduction To Game Programming ● Programmer's perspective of Game Industry ● Introduction to Windows Programming ● 2D animation using DirectX.
Ray Tracing using Programmable Graphics Hardware
Current Student – University of Wisconsin – Stout Applied Mathematics and Computer Science: Software Development Associate Degree in Computer Programming.
Mobile & Casual Gaming OpenGL ES Intro. /red/chapter03.html.
Computer Science – Game DesignUC Santa Cruz Tile Engine.
Martin Kruliš by Martin Kruliš (v1.0)1.
Applications and Rendering pipeline
Computer Graphics Overview
Ying Zhu Georgia State University
School of Computer Science
CUDA Interoperability with Graphical Environments
고급 컴퓨터 그래픽스 (Advanced Computer Graphics)
Advanced Graphics Algorithms Ying Zhu Georgia State University
3D Graphics Rendering PPT By Ricardo Veguilla.
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Understanding Theory and application of 3D
Managed DirectX Joe Gavin.
Reflections from Bumpy Surfaces
Vector iconography: Using SVG images in your app
HW for Computer Graphics
Chapter I Introduction
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
03 | Creating, Texturing and Moving Objects
Computer Graphics Introducing DirectX
Presentation transcript:

3D Programming and DirectX API

Content Mathematics Mathematics Prepare to Write a 3D program Prepare to Write a 3D program Program Structure Program Structure How does the computer calculate 3D image? How does the computer calculate 3D image? Illustration Illustration Other Features in DirectX Library Other Features in DirectX Library

Mathematics Don ’ t worry! If you see this chapter in the book, just skip it, because you ’ ve learned. Don ’ t worry! If you see this chapter in the book, just skip it, because you ’ ve learned. Importance of “ Transform ” Importance of “ Transform ” –Translation –Rotation –Scaling – …… Vector & Matrix Vector & Matrix Other Advanced Algorithm Other Advanced Algorithm

Prepare to Write a 3D program Using Direct3D Using Direct3D Compiler - VS.NET 2003 Compiler - VS.NET 2003 Download DirectX SDK Download DirectX SDK – us/dnanchor/html/anch_directx.asp us/dnanchor/html/anch_directx.asphttp://msdn.microsoft.com/library/default.asp?url=/library/en- us/dnanchor/html/anch_directx.asp –DirectX 9.0 SDK Update - (February 2005) An Easy Book An Easy Book MSDN – MSDN –

Program Structure Initialize D3D Library – Create Device Initialize D3D Library – Create Device Loading or Building Model Loading or Building Model Set Light, Material, and Texture Set Light, Material, and Texture Calculate Transform Matrix, View Matrix, and Projection Matrix Calculate Transform Matrix, View Matrix, and Projection Matrix Render! Render!

Initialize D3D Library IDirect3D9* IDirect3D9* Direct3DCreate9(D3D_SDK_VERSION) Direct3DCreate9(D3D_SDK_VERSION) IDirect3DDevice9* IDirect3DDevice9* CreateDevice() CreateDevice() IDirect3D * CreateDevice() Direct3DCreate9() D3DLibrary IDirect3DDevice9* 3D Device( 3D Card)

How does the computer calculate 3D image? CPU and GPU (Graphic Process Unit) CPU and GPU (Graphic Process Unit) 3D Library – OpenGL and Direct3D 3D Library – OpenGL and Direct3D

How does the computer calculate 3D image? Pipeline Pipeline Data in Model Space World Space World Matrix View Matrix Projection Matrix CPUGPU Camera Space View Space (your screen) Vertex Data Light, Texture, Material

Loading and Building Modal Vertex/Index Buffer Vertex/Index Buffer The Structure of Vertex The Structure of Vertex V1V2 V3 V4 V1 V2 V3 V … … Index Buffer Vertex Buffer

struct Vertex { float x, y, z; float x, y, z; float nx, ny, nz; float nx, ny, nz; float u, v; // texture coordinates float u, v; // texture coordinates}; #define FVF_VERTEX (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1) Demo 1-TexCube Loading and Building Modal XYZnXnY nZU V…

Loading and Building Modal X-file X-file –When the model is complex, we can ’ t build it in our code. –Using 3D graphic tool, ex. Maya, 3D studio MAX, Lightwave, MilkShake –Direct3D have already provide funcs to load and parse X-file –Static Model and Animation Model

Set Light, Material, and Texture Light - light source Light - light source D3DLIGHT9 light; light.Type = D3DLIGHT_DIRECTIONAL; light.Ambient = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f); light.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); light.Specular = D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f); light.Direction = D3DXVECTOR3(1.0f, -1.0f, 0.0f); Demo 2-TexCube 3-TexCube 4-TexCube

Set Light, Material, and Texture Material – reflection of light Material – reflection of light {1.0, 1.0, 0.0, 1.0} {1.0, 0.0, 1.0, 1.0} {0.0, 1.0, 1.0, 1.0} Demo EffetEdit

Set Light, Material, and Texture Texture – surface of 3D object Texture – surface of 3D object Demo 4-Tex 5-Tex

Calculate World Matrix, View Matrix, and Projection Matrix World Matrix World Matrix –D3DXMatrixTranslation( … ) –D3DXMatrixRotationX( … ) –D3DXMatrixIdentity( … ) –D3DXMatrixScaling( … )

Calculate World Matrix, View Matrix, and Projection Matrix View Matrix View Matrix –D3DXMatrixLookAtLH(&V, &position, &target, &up);

Calculate World Matrix, View Matrix, and Projection Matrix Projection Matrix Projection MatrixD3DXMatrixPerspectiveFovLH();

Demo 7-TexCube 8-TexCube

Render!! Prepare for render Prepare for render Device->SetTransform(D3DTS_VIEW, &V); Device->SetTransform(D3DTS_WORLD, &V); Device->SetTransform(D3DTS_PROJECTION, &V); Start and Finish Render Start and Finish Render Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0); Device->BeginScene(); ……./* render render render !!!! */…. Device->EndScene();

Render !! if( mtrl ) device->SetMaterial(mtrl); if( tex ) device->SetTexture(0, tex); device->SetStreamSource(0, _vb, 0, sizeof(Vertex)); device->SetIndices(_ib);device->SetFVF(FVF_VERTEX);device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,24,0,12); Set Material Set Texture Set Index Buffer Tell D3D your vertex format Just Draw It!!

More Skill Terrain – Height Map Terrain – Height Map Shadow Shadow Other Algorithm … Other Algorithm … Good website : Good website :

Samples Airplane Airplane Walking Man Walking Man BasicHLSL BasicHLSL ShadowVolume ShadowVolume Terrain Terrain

Other Features in DirectX Library DirectPlay DirectPlay –Network Game DirectSound DirectSound –Handle sound effect