public PhysicsRenderer(GraphicsDevice device) { this.device = device; this.linebatch = new LineBatch(device); this.basiceffect = new BasicEffect(device); this.basiceffect.VertexColorEnabled = true; }
public void RenderAxis(LineBatch linebatch) { int size = 15; int offset = 20; basiceffect.View = Matrix.Identity; basiceffect.Projection = Matrix.CreateOrthographicOffCenter(-offset, WIDTH - offset, -offset, HEIGHT - offset, camera.near, camera.far); basiceffect.CurrentTechnique.Passes[0].Apply(); linebatch.Add(new LineVertex(new Vector3(0, 0, -1), Color.Red)); linebatch.Add(new LineVertex(new Vector3(size, 0, -1), Color.Red)); linebatch.Add(new LineVertex(new Vector3(0, 0, -1), Color.Green)); linebatch.Add(new LineVertex(new Vector3(0, size, -1), Color.Green)); linebatch.Add(new LineVertex(new Vector3(0, 0, -1), Color.Blue)); linebatch.Add(new LineVertex(new Vector3(0, 0, size-1), Color.Blue)); }
public void Initialize() { device = this.graphics.GraphicsDevice; camera = new Camera(0.1f, 100, 1.2f, WIDTH / (float)HEIGHT); camera.position = new Vector3(0, 0, 0); camera.target = new Vector3(0, 0, 0); trianglebatch = new TriangleBatch(device); linebatch = new LineBatch(device); spritebatch = new SpriteBatch(device); basiceffect = new BasicEffect(device); basiceffect.VertexColorEnabled = true; debugFont = content.Load<SpriteFont>("fonts/debug"); physics = new Physics(); physicsRenderer = new PhysicsRenderer(device); physicsRenderer.SetPhysics(physics); physicsRenderer.SetCamera(camera); physicsStateManager = new PhysicsStateManager(physics); physicsStateManager.SetRecordingFrequency(1 / 15f); AddPhysicsBodies(); }