MULTIMEDIA

Programming with DirectX : View Transformations

1/12/2011 11:46:35 AM
The view transformation matrix is a matrix that represents the viewer. The viewer is commonly known as the game’s camera. A camera is represented by a position and a direction in which it is pointing. In OpenGL and Direct3D, camera matrices are often known as look-at matrices. In Direct3D a look-at matrix can be created using either a left- or right-handed function much like the projection matrix. These functions are called D3DXMatrixLookAtLH() and D3DXMatrixLookAtRH() and have the following prototypes.
D3DXMATRIX * D3DXMatrixLookAtLH(
D3DXMATRIX *pOut,
CONST D3DXVECTOR3 *pEye,
CONST D3DXVECTOR3 *pAt,
CONST D3DXVECTOR3 *pUp
);

D3DXMATRIX * D3DXMatrixLookAtRH(
D3DXMATRIX *pOut,
CONST D3DXVECTOR3 *pEye,
CONST D3DXVECTOR3 *pAt,
CONST D3DXVECTOR3 *pUp
);

The eye vector is the 3D position of the camera. The look-at vector is the position in 3D space at which you are looking. The position you are located at and the position you are looking at define the view’s direction. The up vector is a vector that represents which direction is up. The up vector can be used to allow the camera to be rotated. In a first-person camera, this can be used to rotate the position you are looking at (look-at point) around the up vector to look around you from left to right.

We’ll hold off on discussing the details about views, as well as matrices in general. The purpose of this demo is to see how to transform vectors in a vertex shader; the details and math behind it beyond what was discussed in this chapter come later.

The concatenation of the projection, world, and view matrices forms the model-view projection matrix. This is also known as the MVP matrix.

Other  
  •  Programming with DirectX : World Transformations
  •  Programming with DirectX : Projection Transformations
  •  iPhone 3D Programming : Adding Depth and Realism - Lighting Up (part 2)
  •  iPhone 3D Programming : Adding Depth and Realism - Lighting Up (part 1)
  •  iPhone 3D Programming : Adding Depth and Realism - Surface Normals (part 2)
  •  iPhone 3D Programming : Adding Depth and Realism - Surface Normals (part 1)
  •  iPhone 3D Programming : Adding Depth and Realism - Filling the Wireframe with Triangles
  •  iPhone 3D Programming : Adding Depth and Realism - Creating and Using the Depth Buffer
  •  iPhone 3D Programming : Adding Depth and Realism - Examining the Depth Buffer
  •  iPhone 3D Programming : HelloCone with Fixed Function
  •  iPhone 3D Programming : Vector Beautification with C++
  •  jQuery 1.3 : An image carousel
  •  jQuery 1.3 : Headline rotator
  •  Silverlight : Print a Document
  •  Silverlight : Capture a Webcam
  •  Silverlight : Make Your Application Run out of the Browser
  •  Silverlight : Put Content into a 3D Perspective
  •  Silverlight : Response to Timer Events on the UI Thread
  •  Silverlight : Build a Download and Playback Progress Bar
  •  Silverlight : Play a Video
  •  
    Most View
    Secure Your Smartphone (Part 3)
    Red Redray Player - Dedicated 4K Player
    The Great Software Payola (Part 1)
    Silverlight : Print a Document
    The LTEdge (Part 1)
    Customizing the Windows Vista Interface : Customizing the Start Menu for Easier Program and Document Launching (part 2)
    Organize Videos In iPhoto
    The Reality Of Gaming Laptops (Part 2)
    UK tech skills crisis
    Rig Builder – May 2012 (Part 5)
    Top 10
    ADO.NET Programming : Microsoft SQL Server (part 4) - Working with Typed Data Sets
    ADO.NET Programming : Microsoft SQL Server (part 3) - Using Stored Procedures with DataSet Objects
    ADO.NET Programming : Microsoft SQL Server (part 2) - Using SQL Server Stored Procedures
    ADO.NET Programming : Microsoft SQL Server (part 1) - Connecting to SQL Server, Creating Command Objects
    Windows Phone 8 In-Depth Review (Part 6)
    Windows Phone 8 In-Depth Review (Part 5)
    Windows Phone 8 In-Depth Review (Part 4)
    Windows Phone 8 In-Depth Review (Part 3)
    Windows Phone 8 In-Depth Review (Part 2)
    Windows Phone 8 In-Depth Review (Part 1)