public static Matrix CalculateViewMatrix(Vector3 position, Angle3 lookDir) { Matrix rotation = Matrix.CreateFromYawPitchRoll(lookDir.Yaw, -lookDir.Pitch, 0); Vector3 transformedReference = Vector3.Transform(new Vector3(0,0,1), rotation); Vector3 cameraDirection = position + transformedReference; return Matrix.CreateLookAt(position, cameraDirection, Vector3.Up); }
public PlayerState(GamestateManager mgr, Point viewportSize) { _renderTarget = new RenderTarget(0f); _manager = mgr; _viewportSize = viewportSize; _playerPosition = new Vector3(348, 1705, -192); _playerLookDir = new Angle3(-1.2f, 0, -10.004f);//xxxxx this value gets ~2 added to it somehow _manager.AddSharedData(SharedStateData.PlayerPosition, _playerPosition); _manager.AddSharedData(SharedStateData.PlayerLook, _playerLookDir); _skipNextMouseUpdate = false; _x = new Text2D(_renderTarget, 0, 0, "hi"); _y = new Text2D(_renderTarget, 0, 10, "hi"); _z = new Text2D(_renderTarget, 0, 20, "hi"); _pitch = new Text2D(_renderTarget, 0, 30, "hi"); _yaw = new Text2D(_renderTarget, 0, 40, "hi"); _x.Color = Color.Wheat; _y.Color = Color.Wheat; _z.Color = Color.Wheat; _pitch.Color = Color.Wheat; _yaw.Color = Color.Wheat; }