view_to_matrix(VIEW* view, float *matView, float *matProj);

Calculates transformation and projection matrics for the given view in perspective or isometric mode. Can be used for modifying matrices in a view event, or for setting up matrices for shaders.

Parameters:

view - View to calculate the matrices from.
matView - float* pointer to be filled with the view transformation matrix in float[16] resp. D3DXMATRIX format, or NULL.
matProj - float* pointer to be filled with the view projection matrix in float[16] resp. D3DXMATRIX format, or NULL.

Speed:

Medium

Edition:

 C   LC 

Example (lite-C):

#include <d3d9.h>

...
// calculate the transformation matrix of a split frustum sector (used for PSSM shadows) 
D3DXMATRIX* PSSM_getSectorMatrix(var sector_near,var sector_far)
{
	static D3DXMATRIX mView,mProj,mViewProj;

// store the original clip range
  var old_far = camera.clip_far;
  var old_near = camera.clip_near;
// set the new clip range
  camera.clip_far = sector_far;
  camera.clip_near = sector_near;
// calculate the matrices
  view_to_matrix(camera,&mView,&mProj);
// restore original view
  camera.clip_far = old_far;
  camera.clip_near = old_near;
   
// multiply the matrices to get the view-projection matrix
	D3DXMatrixMultiply(&mViewProj,&mView,&mProj);
  return &mViewProj;
}

See also:

VIEW, view_to_light, view_to_split, ISOMETRIC

► latest version online