Ejemplo n.º 1
0
//Transformation matrix mat with a scaling
void setScale(float *mat, float xScale, float yScale, float zScale) 
{
    setIdentMatrix(mat,4);
	mat[0] = xScale;
	mat[5] = yScale;
	mat[10] = zScale;
}
Ejemplo n.º 2
0
// Transformation matrix mat with a translation
void setTransMatrix(float *mat, float x, float y, float z) {
 
    setIdentMatrix(mat,4);
    mat[12] = x;
    mat[13] = y;
    mat[14] = z;
}
Ejemplo n.º 3
0
void Camera::zoomCam(float zoom) 
{
	float zoomMat[16];
	setTransMatrix(zoomMat, 0.0f, 0.0f, zoom);
	multiplyMatrix(zoomMat, viewMatrix);
	setIdentMatrix(viewMatrix, 4);
	multiplyMatrix(viewMatrix, zoomMat);
}
Ejemplo n.º 4
0
// Projection Matrix
void buildProjMatrix(float fov, float ratio, float nearP, float farP) {
 
    float f = 1.0f / tan (fov * (PI / 360.0));
    setIdentMatrix(projMatrix,4);
    projMatrix[0] = f / ratio;
    projMatrix[1 * 4 + 1] = f;
    projMatrix[2 * 4 + 2] = (farP + nearP) / (nearP - farP);
    projMatrix[3 * 4 + 2] = (2.0f * farP * nearP) / (nearP - farP);
    projMatrix[2 * 4 + 3] = -1.0f;
    projMatrix[3 * 4 + 3] = 0.0f;
}
Ejemplo n.º 5
0
Camera::Camera()
{
	setIdentMatrix(viewMatrix, 4);
}