private void UpdateThirdPerson(bool frontSideView) { var position = Position; var direction = new Vector3(Rotation.X, Rotation.Y, frontSideView ? Rotation.Z : -Rotation.Z); direction.Normalize(); var offset = Rotation * (direction * 3.5f); offset.Y = 2.5f; //offset *= direction; //offset.Normalize(); Direction = direction; Vector3 lookAtOffset = new Vector3( position.X + offset.X, position.Y + offset.Y, position.Z + offset.Z); Target = position; ViewMatrix = MCMatrix.CreateLookAt(lookAtOffset, position, Vector3.Up); Frustum = new BoundingFrustum(ViewMatrix * ProjectionMatrix); }
protected override void UpdateViewMatrix() { var normalPosition = new Vector3(Position.X, 256, Position.Z); var targetPosition = new Vector3(normalPosition.X, 0, normalPosition.Z); ViewMatrix = MCMatrix.CreateLookAt(normalPosition, targetPosition, Vector3.Forward); }
private void UpdateViewMatrixFirstPerson() { var position = Position; var direction = new Vector3(Rotation.X, Rotation.Y, Rotation.Z); direction.Normalize(); //var target = position Target = position + direction; Direction = direction; ViewMatrix = MCMatrix.CreateLookAt(position, Target, Vector3.Up); Frustum = new BoundingFrustum(ViewMatrix * ProjectionMatrix); }