Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. VOID SetupMatrices()
  2. {
  3.     // Set up world matrix
  4.     D3DXMATRIXA16 matWorld;
  5.     D3DXMatrixIdentity( &matWorld );
  6.     D3DXMatrixRotationX( &matWorld, timeGetTime() / 500.0f );
  7.     g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
  8.  
  9.     // Set up our view matrix. A view matrix can be defined given an eye point,
  10.     // a point to lookat, and a direction for which way is up. Here, we set the
  11.     // eye five units back along the z-axis and up three units, look at the
  12.     // origin, and define "up" to be in the y-direction.
  13.     D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f );
  14.     D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
  15.     D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
  16.     D3DXMATRIXA16 matView;
  17.     D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
  18.     g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
  19.  
  20.     // For the projection matrix, we set up a perspective transform (which
  21.     // transforms geometry from 3D view space to 2D viewport space, with
  22.     // a perspective divide making objects smaller in the distance). To build
  23.     // a perpsective transform, we need the field of view (1/4 pi is common),
  24.     // the aspect ratio, and the near and far clipping planes (which define at
  25.     // what distances geometry should be no longer be rendered).
  26.     D3DXMATRIXA16 matProj;
  27.     D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI / 4, 1.0f, 1.0f, 100.0f );
  28.     g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement