/// <summary> /// This is called when the game should draw itself. /// </summary> protected override void Draw(GameTime gameTime) { GraphicsDevice device = graphics.GraphicsDevice; device.Clear(Color.CornflowerBlue); device.BlendState = BlendState.AlphaBlend; // Compute camera matrices. Matrix view = Matrix.CreateLookAt(cameraPosition, cameraPosition + cameraForward, cameraUp); Matrix projection = Matrix.CreatePerspectiveFieldOfView(1, device.Viewport.AspectRatio, 1, 100000); // Draw the checkered ground polygon. Matrix groundTransform = Matrix.CreateScale(20000) * Matrix.CreateRotationX(MathHelper.PiOver2); quadDrawer.DrawQuad(checkerTexture, 32, groundTransform, view, projection); // Draw the game entities. cat.Draw(quadDrawer, cameraPosition, view, projection); dog.Draw(quadDrawer, cameraPosition, view, projection); base.Draw(gameTime); }
/// <summary> /// Draws the entity as a billboard sprite. /// </summary> public void Draw(QuadDrawer quadDrawer, Vector3 cameraPosition, Matrix view, Matrix projection) { Matrix world = Matrix.CreateTranslation(0, 1, 0) * Matrix.CreateScale(800) * Matrix.CreateConstrainedBillboard(Position, cameraPosition, Up, null, null); quadDrawer.DrawQuad(Texture, 1, world, view, projection); }