private void InitializeXNA() { _device = SharedGraphicsDeviceManager.Current.GraphicsDevice; // Set the sharing mode of the graphics device to turn on XNA rendering _device.SetSharingMode(true); // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(_device); BackgroundRenderer = new UIElementRenderer(this, _device.Viewport.Width, _device.Viewport.Height); // Create a timer for this page _gameTimer = new GameTimer(); _gameTimer.UpdateInterval = TimeSpan.FromTicks(333333); _gameTimer.Update += new EventHandler <GameTimerEventArgs>(_gameTimer_Update); _gameTimer.Draw += new EventHandler <GameTimerEventArgs>(_gameTimer_Draw); _cameraMatrix = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward, Vector3.Up); _projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, (float)(this.LayoutRoot.ActualWidth / this.LayoutRoot.ActualHeight), 0.01f, 10000.0f); foreach (LocationsVM.Location l in myVM.SelectedNearbyLocations) { l.Object3dEffect = new BasicEffect(_device); l.Object3dEffect.World = l.WorldMatrix; l.Object3dEffect.View = _cameraMatrix; l.Object3dEffect.Projection = _projectionMatrix; l.Object3dEffect.TextureEnabled = true; } _gameTimer.Start(); }
private void _motion_CurrentValueChanged(object sender, SensorReadingEventArgs <MotionReading> e) { double motionDelta = 0.01; if (!_motion.IsDataValid) { return; } if (Math.Abs(e.SensorReading.Attitude.Yaw - _yaw) > motionDelta) { _yaw = e.SensorReading.Attitude.Yaw; } if (Math.Abs(e.SensorReading.Attitude.Roll - _roll) > motionDelta) { _roll = e.SensorReading.Attitude.Roll; } if (Math.Abs(e.SensorReading.Attitude.Pitch - _pitch) > motionDelta) { _pitch = e.SensorReading.Attitude.Pitch; } Dispatcher.BeginInvoke(delegate() { if (myVM.ClickedNearbyLocation != null) { myVM.ClickedNearbyLocation.CalculateHeadingAngle(MathHelper.ToDegrees(_yaw)); } }); if (_onDragEndAnimation) { return; } if (_gestureState == GestureStateEnum.OnFreeDrag) { _cameraMatrixBehindDrag = Matrix.CreateLookAt(new Vector3(0, 0, 0), new Vector3(0, 0, -1), Vector3.Up); _cameraMatrixBehindDrag *= Matrix.CreateRotationY(-_yaw); _cameraMatrixBehindDrag *= Matrix.CreateRotationZ(_roll); _cameraMatrixBehindDrag *= Matrix.CreateRotationX(-_pitch + MathHelper.PiOver2); } else { _cameraMatrix = Matrix.CreateLookAt(new Vector3(0, 0, 0), new Vector3(0, 0, -1), Vector3.Up); _cameraMatrix *= Matrix.CreateRotationY(-_yaw); _cameraMatrix *= Matrix.CreateRotationZ(_roll); _cameraMatrix *= Matrix.CreateRotationX(-_pitch + MathHelper.PiOver2); //rotate radar Dispatcher.BeginInvoke(delegate() { (radarCanvas.RenderTransform as System.Windows.Media.RotateTransform).Angle = MathHelper.ToDegrees((_yaw)); }); } }
public Camera(Game g, Vector3 position, Vector3 target, Vector3 up) : base(g) { view = Matrix.CreateLookAt(position, target, up); projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4, (float)g.Window.ClientBounds.Width / g.Window.ClientBounds.Height, 1, 100); }
public void InitializeViewport() { // Initialize the viewport and matrixes for 3d projection. viewport = new Viewport(0, 0, (int)this.ActualWidth, (int)this.ActualHeight); float aspect = viewport.AspectRatio; projection = Matrix.CreatePerspectiveFieldOfView(1, aspect, 1, 12); view = Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, Vector3.Up); }
/// <summary> /// Initializes a new instance of the <see cref="ARPanel">Augmented Reality Panel</see> control. /// </summary> public ARPanel() { SizeChanged += panel_SizeChanged; Loaded += panel_Loaded; Unloaded += panel_Unloaded; view = Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, Vector3.Up); world = Matrix.CreateWorld(Vector3.Zero, new Vector3(0, 0, -1), new Vector3(0, 1, 0)); if (IsDesignMode) { _attitude = Matrix.Identity; //This will make control render design time looking horizontal north } }
private void OnLoadedContent(object sender, EventArgs e) { var eye = new Vector3(0.0f, 0.0f, -35.0f); var at = new Vector3(0.0f, 0.0f, 0.0f); var up = new Vector3(0, 1.0f, 0.0f); _worldMatrix = Matrix.Identity; _viewMatrix = Matrix.CreateLookAt(eye, at, up); _projectionMatrix = Matrix.CreatePerspectiveFieldOfView( (float)Math.PI * 0.25f, (float)Component.TargetSize.Width / Component.TargetSize.Height, 1f, 1000f); LoadModel(); }
void UpdateCameraThirdPerson() { // Create a vector pointing the direction the camera is facing. //var transformedReference = Vector3.Transform(, Matrix.CreateRotationY(avatarYaw)); //transformedReference = Vector3.Transform(transformedReference, Matrix.CreateRotationX(avatarPitch)); // Calculate the position the camera is looking from var target = avatarPosition + Vector3.Transform(Vector3.UnitZ, Matrix.CreateFromYawPitchRoll(avatarYaw, avatarPitch, 0)); // Set up the view matrix and projection matrix _view = Matrix.CreateLookAt(avatarPosition, target, new Vector3(0.0f, 1.0f, 0.0f)); var viewport = _graphics.GraphicsDevice.Viewport; var aspectRatio = viewport.Width / (float)viewport.Height; _proj = Matrix.CreatePerspectiveFieldOfView(ViewAngle, aspectRatio, NearClip, FarClip); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { _basicEffect = new BasicEffect(GraphicsDevice) { World = Matrix.Identity, View = Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, Vector3.Up), // Specify how 3D points are projected/transformed onto the 2D screen Projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1.0f, 1000.0f), // Tell BasicEffect to make use of your vertex colors VertexColorEnabled = true }; Level = new Level(_score); }
public void Draw() { GraphicsDevice device = SharedGraphicsDeviceManager.Current.GraphicsDevice; device.BlendState = BlendState.Opaque; device.RasterizerState = RasterizerState.CullCounterClockwise; device.DepthStencilState = DepthStencilState.Default; // Store the old viewport and set the desired viewport Viewport oldViewport = device.Viewport; device.Viewport = new Viewport(state.ViewportRect); // Calculate the world-view-projection matrices for the tank and camera Matrix world = Matrix.CreateScale(.002f) * Matrix.CreateRotationY(MathHelper.ToRadians((float)state.TankRotationY)); Matrix view = Matrix.CreateLookAt(state.CameraPosition, state.CameraTarget, Vector3.Up); Matrix projection = Matrix.CreatePerspectiveFieldOfView(1, device.Viewport.AspectRatio, .01f, 100f); // Draw the sky sky.Draw(view, projection); // Draw the ground groundEffect.World = Matrix.Identity; groundEffect.View = view; groundEffect.Projection = projection; device.SetVertexBuffer(groundVertices); foreach (var pass in groundEffect.CurrentTechnique.Passes) { pass.Apply(); device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); } // Draw the tank tank.Draw(world, view, projection, state); // Reset the viewport device.Viewport = oldViewport; }
private void InitializeXna() { CreateDevice(); var eye = new Vector3(0.0f, 0.0f, -35.0f); var at = new Vector3(0.0f, 0.0f, 0.0f); var up = new Vector3(0, 1.0f, 0.0f); _worldMatrix = Matrix.Identity; _viewMatrix = Matrix.CreateLookAt(eye, at, up); _projectionMatrix = Matrix.CreatePerspectiveFieldOfView( (float)Math.PI * 0.25f, (float)_targetSize.Width / _targetSize.Height, 1f, 1000f); CreateBuffers(); _copySurfaceMethod = typeof(GraphicsDevice).GetMethod("CopySurface", BindingFlags.Instance | BindingFlags.NonPublic); this.CreateContentManager(); this.LoadModel(); }
/// <summary> /// Animates Selected Location Center and zoom in camera /// </summary> /// <param name="l">Location will be animated</param> private void AnimateLocationSelection(LocationsVM.Location l) { float zoomFactor = 0.20f; Vector3 v = new Vector3(l.VectorPoint.X, 0, l.VectorPoint.Z); Matrix cam = Matrix.CreateLookAt(new Vector3(0, 0, 0), v, Vector3.Up); l.IsAnimatingView = true; XNAMatrixAnimation animCam = new XNAMatrixAnimation(l.Object3dEffect.View, cam, TimeSpan.FromSeconds(0.3), 30); animCam.OnAnimating += (XNAMatrixAnimation sender, XNAMatrixAnimationEventArgs e) => { l.Object3dEffect.View = e.Value; }; animCam.OnCompleted += (XNAMatrixAnimation sender, XNAMatrixAnimationEventArgs e) => { l.Object3dEffect.View = e.Value; l.IsAnimatingView = false; }; animCam.Start(); Matrix world = l.WorldMatrix * Matrix.CreateTranslation(new Vector3(-l.VectorPoint.X * zoomFactor, -l.VectorPoint.Y, -l.VectorPoint.Z * zoomFactor)); l.IsAnimatingWorld = true; XNAMatrixAnimation animWorld = new XNAMatrixAnimation(l.Object3dEffect.World, world, TimeSpan.FromSeconds(0.3), 30); animWorld.OnAnimating += (XNAMatrixAnimation sender, XNAMatrixAnimationEventArgs e) => { l.Object3dEffect.World = e.Value; }; animWorld.OnCompleted += (XNAMatrixAnimation sender, XNAMatrixAnimationEventArgs e) => { l.Object3dEffect.World = e.Value; l.IsAnimatingWorld = false; }; animWorld.Start(); }
protected override void Present(XnaTime time) { var device = Graphics.GraphicsDevice; Clear(); // Compute camera matrices. var aspectRatio = (float)device.Viewport.Width / device.Viewport.Height; var view = Matrix.CreateLookAt( new Vector3(0, 0, -200), new Vector3(0, 0, 0), Vector3.Up); var projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4, aspectRatio, 1, 10000); // Pass camera matrices through to the particle system components. _explosionParticles.SetCamera(view, projection); _explosionParticles.Draw(time); }
private void LoadModel() { var modelFile = this.ModelFile; lock (_modelLock) { _model = null; if (_modelLoadRequest != null) { _modelLoadRequest.Dispose(); _modelLoadRequest = null; } } if (string.IsNullOrWhiteSpace(modelFile)) { this.StatusMessage = _modelUnavailableMessage; return; } try { modelFile = Path.Combine(ModelDirectory, modelFile); if (!Path.HasExtension(modelFile)) { modelFile = modelFile + XnaContentExtension; } modelFile = Path.Combine( _workingDirectory, ResourceManager.GetResourcePath(modelFile)); } catch { modelFile = null; } if (modelFile == null || !File.Exists(modelFile)) { this.StatusMessage = _modelUnavailableMessage; return; } modelFile = modelFile.Substring( 0, modelFile.Length - XnaContentExtension.Length); this.StatusMessage = _loadingMessage; if (_contentManager == null) { return; } lock (_modelLock) { _modelLoadRequest = ((Func <string, Model>)_contentManager.Load <Model>) .ToAsync(Scheduler.ThreadPool)(modelFile) .ObserveOnDispatcher() .Subscribe( model => { //var boundingBox = XnaHelper.ComputeBoundingBox(model, Matrix.Identity); //var offset = Math.Max(Math.Abs(boundingBox.Max.Z), Math.Abs(boundingBox.Min.Z)) / 2; var radius = model.Meshes.Max(o => (o.BoundingSphere.Center - Vector3.Zero).Length() + o.BoundingSphere.Radius); var cameraDistance = (radius * this.CameraDistanceMultiplier); //(float)((radius+offset) / Math.Tan(Math.PI / 8d)) + Math.Max(Math.Abs(boundingBox.Max.X), Math.Abs(boundingBox.Min.X)) + 1f; var eye = new Vector3(0.0f, 0.0f, cameraDistance); var at = new Vector3(0.0f, 0.0f, 0.0f); var up = new Vector3(0, 1.0f, 0.0f); ClearValue(StatusMessagePropertyKey); lock (_modelLock) { if (_modelLoadRequest == null) { return; } _modelLoadRequest = null; _model = model; _viewMatrix = Matrix.CreateLookAt(eye, at, up); } }, e => { lock (_modelLock) { if (_modelLoadRequest == null) { return; } _modelLoadRequest = null; this.StatusMessage = _loadFailureMessage; } }); } }
private void LoadModel() { var modelFile = ModelFile; lock (_modelLock) { _model = null; if (_modelLoadRequest != null) { _modelLoadRequest.Dispose(); _modelLoadRequest = null; } } if (string.IsNullOrWhiteSpace(modelFile)) { StatusMessage = _modelUnavailableMessage; return; } try { modelFile = Path.Combine(ModelDirectory, modelFile); if (!Path.HasExtension(modelFile)) { modelFile = modelFile + XnaContentExtension; } modelFile = Path.Combine( _workingDirectory, ResourceManager.GetResourcePath(modelFile)); } catch { modelFile = null; } if (modelFile == null || !File.Exists(modelFile)) { StatusMessage = _modelUnavailableMessage; return; } modelFile = modelFile.Substring( 0, modelFile.Length - XnaContentExtension.Length); StatusMessage = _loadingMessage; var contentManager = Component.Content; if (contentManager == null) { return; } lock (_modelLock) { _modelLoadRequest = ((Func <string, Model>)contentManager.Load <Model>) .ToAsync(Scheduler.ThreadPool)(modelFile) .ObserveOnDispatcher() .Subscribe( model => { var radius = model.Meshes.Max(o => (o.BoundingSphere.Center - Vector3.Zero).Length() + o.BoundingSphere.Radius); var cameraDistance = (radius * CameraDistanceMultiplier); var eye = new Vector3(0.0f, 0.0f, cameraDistance); var at = new Vector3(0.0f, 0.0f, 0.0f); var up = new Vector3(0, 1.0f, 0.0f); ClearValue(StatusMessagePropertyKey); lock (_modelLock) { if (_modelLoadRequest == null) { return; } _modelLoadRequest = null; _model = model; _viewMatrix = Matrix.CreateLookAt(eye, at, up); } }, e => { lock (_modelLock) { if (_modelLoadRequest == null) { return; } _modelLoadRequest = null; StatusMessage = _loadFailureMessage; } }); } }
public virtual void Initialize() { float tilt = MathHelper.ToRadians(0); // 0 degree angle // Use the world matrix to tilt the cube along x and y axes. _worldMatrix = Matrix.CreateRotationX(tilt) * Matrix.CreateRotationY(tilt); _viewMatrix = Matrix.CreateLookAt(new Vector3(5, 5, 5), Vector3.Zero, Vector3.Up); _projectionMatrix = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(45), // 45 degree angle (float)GraphicsDevice.Viewport.Width / (float)GraphicsDevice.Viewport.Height, 1.0f, 100.0f); _basicEffect = new BasicEffect(GraphicsDevice); _basicEffect.World = _worldMatrix; _basicEffect.View = _viewMatrix; _basicEffect.Projection = _projectionMatrix; // primitive color _basicEffect.AmbientLightColor = new Vector3(0.1f, 0.1f, 0.1f); _basicEffect.DiffuseColor = new Vector3(1.0f, 1.0f, 1.0f); _basicEffect.SpecularColor = new Vector3(0.25f, 0.25f, 0.25f); _basicEffect.SpecularPower = 5.0f; _basicEffect.Alpha = 1.0f; _basicEffect.LightingEnabled = true; if (_basicEffect.LightingEnabled) { _basicEffect.DirectionalLight0.Enabled = true; // enable each light individually if (_basicEffect.DirectionalLight0.Enabled) { // x direction _basicEffect.DirectionalLight0.DiffuseColor = new Vector3(1, 0, 0); // range is 0 to 1 _basicEffect.DirectionalLight0.Direction = Vector3.Normalize(new Vector3(-1, 0, 0)); // points from the light to the origin of the scene _basicEffect.DirectionalLight0.SpecularColor = Vector3.One; } _basicEffect.DirectionalLight1.Enabled = true; if (_basicEffect.DirectionalLight1.Enabled) { // y direction _basicEffect.DirectionalLight1.DiffuseColor = new Vector3(0, 0.75f, 0); _basicEffect.DirectionalLight1.Direction = Vector3.Normalize(new Vector3(0, -1, 0)); _basicEffect.DirectionalLight1.SpecularColor = Vector3.One; } _basicEffect.DirectionalLight2.Enabled = true; if (_basicEffect.DirectionalLight2.Enabled) { // z direction _basicEffect.DirectionalLight2.DiffuseColor = new Vector3(0, 0, 0.5f); _basicEffect.DirectionalLight2.Direction = Vector3.Normalize(new Vector3(0, 0, -1)); _basicEffect.DirectionalLight2.SpecularColor = Vector3.One; } } vertexDeclaration = new VertexDeclaration(new[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0), new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0) }); Vector3 topLeftFront = new Vector3(-1.0f, 1.0f, 1.0f); Vector3 bottomLeftFront = new Vector3(-1.0f, -1.0f, 1.0f); Vector3 topRightFront = new Vector3(1.0f, 1.0f, 1.0f); Vector3 bottomRightFront = new Vector3(1.0f, -1.0f, 1.0f); Vector3 topLeftBack = new Vector3(-1.0f, 1.0f, -1.0f); Vector3 topRightBack = new Vector3(1.0f, 1.0f, -1.0f); Vector3 bottomLeftBack = new Vector3(-1.0f, -1.0f, -1.0f); Vector3 bottomRightBack = new Vector3(1.0f, -1.0f, -1.0f); Vector2 textureTopLeft = new Vector2(0.0f, 0.0f); Vector2 textureTopRight = new Vector2(1.0f, 0.0f); Vector2 textureBottomLeft = new Vector2(0.0f, 1.0f); Vector2 textureBottomRight = new Vector2(1.0f, 1.0f); Vector3 frontNormal = new Vector3(0.0f, 0.0f, 1.0f); Vector3 backNormal = new Vector3(0.0f, 0.0f, -1.0f); Vector3 topNormal = new Vector3(0.0f, 1.0f, 0.0f); Vector3 bottomNormal = new Vector3(0.0f, -1.0f, 0.0f); Vector3 leftNormal = new Vector3(-1.0f, 0.0f, 0.0f); Vector3 rightNormal = new Vector3(1.0f, 0.0f, 0.0f); var cubeVertices = new VertexPositionNormalTexture[36]; // Front face. cubeVertices[0] = new VertexPositionNormalTexture(topLeftFront, frontNormal, textureTopLeft); cubeVertices[1] = new VertexPositionNormalTexture(bottomLeftFront, frontNormal, textureBottomLeft); cubeVertices[2] = new VertexPositionNormalTexture(topRightFront, frontNormal, textureTopRight); cubeVertices[3] = new VertexPositionNormalTexture(bottomLeftFront, frontNormal, textureBottomLeft); cubeVertices[4] = new VertexPositionNormalTexture(bottomRightFront, frontNormal, textureBottomRight); cubeVertices[5] = new VertexPositionNormalTexture(topRightFront, frontNormal, textureTopRight); // Back face. cubeVertices[6] = new VertexPositionNormalTexture(topLeftBack, backNormal, textureTopRight); cubeVertices[7] = new VertexPositionNormalTexture(topRightBack, backNormal, textureTopLeft); cubeVertices[8] = new VertexPositionNormalTexture(bottomLeftBack, backNormal, textureBottomRight); cubeVertices[9] = new VertexPositionNormalTexture(bottomLeftBack, backNormal, textureBottomRight); cubeVertices[10] = new VertexPositionNormalTexture(topRightBack, backNormal, textureTopLeft); cubeVertices[11] = new VertexPositionNormalTexture(bottomRightBack, backNormal, textureBottomLeft); // Top face. cubeVertices[12] = new VertexPositionNormalTexture(topLeftFront, topNormal, textureBottomLeft); cubeVertices[13] = new VertexPositionNormalTexture(topRightBack, topNormal, textureTopRight); cubeVertices[14] = new VertexPositionNormalTexture(topLeftBack, topNormal, textureTopLeft); cubeVertices[15] = new VertexPositionNormalTexture(topLeftFront, topNormal, textureBottomLeft); cubeVertices[16] = new VertexPositionNormalTexture(topRightFront, topNormal, textureBottomRight); cubeVertices[17] = new VertexPositionNormalTexture(topRightBack, topNormal, textureTopRight); // Bottom face. cubeVertices[18] = new VertexPositionNormalTexture(bottomLeftFront, bottomNormal, textureTopLeft); cubeVertices[19] = new VertexPositionNormalTexture(bottomLeftBack, bottomNormal, textureBottomLeft); cubeVertices[20] = new VertexPositionNormalTexture(bottomRightBack, bottomNormal, textureBottomRight); cubeVertices[21] = new VertexPositionNormalTexture(bottomLeftFront, bottomNormal, textureTopLeft); cubeVertices[22] = new VertexPositionNormalTexture(bottomRightBack, bottomNormal, textureBottomRight); cubeVertices[23] = new VertexPositionNormalTexture(bottomRightFront, bottomNormal, textureTopRight); // Left face. cubeVertices[24] = new VertexPositionNormalTexture(topLeftFront, leftNormal, textureTopRight); cubeVertices[25] = new VertexPositionNormalTexture(bottomLeftBack, leftNormal, textureBottomLeft); cubeVertices[26] = new VertexPositionNormalTexture(bottomLeftFront, leftNormal, textureBottomRight); cubeVertices[27] = new VertexPositionNormalTexture(topLeftBack, leftNormal, textureTopLeft); cubeVertices[28] = new VertexPositionNormalTexture(bottomLeftBack, leftNormal, textureBottomLeft); cubeVertices[29] = new VertexPositionNormalTexture(topLeftFront, leftNormal, textureTopRight); // Right face. cubeVertices[30] = new VertexPositionNormalTexture(topRightFront, rightNormal, textureTopLeft); cubeVertices[31] = new VertexPositionNormalTexture(bottomRightFront, rightNormal, textureBottomLeft); cubeVertices[32] = new VertexPositionNormalTexture(bottomRightBack, rightNormal, textureBottomRight); cubeVertices[33] = new VertexPositionNormalTexture(topRightBack, rightNormal, textureTopRight); cubeVertices[34] = new VertexPositionNormalTexture(topRightFront, rightNormal, textureTopLeft); cubeVertices[35] = new VertexPositionNormalTexture(bottomRightBack, rightNormal, textureBottomRight); _vertexBuffer = new VertexBuffer(GraphicsDevice, vertexDeclaration, cubeVertices.Length, BufferUsage.None); _vertexBuffer.SetData(cubeVertices); }
MathboxRenderer(Machine machine, ScreenManager screenManager) { Machine = machine; Memory = Machine.Mathbox.Memory16; ScreenManager = screenManager; if (!(screenManager.Game is I_Robot.Game game)) { throw new Exception("VideoInterpreter can only be used with I_Robot.Game"); } Game = game; DisplayListManager = new DisplayList.Manager(this); Object = new ObjectRenderer(this); Terrain = new TerrainRenderer(this); // create our scene buffer // this buffer has a z-buffer SceneBuffer = new RenderTarget2D( Game.GraphicsDevice, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height, false, Game.GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.None, 8, RenderTargetUsage.DiscardContents); // create our two screen buffers // these buffers do not require depth sorting, they are simply raw bitmaps // however the contents need to be preserved when rendering context is reset for (int n = 0; n < ScreenBuffers.Length; n++) { ScreenBuffers[n] = new RenderTarget2D( Game.GraphicsDevice, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height, false, Game.GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); } camTarget = new Vector3(0f, 0f, 0f); camPosition = new Vector3(0f, 0f, -1f); double scaleToMonitor = Emulation.Machine.MonitorAspectRatio / Emulation.Machine.NativeAspectRatio; projectionMatrix = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(45f), (float)(Game.GraphicsDevice.Viewport.AspectRatio / scaleToMonitor), 0.1f, 65536f); // it's important to move the projection matrix down a bit, this matches what I, Robot seems to do projectionMatrix = projectionMatrix * Matrix.CreateTranslation(new Vector3(0, -0.1f, 0)); viewMatrix = Matrix.CreateLookAt(camPosition, camTarget, Vector3.Up); worldMatrix = Matrix.CreateWorld(Vector3.Zero, Vector3.Forward, Vector3.Down); basicEffect = new BasicEffect(Game.GraphicsDevice); basicEffect.Alpha = 1f; basicEffect.VertexColorEnabled = true; // Want to see the colors of the vertices, this needs to be on // Lighting requires normal information which VertexPositionColor does not have // If you want to use lighting and VPC you need to create a custom def basicEffect.LightingEnabled = false; }