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
  •  
    Video
    Top 10
    -  Windows Vista : Installing and Running Applications - Launching Applications
    -  Windows Vista : Installing and Running Applications - Applications and the Registry, Understanding Application Compatibility
    -  Windows Vista : Installing and Running Applications - Practicing Safe Setups
    -  Windows Server 2003 : Domain Name System - Command-Line Utilities
    -  Microsoft .NET : Design Principles and Patterns - From Principles to Patterns (part 2)
    -  Microsoft .NET : Design Principles and Patterns - From Principles to Patterns (part 1)
    -  Brother MFC-J4510DW - An Innovative All-In-One A3 Printer
    -  Computer Planet I7 Extreme Gaming PC
    -  All We Need To Know About Green Computing (Part 4)
    -  All We Need To Know About Green Computing (Part 3)
    Most View
    -  Managing Xen : Xen Domain Configuration Files
    -  Programming WCF Services : Queued Services - Transactions
    -  Alienware M17X - Best In Class Gaming Performance
    -  We Help You Find Your Ideal Smartphone (Part 4)
    -  Choosing The Right Parts For Your Build (Part 3) - Picking the right video card
    -  Homeplug Problems In A Factory Setting (Part 2)
    -  Guide To Upgrades With The Greatest Effects (Part 2)
    -  Microsoft ASP.NET 4 : Profiles - Understanding Profiles
    -  VMware Fusion 5 - Your Mac is Virtually a PC
    -  Running Windows 8 (part 2) - Power Plans, Sleep Modes, and Shutdown
    -  The Ultimate PC Security Toolbox (Part 1)
    -  The big test … Inter Core Power (Part 1) - Acer Aspire Ethos 8951G
    -  Windows Vista : Build Your Network (part 4) - Troubleshoot Wireless Networks
    -  Mac - That Syncing Feeling
    -  Macbook Air vs. Ultrabook Platform (Part 2)
    -  Find Yourself With Geolocation Technology (Part 3)
    -  The Complete Guide To Garageband (Part 1)
    -  Generation I (For Insecure)?
    -  Kingston SSDNow mS100 64GB - One Of The Cheapest SSDs Around
    -  You Can Master RAW (Part 4)