1 / 24

Direct3D Workshop

Direct3D Workshop. November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals. Workshop Breakdown. Part 1: 3D Graphics Pipeline Part 2: Projective Space Part 3: Windows Programming Intermission Part 4: Setting Up Direct3D Part 5: Using Direct3D.

dionne
Download Presentation

Direct3D Workshop

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. Direct3DWorkshop November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals

  2. Workshop Breakdown • Part 1: 3D Graphics Pipeline • Part 2: Projective Space • Part 3: Windows Programming • Intermission • Part 4: Setting Up Direct3D • Part 5: Using Direct3D

  3. Notes and Code Samples • You can download these notes and all the code samples from http://p2pclub.eng.usf.edu/direct3d/

  4. Part 2Projective Space

  5. Motivation • How should space be represented in computer graphics? • Using linear algebra seems like a fairly natural way to represent space, but eventually you will find it has its limits. • A better solution is called projective space, and it’s the math being used behind all graphics cards today. • Let’s start with the linear algebra and develop projective spaces from there.

  6. Vectors • Remember vectors? • They have direction and magnitude. • We usually break down vectors into x, y, and z components. • Vectors can represent coordinates (displacement from an origin).

  7. Matrices • Remember matrices? • Matrices can represent transformations • From a vector to a vector. • From another matrix to another matrix. • Matrices can also represent tensors, orientations, or coordinate systems.

  8. Matrix-Vector Multiplication • Each columns of the matrix can be interpreted as transforming a component of the vector.

  9. Linear Transformations • A transformation T is linear iff • Linear transformations include Scaling, Shearing, and Rotations. • Translation is not linear:

  10. Linear Transformations (Cont’d) • A transformation is linear iff it can be written in matrix-vector form: • You can find the columns of A by transforming the standard basis: • Multiplying matrices together results in a composition of transforms.

  11. Affine Spaces • Extending vector spaces, affine spaces add another set of objects called points. • A point has a position, but not a direction or magnitude. • Points have only a couple operations: • P – Q = v • Q + v = P • Where P and Q are points and v is a vector. • You cannot add two points together or multiply a point by a scaler.

  12. Affine Frame • Let e1, e2, e3 form a basis for the vectors in an affine space, A. • Let O be a point in A. We will call this point the origin. • Then e1, e2, e3, O forms a frame for A. • Any vector in A can be written as: • Any point can be written as:

  13. Affine Coordinates • Using frames we can write vectors like this: • And points like this:

  14. Affine Coordinates • The appended 0 or 1 is called the w-component. • In affine space this is either • 0 for a vector • 1 for a point • And anything else is undefined. • Note that if you add vectors together or scale them, the result is a vector, but if you try the same with points, the result is undefined.

  15. Affine Transform • An affine transform adds translation to a linear transform. • In regular vector space it has the form: • In affine space it is written as: • If you run a point through this transform it is translated, while vectors are not.

  16. Perspective • Projective space is an extension to affine space. • Using transformations in this space we will be able to calculate perspective.

  17. Projective Space • In projective space, the w-component is either 0 for a vector or any nonzero real number for a point. • However, coordinates in projective space are homogeneous. • Two points in projection space are said to be equivalent if the coordinates of one are a multiple of the other. • That is, if:

  18. Projective Space (Cont’d) • Points in projective space actually represent lines through the origin. • We can standardize the points, by dividing by w so that its w component is 1.

  19. Projective Space (Cont’d) • In the case of the projective plane (the 2D projective space). • 3D coordinates are used. • The intersection points of the lines through the origin and the plane w=1 make a perspective image of the space.

  20. Projective Transform • The projective transform generalizes the affine transform. • With homogeneous coordinates it looks like: • With linear algebra it would look like this:

  21. Perspective Transform • When perspective is actually calculated in computer graphics, it doesn’t usually flatten the space. • Instead coordinates are transformed so that the viewing frustum is transformed into a unit square • This is done through a composite of a scaling and a projective transform.

  22. Direct3D Matrices and Vectors • Direct3D includes a matrices and vectors (as well as planes and quaternions). • D3DVECTOR and D3DMATRIX • D3DXVECTOR# and D3DMATRIX# • D3DXMATRIXA# • Where # is an integer. • List of functions for D3DX* structures http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3dx/functions/math/mathfunctions.asp

  23. Direct3D Math Quirks • Be aware of Direct3D’s left handed coordinate system • X is positive to the left • Y is positive to the top • Z is position going into the monitor • Matrices are multiplied on the right side of a vector:

  24. References • Computer-Aided Geometric Design by F. Yamaguchi • Computer Animation Slides by JeHee Lee http://mrl.snu.ac.kr/CourseAnimation/ • Computer Graphics Notes by Ken Joy http://graphics.idav.ucdavis.edu/education/GraphicsNotes/Graphics-Notes.html

More Related