// simple camera

function camera()
{
	// the view mat
	this.view = new CanvasMatrix4();
	
	// world view
	this.w_axis = new vec3(0,0,0);
	this.x_axis = new vec3(1,0,0);
	this.y_axis = new vec3(0,1,0);
	this.z_axis = new vec3(0,0,1);
}

camera.prototype.updateView = function()
{
	tempM = new CanvasMatrix4()
	
	tempM.load([this.x_axis.x, this.x_axis.y, this.x_axis.z, 0,
							 this.y_axis.x, this.y_axis.y, this.y_axis.z, 0,
							 this.z_axis.x, this.z_axis.y, this.z_axis.z, 0,
							 this.w_axis.x, this.w_axis.y, this.w_axis.z, 1]);
				
	tempM.m31 *= -1;
	tempM.m32 *= -1; 
	tempM.m33 *= -1; 
	
	tempM.m11 *= -1;
	tempM.m12 *= -1; 
	tempM.m13 *= -1; 
	
	this.view.load(tempM);
	
	this.view.m41 = 0;
	this.view.m42 = 0;
	this.view.m43 = 0;
	
	this.view.transpose();
	
	this.view.m41 = -dotVec3(new vec3(tempM.m11, tempM.m12, tempM.m13), new vec3(tempM.m41, tempM.m42,tempM.m43));
	this.view.m42 = -dotVec3(new vec3(tempM.m21, tempM.m22, tempM.m23), new vec3(tempM.m41, tempM.m42,tempM.m43));
	this.view.m43 = -dotVec3(new vec3(tempM.m31, tempM.m32, tempM.m33), new vec3(tempM.m41, tempM.m42,tempM.m43));
}


camera.prototype.setLookAt = function(posVec, targetVec, upVec)
{
	this.w_axis = new vec3(posVec.x, posVec.y, posVec.z);
	
	this.z_axis = subVec3(targetVec, this.w_axis)
	this.z_axis.normalize();
	
	this.x_axis = crossVec3(upVec, this.z_axis);
	this.x_axis.normalize();

	this.y_axis = crossVec3(this.z_axis, this.x_axis);
	this.y_axis.normalize();
	
	this.updateView();
}
