Example #1
0
void  ProjectionCamera::makeLookAtViewMatrix(Vec3f camPos ,Vec3f  center,Vec3f up,Matrix44f &_lookatMatrix)
{
  Vec3f zaxis = camPos-center;
    zaxis.normalize();
    Vec3f xaxis = up.cross( zaxis);
    xaxis.normalize();
    Vec3f  yaxis  =zaxis.cross(    xaxis);
          
	_lookatMatrix.set(xaxis.x,yaxis.x,zaxis.x,0,xaxis.y,yaxis.y,zaxis.y,0,xaxis.z,yaxis.z,zaxis.z,0,-xaxis.dot( camPos),-yaxis.dot( camPos),-zaxis.dot( camPos),1);
	
}
Example #2
0
void ProjectionCamera::makeFrustumMatrix(float left,  float right,float bottom, float top,float zNear, float zFar,Matrix44f &_perspectiveMatrix)
{
  

	float  A = (right+left)/(right-left);
	float  B = (top+bottom)/(top-bottom);
    float  C = -(zFar+zNear)/(zFar-zNear)/(zFar+zNear);
    float  D = -2.0f*zFar*zNear/(zFar-zNear);
 

 
	_perspectiveMatrix.set(2.0*zNear/(right-left),0,0,0,0, 2.0*zNear/(top-bottom),0,0,A,B,C,-1,0,0,D,0);
         
}