public Camera(GraphicsDevice graphicsDevice, Vector3 position, Vector3 lookAtVec, ScreenSplit screenSplit) { this.graphicsDevice = graphicsDevice; this.pos = position; this.rot = Matrix.CreateTranslation(Vector3.Zero); this.lookAt = lookAtVec; view = Matrix.CreateLookAt(pos, this.lookAt, Vector3.Up); projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, graphicsDevice.Viewport.AspectRatio * (screenSplit == ScreenSplit.two ? 2 : 1), 0.01f, 1600); //do a blog entry on the near plane being 0.01 and 1; }
public RenderMaster(ScreenSplit option, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, Effect sobelEffect, Vector3 bounds) { this.renderObjectLists = new Dictionary<string, List<CompositeModel>>(); renderObjectLists.Add("_master", new List<CompositeModel>()); currentList = renderObjectLists["_master"]; this.screenSplit = option; this.bounds = bounds; this.graphicsDevice = graphicsDevice; this.spriteBatch = spriteBatch; //arrays of render targets, as to match number of screens to draw normalRenderTarget = new RenderTarget2D[(int)this.screenSplit]; depthRenderTarget = new RenderTarget2D[(int)this.screenSplit]; toonRenderTarget = new RenderTarget2D[(int)this.screenSplit]; screenRect = new Rectangle[(int)this.screenSplit]; //this creates a bunch of targets of the right size for rendering multiple viewports for (int i = 0; i < (int)this.screenSplit; i++) { screenRect[i] = new Rectangle( (i / 2) * this.graphicsDevice.Viewport.Width / 2, (i % 2) * this.graphicsDevice.Viewport.Height / 2, this.graphicsDevice.Viewport.Width / ((int)screenSplit == 4 ? 2 : 1), this.graphicsDevice.Viewport.Height / ((int)screenSplit == 1 ? 1 : 2)); normalRenderTarget[i] = new RenderTarget2D(this.graphicsDevice, screenRect[i].Width, screenRect[i].Height, false, this.graphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); depthRenderTarget[i] = new RenderTarget2D(this.graphicsDevice, screenRect[i].Width, screenRect[i].Height, false, this.graphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); toonRenderTarget[i] = new RenderTarget2D(this.graphicsDevice, screenRect[i].Width, screenRect[i].Height, false, this.graphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); } this.sobelEffect = sobelEffect; }