Beispiel #1
0
void Camera::SetYaw(float y)
{ 
	yaw = y;
	Matrix4x4f Rx = Matrix4x4f::RotationX(pitch);
	Matrix4x4f Ry = Matrix4x4f::RotationY(yaw);
	Matrix4x4f R = Ry * Rx;
	forward = R.TransformVector(Vector3f(0, 0, -1));
	right = R.TransformVector(Vector3f(1, 0, 0));
	up = R.TransformVector(Vector3f(0, 1, 0));
}
Beispiel #2
0
void Camera::LookUp(float angle)
{
	if(pitch - angle > PI/2.0f - 0.1)
	{
		pitch = PI/2.0f - 0.1;
	}
	else if(pitch - angle < -PI/2.0f)
	{
		pitch = -PI/2.0f + 0.1;
	}
	else
		pitch -= angle;

	Matrix4x4f Rx = Matrix4x4f::RotationX(pitch);
	Matrix4x4f Ry = Matrix4x4f::RotationY(yaw);
	Matrix4x4f R = Ry * Rx;
	forward = R.TransformVector(Vector3f(0, 0, -1));
	right = R.TransformVector(Vector3f(1, 0, 0));
	up = R.TransformVector(Vector3f(0, 1, 0));
}