/***************************************************************************** Perspective routines for CS480 ****************************************************************************** Author: ******************************************************************************/ #include #include #include #include #include #include "draw.h" /* Write a routine that computes the 4x4 perspective projection matrix, by first computing 4 intermediate matrices: Mview -- the 4x4 matrix that describes the transform from camera to world coordinates. Mshear -- the 4x4 matrix that shears the perspective viewing frustrum axis into alignment with the z axis. Mscale -- the 4x4 matrix that scales the viewing frustrum into a parallelpiped. Mnorm -- the 4x4 matrix that describes the transform from the view-plane window to the screen window (viewport to device coordinate transform). Rather than normalizing to the unit cube, normalize to the viewport's screen coordinates. The resulting view-volume will be bounded by the window's x,y screen coordinates, and the z clip plane's world coordinates. These matrices are then multiplied together to obtain the final, view-normalized perspective projection matrix "Nper." Be sure to use the 4x4 matrix multiplication routine provided in "matrix.c" */ compute_Nper(VUP,VPN,VRP,PRP,umin,umax,vmin,vmax,xmin,xmax,ymin,ymax,Nper) float VUP[3],VRP[3],VPN[3],PRP[3]; /* the various viewing specifications */ float umin,umax,vmin,vmax; /* the window bounds in view coordinates */ float xmin,xmax,ymin,ymax; /* the window bounds in screen coordinates */ float Nper[4][4]; /* the resulting perspective projection matrix */ { }