public void SetInverseCamera(Camera3D camera) { if (InverseView != null) { InverseView.SetValue(camera.InverseView); } if (InverseViewProjection != null) { InverseViewProjection.SetValue(camera.InverseViewProjection); } if (CameraPosition != null) { CameraPosition.SetValue(camera.Position); } if (ViewProjection != null) { ViewProjection.SetValue(camera.ViewMatrix * camera.ProjectionMatrix); } }
private Matrix SetModelVisualizationProjection(int leg) { Vector3 cameraPosition = Distance * new Vector3( (float)(Math.Cos(HorizantalAngle) * Math.Cos(VerticalAngle)), (float)(Math.Sin(HorizantalAngle) * Math.Cos(VerticalAngle)), (float)(Math.Sin(VerticalAngle))); Matrix Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(20f), XDevice.DisplayMode.AspectRatio, 0.001f, 5); Matrix View = Matrix.CreateLookAt( cameraPosition, Vector3.Zero, Vector3.UnitZ); Matrix World = Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationZ(-MathHelper.PiOver2) * Matrix.CreateScale(-1f, 1f, 1f); Matrix MainWorld = World; World *= (leg == 2 ? Matrix.CreateTranslation(0f, 0f, -(ProjectionYMax + ProjectionYMin) / 2f) : Matrix.CreateTranslation(CoreX * (leg == 0 ? -1f : 1f), CoreY, -(ProjectionYMax + ProjectionYMin) / 2f)); LightPosition.SetValue(cameraPosition); CameraPosition.SetValue(cameraPosition); WorldTransform.SetValue(World); ModelTransform.SetValue(World * View * Projection); NormalTransform.SetValue(Matrix.Transpose(Matrix.Invert(World))); return(MainWorld * View * Projection); }